public abstract class AbstractLoginModule extends java.lang.Object implements javax.security.auth.spi.LoginModule
LoginModulethat implements
base functionality. The methods login() and commit() must
be implemented by subclasses. The default implementations of
initialize(Subject, CallbackHandler, Map, Map), abort() and
logout() should be sufficient for most purposes.| Modifier and Type | Field and 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 and Description |
|---|
AbstractLoginModule() |
| Modifier and Type | Method and 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 given
Subject,
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.
|
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
commit() phase of login.protected java.util.Map<java.lang.String,?> m_state
protected javax.security.auth.Subject m_subject
protected static final java.lang.String NULL
public AbstractLoginModule()
public final boolean abort()
m_principals.
It always returns true.abort in interface javax.security.auth.spi.LoginModuleLoginModule.abort()public final boolean commit()
m_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 in m_principals are removed
from the Subject's set. Otherwise, the principals added to
m_principals in the login() method are added to
the Subject's set.commit in interface javax.security.auth.spi.LoginModuletrue if the commit succeeded, or
false if the previous call to login()
failedLoginModule.commit()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)
Subject,
callback handler, options and shared state. In particular, the member
variable m_principals is initialized as a blank Set.initialize in interface javax.security.auth.spi.LoginModulesubject - callbackHandler - sharedState - options - LoginModule.initialize(javax.security.auth.Subject,
javax.security.auth.callback.CallbackHandler, java.util.Map, java.util.Map)public abstract boolean login() throws javax.security.auth.login.LoginException
truelogin in interface javax.security.auth.spi.LoginModuletrue if the commit succeeded, or
false if this LoginModule should be ignored.javax.security.auth.login.LoginException - if the authentication failsLoginModule.login()public final boolean logout()
m_principals
from the Subject's principal set.logout in interface javax.security.auth.spi.LoginModuletrue if the commit succeeded, or
false if this LoginModule should be ignoredLoginModule.logout()Copyright (c) 2001-2022 The Apache Software Foundation. All rights reserved.