Class AuthenticationServiceImpl
- java.lang.Object
-
- org.glassfish.security.services.impl.AuthenticationServiceImpl
-
- All Implemented Interfaces:
org.glassfish.hk2.api.PostConstruct,AuthenticationService,SecurityService
@Service @Singleton public class AuthenticationServiceImpl extends Object implements AuthenticationService, org.glassfish.hk2.api.PostConstruct
The Authentication Service Implementation. Use JAAS LoginContext with the LoginModule(s) specified by the service configuration.
-
-
Constructor Summary
Constructors Constructor Description AuthenticationServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Subjectimpersonate(String user, String[] groups, Subject subject, boolean virtual)Impersonate a user, specifying the user and group principal names that should be established in the resulting Subject.voidinitialize(SecurityConfiguration securityServiceConfiguration)Initialize the Authentication Service configuration.Subjectlogin(String username, char[] password, Subject subject)Log in a user with username and password.Subjectlogin(CallbackHandler cbh, Subject subject)Authenticate using a CallbackHandler to provider username/password, X.509 certificate, or Secure Admin token.voidpostConstruct()Handle lookup of authentication service configuration and initialization.
-
-
-
Method Detail
-
initialize
public void initialize(SecurityConfiguration securityServiceConfiguration)
Initialize the Authentication Service configuration. Create the JAAS Configuration using the specified LoginModule configurations- Specified by:
initializein interfaceSecurityService
-
login
public Subject login(String username, char[] password, Subject subject) throws LoginException
Description copied from interface:AuthenticationServiceLog in a user with username and password.- Specified by:
loginin interfaceAuthenticationService- Parameters:
username- The username.password- The password.subject- An optional Subject to receive principals and credentials for the logged in user. If provided, it will be returned as the return value; if not, a new Subject will be returned.- Returns:
- A Subject representing the logged in user.
- Throws:
LoginException
-
login
public Subject login(CallbackHandler cbh, Subject subject) throws LoginException
Description copied from interface:AuthenticationServiceAuthenticate using a CallbackHandler to provider username/password, X.509 certificate, or Secure Admin token.- Specified by:
loginin interfaceAuthenticationService- Parameters:
cbh- The CallbackHandler.subject- An optional Subject to receive principals and credentials for the logged in user. If provided, it will be returned as the return value; if not, a new Subject will be returned.- Returns:
- A Subject representing the logged in user.
- Throws:
LoginException
-
impersonate
public Subject impersonate(String user, String[] groups, Subject subject, boolean virtual) throws LoginException
Description copied from interface:AuthenticationServiceImpersonate a user, specifying the user and group principal names that should be established in the resulting Subject. Note that, that this method always behaves as ifvirtual were true in the case that the underlying user store provider does not support user lookup.- Specified by:
impersonatein interfaceAuthenticationService- Parameters:
user- The username.groups- An array of group names. Ifvirtual is true, group principals will be created using this array. Ifvirtual is false and groups is non-null, it will be used to filter the groups returned by the configured UserStoreProvider.subject- An optional Subject to receive principals and credentials for the logged in user. If provided, it will be returned as the return value; if not, a new Subject will be returned.virtual- If true, simply create a subject with the given user and group names. If false, configured UserStoreProvider will be queried for the given username and a Subject created only if the user exists. Groups will be populated with the intersection of the groups parameter and the groups returned by the UserStoreProvider.- Returns:
- A Subject representing the impersonated user.
- Throws:
LoginException
-
postConstruct
public void postConstruct()
Handle lookup of authentication service configuration and initialization. If no service is configured the service run-time will throw exceptions. Addresses alternate configuration handling until adopt @Proxiable support.- Specified by:
postConstructin interfaceorg.glassfish.hk2.api.PostConstruct
-
-