Top Description Fields Constructors Methods
org.apache.catalina.realm

public Class JAASMemoryLoginModule

extends MemoryRealm
implements LoginModule
Class Inheritance
All Implemented Interfaces
javax.security.auth.spi.LoginModule
Imports
java.io.File, .IOException, java.security.Principal, java.util.Map, .Map.Entry, javax.security.auth.Subject, javax.security.auth.callback.Callback, .CallbackHandler, .NameCallback, .PasswordCallback, .TextInputCallback, .UnsupportedCallbackException, javax.security.auth.login.FailedLoginException, .LoginException, javax.security.auth.spi.LoginModule, jakarta.servlet.http.HttpServletRequest, org.apache.catalina.CredentialHandler, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.IntrospectionUtils, org.apache.tomcat.util.digester.Digester

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.

This class recognizes the following string-valued options, which are specified in the configuration file and passed to initialize(Subject, CallbackHandler, Map, Map) 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.

Author
Craig R. McClanahan

Field Summary

Modifier and TypeField and Description
protected CallbackHandler
callbackHandler

The callback handler responsible for answering our requests.

protected boolean
committed

Has our own commit() returned successfully?

private static final Log
protected Map<String, ?>
options

The configuration information for this LoginModule.

protected String
pathname

Hides org.apache.catalina.realm.MemoryRealm.pathname.

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

The Principal identified by our validation, or null if validation failed.

protected Map<String, ?>
sharedState

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

protected Subject
subject

The subject for which we are performing authentication.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
abort()

Implements javax.security.auth.spi.LoginModule.abort.

Method to abort the authentication process (phase 2).

public boolean
commit()

Implements javax.security.auth.spi.LoginModule.commit.

Method to commit the authentication process (phase 2).

private String
public void
initialize(Subject
the Subject to be authenticated.
subject
,
CallbackHandler
a CallbackHandler for communicating with the end user (prompting for usernames and passwords, for example).
callbackHandler
,
Map<String, ?>
state shared with other configured LoginModules.
sharedState
,
Map<String, ?>
options specified in the login Configuration for this particular LoginModule.
options
)

Implements javax.security.auth.spi.LoginModule.initialize.

Initialize this LoginModule.

protected void
load()

Load the contents of our configuration file.

public boolean
login()

Implements javax.security.auth.spi.LoginModule.login.

Method to authenticate a Subject (phase 1).

public boolean
logout()

Implements javax.security.auth.spi.LoginModule.logout.

Method which logs out a Subject.

Inherited from org.apache.catalina.realm.MemoryRealm:
addUserauthenticategetDigestergetPasswordgetPathnamegetPrincipalsetPathnamestartInternal

Field Detail

callbackHandlerback to summary
protected CallbackHandler callbackHandler

The callback handler responsible for answering our requests.

committedback to summary
protected boolean committed

Has our own commit() returned successfully?

logback to summary
private static final Log log

Hides org.apache.catalina.realm.MemoryRealm.log.

optionsback to summary
protected Map<String, ?> options

The configuration information for this LoginModule.

pathnameback to summary
protected String pathname

Hides org.apache.catalina.realm.MemoryRealm.pathname.

The absolute or relative pathname to the XML configuration file.

principalback to summary
protected Principal principal

The Principal identified by our validation, or null if validation failed.

sharedStateback to summary
protected Map<String, ?> sharedState

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

subjectback to summary
protected Subject subject

The subject for which we are performing authentication.

Constructor Detail

JAASMemoryLoginModuleback to summary
public JAASMemoryLoginModule()

Method Detail

abortback to summary
public boolean abort() throws LoginException

Implements javax.security.auth.spi.LoginModule.abort.

Doc from javax.security.auth.spi.LoginModule.abort.

Method to abort the authentication process (phase 2).

This method is called if the LoginContext's overall authentication failed. (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules did not succeed).

If this LoginModule's own authentication attempt succeeded (checked by retrieving the private state saved by the login method), then this method cleans up any state that was originally saved.

Returns:boolean

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

Annotations
@Override
Exceptions
LoginException:
if the abort fails
commitback to summary
public boolean commit() throws LoginException

Implements javax.security.auth.spi.LoginModule.commit.

Doc from javax.security.auth.spi.LoginModule.commit.

Method to commit the authentication process (phase 2).

This method is called if the LoginContext's overall authentication succeeded (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules succeeded).

If this LoginModule's own authentication attempt succeeded (checked by retrieving the private state saved by the login method), then this method associates relevant Principals and Credentials with the Subject located in the LoginModule. If this LoginModule's own authentication attempted failed, then this method removes/destroys any state that was originally saved.

Returns:boolean

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

Annotations
@Override
Exceptions
LoginException:
if the commit fails
getCatalinaBaseback to summary
private String getCatalinaBase()
initializeback to summary
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options)

Implements javax.security.auth.spi.LoginModule.initialize.

Doc from javax.security.auth.spi.LoginModule.initialize.

Initialize this LoginModule.

This method is called by the LoginContext after this LoginModule has been instantiated. The purpose of this method is to initialize this LoginModule with the relevant information. If this LoginModule does not understand any of the data stored in sharedState or options parameters, they can be ignored.

Parameters
subject:Subject

the Subject to be authenticated.

callbackHandler:CallbackHandler

a CallbackHandler for communicating with the end user (prompting for usernames and passwords, for example).

sharedState:Map<String, ?>

state shared with other configured LoginModules.

options:Map<String, ?>

options specified in the login Configuration for this particular LoginModule.

Annotations
@Override
loadback to summary
protected void load()

Load the contents of our configuration file.

loginback to summary
public boolean login() throws LoginException

Implements javax.security.auth.spi.LoginModule.login.

Doc from javax.security.auth.spi.LoginModule.login.

Method to authenticate a Subject (phase 1).

The implementation of this method authenticates a Subject. For example, it may prompt for Subject information such as a username and password and then attempt to verify the password. This method saves the result of the authentication attempt as private state within the LoginModule.

Returns:boolean

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

Annotations
@Override
Exceptions
LoginException:
if the authentication fails
logoutback to summary
public boolean logout() throws LoginException

Implements javax.security.auth.spi.LoginModule.logout.

Doc from javax.security.auth.spi.LoginModule.logout.

Method which logs out a Subject.

An implementation of this method might remove/destroy a Subject's Principals and Credentials.

Returns:boolean

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

Annotations
@Override
Exceptions
LoginException:
if the logout fails