SEC-1037: Made LdapAuthenticationProvider implement MessageSourceAware.
This commit is contained in:
parent
843d0e6910
commit
d508adbf8b
|
@ -32,6 +32,8 @@ import org.springframework.security.userdetails.UsernameNotFoundException;
|
||||||
import org.springframework.security.userdetails.ldap.LdapUserDetailsMapper;
|
import org.springframework.security.userdetails.ldap.LdapUserDetailsMapper;
|
||||||
import org.springframework.security.userdetails.ldap.UserDetailsContextMapper;
|
import org.springframework.security.userdetails.ldap.UserDetailsContextMapper;
|
||||||
import org.springframework.security.util.AuthorityUtils;
|
import org.springframework.security.util.AuthorityUtils;
|
||||||
|
import org.springframework.context.MessageSource;
|
||||||
|
import org.springframework.context.MessageSourceAware;
|
||||||
import org.springframework.context.support.MessageSourceAccessor;
|
import org.springframework.context.support.MessageSourceAccessor;
|
||||||
import org.springframework.ldap.NamingException;
|
import org.springframework.ldap.NamingException;
|
||||||
import org.springframework.ldap.core.DirContextOperations;
|
import org.springframework.ldap.core.DirContextOperations;
|
||||||
|
@ -100,7 +102,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
* </bean>
|
* </bean>
|
||||||
* </constructor-arg>
|
* </constructor-arg>
|
||||||
* </bean>
|
* </bean>
|
||||||
* </pre>
|
*</pre>
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* This would set up the provider to access an LDAP server with URL
|
* This would set up the provider to access an LDAP server with URL
|
||||||
|
@ -125,7 +127,7 @@ import org.apache.commons.logging.LogFactory;
|
||||||
* @see org.springframework.security.providers.ldap.authenticator.BindAuthenticator
|
* @see org.springframework.security.providers.ldap.authenticator.BindAuthenticator
|
||||||
* @see DefaultLdapAuthoritiesPopulator
|
* @see DefaultLdapAuthoritiesPopulator
|
||||||
*/
|
*/
|
||||||
public class LdapAuthenticationProvider implements AuthenticationProvider {
|
public class LdapAuthenticationProvider implements AuthenticationProvider, MessageSourceAware {
|
||||||
//~ Static fields/initializers =====================================================================================
|
//~ Static fields/initializers =====================================================================================
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(LdapAuthenticationProvider.class);
|
private static final Log logger = LogFactory.getLog(LdapAuthenticationProvider.class);
|
||||||
|
@ -211,6 +213,10 @@ public class LdapAuthenticationProvider implements AuthenticationProvider {
|
||||||
this.useAuthenticationRequestCredentials = useAuthenticationRequestCredentials;
|
this.useAuthenticationRequestCredentials = useAuthenticationRequestCredentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMessageSource(MessageSource messageSource) {
|
||||||
|
this.messages = new MessageSourceAccessor(messageSource);
|
||||||
|
}
|
||||||
|
|
||||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||||
Assert.isInstanceOf(UsernamePasswordAuthenticationToken.class, authentication,
|
Assert.isInstanceOf(UsernamePasswordAuthenticationToken.class, authentication,
|
||||||
messages.getMessage("AbstractUserDetailsAuthenticationProvider.onlySupports",
|
messages.getMessage("AbstractUserDetailsAuthenticationProvider.onlySupports",
|
||||||
|
|
Loading…
Reference in New Issue