public final class AuthContext extends Object
LoginContext
provided by
JAAS by supporting organization environments that cannot handle sessions, for
example, HTTP/HTML.
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 has been supplied. The caller then checks if the user has
successfully been authenticated. If successfully authenticated, the caller
can then get the
Subject
for the user; if not successfully
authenticated, the caller obtains the LoginException.
Modifier and Type | Field and Description |
---|---|
protected String |
applicationName |
static int |
AUTH_COMPLETED
This login status indicates that the user has been
successfully logged out.
|
static int |
AUTH_FAILED
This login status indicates that the login process
has failed.
|
static int |
AUTH_IN_PROGRESS
This login status indicates that the login process
is in progress.
|
static int |
AUTH_NOT_STARTED
This login status indicates that the login process
has not started yet.
|
static int |
AUTH_SUCCESS
This login status indicates that the login process
has succeeded.
|
protected String |
authComponentName |
protected static Debug |
authDebug |
protected static String |
authDebugName |
protected static String |
authKeyName |
protected Callback[] |
informationRequired |
protected LoginContext |
loginContext |
protected LoginException |
loginException |
protected int |
loginStatus |
protected AuthLoginThread |
loginThread |
protected static I18n |
myAuthI18n |
protected String |
organizationName |
protected Callback[] |
submittedInformation |
protected SSOToken |
token |
Modifier | Constructor and Description |
---|---|
|
AuthContext()
Constructor to get an instance of
AuthContext . |
|
AuthContext(Principal principal,
char[] password)
Constructor to get an authenticated instance
of this class given the
java.security.Principal the user
would like to be authenticated as, and the password for
the user. |
|
AuthContext(Principal principal,
char[] password,
String hostname,
int port) |
|
AuthContext(String orgName)
Constructor to get an instance of this class
given the organization name
orgName . |
protected |
AuthContext(String orgName,
AuthSubject subject)
Constructor to get an instance of this class given the organization name
orgName the user would like to access, and the principal's
subject the user would like to be authenticated as. |
|
AuthContext(String orgName,
Principal principal,
char[] password)
Constructor to get an instance of this class
given the organization name
orgName the user would like to
access, the java.security.Principal
the user would like to
be authenticated as, and the password for the user. |
Modifier and Type | Method and Description |
---|---|
protected String |
getApplicationName() |
AuthPrincipal |
getAuthPrincipal()
Deprecated.
Use getPrincipal() instead
|
LoginException |
getLoginException()
Returns login exception, if any, during the
authentication process.
|
int |
getLoginStatus()
Returns the current state of the login process.
|
String |
getOrganizationName()
Method to get organization name that was set during
construction of this instance.
|
Principal |
getPrincipal()
Returns the (first)
AuthPrincipal in
the Subject . |
protected Set |
getPrincipals()
Method to get the set of
AuthPrincipal s in the
Subject . |
Callback[] |
getRequirements()
Returns an array of
Callback objects
that must be populated by the user and returned back. |
SSOToken |
getSSOToken()
Method to get the Single-Sign-On (SSO) Token.
|
protected AuthSubject |
getSubject()
Returns the set of Principals the user has been authenticated as.
|
boolean |
hasMoreRequirements()
Returns true if the login process requires more
information from the user to complete the authentication.
|
void |
logout()
Logs the user out.
|
protected void |
reset()
Method to reset this instance of
AuthContext object, so
that a new login process can be initiated. |
protected void |
reset(AuthSubject subject)
Method to reset this instance of
AuthContext object, so
that a new login process can be initiated for the given
Subject . |
protected void |
setLoginStatus(int status)
Method to set the login status.
|
void |
startLogin()
Method to start the login process.
|
void |
submitRequiredInformation(Callback[] info)
Submits the populated
Callback
objects to the authentication plug-in modules. |
public static final int AUTH_NOT_STARTED
startLogin
has not been called.public static final int AUTH_IN_PROGRESS
startLogin
method has been called and that this object is waiting for the user to
send authentication information.public static final int AUTH_SUCCESS
public static final int AUTH_FAILED
public static final int AUTH_COMPLETED
protected final String authComponentName
protected static final String authKeyName
protected static final String authDebugName
protected static Debug authDebug
protected String organizationName
protected String applicationName
protected int loginStatus
protected LoginException loginException
protected Callback[] informationRequired
protected Callback[] submittedInformation
protected AuthLoginThread loginThread
protected LoginContext loginContext
protected SSOToken token
protected static I18n myAuthI18n
public AuthContext() throws LoginException
AuthContext
. Caller would then use
getRequirements()
and submitRequirements()
to pass the credentials needed for authentication by the plugin modules.LoginException
public AuthContext(Principal principal, char[] password) throws LoginException
java.security.Principal
the user
would like to be authenticated as, and the password
for
the user.principal
- name of the user to be authenticatedpassword
- password for the userLoginException
public AuthContext(Principal principal, char[] password, String hostname, int port) throws LoginException
LoginException
public AuthContext(String orgName, Principal principal, char[] password) throws LoginException
orgName
the user would like to
access, the java.security.Principal
the user would like to
be authenticated as, and the password
for the user.orgName
- name of the user's organizationprincipal
- name of the user to be authenticatedpassword
- password for the userLoginException
protected AuthContext(String orgName, AuthSubject subject) throws LoginException
orgName
the user would like to access, and the principal's
subject
the user would like to be authenticated as.LoginException
public AuthContext(String orgName) throws LoginException
orgName
. The plug-in modules
would then query for the user name and related information.orgName
- organization name.LoginException
protected void reset() throws LoginException
AuthContext
object, so
that a new login process can be initiated. Authenticates the user to the
same organization or resource this object was instantiated with. If this
object was instantiated with a
Subject
, it will be
ignored.LoginException
protected void reset(AuthSubject subject) throws LoginException
AuthContext
object, so
that a new login process can be initiated for the given
Subject
. Authenticates the user to the same organization
or resource this object was instantiated with.LoginException
protected AuthSubject getSubject()
null
.public void startLogin() throws LoginException
LoginException
public boolean hasMoreRequirements()
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 that must be
populated by the user and returned back.public void submitRequiredInformation(Callback[] info)
Callback
objects to the authentication plug-in modules. Called after
getInformationRequired
method and obtaining user's
response to these requests.info
- array of Callback
objects.public void logout() throws LoginException
LoginException
public LoginException getLoginException()
public int getLoginStatus()
protected void setLoginStatus(int status)
public Principal getPrincipal()
AuthPrincipal
in
the Subject
. Returns the first Principal
,
if more than one exists.AuthPrincipal
in the
Subject
.public AuthPrincipal getAuthPrincipal()
AuthPrincipal
in the
Subject
. Returns the first Principal
, if
more than one exists.protected Set getPrincipals()
AuthPrincipal
s in the
Subject
.public String getOrganizationName()
null
if it was not initialized
during construction of this instanceprotected String getApplicationName()
public SSOToken getSSOToken() throws InvalidAuthContextException
InvalidAuthContextException
Copyright © 2010–2025 Open Identity Platform Community. All rights reserved.