org.apache.catalina.realm

Class JAASMemoryLoginModule

Implemented Interfaces:
LoginModule, Lifecycle, MBeanRegistration, Realm

public class JAASMemoryLoginModule
extends MemoryRealm
implements LoginModule, Realm

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:

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: 1.7 $ $Date: 2004/02/27 14:58:45 $

Author:
Craig R. McClanahan

Field Summary

protected 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 Map
options
The configuration information for this LoginModule.
protected String
pathname
The absolute or relative pathname to the XML configuration file.
protected Principal
principal
The Principal identified by our validation, or null if validation falied.
protected HashMap
principals
The set of Principals loaded from our configuration file.
protected Map
sharedState
The state information that is shared with other configured LoginModule instances.
protected static StringManager
sm
The string manager for this package.
protected Subject
subject
The subject for which we are performing authentication.

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

info, name

Fields inherited from class org.apache.catalina.realm.RealmBase

container, controller, debug, digest, digestEncoding, domain, host, info, initialized, lifecycle, md, md5Encoder, md5Helper, mserver, oname, path, sm, started, support, type, 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.
SecurityConstraint[]
findSecurityConstraints(HttpRequest request, Context context)
Return the SecurityConstraints configured to guard the request URI for this request, or null if there is no such constraint.
void
initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, 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, getInfo, getName, getPassword, getPathname, getPrincipal, getPrincipals, setPathname, start, stop

Methods inherited from class org.apache.catalina.realm.RealmBase

Digest, addLifecycleListener, addPropertyChangeListener, authenticate, authenticate, authenticate, authenticate, destroy, digest, findLifecycleListeners, findSecurityConstraints, getContainer, getController, getDebug, getDigest, getDigest, getDigestEncoding, getDomain, getInfo, getName, getObjectName, getPassword, getPrincipal, getType, getValidate, hasMessageDigest, hasResourcePermission, hasRole, hasUserDataPermission, init, log, log, main, postDeregister, postRegister, preDeregister, preRegister, removeLifecycleListener, removePropertyChangeListener, setContainer, setController, setDebug, setDigest, setDigestEncoding, setValidate, start, stop

Field Details

callbackHandler

protected 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 Map options
The configuration information for this LoginModule.


pathname

protected String pathname
The absolute or relative pathname to the XML configuration file.


principal

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


principals

protected HashMap principals
The set of Principals loaded from our configuration file.


sharedState

protected Map sharedState
The state information that is shared with other configured LoginModule instances.


sm

protected static StringManager sm
The string manager for this package.


subject

protected Subject subject
The subject for which we are performing authentication.

Constructor Details

JAASMemoryLoginModule

public JAASMemoryLoginModule()

Method Details

abort

public boolean abort()
            throws 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.

Returns:
true if this method succeeded, or false if this LoginModule should be ignored


commit

public boolean commit()
            throws 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.

Returns:
true if the authentication succeeded, or false if this LoginModule should be ignored


findSecurityConstraints

public SecurityConstraint[] findSecurityConstraints(HttpRequest request,
                                                    Context context)
Return the SecurityConstraints configured to guard the request URI for this request, or null if there is no such constraint.
Specified by:
findSecurityConstraints in interface Realm
Overrides:
findSecurityConstraints in interface RealmBase

Parameters:
request - Request we are processing
context - Context the Request is mapped to


initialize

public void initialize(Subject subject,
                       CallbackHandler callbackHandler,
                       Map sharedState,
                       Map options)
Initialize this LoginModule with the specified configuration information.

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


load

protected void load()
Load the contents of our configuration file.


login

public boolean login()
            throws LoginException
Phase 1 of authenticating a Subject.

Returns:
true if the authentication succeeded, or false if this LoginModule should be ignored


logout

public boolean logout()
            throws LoginException
Log out this user.

Returns:
true in all cases because thie LoginModule should not be ignored


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.