Class SecurityContextLoginModule
java.lang.Object
org.springframework.security.authentication.jaas.SecurityContextLoginModule
- All Implemented Interfaces:
- LoginModule
An implementation of 
LoginModule that uses a Spring Security
 SecurityContext to
 provide authentication.
 
 This LoginModule provides opposite functionality to the
 JaasAuthenticationProvider API, and should not really be used in conjunction
 with it.
 
 The JaasAuthenticationProvider allows Spring Security to authenticate against
 Jaas.
 
 The SecurityContextLoginModule allows a Jaas based application to authenticate against
 Spring Security. If there is no Authentication in the SecurityContextHolder the
 login() method will throw a LoginException by default. This functionality can be
 changed with the ignoreMissingAuthentication option by setting it to "true".
 Setting ignoreMissingAuthentication=true will tell the SecurityContextLoginModule to
 simply return false and be ignored if the authentication is null.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanabort()Abort the authentication process by forgetting the Spring SecurityAuthentication.booleancommit()Authenticate theSubject(phase two) by adding the Spring SecurityAuthenticationto theSubject's principals.voidinitialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) Initialize thisLoginModule.booleanlogin()Authenticate theSubject(phase one) by extracting the Spring SecurityAuthenticationfrom the currentSecurityContext.booleanlogout()Log out theSubject.voidsetSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use.
- 
Constructor Details- 
SecurityContextLoginModulepublic SecurityContextLoginModule()
 
- 
- 
Method Details- 
abortpublic boolean abort()Abort the authentication process by forgetting the Spring SecurityAuthentication.- Specified by:
- abortin interface- LoginModule
- Returns:
- true if this method succeeded, or false if this LoginModuleshould be ignored.
 
- 
commitpublic boolean commit()Authenticate theSubject(phase two) by adding the Spring SecurityAuthenticationto theSubject's principals.- Specified by:
- commitin interface- LoginModule
- Returns:
- true if this method succeeded, or false if this LoginModuleshould be ignored.
 
- 
setSecurityContextHolderStrategypublic void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use. The default action is to use theSecurityContextHolderStrategystored inSecurityContextHolder.- Since:
- 5.8
 
- 
initializepublic void initialize(Subject subject, CallbackHandler callbackHandler, Map sharedState, Map options) Initialize thisLoginModule. Ignores the callback handler, since the code establishing theLoginContextlikely won't provide one that understands Spring Security. Also ignores thesharedStateandoptionsparameters, since none are recognized.- Specified by:
- initializein interface- LoginModule
- Parameters:
- subject- the- Subjectto be authenticated.
- callbackHandler- is ignored
- sharedState- is ignored
- options- are ignored
 
- 
loginAuthenticate theSubject(phase one) by extracting the Spring SecurityAuthenticationfrom the currentSecurityContext.- Specified by:
- loginin interface- LoginModule
- Returns:
- true if the authentication succeeded, or false if this
 LoginModuleshould be ignored.
- Throws:
- LoginException- if the authentication fails
 
- 
logoutpublic boolean logout()Log out theSubject.- Specified by:
- logoutin interface- LoginModule
- Returns:
- true if this method succeeded, or false if this LoginModuleshould be ignored.
 
 
-