Browse Source

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.
Luke Taylor 15 years ago
parent
commit
977bc2b164
22 changed files with 70 additions and 167 deletions
  1. 1 3
      acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java
  2. 0 1
      cas/cas.gradle
  3. 0 4
      cas/pom.xml
  4. 7 18
      cas/src/main/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCache.java
  5. 3 3
      config/config.gradle
  6. 1 4
      config/src/test/java/org/springframework/security/config/PostProcessedMockUserDetailsService.java
  7. 1 3
      core/src/main/java/org/springframework/security/access/hierarchicalroles/UserDetailsServiceWrapper.java
  8. 4 3
      core/src/main/java/org/springframework/security/authentication/dao/DaoAuthenticationProvider.java
  9. 2 12
      core/src/main/java/org/springframework/security/authentication/encoding/PasswordEncoder.java
  10. 2 4
      core/src/main/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapper.java
  11. 1 5
      core/src/main/java/org/springframework/security/core/userdetails/UserDetailsService.java
  12. 4 17
      core/src/main/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCache.java
  13. 1 2
      core/src/main/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImpl.java
  14. 1 4
      core/src/main/java/org/springframework/security/core/userdetails/memory/InMemoryDaoImpl.java
  15. 1 5
      core/src/main/java/org/springframework/security/remoting/dns/DnsLookupException.java
  16. 0 11
      core/src/test/java/org/springframework/security/access/hierarchicalroles/UserDetailsServiceWrapperTests.java
  17. 8 17
      core/src/test/java/org/springframework/security/authentication/dao/DaoAuthenticationProviderTests.java
  18. 2 7
      core/src/test/java/org/springframework/security/authentication/encoding/BasePasswordEncoderTests.java
  19. 1 6
      core/src/test/java/org/springframework/security/core/userdetails/MockUserDetailsService.java
  20. 1 7
      core/src/test/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapperTests.java
  21. 29 30
      ldap/src/main/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManager.java
  22. 0 1
      openid/openid.gradle

+ 1 - 3
acl/src/main/java/org/springframework/security/acls/jdbc/BasicLookupStrategy.java

@@ -29,7 +29,6 @@ import java.util.Set;
 
 
 import javax.sql.DataSource;
 import javax.sql.DataSource;
 
 
-import org.springframework.dao.DataAccessException;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.PreparedStatementSetter;
 import org.springframework.jdbc.core.PreparedStatementSetter;
 import org.springframework.jdbc.core.ResultSetExtractor;
 import org.springframework.jdbc.core.ResultSetExtractor;
@@ -495,9 +494,8 @@ public final class BasicLookupStrategy implements LookupStrategy {
          * @param rs The {@link ResultSet} to be processed
          * @param rs The {@link ResultSet} to be processed
          * @return a list of parent IDs remaining to be looked up (may be empty, but never <tt>null</tt>)
          * @return a list of parent IDs remaining to be looked up (may be empty, but never <tt>null</tt>)
          * @throws SQLException
          * @throws SQLException
-         * @throws DataAccessException
          */
          */
-        public Set<Long> extractData(ResultSet rs) throws SQLException, DataAccessException {
+        public Set<Long> extractData(ResultSet rs) throws SQLException {
             Set<Long> parentIdsToLookup = new HashSet<Long>(); // Set of parent_id Longs
             Set<Long> parentIdsToLookup = new HashSet<Long>(); // Set of parent_id Longs
 
 
             while (rs.next()) {
             while (rs.next()) {

+ 0 - 1
cas/cas.gradle

@@ -4,7 +4,6 @@ dependencies {
             project(':spring-security-web'),
             project(':spring-security-web'),
             "org.springframework:spring-context:$springVersion",
             "org.springframework:spring-context:$springVersion",
             "org.springframework:spring-beans:$springVersion",
             "org.springframework:spring-beans:$springVersion",
-            "org.springframework:spring-tx:$springVersion",
             "org.springframework:spring-web:$springVersion",
             "org.springframework:spring-web:$springVersion",
             "org.jasig.cas:cas-client-core:3.1.9",
             "org.jasig.cas:cas-client-core:3.1.9",
             "net.sf.ehcache:ehcache:$ehcacheVersion"
             "net.sf.ehcache:ehcache:$ehcacheVersion"

+ 0 - 4
cas/pom.xml

@@ -24,10 +24,6 @@
             <groupId>javax.servlet</groupId>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>
             <artifactId>servlet-api</artifactId>
         </dependency>
         </dependency>
-        <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-tx</artifactId>
-        </dependency>
         <dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <groupId>org.springframework</groupId>
             <artifactId>spring-test</artifactId>
             <artifactId>spring-test</artifactId>

+ 7 - 18
cas/src/main/java/org/springframework/security/cas/authentication/EhCacheBasedTicketCache.java

@@ -15,23 +15,17 @@
 
 
 package org.springframework.security.cas.authentication;
 package org.springframework.security.cas.authentication;
 
 
-import net.sf.ehcache.CacheException;
-import net.sf.ehcache.Element;
 import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Ehcache;
-
+import net.sf.ehcache.Element;
 
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.logging.LogFactory;
-
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.InitializingBean;
-
-import org.springframework.dao.DataRetrievalFailureException;
-
 import org.springframework.util.Assert;
 import org.springframework.util.Assert;
 
 
 
 
 /**
 /**
- * Caches tickets using a Spring IoC defined <A HREF="http://ehcache.sourceforge.net">EHCACHE</a>.
+ * Caches tickets using a Spring IoC defined <a href="http://ehcache.sourceforge.net">EHCACHE</a>.
  *
  *
  * @author Ben Alex
  * @author Ben Alex
  */
  */
@@ -51,18 +45,13 @@ public class EhCacheBasedTicketCache implements StatelessTicketCache, Initializi
     }
     }
 
 
     public CasAuthenticationToken getByTicketId(final String serviceTicket) {
     public CasAuthenticationToken getByTicketId(final String serviceTicket) {
-        try {
-            final Element element = cache.get(serviceTicket);
-
-            if (logger.isDebugEnabled()) {
-                logger.debug("Cache hit: " + (element != null) + "; service ticket: " + serviceTicket);
-            }
-
-            return element == null ? null : (CasAuthenticationToken) element.getValue();
+        final Element element = cache.get(serviceTicket);
 
 
-        } catch (CacheException cacheException) {
-            throw new DataRetrievalFailureException("Cache failure: " + cacheException.getMessage());
+        if (logger.isDebugEnabled()) {
+            logger.debug("Cache hit: " + (element != null) + "; service ticket: " + serviceTicket);
         }
         }
+
+        return element == null ? null : (CasAuthenticationToken) element.getValue();
     }
     }
 
 
     public Ehcache getCache() {
     public Ehcache getCache() {

+ 3 - 3
config/config.gradle

@@ -9,8 +9,7 @@ dependencies {
             "org.springframework:spring-aop:$springVersion",
             "org.springframework:spring-aop:$springVersion",
             "org.springframework:spring-context:$springVersion",
             "org.springframework:spring-context:$springVersion",
             "org.springframework:spring-web:$springVersion",
             "org.springframework:spring-web:$springVersion",
-            "org.springframework:spring-beans:$springVersion",
-            "org.springframework:spring-tx:$springVersion"
+            "org.springframework:spring-beans:$springVersion"
 
 
     provided "javax.servlet:servlet-api:2.5"
     provided "javax.servlet:servlet-api:2.5"
 
 
@@ -20,7 +19,8 @@ dependencies {
                 'javax.annotation:jsr250-api:1.0',
                 'javax.annotation:jsr250-api:1.0',
                 'aopalliance:aopalliance:1.0',
                 'aopalliance:aopalliance:1.0',
                 "org.springframework.ldap:spring-ldap-core:$springLdapVersion",
                 "org.springframework.ldap:spring-ldap-core:$springLdapVersion",
-                "org.springframework:spring-jdbc:$springVersion"
+                "org.springframework:spring-jdbc:$springVersion",
+                "org.springframework:spring-tx:$springVersion"
 
 
     testRuntime "hsqldb:hsqldb:$hsqlVersion"
     testRuntime "hsqldb:hsqldb:$hsqlVersion"
 }
 }

+ 1 - 4
config/src/test/java/org/springframework/security/config/PostProcessedMockUserDetailsService.java

@@ -1,9 +1,7 @@
 package org.springframework.security.config;
 package org.springframework.security.config;
 
 
-import org.springframework.dao.DataAccessException;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
 
 
 public class PostProcessedMockUserDetailsService implements UserDetailsService {
 public class PostProcessedMockUserDetailsService implements UserDetailsService {
     private String postProcessorWasHere;
     private String postProcessorWasHere;
@@ -20,8 +18,7 @@ public class PostProcessedMockUserDetailsService implements UserDetailsService {
         this.postProcessorWasHere = postProcessorWasHere;
         this.postProcessorWasHere = postProcessorWasHere;
     }
     }
 
 
-    public UserDetails loadUserByUsername(String username)
-            throws UsernameNotFoundException, DataAccessException {
+    public UserDetails loadUserByUsername(String username) {
         throw new UnsupportedOperationException("Not for actual use");
         throw new UnsupportedOperationException("Not for actual use");
     }
     }
 }
 }

+ 1 - 3
core/src/main/java/org/springframework/security/access/hierarchicalroles/UserDetailsServiceWrapper.java

@@ -16,8 +16,6 @@ package org.springframework.security.access.hierarchicalroles;
 
 
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetailsService;
 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>
  * 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;
         this.userDetailsService = userDetailsService;
     }
     }
 
 
-    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
+    public UserDetails loadUserByUsername(String username) {
         UserDetails userDetails = userDetailsService.loadUserByUsername(username);
         UserDetails userDetails = userDetailsService.loadUserByUsername(username);
         // wrapped UserDetailsService might throw UsernameNotFoundException or DataAccessException which will then bubble up
         // wrapped UserDetailsService might throw UsernameNotFoundException or DataAccessException which will then bubble up
         return new UserDetailsWrapper(userDetails, roleHierarchy);
         return new UserDetailsWrapper(userDetails, roleHierarchy);

+ 4 - 3
core/src/main/java/org/springframework/security/authentication/dao/DaoAuthenticationProvider.java

@@ -24,7 +24,7 @@ import org.springframework.security.authentication.encoding.PlaintextPasswordEnc
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.core.AuthenticationException;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.dao.DataAccessException;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
 import org.springframework.util.Assert;
 import org.springframework.util.Assert;
 
 
 /**
 /**
@@ -80,8 +80,9 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
 
 
         try {
         try {
             loadedUser = this.getUserDetailsService().loadUserByUsername(username);
             loadedUser = this.getUserDetailsService().loadUserByUsername(username);
-        }
-        catch (DataAccessException repositoryProblem) {
+        } catch (UsernameNotFoundException notFound) {
+            throw notFound;
+        } catch (Exception repositoryProblem) {
             throw new AuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem);
             throw new AuthenticationServiceException(repositoryProblem.getMessage(), repositoryProblem);
         }
         }
 
 

+ 2 - 12
core/src/main/java/org/springframework/security/authentication/encoding/PasswordEncoder.java

@@ -15,13 +15,9 @@
 
 
 package org.springframework.security.authentication.encoding;
 package org.springframework.security.authentication.encoding;
 
 
-import org.springframework.dao.DataAccessException;
-
 
 
 /**
 /**
- * <p>
  * Interface for performing authentication operations on a password.
  * Interface for performing authentication operations on a password.
- * </p>
  *
  *
  * @author colin sampaleanu
  * @author colin sampaleanu
  */
  */
@@ -48,11 +44,8 @@ public interface PasswordEncoder {
      *        <code>null</code> value is legal.
      *        <code>null</code> value is legal.
      *
      *
      * @return encoded password
      * @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>
      * <p>Validates a specified "raw" password against an encoded password.</p>
@@ -67,9 +60,6 @@ public interface PasswordEncoder {
      *        <code>null</code> value is legal.
      *        <code>null</code> value is legal.
      *
      *
      * @return true if the password is valid , false otherwise
      * @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);
 }
 }

+ 2 - 4
core/src/main/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapper.java

@@ -1,8 +1,7 @@
 package org.springframework.security.core.userdetails;
 package org.springframework.security.core.userdetails;
 
 
-import org.springframework.security.core.Authentication;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.InitializingBean;
-import org.springframework.dao.DataAccessException;
+import org.springframework.security.core.Authentication;
 import org.springframework.util.Assert;
 import org.springframework.util.Assert;
 
 
 /**
 /**
@@ -48,8 +47,7 @@ public class UserDetailsByNameServiceWrapper implements AuthenticationUserDetail
      * Get the UserDetails object from the wrapped UserDetailsService
      * Get the UserDetails object from the wrapped UserDetailsService
      * implementation
      * implementation
      */
      */
-    public UserDetails loadUserDetails(Authentication authentication) throws UsernameNotFoundException,
-            DataAccessException {
+    public UserDetails loadUserDetails(Authentication authentication) throws UsernameNotFoundException {
         return this.userDetailsService.loadUserByUsername(authentication.getName());
         return this.userDetailsService.loadUserByUsername(authentication.getName());
     }
     }
 
 

+ 1 - 5
core/src/main/java/org/springframework/security/core/userdetails/UserDetailsService.java

@@ -15,8 +15,6 @@
 
 
 package org.springframework.security.core.userdetails;
 package org.springframework.security.core.userdetails;
 
 
-import org.springframework.dao.DataAccessException;
-
 
 
 /**
 /**
  * Core interface which loads user-specific data.
  * Core interface which loads user-specific data.
@@ -46,8 +44,6 @@ public interface UserDetailsService {
      * @return a fully populated user record (never <code>null</code>)
      * @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 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;
 }
 }

+ 4 - 17
core/src/main/java/org/springframework/security/core/userdetails/cache/EhCacheBasedUserCache.java

@@ -15,21 +15,14 @@
 
 
 package org.springframework.security.core.userdetails.cache;
 package org.springframework.security.core.userdetails.cache;
 
 
-import net.sf.ehcache.CacheException;
-import net.sf.ehcache.Element;
 import net.sf.ehcache.Ehcache;
 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.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.logging.LogFactory;
-
 import org.springframework.beans.factory.InitializingBean;
 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;
 import org.springframework.util.Assert;
 
 
 
 
@@ -59,13 +52,7 @@ public class EhCacheBasedUserCache implements UserCache, InitializingBean {
     }
     }
 
 
     public UserDetails getUserFromCache(String username) {
     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()) {
         if (logger.isDebugEnabled()) {
             logger.debug("Cache hit: " + (element != null) + "; username: " + username);
             logger.debug("Cache hit: " + (element != null) + "; username: " + username);

+ 1 - 2
core/src/main/java/org/springframework/security/core/userdetails/jdbc/JdbcDaoImpl.java

@@ -24,7 +24,6 @@ import java.util.Set;
 
 
 import org.springframework.context.ApplicationContextException;
 import org.springframework.context.ApplicationContextException;
 import org.springframework.context.support.MessageSourceAccessor;
 import org.springframework.context.support.MessageSourceAccessor;
-import org.springframework.dao.DataAccessException;
 import org.springframework.jdbc.core.RowMapper;
 import org.springframework.jdbc.core.RowMapper;
 import org.springframework.jdbc.core.support.JdbcDaoSupport;
 import org.springframework.jdbc.core.support.JdbcDaoSupport;
 import org.springframework.security.core.GrantedAuthority;
 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");
         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);
         List<UserDetails> users = loadUsersByUsername(username);
 
 
         if (users.size() == 0) {
         if (users.size() == 0) {

+ 1 - 4
core/src/main/java/org/springframework/security/core/userdetails/memory/InMemoryDaoImpl.java

@@ -21,8 +21,6 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException;
 
 
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.InitializingBean;
 
 
-import org.springframework.dao.DataAccessException;
-
 import org.springframework.util.Assert;
 import org.springframework.util.Assert;
 
 
 import java.util.Properties;
 import java.util.Properties;
@@ -49,8 +47,7 @@ public class InMemoryDaoImpl implements UserDetailsService, InitializingBean {
         return userMap;
         return userMap;
     }
     }
 
 
-    public UserDetails loadUserByUsername(String username)
-        throws UsernameNotFoundException, DataAccessException {
+    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
         return userMap.getUser(username);
         return userMap.getUser(username);
     }
     }
 
 

+ 1 - 5
core/src/main/java/org/springframework/security/remoting/dns/DnsLookupException.java

@@ -16,17 +16,13 @@
 
 
 package org.springframework.security.remoting.dns;
 package org.springframework.security.remoting.dns;
 
 
-import org.springframework.dao.DataAccessException;
-
 /**
 /**
  * This will be thrown for unknown DNS errors.
  * This will be thrown for unknown DNS errors.
  *
  *
  * @author Mike Wiesner
  * @author Mike Wiesner
  * @since 3.0
  * @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) {
     public DnsLookupException(String msg, Throwable cause) {
         super(msg, cause);
         super(msg, cause);

+ 0 - 11
core/src/test/java/org/springframework/security/access/hierarchicalroles/UserDetailsServiceWrapperTests.java

@@ -9,10 +9,6 @@ import org.jmock.integration.junit4.JUnit4Mockery;
 import org.junit.Before;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runner.RunWith;
-import org.springframework.dao.DataAccessException;
-import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl;
-import org.springframework.security.access.hierarchicalroles.UserDetailsServiceWrapper;
 import org.springframework.security.core.authority.AuthorityUtils;
 import org.springframework.security.core.authority.AuthorityUtils;
 import org.springframework.security.core.userdetails.User;
 import org.springframework.security.core.userdetails.User;
 import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.security.core.userdetails.UserDetails;
@@ -38,7 +34,6 @@ public class UserDetailsServiceWrapperTests {
         jmockContext.checking( new Expectations() {{
         jmockContext.checking( new Expectations() {{
             allowing(wrappedUserDetailsService).loadUserByUsername("EXISTING_USER"); will(returnValue(user));
             allowing(wrappedUserDetailsService).loadUserByUsername("EXISTING_USER"); will(returnValue(user));
             allowing(wrappedUserDetailsService).loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION"); will(throwException(new UsernameNotFoundException("USERNAME_NOT_FOUND_EXCEPTION")));
             allowing(wrappedUserDetailsService).loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION"); will(throwException(new UsernameNotFoundException("USERNAME_NOT_FOUND_EXCEPTION")));
-            allowing(wrappedUserDetailsService).loadUserByUsername("DATA_ACCESS_EXCEPTION"); will(throwException(new EmptyResultDataAccessException(1234)));
         }});
         }});
         this.wrappedUserDetailsService = wrappedUserDetailsService;
         this.wrappedUserDetailsService = wrappedUserDetailsService;
         userDetailsServiceWrapper = new UserDetailsServiceWrapper();
         userDetailsServiceWrapper = new UserDetailsServiceWrapper();
@@ -63,16 +58,10 @@ public class UserDetailsServiceWrapperTests {
             userDetails = userDetailsServiceWrapper.loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION");
             userDetails = userDetailsServiceWrapper.loadUserByUsername("USERNAME_NOT_FOUND_EXCEPTION");
             fail("testLoadUserByUsername() - UsernameNotFoundException did not bubble up!");
             fail("testLoadUserByUsername() - UsernameNotFoundException did not bubble up!");
         } catch (UsernameNotFoundException e) {}
         } catch (UsernameNotFoundException e) {}
-
-        try {
-            userDetails = userDetailsServiceWrapper.loadUserByUsername("DATA_ACCESS_EXCEPTION");
-            fail("testLoadUserByUsername() - DataAccessException did not bubble up!");
-        } catch (DataAccessException e) {}
     }
     }
 
 
     @Test
     @Test
     public void testGetWrappedUserDetailsService() {
     public void testGetWrappedUserDetailsService() {
         assertTrue(userDetailsServiceWrapper.getWrappedUserDetailsService() == wrappedUserDetailsService);
         assertTrue(userDetailsServiceWrapper.getWrappedUserDetailsService() == wrappedUserDetailsService);
     }
     }
-
 }
 }

+ 8 - 17
core/src/test/java/org/springframework/security/authentication/dao/DaoAuthenticationProviderTests.java

@@ -19,7 +19,6 @@ import java.util.List;
 
 
 import junit.framework.TestCase;
 import junit.framework.TestCase;
 
 
-import org.springframework.dao.DataAccessException;
 import org.springframework.dao.DataRetrievalFailureException;
 import org.springframework.dao.DataRetrievalFailureException;
 import org.springframework.security.authentication.AccountExpiredException;
 import org.springframework.security.authentication.AccountExpiredException;
 import org.springframework.security.authentication.AuthenticationServiceException;
 import org.springframework.security.authentication.AuthenticationServiceException;
@@ -437,15 +436,13 @@ public class DaoAuthenticationProviderTests extends TestCase {
     //~ Inner Classes ==================================================================================================
     //~ Inner Classes ==================================================================================================
 
 
     private class MockAuthenticationDaoReturnsNull implements UserDetailsService {
     private class MockAuthenticationDaoReturnsNull implements UserDetailsService {
-        public UserDetails loadUserByUsername(String username)
-            throws UsernameNotFoundException, DataAccessException {
+        public UserDetails loadUserByUsername(String username) {
             return null;
             return null;
         }
         }
     }
     }
 
 
     private class MockAuthenticationDaoSimulateBackendError implements UserDetailsService {
     private class MockAuthenticationDaoSimulateBackendError implements UserDetailsService {
-        public UserDetails loadUserByUsername(String username)
-            throws UsernameNotFoundException, DataAccessException {
+        public UserDetails loadUserByUsername(String username) {
             throw new DataRetrievalFailureException("This mock simulator is designed to fail");
             throw new DataRetrievalFailureException("This mock simulator is designed to fail");
         }
         }
     }
     }
@@ -453,8 +450,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
     private class MockAuthenticationDaoUserrod implements UserDetailsService {
     private class MockAuthenticationDaoUserrod implements UserDetailsService {
         private String password = "koala";
         private String password = "koala";
 
 
-        public UserDetails loadUserByUsername(String username)
-            throws UsernameNotFoundException, DataAccessException {
+        public UserDetails loadUserByUsername(String username) {
             if ("rod".equals(username)) {
             if ("rod".equals(username)) {
                 return new User("rod", password, true, true, true, true, ROLES_12);
                 return new User("rod", password, true, true, true, true, ROLES_12);
             } else {
             } else {
@@ -468,8 +464,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
     }
     }
 
 
     private class MockAuthenticationDaoUserrodWithSalt implements UserDetailsService {
     private class MockAuthenticationDaoUserrodWithSalt implements UserDetailsService {
-        public UserDetails loadUserByUsername(String username)
-            throws UsernameNotFoundException, DataAccessException {
+        public UserDetails loadUserByUsername(String username) {
             if ("rod".equals(username)) {
             if ("rod".equals(username)) {
                 return new User("rod", "koala{SYSTEM_SALT_VALUE}", true, true, true, true, ROLES_12);
                 return new User("rod", "koala{SYSTEM_SALT_VALUE}", true, true, true, true, ROLES_12);
             } else {
             } else {
@@ -479,8 +474,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
     }
     }
 
 
     private class MockAuthenticationDaoUserPeter implements UserDetailsService {
     private class MockAuthenticationDaoUserPeter implements UserDetailsService {
-        public UserDetails loadUserByUsername(String username)
-            throws UsernameNotFoundException, DataAccessException {
+        public UserDetails loadUserByUsername(String username) {
             if ("peter".equals(username)) {
             if ("peter".equals(username)) {
                 return new User("peter", "opal", false, true, true, true, ROLES_12);
                 return new User("peter", "opal", false, true, true, true, ROLES_12);
             } else {
             } else {
@@ -490,8 +484,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
     }
     }
 
 
     private class MockAuthenticationDaoUserPeterAccountExpired implements UserDetailsService {
     private class MockAuthenticationDaoUserPeterAccountExpired implements UserDetailsService {
-        public UserDetails loadUserByUsername(String username)
-            throws UsernameNotFoundException, DataAccessException {
+        public UserDetails loadUserByUsername(String username) {
             if ("peter".equals(username)) {
             if ("peter".equals(username)) {
                 return new User("peter", "opal", true, false, true, true, ROLES_12);
                 return new User("peter", "opal", true, false, true, true, ROLES_12);
             } else {
             } else {
@@ -501,8 +494,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
     }
     }
 
 
     private class MockAuthenticationDaoUserPeterAccountLocked implements UserDetailsService {
     private class MockAuthenticationDaoUserPeterAccountLocked implements UserDetailsService {
-        public UserDetails loadUserByUsername(String username)
-            throws UsernameNotFoundException, DataAccessException {
+        public UserDetails loadUserByUsername(String username) {
             if ("peter".equals(username)) {
             if ("peter".equals(username)) {
                 return new User("peter", "opal", true, true, true, false, ROLES_12);
                 return new User("peter", "opal", true, true, true, false, ROLES_12);
             } else {
             } else {
@@ -512,8 +504,7 @@ public class DaoAuthenticationProviderTests extends TestCase {
     }
     }
 
 
     private class MockAuthenticationDaoUserPeterCredentialsExpired implements UserDetailsService {
     private class MockAuthenticationDaoUserPeterCredentialsExpired implements UserDetailsService {
-        public UserDetails loadUserByUsername(String username)
-            throws UsernameNotFoundException, DataAccessException {
+        public UserDetails loadUserByUsername(String username) {
             if ("peter".equals(username)) {
             if ("peter".equals(username)) {
                 return new User("peter", "opal", true, true, false, true, ROLES_12);
                 return new User("peter", "opal", true, true, false, true, ROLES_12);
             } else {
             } else {

+ 2 - 7
core/src/test/java/org/springframework/security/authentication/encoding/BasePasswordEncoderTests.java

@@ -17,9 +17,6 @@ package org.springframework.security.authentication.encoding;
 
 
 import junit.framework.TestCase;
 import junit.framework.TestCase;
 
 
-import org.springframework.dao.DataAccessException;
-import org.springframework.security.authentication.encoding.BasePasswordEncoder;
-
 
 
 /**
 /**
  * <p>TestCase for BasePasswordEncoder.</p>
  * <p>TestCase for BasePasswordEncoder.</p>
@@ -126,13 +123,11 @@ public class BasePasswordEncoderTests extends TestCase {
     //~ Inner Classes ==================================================================================================
     //~ Inner Classes ==================================================================================================
 
 
     private class MockPasswordEncoder extends BasePasswordEncoder {
     private class MockPasswordEncoder extends BasePasswordEncoder {
-        public String encodePassword(String rawPass, Object salt)
-            throws DataAccessException {
+        public String encodePassword(String rawPass, Object salt) {
             throw new UnsupportedOperationException("mock method not implemented");
             throw new UnsupportedOperationException("mock method not implemented");
         }
         }
 
 
-        public boolean isPasswordValid(String encPass, String rawPass, Object salt)
-            throws DataAccessException {
+        public boolean isPasswordValid(String encPass, String rawPass, Object salt) {
             throw new UnsupportedOperationException("mock method not implemented");
             throw new UnsupportedOperationException("mock method not implemented");
         }
         }
 
 

+ 1 - 6
core/src/test/java/org/springframework/security/core/userdetails/MockUserDetailsService.java

@@ -4,13 +4,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
-import org.springframework.dao.DataAccessException;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.authority.AuthorityUtils;
 import org.springframework.security.core.authority.AuthorityUtils;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
 
 
 /**
 /**
  * A test UserDetailsService containing a set of standard usernames corresponding to their account status:
  * A test UserDetailsService containing a set of standard usernames corresponding to their account status:
@@ -30,7 +25,7 @@ public class MockUserDetailsService implements UserDetailsService {
         users.put("expired", new User("expired", "",true,false,true,true,auths));
         users.put("expired", new User("expired", "",true,false,true,true,auths));
     }
     }
 
 
-    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
+    public UserDetails loadUserByUsername(String username) {
         if (users.get(username) == null) {
         if (users.get(username) == null) {
             throw new UsernameNotFoundException("User not found: " + username);
             throw new UsernameNotFoundException("User not found: " + username);
         }
         }

+ 1 - 7
core/src/test/java/org/springframework/security/core/userdetails/UserDetailsByNameServiceWrapperTests.java

@@ -2,14 +2,8 @@ package org.springframework.security.core.userdetails;
 
 
 import junit.framework.TestCase;
 import junit.framework.TestCase;
 
 
-import org.springframework.dao.DataAccessException;
 import org.springframework.security.authentication.TestingAuthenticationToken;
 import org.springframework.security.authentication.TestingAuthenticationToken;
 import org.springframework.security.core.authority.AuthorityUtils;
 import org.springframework.security.core.authority.AuthorityUtils;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
 
 
 /**
 /**
  *
  *
@@ -33,7 +27,7 @@ public class UserDetailsByNameServiceWrapperTests extends TestCase {
         UserDetailsByNameServiceWrapper svc = new UserDetailsByNameServiceWrapper();
         UserDetailsByNameServiceWrapper svc = new UserDetailsByNameServiceWrapper();
         final User user = new User("dummy", "dummy", true, true, true, true, AuthorityUtils.NO_AUTHORITIES);
         final User user = new User("dummy", "dummy", true, true, true, true, AuthorityUtils.NO_AUTHORITIES);
         svc.setUserDetailsService(new UserDetailsService() {
         svc.setUserDetailsService(new UserDetailsService() {
-            public UserDetails loadUserByUsername(String name) throws UsernameNotFoundException, DataAccessException {
+            public UserDetails loadUserByUsername(String name) {
                 if (user != null && user.getUsername().equals(name)) {
                 if (user != null && user.getUsername().equals(name)) {
                     return user;
                     return user;
                 } else {
                 } else {

+ 29 - 30
ldap/src/main/java/org/springframework/security/ldap/userdetails/LdapUserDetailsManager.java

@@ -14,30 +14,11 @@
  */
  */
 package org.springframework.security.ldap.userdetails;
 package org.springframework.security.ldap.userdetails;
 
 
-import org.springframework.security.authentication.BadCredentialsException;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.GrantedAuthorityImpl;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.security.ldap.LdapUsernameToDnMapper;
-import org.springframework.security.ldap.LdapUtils;
-import org.springframework.security.ldap.DefaultLdapUsernameToDnMapper;
-import org.springframework.security.provisioning.UserDetailsManager;
-import org.springframework.dao.DataAccessException;
-import org.springframework.ldap.core.AttributesMapper;
-import org.springframework.ldap.core.AttributesMapperCallbackHandler;
-import org.springframework.ldap.core.ContextExecutor;
-import org.springframework.ldap.core.ContextSource;
-import org.springframework.ldap.core.DirContextAdapter;
-import org.springframework.ldap.core.DistinguishedName;
-import org.springframework.ldap.core.LdapTemplate;
-import org.springframework.ldap.core.SearchExecutor;
-import org.springframework.util.Assert;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
 
 
 import javax.naming.Context;
 import javax.naming.Context;
 import javax.naming.NameNotFoundException;
 import javax.naming.NameNotFoundException;
@@ -51,11 +32,29 @@ import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 import javax.naming.directory.SearchResult;
 import javax.naming.ldap.LdapContext;
 import javax.naming.ldap.LdapContext;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.ldap.core.AttributesMapper;
+import org.springframework.ldap.core.AttributesMapperCallbackHandler;
+import org.springframework.ldap.core.ContextExecutor;
+import org.springframework.ldap.core.ContextSource;
+import org.springframework.ldap.core.DirContextAdapter;
+import org.springframework.ldap.core.DistinguishedName;
+import org.springframework.ldap.core.LdapTemplate;
+import org.springframework.ldap.core.SearchExecutor;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.authority.GrantedAuthorityImpl;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.security.ldap.DefaultLdapUsernameToDnMapper;
+import org.springframework.security.ldap.LdapUsernameToDnMapper;
+import org.springframework.security.ldap.LdapUtils;
+import org.springframework.security.provisioning.UserDetailsManager;
+import org.springframework.util.Assert;
 
 
 /**
 /**
  * An Ldap implementation of UserDetailsManager.
  * An Ldap implementation of UserDetailsManager.
@@ -123,7 +122,7 @@ public class LdapUserDetailsManager implements UserDetailsManager {
         template = new LdapTemplate(contextSource);
         template = new LdapTemplate(contextSource);
     }
     }
 
 
-    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
+    public UserDetails loadUserByUsername(String username) {
         DistinguishedName dn = usernameMapper.buildDn(username);
         DistinguishedName dn = usernameMapper.buildDn(username);
         List<GrantedAuthority> authorities = getUserAuthorities(dn, username);
         List<GrantedAuthority> authorities = getUserAuthorities(dn, username);
 
 

+ 0 - 1
openid/openid.gradle

@@ -7,7 +7,6 @@ dependencies {
             "org.springframework:spring-aop:$springVersion",
             "org.springframework:spring-aop:$springVersion",
             "org.springframework:spring-context:$springVersion",
             "org.springframework:spring-context:$springVersion",
             "org.springframework:spring-beans:$springVersion",
             "org.springframework:spring-beans:$springVersion",
-            "org.springframework:spring-tx:$springVersion",
             "org.springframework:spring-web:$springVersion"
             "org.springframework:spring-web:$springVersion"
 
 
     provided 'javax.servlet:servlet-api:2.5'
     provided 'javax.servlet:servlet-api:2.5'