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.
Modifier and Type | Field and Description |
---|---|
AMLoginContext |
amlc
AuthLoginContext
|
protected static Debug |
authDebug
Hold the debug instance
|
protected static ResourceBundle |
bundle
Holds the locale-specific information
|
protected String |
hostName
Holds the host name
|
protected javax.servlet.http.HttpSession |
httpSession
Holds the http session
|
static String |
INDEX_NAME
authentication index name
|
static String |
INDEX_TYPE
authentication index type
|
protected Callback[] |
informationRequired
Holds call back information
|
static String |
LDAP_AUTH_URL
Holds LDAP URL
|
static String |
LOCALE
locale setting
|
protected AuthLoginException |
loginException
AuthLoginException
|
protected AuthContext.Status |
loginStatus |
LoginStatus |
ls
Holds LoginStatus
|
protected Set |
moduleInstanceNames
Holds the set of module instance names
|
protected String |
organizationName
Holds organizationName
|
protected char[] |
password
character array for password
|
static String |
PASSWORD
Holds Password for the user
|
static String |
PRINCIPAL
Holds principal name to be authenticated
|
static String |
REDIRECT_URL
Redirection URL
|
protected SSOToken |
ssoToken
Holds Single Sign on Token
|
protected Subject |
subject
Holds subject
|
static String |
SUBJECT
authentication subject
|
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. |
String |
getAuthIdentifier()
Returns the current 'authIdentifier' of the authentication process as
String Session ID.
|
protected static Callback[] |
getCallbacks(Callback[] recdCallbacks,
boolean noFilter)
Returns the array of
Callback requirements objects |
protected String |
getClientHostName()
Returns the clients host name
|
String |
getErrorCode()
Returns the error code.
|
String |
getErrorMessage()
Returns the error message.
|
String |
getErrorTemplate()
Returns the error template.
|
String |
getFailureURL()
Returns the Failure Login URL for the authenticating user.
|
protected javax.servlet.http.HttpSession |
getHttpSession()
Returns the
HTTPSession associated with the current
authentication context |
String |
getLockoutMsg()
Returns the account lockout message.
|
AuthLoginException |
getLoginException()
Returns login exception, if any, during
the authentication process.
|
LoginState |
getLoginState()
Returns the login state
|
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. |
String |
getOrgDN()
Returns the Organization DN
|
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.
|
String |
getSuccessURL()
Returns the Successful Login URL for the authenticated user.
|
boolean |
hasMoreRequirements()
Checks if the login process requires more information from the user to
complete the authentication.
|
boolean |
hasMoreRequirements(boolean noFilter)
Checks if the login process requires more information from the user to
complete the authentication
|
boolean |
isLockedOut()
Checks the account is locked out
|
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(AuthContext.IndexType type,
String indexName,
Map envMap,
String locale)
Starts the login process for the given
AuthContextLocal
object identified by the index type and index name. |
protected void |
login(AuthContext.IndexType type,
String indexName,
Principal principal,
char[] password,
Subject subject)
Performs the Login for the given AuthContext
|
protected void |
login(AuthContext.IndexType type,
String indexName,
Principal principal,
char[] password,
Subject subject,
Map envMap,
String locale)
Performs the Login for the given AuthContext
|
void |
login(AuthContext.IndexType type,
String indexName,
String locale)
Starts the login process for the given
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 |
reset()
Resets this instance of
AuthContextLocal
object, so that a new login process can be initiated. |
void |
setClientHostName(String hostname)
Sets the client's host name , this method is used in case of remote
authentication,to set the client's hostname or IP address.
|
void |
setHttpSession(javax.servlet.http.HttpSession session)
Sets the
HttpSession that will be used by
the SSO component to store the session information. |
void |
setLoginException(AuthLoginException exception)
Sets the login exception that represents errors during the
authentication process.
|
void |
setLoginState(LoginState state)
Sets the Login State
|
protected void |
setLoginStatus(AuthContext.Status status)
Sets the login status.
|
void |
setOrgDN(String orgDN)
Sets the Organization DN
|
void |
submitRequirements(Callback[] info)
Submit the populated
Callback objects
to the authentication plug-in modules. |
boolean |
submittedRequirements() |
protected static Debug authDebug
protected static ResourceBundle bundle
protected String organizationName
protected Set moduleInstanceNames
protected AuthContext.Status loginStatus
protected String hostName
protected javax.servlet.http.HttpSession httpSession
protected SSOToken ssoToken
protected volatile AuthLoginException loginException
protected Callback[] informationRequired
public AMLoginContext amlc
public LoginStatus ls
protected Subject subject
protected char[] password
public static final String LDAP_AUTH_URL
public static final String PRINCIPAL
public static final String PASSWORD
public static final String SUBJECT
public static final String INDEX_TYPE
public static final String INDEX_NAME
public static final String LOCALE
public static final String REDIRECT_URL
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 void login(AuthContext.IndexType type, String indexName, String locale) 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.
The locale specifies the user preferred locale setting.type
- authentication index type.indexName
- authentication index name.locale
- locale setting.AuthLoginException
- if an error occurred during
login process.public void login(AuthContext.IndexType type, String indexName, Map envMap, String locale) 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.
The locale specifies the user preferred locale setting.type
- authentication index type.indexName
- authentication index name.envMap
- Environment Map, key is String, value is set of string.
this is applicable only when the type is
AuthContext.IndexType.RESOURCE
locale
- locale setting.AuthLoginException
- if an error occurred during
login process.protected void login(AuthContext.IndexType type, String indexName, Principal principal, char[] password, Subject subject) throws AuthLoginException
type
- authentication index typeindexName
- authentication index nameprincipal
- principal name of the user to be authenticatedpassword
- password for the usersubject
- authentication subjectAuthLoginException
- if error occurs during loginprotected void login(AuthContext.IndexType type, String indexName, Principal principal, char[] password, Subject subject, Map envMap, String locale) throws AuthLoginException
type
- authentication index typeindexName
- authentication index nameprincipal
- principal name of the user to be authenticatedpassword
- password for the usersubject
- authentication subjectenvMap
- Environment map, this is applicable only when the type
is AuthContext.IndexType.RESOURCE
locale
- locale settingAuthLoginException
- if error occurs during loginpublic void reset()
AuthContextLocal
object, so that a new login process can be initiated.
A new authentication process can started using any
one of the login
methods.public Subject getSubject()
null
.public boolean hasMoreRequirements()
true
if more credentials are required
from the user.public boolean hasMoreRequirements(boolean noFilter)
noFilter
- falg to indicate if there is a Filtertrue
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 void setLoginException(AuthLoginException exception)
exception
- AuthLoginException to be set.public AuthContext.Status getStatus()
protected void setLoginStatus(AuthContext.Status status)
status
- login statuspublic SSOToken getSSOToken()
public String getSuccessURL()
public String getFailureURL()
public String getOrganizationName()
AuthContextLocal
constructor.public void abort() throws AuthLoginException
login
call that has not yet completed.AuthLoginException
- if an error occurred during abort.public String getErrorTemplate()
public String getErrorMessage()
public String getErrorCode()
public String getAuthIdentifier()
authIdentifier
of the authentication processpublic String getLockoutMsg()
public boolean isLockedOut()
true
if the account is locked,
false
otherwisepublic void setClientHostName(String hostname)
hostname
- Host name.protected String getClientHostName()
public boolean submittedRequirements()
public void setHttpSession(javax.servlet.http.HttpSession session)
HttpSession
that will be used by
the SSO component to store the session information. In the
absence of HttpSession
the information is stored
in HashMap
and will have issues with fail-over.
With session fail-over turned on HttpSession
would be provide persistance storage mechanism for SSO.session
- HttpSessionprotected javax.servlet.http.HttpSession getHttpSession()
HTTPSession
associated with the current
authentication contextprotected static Callback[] getCallbacks(Callback[] recdCallbacks, boolean noFilter)
Callback
requirements objectsrecdCallbacks
- callbacks requirementsnoFilter
- boolean to indicate if filter existsCallback
objectspublic void setLoginState(LoginState state)
state
- login statepublic LoginState getLoginState()
public void setOrgDN(String orgDN)
orgDN
- Organization DNpublic String getOrgDN()
Copyright © 2010–2025 Open Identity Platform Community. All rights reserved.