public final class WebAndEjbToJaasBridge extends Object
Note that the JAAS system determines which LoginModule is ultimately being called, for instance the
FileLoginModule.
Actual LoginModules in Payara are each paired with a Payara Realm, for instance the FileLoginModule
is paired with the FileRealm. The LoginModule typically does very little else than directly delegating
to its peer Realm.
Also note that with few exceptions neither the LoginModule nor the Realm set the current security context, but only validate credentials and, if valid, return zero or more roles. The methods in this class set the security context if the JAAS credential validation succeeds.
All LoginModules used by Payara have the convention that* credentials are passed in via a Subject instance
(instead of the usual CallbackHandler). The validation outcome is a boolean, but is being passed via an exception.
No exception means success, while an exception means no success. If the LoginModule/Realm returned any roles they will
put into the same Subject instance that was used to pass the credentials in.
| Modifier and Type | Method and Description |
|---|---|
static void |
doX500Login(Subject subject,
String appModuleID)
A special case login for X500Name credentials.
|
static void |
login(DigestCredentials digestCred)
Performs Digest authentication based on RFC 2617.
|
static void |
login(String username,
char[] password,
String realmName)
This method is just a convenience wrapper for login(Subject, Class) method.
|
static void |
login(Subject subject,
Class<?> credentialClass)
This method performs the login on the server side.
|
static void |
loginPrincipal(String username,
String realmName)
This method is used for logging in a run As principal.
|
static void |
logout()
This method logs out the user by clearing the security context.
|
public static void login(String username, char[] password, String realmName)
String - usernameString - passwordString - realmName the name of the realm to login into, if realmName is null, we login into
the default realmpublic static void login(Subject subject, Class<?> credentialClass)
This method is the main login method for Payara. It is called with a Subject and the type (class) of credential which should be checked. The Subject must contain a credential of the specified type or login will fail.
While the implementation has been cleaned up, the login process still consists of a number of special cases which are treated separately at the realm level. In the future tighter JAAS integration could clean some of this up.
The following credential types are recognized at this time:
subject - the subject of the clientcredentialClass - the class of the credential packaged in the subject.LoginException - when login failspublic static void doX500Login(Subject subject, String appModuleID)
LoginException - when login failspublic static void login(DigestCredentials digestCred) throws LoginException
digestCred - DigestCredentialsLoginExceptionpublic static void loginPrincipal(String username, String realmName)
LoginException - if login failspublic static void logout()
LoginException - if logout failsCopyright © 2019. All rights reserved.