Class Authenticator


  • public class Authenticator
    extends java.lang.Object
    Provides functionality to authenticate users against an ldap directory.
    Author:
    Middleware Services
    • Field Detail

      • logger

        protected final org.slf4j.Logger logger
        Logger for this class.
    • Constructor Detail

      • Authenticator

        public Authenticator()
        Default constructor.
      • Authenticator

        public Authenticator​(DnResolver resolver,
                             AuthenticationHandler handler)
        Creates a new authenticator.
        Parameters:
        resolver - dn resolver
        handler - authentication handler
    • Method Detail

      • getDnResolver

        public DnResolver getDnResolver()
        Returns the DN resolver.
        Returns:
        DN resolver
      • setDnResolver

        public void setDnResolver​(DnResolver resolver)
        Sets the DN resolver.
        Parameters:
        resolver - for finding DNs
      • getAuthenticationHandler

        public AuthenticationHandler getAuthenticationHandler()
        Returns the authentication handler.
        Returns:
        authentication handler
      • setAuthenticationHandler

        public void setAuthenticationHandler​(AuthenticationHandler handler)
        Sets the authentication handler.
        Parameters:
        handler - for performing authentication
      • getEntryResolver

        public EntryResolver getEntryResolver()
        Returns the entry resolver.
        Returns:
        entry resolver
      • setEntryResolver

        public void setEntryResolver​(EntryResolver resolver)
        Sets the entry resolver.
        Parameters:
        resolver - for finding entries
      • getResolveEntryOnFailure

        public boolean getResolveEntryOnFailure()
        Returns whether to execute the entry resolver on authentication failure.
        Returns:
        whether to execute the entry resolver on authentication failure
      • setResolveEntryOnFailure

        public void setResolveEntryOnFailure​(boolean b)
        Sets whether to execute the entry resolver on authentication failure.
        Parameters:
        b - whether to execute the entry resolver
      • getReturnAttributes

        public java.lang.String[] getReturnAttributes()
        Returns the return attributes.
        Returns:
        attributes to return
      • setReturnAttributes

        public void setReturnAttributes​(java.lang.String... attrs)
        Sets the return attributes.
        Parameters:
        attrs - return attributes
      • getRequestHandlers

        public AuthenticationRequestHandler[] getRequestHandlers()
        Returns the authentication request handlers.
        Returns:
        authentication request handlers
      • setRequestHandlers

        public void setRequestHandlers​(AuthenticationRequestHandler... handlers)
        Sets the authentication request handlers.
        Parameters:
        handlers - authentication request handlers
      • getResponseHandlers

        public AuthenticationResponseHandler[] getResponseHandlers()
        Returns the authentication response handlers.
        Returns:
        authentication response handlers
      • setResponseHandlers

        public void setResponseHandlers​(AuthenticationResponseHandler... handlers)
        Sets the authentication response handlers.
        Parameters:
        handlers - authentication response handlers
      • resolveDn

        public java.lang.String resolveDn​(User user)
                                   throws LdapException
        This will attempt to find the DN for the supplied user. DnResolver.resolve(User) is invoked to perform this operation.
        Parameters:
        user - to find DN for
        Returns:
        user DN
        Throws:
        LdapException - if an LDAP error occurs during resolution
      • validateInput

        protected AuthenticationResponse validateInput​(java.lang.String dn,
                                                       AuthenticationRequest request)
        Validates the authentication request and resolved DN. Returns an authentication response if validation failed.
        Parameters:
        dn - to validate
        request - to validate
        Returns:
        authentication response if validation failed, otherwise null
      • processRequest

        protected AuthenticationRequest processRequest​(java.lang.String dn,
                                                       AuthenticationRequest request)
                                                throws LdapException
        Creates a new authentication request applying any applicable configuration on this authenticator. Returns the supplied request if no configuration is applied.
        Parameters:
        dn - to process
        request - to process
        Returns:
        authentication request
        Throws:
        LdapException - if an error occurs with a request handler
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • builder

        public static Authenticator.Builder builder()
        Creates a builder for this class.
        Returns:
        new builder