Class AbstractAuthenticator<T extends AuthenticatorConfig>

  • Type Parameters:
    T - type of AuthenticatorConfig
    Direct Known Subclasses:
    Authenticator

    public abstract class AbstractAuthenticator<T extends AuthenticatorConfig>
    extends java.lang.Object
    AbstractAuthenticator provides basic functionality for authenticating against an LDAP.
    Version:
    $Revision: 1743 $ $Date: 2010-11-19 18:00:18 +0100 (Fri, 19 Nov 2010) $
    Author:
    Middleware Services
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected T config
      Authenticator configuration environment.
      protected org.apache.commons.logging.Log logger
      Log for this class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected javax.naming.directory.Attributes authenticateAndAuthorize​(java.lang.String dn, java.lang.Object credential, boolean searchAttrs, java.lang.String[] retAttrs, AuthenticationResultHandler[] authResultHandler, AuthorizationHandler[] authzHandler)
      This will authenticate by binding to the LDAP with the supplied dn and credential.
      protected boolean authenticateAndAuthorize​(java.lang.String dn, java.lang.Object credential, AuthenticationResultHandler[] authResultHandler, AuthorizationHandler[] authzHandler)
      This will authenticate by binding to the LDAP with the supplied dn and credential.
      void close()
      This will close the connection on the underlying DN resolver.
      void setAuthenticatorConfig​(T authConfig)
      This will set the config parameters of this Authenticator.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        protected final org.apache.commons.logging.Log logger
        Log for this class.
    • Constructor Detail

      • AbstractAuthenticator

        public AbstractAuthenticator()
    • Method Detail

      • setAuthenticatorConfig

        public void setAuthenticatorConfig​(T authConfig)
        This will set the config parameters of this Authenticator.
        Parameters:
        authConfig - AuthenticatorConfig
      • authenticateAndAuthorize

        protected boolean authenticateAndAuthorize​(java.lang.String dn,
                                                   java.lang.Object credential,
                                                   AuthenticationResultHandler[] authResultHandler,
                                                   AuthorizationHandler[] authzHandler)
                                            throws javax.naming.NamingException
        This will authenticate by binding to the LDAP with the supplied dn and credential. See authenticateAndAuthorize( String, Object, boolean, String[], AuthenticationResultHandler[], AuthorizationHandler[]).
        Parameters:
        dn - String for bind
        credential - Object for bind
        authResultHandler - AuthenticationResultHandler[] to post process authentication results
        authzHandler - AuthorizationHandler[] to process authorization after authentication
        Returns:
        boolean - whether the bind succeeded
        Throws:
        javax.naming.NamingException - if the authentication fails for any other reason than invalid credentials
      • authenticateAndAuthorize

        protected javax.naming.directory.Attributes authenticateAndAuthorize​(java.lang.String dn,
                                                                             java.lang.Object credential,
                                                                             boolean searchAttrs,
                                                                             java.lang.String[] retAttrs,
                                                                             AuthenticationResultHandler[] authResultHandler,
                                                                             AuthorizationHandler[] authzHandler)
                                                                      throws javax.naming.NamingException
        This will authenticate by binding to the LDAP with the supplied dn and credential. Authentication will never succeed if LdapConfig.getAuthtype() is set to 'none'. If retAttrs is null and searchAttrs is true then all user attributes will be returned. If retAttrs is an empty array and searchAttrs is true then no attributes will be returned. This method throws AuthenticationException if authentication fails and AuthorizationException if authorization fails.
        Parameters:
        dn - String for bind
        credential - Object for bind
        searchAttrs - boolean whether to perform attribute search
        retAttrs - String[] user attributes to return
        authResultHandler - AuthenticationResultHandler[] to post process authentication results
        authzHandler - AuthorizationHandler[] to process authorization after authentication
        Returns:
        Attribute - belonging to the supplied user, returns null if searchAttrs is false
        Throws:
        javax.naming.NamingException - if any of the ldap operations fail
        javax.naming.AuthenticationException - if authentication fails
        AuthorizationException - if authorization fails
      • close

        public void close()
        This will close the connection on the underlying DN resolver.