Removed unused autodetect method and reformatted code.

This commit is contained in:
Luke Taylor 2007-10-18 16:50:31 +00:00
parent bd740a91a2
commit 380b22f50d

View File

@ -15,8 +15,6 @@
package org.springframework.security.providers.dao; package org.springframework.security.providers.dao;
import java.util.Map;
import org.springframework.security.AuthenticationException; import org.springframework.security.AuthenticationException;
import org.springframework.security.AuthenticationServiceException; import org.springframework.security.AuthenticationServiceException;
import org.springframework.security.BadCredentialsException; import org.springframework.security.BadCredentialsException;
@ -26,7 +24,6 @@ import org.springframework.security.providers.encoding.PasswordEncoder;
import org.springframework.security.providers.encoding.PlaintextPasswordEncoder; import org.springframework.security.providers.encoding.PlaintextPasswordEncoder;
import org.springframework.security.userdetails.UserDetails; import org.springframework.security.userdetails.UserDetails;
import org.springframework.security.userdetails.UserDetailsService; import org.springframework.security.userdetails.UserDetailsService;
import org.springframework.context.ApplicationContext;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -40,8 +37,7 @@ import org.springframework.util.Assert;
*/ */
public class DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider { public class DaoAuthenticationProvider extends AbstractUserDetailsAuthenticationProvider {
// ~ Instance fields //~ Instance fields ================================================================================================
// ================================================================================================
private PasswordEncoder passwordEncoder = new PlaintextPasswordEncoder(); private PasswordEncoder passwordEncoder = new PlaintextPasswordEncoder();
@ -51,8 +47,7 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
private boolean includeDetailsObject = true; private boolean includeDetailsObject = true;
// ~ Methods //~ Methods ========================================================================================================
// ========================================================================================================
protected void additionalAuthenticationChecks(UserDetails userDetails, protected void additionalAuthenticationChecks(UserDetails userDetails,
UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
@ -82,31 +77,6 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
Assert.notNull(this.userDetailsService, "A UserDetailsService must be set"); Assert.notNull(this.userDetailsService, "A UserDetailsService must be set");
} }
/**
* Introspects the <code>Applicationcontext</code> for the single instance
* of {@link AccessDeniedHandler}. If found invoke
* setAccessDeniedHandler(AccessDeniedHandler accessDeniedHandler) method by
* providing the found instance of accessDeniedHandler as a method
* parameter. If more than one instance of <code>AccessDeniedHandler</code>
* is found, the method throws <code>IllegalStateException</code>.
*
* @param applicationContext to locate the instance
*/
private void autoDetectAnyUserDetailsServiceAndUseIt(ApplicationContext applicationContext) {
if (applicationContext != null) {
Map map = applicationContext.getBeansOfType(UserDetailsService.class);
if (map.size() > 1) {
throw new IllegalArgumentException(
"More than one UserDetailsService beans detected please refer to the one using "
+ " [ principalRepositoryBeanRef ] " + "attribute");
}
else if (map.size() == 1) {
setUserDetailsService((UserDetailsService) map.values().iterator().next());
}
}
}
public PasswordEncoder getPasswordEncoder() { public PasswordEncoder getPasswordEncoder() {
return passwordEncoder; return passwordEncoder;
} }
@ -138,9 +108,8 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
} }
/** /**
* Sets the PasswordEncoder instance to be used to encode and validate * Sets the PasswordEncoder instance to be used to encode and validate passwords.
* passwords. If not set, {@link PlaintextPasswordEncoder} will be used by * If not set, {@link PlaintextPasswordEncoder} will be used by default.
* default.
* *
* @param passwordEncoder The passwordEncoder to use * @param passwordEncoder The passwordEncoder to use
*/ */
@ -151,11 +120,9 @@ public class DaoAuthenticationProvider extends AbstractUserDetailsAuthentication
/** /**
* The source of salts to use when decoding passwords. <code>null</code> * The source of salts to use when decoding passwords. <code>null</code>
* is a valid value, meaning the <code>DaoAuthenticationProvider</code> * is a valid value, meaning the <code>DaoAuthenticationProvider</code>
* will present <code>null</code> to the relevant * will present <code>null</code> to the relevant <code>PasswordEncoder</code>.
* <code>PasswordEncoder</code>.
* *
* @param saltSource to use when attempting to decode passwords via the * @param saltSource to use when attempting to decode passwords via the <code>PasswordEncoder</code>
* <code>PasswordEncoder</code>
*/ */
public void setSaltSource(SaltSource saltSource) { public void setSaltSource(SaltSource saltSource) {
this.saltSource = saltSource; this.saltSource = saltSource;