|
Préférences
Moteurs de recherche
|
||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.5.0
javax.security.auth.login
|
Constructor Summary | |
---|---|
LoginContext(String name)
Instantiate a new LoginContext object with a name. |
|
LoginContext(String name,
CallbackHandler callbackHandler)
Instantiate a new LoginContext object with a name
and a CallbackHandler object. |
|
LoginContext(String name,
Subject subject)
Instantiate a new LoginContext object with a name
and a Subject object. |
|
LoginContext(String name,
Subject subject,
CallbackHandler callbackHandler)
Instantiate a new LoginContext object with a name,
a Subject to be authenticated, and a
CallbackHandler object. |
|
LoginContext(String name,
Subject subject,
CallbackHandler callbackHandler,
Configuration config)
Instantiate a new LoginContext object with a name,
a Subject to be authenticated,
a CallbackHandler object, and a login
Configuration . |
Method Summary | |
---|---|
Subject |
getSubject()
Return the authenticated Subject. |
void |
login()
Perform the authentication. |
void |
logout()
Logout the Subject . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LoginContext(String name) throws LoginException
LoginContext
object with a name.
name
- the name used as the index into the
Configuration
.
LoginException
- if the caller-specified name
does not appear in the Configuration
and there is no Configuration
entry
for "other", or if the
auth.login.defaultCallbackHandler
security property was set, but the implementation
class could not be loaded.
SecurityException
- if a SecurityManager is set and
the caller does not have
AuthPermission("createLoginContext.name"),
or if a configuration entry for name does not exist and
the caller does not additionally have
AuthPermission("createLoginContext.other")public LoginContext(String name, Subject subject) throws LoginException
LoginContext
object with a name
and a Subject
object.
name
- the name used as the index into the
Configuration
. subject
- the Subject
to authenticate.
LoginException
- if the caller-specified name
does not appear in the Configuration
and there is no Configuration
entry
for "other", if the caller-specified subject
is null
, or if the
auth.login.defaultCallbackHandler
security property was set, but the implementation
class could not be loaded.
SecurityException
- if a SecurityManager is set and
the caller does not have
AuthPermission("createLoginContext.name"),
or if a configuration entry for name does not exist and
the caller does not additionally have
AuthPermission("createLoginContext.other")public LoginContext(String name, CallbackHandler callbackHandler) throws LoginException
LoginContext
object with a name
and a CallbackHandler
object.
name
- the name used as the index into the
Configuration
. callbackHandler
- the CallbackHandler
object used by
LoginModules to communicate with the user.
LoginException
- if the caller-specified name
does not appear in the Configuration
and there is no Configuration
entry
for "other", or if the caller-specified
callbackHandler
is null
.
SecurityException
- if a SecurityManager is set and
the caller does not have
AuthPermission("createLoginContext.name"),
or if a configuration entry for name does not exist and
the caller does not additionally have
AuthPermission("createLoginContext.other")public LoginContext(String name, Subject subject, CallbackHandler callbackHandler) throws LoginException
LoginContext
object with a name,
a Subject
to be authenticated, and a
CallbackHandler
object.
name
- the name used as the index into the
Configuration
. subject
- the Subject
to authenticate. callbackHandler
- the CallbackHandler
object used by
LoginModules to communicate with the user.
LoginException
- if the caller-specified name
does not appear in the Configuration
and there is no Configuration
entry
for "other", or if the caller-specified
subject
is null
,
or if the caller-specified
callbackHandler
is null
.
SecurityException
- if a SecurityManager is set and
the caller does not have
AuthPermission("createLoginContext.name"),
or if a configuration entry for name does not exist and
the caller does not additionally have
AuthPermission("createLoginContext.other")public LoginContext(String name, Subject subject, CallbackHandler callbackHandler, Configuration config) throws LoginException
LoginContext
object with a name,
a Subject
to be authenticated,
a CallbackHandler
object, and a login
Configuration
.
name
- the name used as the index into the caller-specified
Configuration
. subject
- the Subject
to authenticate,
or null
. callbackHandler
- the CallbackHandler
object used by
LoginModules to communicate with the user, or null
.
config
- the Configuration
that lists the
login modules to be called to perform the authentication,
or null
.
LoginException
- if the caller-specified name
does not appear in the Configuration
and there is no Configuration
entry
for "other".
SecurityException
- if a SecurityManager is set,
config is null
,
and either the caller does not have
AuthPermission("createLoginContext.name"),
or if a configuration entry for name does not exist and
the caller does not additionally have
AuthPermission("createLoginContext.other")Method Detail |
---|
public void login() throws LoginException
This method invokes the login
method for each
LoginModule configured for the name specified to the
LoginContext
constructor, as determined by the login
Configuration
. Each LoginModule
then performs its respective type of authentication
(username/password, smart card pin verification, etc.).
This method completes a 2-phase authentication process by
calling each configured LoginModule's commit
method
if the overall authentication succeeded (the relevant REQUIRED,
REQUISITE, SUFFICIENT, and OPTIONAL LoginModules succeeded),
or by calling each configured LoginModule's abort
method
if the overall authentication failed. If authentication succeeded,
each successful LoginModule's commit
method associates
the relevant Principals and Credentials with the Subject
.
If authentication failed, each LoginModule's abort
method
removes/destroys any previously stored state.
If the commit
phase of the authentication process
fails, then the overall authentication fails and this method
invokes the abort
method for each configured
LoginModule
.
If the abort
phase
fails for any reason, then this method propagates the
original exception thrown either during the login
phase
or the commit
phase. In either case, the overall
authentication fails.
In the case where multiple LoginModules fail,
this method propagates the exception raised by the first
LoginModule
which failed.
Note that if this method enters the abort
phase
(either the login
or commit
phase failed),
this method invokes all LoginModules configured for the
application regardless of their respective Configuration
flag parameters. Essentially this means that Requisite
and Sufficient
semantics are ignored during the
abort
phase. This guarantees that proper cleanup
and state restoration can take place.
LoginException
- if the authentication fails.public void logout() throws LoginException
Subject
.
This method invokes the logout
method for each
LoginModule
configured for this LoginContext
.
Each LoginModule
performs its respective logout procedure
which may include removing/destroying
Principal
and Credential
information
from the Subject
and state cleanup.
Note that this method invokes all LoginModules configured for the
application regardless of their respective
Configuration
flag parameters. Essentially this means
that Requisite
and Sufficient
semantics are
ignored for this method. This guarantees that proper cleanup
and state restoration can take place.
LoginException
- if the logout fails.public Subject getSubject()