## org.apache.catalina.realm
Class JAASMemoryLoginModule

    java.lang.Object
      org.apache.catalina.realm.RealmBase
          org.apache.catalina.realm.MemoryRealm
              org.apache.catalina.realm.JAASMemoryLoginModule

All Implemented Interfaces:
  Lifecycle, javax.security.auth.spi.LoginModule, Realm

public class JAASMemoryLoginModule
extends MemoryRealm
implements javax.security.auth.spi.LoginModule

Implementation of the JAAS LoginModule interface, primarily for use in testing `JAASRealm`. It utilizes an XML-format data file of username/password/role information identical to that supported by `org.apache.catalina.realm.MemoryRealm` (except that digested passwords are not supported).

This class recognizes the following string-valued options, which are specified in the configuration file (and passed to our constructor in the `options` argument:

- debug - Set to "true" to get debugging messages generated to System.out. The default value is `false`.
- pathname - Relative (to the pathname specified by the "catalina.base" system property) or absolute pahtname to the XML file containing our user information, in the format supported by `MemoryRealm`. The default value matches the MemoryRealm default.

IMPLEMENTATION NOTE - This class implements `Realm` only to satisfy the calling requirements of the `GenericPrincipal` constructor. It does not actually perform the functionality required of a `Realm` implementation.

Version:
  $Revision: 466595 $ $Date: 2006-10-21 23:24:41 +0100 (Sat, 21 Oct 2006) $
Author:
  Craig R. McClanahan

Field Summary
`protected javax.security.auth.callback.CallbackHandler` `callbackHandler` The callback handler responsible for answering our requests.
`protected boolean` `committed` Has our own `commit()` returned successfully?
`protected boolean` `debug` Should we log debugging messages?
`protected java.lang.String` `info` Descriptive information about this Realm implementation.
`protected java.util.Map` `options` The configuration information for this `LoginModule`.
`protected java.lang.String` `pathname` The absolute or relative pathname to the XML configuration file.
`protected java.security.Principal` `principal` The `Principal` identified by our validation, or `null` if validation falied.
`protected java.util.HashMap` `principals` The set of `Principals` loaded from our configuration file.
`protected java.util.Map` `sharedState` The state information that is shared with other configured `LoginModule` instances.
`protected javax.security.auth.Subject` `subject` The subject for which we are performing authentication.

Fields inherited from class org.apache.catalina.realm.MemoryRealm
`name`

Fields inherited from class org.apache.catalina.realm.RealmBase
`container, digest, digestEncoding, lifecycle, md, md5Encoder, md5Helper, started, support, validate`

Fields inherited from interface org.apache.catalina.Lifecycle
`AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, START_EVENT, STOP_EVENT`

Constructor Summary
`JAASMemoryLoginModule()`

Method Summary
`boolean` `abort()` Phase 2 of authenticating a `Subject` when Phase 1 fails.
`boolean` `commit()` Phase 2 of authenticating a `Subject` when Phase 1 was successful.
`java.lang.String` `getInfo()` Return descriptive information about this Realm implementation and the corresponding version number, in the format `<description>/<version>`.
`void` `initialize(javax.security.auth.Subject subject, javax.security.auth.callback.CallbackHandler callbackHandler, java.util.Map sharedState, java.util.Map options)` Initialize this `LoginModule` with the specified configuration information.
`protected void` `load()` Load the contents of our configuration file.
`boolean` `login()` Phase 1 of authenticating a `Subject`.
`boolean` `logout()` Log out this user.

Methods inherited from class org.apache.catalina.realm.MemoryRealm
`authenticate, getDigester, getName, getPassword, getPathname, getPrincipal, setPathname, start, stop`

Methods inherited from class org.apache.catalina.realm.RealmBase
`addLifecycleListener, addPropertyChangeListener, authenticate, authenticate, authenticate, digest, Digest, findLifecycleListeners, getContainer, getDebug, getDigest, getDigest, getDigestEncoding, getPrincipal, getValidate, hasMessageDigest, hasRole, log, log, main, removeLifecycleListener, removePropertyChangeListener, setContainer, setDebug, setDigest, setDigestEncoding, setValidate`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### info

    protected final java.lang.String info

  Descriptive information about this Realm implementation.

  See Also:
    Constant Field Values

### callbackHandler

    protected javax.security.auth.callback.CallbackHandler callbackHandler

  The callback handler responsible for answering our requests.

### committed

    protected boolean committed

  Has our own `commit()` returned successfully?

### debug

    protected boolean debug

  Should we log debugging messages?

### options

    protected java.util.Map options

  The configuration information for this `LoginModule`.

### pathname

    protected java.lang.String pathname

  The absolute or relative pathname to the XML configuration file.

### principal

    protected java.security.Principal principal

  The `Principal` identified by our validation, or `null` if validation falied.

### principals

    protected java.util.HashMap principals

  The set of `Principals` loaded from our configuration file.

### sharedState

    protected java.util.Map sharedState

  The state information that is shared with other configured `LoginModule` instances.

### subject

    protected javax.security.auth.Subject subject

  The subject for which we are performing authentication.

Constructor Detail

### JAASMemoryLoginModule

    public JAASMemoryLoginModule()

Method Detail

### abort

    public boolean abort()
                  throws javax.security.auth.login.LoginException

  Phase 2 of authenticating a `Subject` when Phase 1 fails. This method is called if the `LoginContext` failed somewhere in the overall authentication chain.

  Specified by:
    `abort` in interface `javax.security.auth.spi.LoginModule`
  Returns:
    `true` if this method succeeded, or `false` if this `LoginModule` should be ignored
  Throws:
    `javax.security.auth.login.LoginException` - if the abort fails

### commit

    public boolean commit()
                   throws javax.security.auth.login.LoginException

  Phase 2 of authenticating a `Subject` when Phase 1 was successful. This method is called if the `LoginContext` succeeded in the overall authentication chain.

  Specified by:
    `commit` in interface `javax.security.auth.spi.LoginModule`
  Returns:
    `true` if the authentication succeeded, or `false` if this `LoginModule` should be ignored
  Throws:
    `javax.security.auth.login.LoginException` - if the commit fails

### initialize

    public void initialize(javax.security.auth.Subject subject,
                           javax.security.auth.callback.CallbackHandler callbackHandler,
                           java.util.Map sharedState,
                           java.util.Map options)

  Initialize this `LoginModule` with the specified configuration information.

  Specified by:
    `initialize` in interface `javax.security.auth.spi.LoginModule`
  Parameters:
    `subject` - The `Subject` to be authenticated
    `callbackHandler` - A `CallbackHandler` for communicating with the end user as necessary
    `sharedState` - State information shared with other `LoginModule` instances
    `options` - Configuration information for this specific `LoginModule` instance

### login

    public boolean login()
                  throws javax.security.auth.login.LoginException

  Phase 1 of authenticating a `Subject`.

  Specified by:
    `login` in interface `javax.security.auth.spi.LoginModule`
  Returns:
    `true` if the authentication succeeded, or `false` if this `LoginModule` should be ignored
  Throws:
    `javax.security.auth.login.LoginException` - if the authentication fails

### logout

    public boolean logout()
                   throws javax.security.auth.login.LoginException

  Log out this user.

  Specified by:
    `logout` in interface `javax.security.auth.spi.LoginModule`
  Returns:
    `true` in all cases because thie `LoginModule` should not be ignored
  Throws:
    `javax.security.auth.login.LoginException` - if logging out failed

### getInfo

    public java.lang.String getInfo()

  Return descriptive information about this Realm implementation and the corresponding version number, in the format `<description>/<version>`.

  Specified by:
    `getInfo` in interface `Realm`
  Overrides:
    `getInfo` in class `MemoryRealm`

### load

    protected void load()

  Load the contents of our configuration file.

Copyright © 2000-2002 Apache Software Foundation. All Rights Reserved.