Package org.apache.wiki.auth.login
Class AbstractLoginModule
- java.lang.Object
-
- org.apache.wiki.auth.login.AbstractLoginModule
-
- All Implemented Interfaces:
javax.security.auth.spi.LoginModule
- Direct Known Subclasses:
AnonymousLoginModule
,CookieAssertionLoginModule
,CookieAuthenticationLoginModule
,UserDatabaseLoginModule
,WebContainerLoginModule
public abstract class AbstractLoginModule extends java.lang.Object implements javax.security.auth.spi.LoginModule
Abstract JAASLoginModule
that implements base functionality. The methodslogin()
andcommit()
must be implemented by subclasses. The default implementations ofinitialize(Subject, CallbackHandler, Map, Map)
,abort()
andlogout()
should be sufficient for most purposes.- Since:
- 2.3
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.security.auth.callback.CallbackHandler
m_handler
protected java.util.Map<java.lang.String,?>
m_options
protected java.util.Collection<java.security.Principal>
m_principals
Implementing classes should add Principals to this collection; these will be added to the principal set when the overall login succeeds.protected java.util.Map<java.lang.String,?>
m_state
protected javax.security.auth.Subject
m_subject
protected static java.lang.String
NULL
-
Constructor Summary
Constructors Constructor Description AbstractLoginModule()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
abort()
Aborts the login; called if the LoginContext's overall authentication failed.boolean
commit()
Commits the login.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)
Initializes the LoginModule with a givenSubject
, callback handler, options and shared state.abstract boolean
login()
Logs in the user by calling back to the registered CallbackHandler with a series of callbacks.boolean
logout()
Logs the user out.
-
-
-
Field Detail
-
m_handler
protected javax.security.auth.callback.CallbackHandler m_handler
-
m_options
protected java.util.Map<java.lang.String,?> m_options
-
m_principals
protected java.util.Collection<java.security.Principal> m_principals
Implementing classes should add Principals to this collection; these will be added to the principal set when the overall login succeeds. These Principals will be added to the Subject during thecommit()
phase of login.
-
m_state
protected java.util.Map<java.lang.String,?> m_state
-
m_subject
protected javax.security.auth.Subject m_subject
-
NULL
protected static final java.lang.String NULL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractLoginModule
public AbstractLoginModule()
-
-
Method Detail
-
abort
public final boolean abort()
Aborts the login; called if the LoginContext's overall authentication failed. (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules did not succeed). Specifically, it removes Principals from the Subject that are associated with the individual LoginModule; these will be those contained inm_principals
. It always returnstrue
.- Specified by:
abort
in interfacejavax.security.auth.spi.LoginModule
- Returns:
- True, always.
- See Also:
LoginModule.abort()
-
commit
public final boolean commit()
Commits the login. If the overall login method succeeded, adds principals to the Subject's set; generally, these will be the user's actual Principal, plus one or more Role principals. The state of them_principals
member variable is consulted to determine whether to add the principals. If its size is 0 (because the login failed), the login is considered to have failed; in this case, all principals inm_principals
are removed from the Subject's set. Otherwise, the principals added tom_principals
in thelogin()
method are added to the Subject's set.- Specified by:
commit
in interfacejavax.security.auth.spi.LoginModule
- Returns:
true
if the commit succeeded, orfalse
if the previous call tologin()
failed- See Also:
LoginModule.commit()
-
initialize
public final 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)
Initializes the LoginModule with a givenSubject
, callback handler, options and shared state. In particular, the member variablem_principals
is initialized as a blank Set.- Specified by:
initialize
in interfacejavax.security.auth.spi.LoginModule
- Parameters:
subject
-callbackHandler
-sharedState
-options
-- See Also:
LoginModule.initialize(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler, java.util.Map, java.util.Map)
-
login
public abstract boolean login() throws javax.security.auth.login.LoginException
Logs in the user by calling back to the registered CallbackHandler with a series of callbacks. If the login succeeds, this method returnstrue
- Specified by:
login
in interfacejavax.security.auth.spi.LoginModule
- Returns:
true
if the commit succeeded, orfalse
if this LoginModule should be ignored.- Throws:
javax.security.auth.login.LoginException
- if the authentication fails- See Also:
LoginModule.login()
-
logout
public final boolean logout()
Logs the user out. Removes all principals inm_principals
from the Subject's principal set.- Specified by:
logout
in interfacejavax.security.auth.spi.LoginModule
- Returns:
true
if the commit succeeded, orfalse
if this LoginModule should be ignored- See Also:
LoginModule.logout()
-
-