public final class AuthContextLocal extends Object implements Serializable
AuthContextLocal
provides the implementation for
authenticating users.
A typical caller instantiates this class and starts the login process.
The caller then obtains an array of Callback
objects,
which contains the information required by the authentication plug-in
module. The caller requests information from the user. On receiving
the information from the user, the caller submits the same to this class.
If more information is required, the above process continues until all
the information required by the plug-ins/authentication modules, has
been supplied. The caller then checks if the user has successfully
been authenticated. If successfully authenticated, the caller can
then get the Subject
and SSOToken
for the user;
if not successfully authenticated, the caller obtains the AuthLoginException.
The implementation supports authenticating users either locally i.e., in process with all authentication modules configured or remotely to an authentication service/framework. (See documentation to configure in either of the modes).
The getRequirements()
and submitRequirements()
are used to pass the user credentials for authentication by the plugin
modules,getStatus()
returns the authentication status.
It should be serializable as a requirement to be stored in HttpSession.
Constructor and Description |
---|
AuthContextLocal(String orgName)
Creates
AuthContextLocal instance is obtained for a given
organization name, or sub organization name. |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Terminates an ongoing
login call that has not yet completed. |
AuthLoginException |
getLoginException()
Returns login exception, if any, during
the authentication process.
|
Set |
getModuleInstanceNames()
Returns authentication module/s instances(or) plugin(s) configured
for an organization, or sub-organization that was set during the
AuthContext constructor. |
String |
getOrganizationName()
Returns the the organization name that was set during the
AuthContextLocal constructor. |
Callback[] |
getRequirements()
Returns an array of
Callback objects that
must be populated by the user and returned back. |
Callback[] |
getRequirements(boolean noFilter)
Returns an array of
Callback objects that
must be populated by the user and returned back. |
SSOToken |
getSSOToken()
Returns the Single-Sign-On (SSO) Token for the authenticated
user.Single-Sign-On token can be used as the authenticated token.
|
AuthContext.Status |
getStatus()
Returns the current status of the authentication process.
|
Subject |
getSubject()
Returns the set of Principals the user has been authenticated as.
|
boolean |
hasMoreRequirements()
Checks if the login process requires more information from the user to
complete the authentication.
|
void |
login()
Starts the login process for the given
AuthContextLocal
object. |
void |
login(AuthContext.IndexType type,
String indexName)
Start the login process for the
AuthContextLocal object
identified by the index type and index name. |
void |
login(Principal principal,
char[] password)
Starts the login process for the given
AuthContextLocal s
object for the given Principal and the user's password. |
void |
login(Subject subject)
Starts the login process for the given
AuthContextLocal
object for the given Subject . |
void |
logout()
Logs out the user and also invalidates the
SSOToken
associated with this AuthContextLocal . |
void |
submitRequirements(Callback[] info)
Submit the populated
Callback objects
to the authentication plug-in modules. |
public AuthContextLocal(String orgName)
AuthContextLocal
instance is obtained for a given
organization name, or sub organization name. login
method is
then used to start the authentication process.orgName
- name of the user's organization.public Set getModuleInstanceNames()
AuthContext
constructor.UnsupportedOperationException
- if an error occurred.public void login() throws AuthLoginException
AuthContextLocal
object.AuthLoginException
- if an error occurred during login.public void login(Principal principal, char[] password) throws AuthLoginException
AuthContextLocal
s
object for the given Principal
and the user's password.
This method should be called primarily
when the authenticator knows there would no other
credentials needed to complete the authentication process.principal
- Principal
of the user to be authenticated.password
- password for the user.AuthLoginException
- if an error occurred
during login.public void login(AuthContext.IndexType type, String indexName) throws AuthLoginException
AuthContextLocal
object
identified by the index type and index name.
The IndexType
defines the possible kinds
of "objects" or "resources" for which an authentication can
be performed. Currently supported index types are
users, roles, services (or application), levels and mechanism.type
- authentication index type.indexName
- authentication index name.AuthLoginException
- if an error occurred
during login.public void login(Subject subject) throws AuthLoginException
AuthContextLocal
object for the given Subject
.
Refer to JAAS for description on Subject
.subject
- Subject
of the user to be authenticated.AuthLoginException
- if an error occurred
during login.public Subject getSubject()
null
.public boolean hasMoreRequirements()
true
if more credentials are required
from the user.public Callback[] getRequirements()
Callback
objects that
must be populated by the user and returned back.
These objects are requested by the authentication plug-ins,
and these are usually displayed to the user. The user then provides
the requested information for it to be authenticated.Callback
objects requesting credentials
from user.public Callback[] getRequirements(boolean noFilter)
Callback
objects that
must be populated by the user and returned back.
These objects are requested by the authentication plug-ins,
and these are usually displayed to the user. The user then provides
the requested information for it to be authenticated.noFilter
- flag to indicate if there is a FilterCallback
objects requesting credentials
from user.public void submitRequirements(Callback[] info)
Callback
objects
to the authentication plug-in modules. Called after
getRequirements
method and obtaining
user's response to these requests.info
- array of Callback
objectspublic void logout() throws AuthLoginException
SSOToken
associated with this AuthContextLocal
.AuthLoginException
- if an error occurred during logoutpublic AuthLoginException getLoginException()
public AuthContext.Status getStatus()
public SSOToken getSSOToken()
public String getOrganizationName()
AuthContextLocal
constructor.public void abort() throws AuthLoginException
login
call that has not yet completed.AuthLoginException
- if an error occurred during abort.Copyright © 2010-2018, ForgeRock All Rights Reserved.