Class AbstractLoginModule

  • All Implemented Interfaces:
    javax.security.auth.spi.LoginModule

    @ProviderType
    public abstract class AbstractLoginModule
    extends java.lang.Object
    implements javax.security.auth.spi.LoginModule
    Abstract implementation of the LoginModule interface that can act as base class for login modules that aim to authenticate subjects against information stored in the content repository.

    LoginModule Methods

    This base class provides a simple implementation for the following methods of the LoginModule interface:

    • Initialize: Initialization of this abstract module sets the following protected instance fields:
      • subject: The subject to be authenticated,
      • callbackHandler: The callback handler passed to the login module,
      • shareState: The map used to share state information with other login modules,
      • options: The configuration options of this login module as specified in the Configuration.
    • Logout: If the authenticated subject is not empty this logout implementation attempts to clear both principals and public credentials and returns true.
    • Abort: Clears the state of this login module by setting all private instance variables created in phase 1 or 2 to null. Subclasses are in charge of releasing their own state information by either overriding clearState().

    Utility Methods

    The following methods are provided in addition:

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String SHARED_KEY_ATTRIBUTES
      Key of the sharedState entry referring to public attributes that are shared between multiple login modules.
      static java.lang.String SHARED_KEY_CREDENTIALS
      Key of the sharedState entry referring to validated Credentials that is shared between multiple login modules.
      static java.lang.String SHARED_KEY_LOGIN_NAME
      Key of the sharedState entry referring to a valid login ID that is shared between multiple login modules.
      static java.lang.String SHARED_KEY_PRE_AUTH_LOGIN
      Key of the sharedState entry referring to pre authenticated login information that is shared between multiple login modules.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean abort()  
      void initialize​(javax.security.auth.Subject subject, javax.security.auth.callback.CallbackHandler callbackHandler, java.util.Map<java.lang.String,​?> sharedState, java.util.Map<java.lang.String,​?> options)  
      boolean logout()
      Besteffort default implementation of LoginModule.logout(), which removes all principals and all public credentials of type Credentials and AuthInfo from the subject.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.security.auth.spi.LoginModule

        commit, login
    • Field Detail

      • SHARED_KEY_CREDENTIALS

        public static final java.lang.String SHARED_KEY_CREDENTIALS
        Key of the sharedState entry referring to validated Credentials that is shared between multiple login modules.
        See Also:
        Constant Field Values
      • SHARED_KEY_LOGIN_NAME

        public static final java.lang.String SHARED_KEY_LOGIN_NAME
        Key of the sharedState entry referring to a valid login ID that is shared between multiple login modules.
        See Also:
        Constant Field Values
      • SHARED_KEY_ATTRIBUTES

        public static final java.lang.String SHARED_KEY_ATTRIBUTES
        Key of the sharedState entry referring to public attributes that are shared between multiple login modules.
        See Also:
        Constant Field Values
      • SHARED_KEY_PRE_AUTH_LOGIN

        public static final java.lang.String SHARED_KEY_PRE_AUTH_LOGIN
        Key of the sharedState entry referring to pre authenticated login information that is shared between multiple login modules.
    • Constructor Detail

      • AbstractLoginModule

        public AbstractLoginModule()
    • Method Detail

      • initialize

        public void initialize​(javax.security.auth.Subject subject,
                               javax.security.auth.callback.CallbackHandler callbackHandler,
                               java.util.Map<java.lang.String,​?> sharedState,
                               java.util.Map<java.lang.String,​?> options)
        Specified by:
        initialize in interface javax.security.auth.spi.LoginModule
      • logout

        public boolean logout()
                       throws javax.security.auth.login.LoginException
        Besteffort default implementation of LoginModule.logout(), which removes all principals and all public credentials of type Credentials and AuthInfo from the subject. It will return false, if either principal set or credentials set is empty. Note, that this implementation is not able to only remove those principals/credentials that have been added by this very login module instance. Therefore subclasses should overwrite this method to provide a fully compliant solution of logout(). They may however take advantage of logout(Set, Set) in order to simplify the implementation of a logout that is compatible with the LoginModule.logout() contract incorporating the additional recommendations highlighted at JAAS LoginModule Dev Guide
        Specified by:
        logout in interface javax.security.auth.spi.LoginModule
        Returns:
        true if neither principals nor public credentials of type Credentials or AuthInfo stored in the Subject are empty; false otherwise
        Throws:
        javax.security.auth.login.LoginException - if the subject is readonly and destroying Destroyable credentials fails with DestroyFailedException.
      • abort

        public boolean abort()
                      throws javax.security.auth.login.LoginException
        Specified by:
        abort in interface javax.security.auth.spi.LoginModule
        Throws:
        javax.security.auth.login.LoginException