SEC-1433: Reduce the number of direct dependencies on DataAccessException from spring-tx.
It is still required as a compile-time dependency by classes which use Spring's JDBC support, but it doesn't really have to be used in many interfaces and classes which are not necessarily backed by JDBC implementations.
This commit is contained in:
@@ -16,8 +16,6 @@ package org.springframework.security.access.hierarchicalroles;
|
||||
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
/**
|
||||
* This class wraps Spring Security's <tt>UserDetailsService</tt> in a way that its <tt>loadUserByUsername()</tt>
|
||||
@@ -42,7 +40,7 @@ public class UserDetailsServiceWrapper implements UserDetailsService {
|
||||
this.userDetailsService = userDetailsService;
|
||||
}
|
||||
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
|
||||
public UserDetails loadUserByUsername(String username) {
|
||||
UserDetails userDetails = userDetailsService.loadUserByUsername(username);
|
||||
// wrapped UserDetailsService might throw UsernameNotFoundException or DataAccessException which will then bubble up
|
||||
return new UserDetailsWrapper(userDetails, roleHierarchy);
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.security.authentication.encoding.PlaintextPasswordEnc
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -80,8 +80,9 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
|
||||
|
||||
try {
|
||||
loadedUser = this.getUserDetailsService().loadUserByUsername(username);
|
||||
}
|
||||
catch (DataAccessException repositoryProblem) {
|
||||
} catch (UsernameNotFoundException notFound) {
|
||||
throw notFound;
|
||||
} catch (Exception repositoryProblem) {
|
||||
throw new AuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,13 +15,9 @@
|
||||
|
||||
package org.springframework.security.authentication.encoding;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Interface for performing authentication operations on a password.
|
||||
* </p>
|
||||
*
|
||||
* @author colin sampaleanu
|
||||
*/
|
||||
@@ -48,11 +44,8 @@ public interface PasswordEncoder {
|
||||
* <code>null</code> value is legal.
|
||||
*
|
||||
* @return encoded password
|
||||
*
|
||||
* @throws DataAccessException DOCUMENT ME!
|
||||
*/
|
||||
String encodePassword(String rawPass, Object salt)
|
||||
throws DataAccessException;
|
||||
String encodePassword(String rawPass, Object salt);
|
||||
|
||||
/**
|
||||
* <p>Validates a specified "raw" password against an encoded password.</p>
|
||||
@@ -67,9 +60,6 @@ public interface PasswordEncoder {
|
||||
* <code>null</code> value is legal.
|
||||
*
|
||||
* @return true if the password is valid , false otherwise
|
||||
*
|
||||
* @throws DataAccessException DOCUMENT ME!
|
||||
*/
|
||||
boolean isPasswordValid(String encPass, String rawPass, Object salt)
|
||||
throws DataAccessException;
|
||||
boolean isPasswordValid(String encPass, String rawPass, Object salt);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package org.springframework.security.core.userdetails;
|
||||
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -48,8 +47,7 @@ public class UserDetailsByNameServiceWrapper implements AuthenticationUserDetail
|
||||
* Get the UserDetails object from the wrapped UserDetailsService
|
||||
* implementation
|
||||
*/
|
||||
public UserDetails loadUserDetails(Authentication authentication) throws UsernameNotFoundException,
|
||||
DataAccessException {
|
||||
public UserDetails loadUserDetails(Authentication authentication) throws UsernameNotFoundException {
|
||||
return this.userDetailsService.loadUserByUsername(authentication.getName());
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
|
||||
package org.springframework.security.core.userdetails;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
|
||||
/**
|
||||
* Core interface which loads user-specific data.
|
||||
@@ -46,8 +44,6 @@ public interface UserDetailsService {
|
||||
* @return a fully populated user record (never <code>null</code>)
|
||||
*
|
||||
* @throws UsernameNotFoundException if the user could not be found or the user has no GrantedAuthority
|
||||
* @throws DataAccessException if user could not be found for a repository-specific reason
|
||||
*/
|
||||
UserDetails loadUserByUsername(String username)
|
||||
throws UsernameNotFoundException, DataAccessException;
|
||||
UserDetails loadUserByUsername(String username) throws UsernameNotFoundException;
|
||||
}
|
||||
|
||||
@@ -15,21 +15,14 @@
|
||||
|
||||
package org.springframework.security.core.userdetails.cache;
|
||||
|
||||
import net.sf.ehcache.CacheException;
|
||||
import net.sf.ehcache.Element;
|
||||
import net.sf.ehcache.Ehcache;
|
||||
|
||||
|
||||
import org.springframework.security.core.userdetails.UserCache;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import net.sf.ehcache.Element;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import org.springframework.dao.DataRetrievalFailureException;
|
||||
|
||||
import org.springframework.security.core.userdetails.UserCache;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
@@ -59,13 +52,7 @@ public class EhCacheBasedUserCache implements UserCache, InitializingBean {
|
||||
}
|
||||
|
||||
public UserDetails getUserFromCache(String username) {
|
||||
Element element = null;
|
||||
|
||||
try {
|
||||
element = cache.get(username);
|
||||
} catch (CacheException cacheException) {
|
||||
throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage());
|
||||
}
|
||||
Element element = cache.get(username);
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Cache hit: " + (element != null) + "; username: " + username);
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.Set;
|
||||
|
||||
import org.springframework.context.ApplicationContextException;
|
||||
import org.springframework.context.support.MessageSourceAccessor;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.support.JdbcDaoSupport;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
@@ -148,7 +147,7 @@ public class JdbcDaoImpl extends JdbcDaoSupport implements UserDetailsService {
|
||||
Assert.isTrue(enableAuthorities || enableGroups, "Use of either authorities or groups must be enabled");
|
||||
}
|
||||
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
List<UserDetails> users = loadUsersByUsername(username);
|
||||
|
||||
if (users.size() == 0) {
|
||||
|
||||
@@ -21,8 +21,6 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.Properties;
|
||||
@@ -49,8 +47,7 @@ public class InMemoryDaoImpl implements UserDetailsService, InitializingBean {
|
||||
return userMap;
|
||||
}
|
||||
|
||||
public UserDetails loadUserByUsername(String username)
|
||||
throws UsernameNotFoundException, DataAccessException {
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
return userMap.getUser(username);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,17 +16,13 @@
|
||||
|
||||
package org.springframework.security.remoting.dns;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
|
||||
/**
|
||||
* This will be thrown for unknown DNS errors.
|
||||
*
|
||||
* @author Mike Wiesner
|
||||
* @since 3.0
|
||||
*/
|
||||
public class DnsLookupException extends DataAccessException {
|
||||
|
||||
private static final long serialVersionUID = -7538424279394361310L;
|
||||
public class DnsLookupException extends RuntimeException {
|
||||
|
||||
public DnsLookupException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
|
||||
Reference in New Issue
Block a user