Class AbstractLdapAuthenticationProvider

  • All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.context.MessageSourceAware, org.springframework.security.authentication.AuthenticationProvider
    Direct Known Subclasses:
    ActiveDirectoryLdapAuthenticationProvider, LdapAuthenticationProvider

    public abstract class AbstractLdapAuthenticationProvider
    extends java.lang.Object
    implements org.springframework.security.authentication.AuthenticationProvider, org.springframework.context.MessageSourceAware
    Base class for the standard LdapAuthenticationProvider and the ActiveDirectoryLdapAuthenticationProvider.
    Since:
    3.1
    • Field Detail

      • logger

        protected final org.apache.commons.logging.Log logger
      • messages

        protected org.springframework.context.support.MessageSourceAccessor messages
    • Constructor Detail

      • AbstractLdapAuthenticationProvider

        public AbstractLdapAuthenticationProvider()
    • Method Detail

      • authenticate

        public org.springframework.security.core.Authentication authenticate​(org.springframework.security.core.Authentication authentication)
                                                                      throws org.springframework.security.core.AuthenticationException
        Specified by:
        authenticate in interface org.springframework.security.authentication.AuthenticationProvider
        Throws:
        org.springframework.security.core.AuthenticationException
      • doAuthentication

        protected abstract org.springframework.ldap.core.DirContextOperations doAuthentication​(org.springframework.security.authentication.UsernamePasswordAuthenticationToken auth)
      • loadUserAuthorities

        protected abstract java.util.Collection<? extends org.springframework.security.core.GrantedAuthority> loadUserAuthorities​(org.springframework.ldap.core.DirContextOperations userData,
                                                                                                                                  java.lang.String username,
                                                                                                                                  java.lang.String password)
      • createSuccessfulAuthentication

        protected org.springframework.security.core.Authentication createSuccessfulAuthentication​(org.springframework.security.authentication.UsernamePasswordAuthenticationToken authentication,
                                                                                                  org.springframework.security.core.userdetails.UserDetails user)
        Creates the final Authentication object which will be returned from the authenticate method.
        Parameters:
        authentication - the original authentication request token
        user - the UserDetails instance returned by the configured UserDetailsContextMapper.
        Returns:
        the Authentication object for the fully authenticated user.
      • supports

        public boolean supports​(java.lang.Class<?> authentication)
        Specified by:
        supports in interface org.springframework.security.authentication.AuthenticationProvider
      • setUseAuthenticationRequestCredentials

        public void setUseAuthenticationRequestCredentials​(boolean useAuthenticationRequestCredentials)
        Determines whether the supplied password will be used as the credentials in the successful authentication token. If set to false, then the password will be obtained from the UserDetails object created by the configured UserDetailsContextMapper. Often it will not be possible to read the password from the directory, so defaults to true.
        Parameters:
        useAuthenticationRequestCredentials -
      • setMessageSource

        public void setMessageSource​(org.springframework.context.MessageSource messageSource)
        Specified by:
        setMessageSource in interface org.springframework.context.MessageSourceAware
      • setAuthoritiesMapper

        public void setAuthoritiesMapper​(org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper authoritiesMapper)
      • getUserDetailsContextMapper

        protected UserDetailsContextMapper getUserDetailsContextMapper()
        Provides access to the injected UserDetailsContextMapper strategy for use by subclasses.