Class DefaultJaasAuthenticationProvider
java.lang.Object
org.springframework.security.authentication.jaas.AbstractJaasAuthenticationProvider
org.springframework.security.authentication.jaas.DefaultJaasAuthenticationProvider
- All Implemented Interfaces:
EventListener
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.ApplicationEventPublisherAware
,org.springframework.context.ApplicationListener<SessionDestroyedEvent>
,AuthenticationProvider
Creates a LoginContext using the Configuration provided to it. This allows the
configuration to be injected regardless of the value of
Configuration.getConfiguration()
.
While not bound to any particular Configuration implementation, an in memory version of
a JAAS configuration can be represented using InMemoryConfiguration
.
The following JAAS configuration:
SPRINGSECURITY { sample.SampleLoginModule required; };
Can be represented as follows:
<bean id="jaasAuthProvider" class="org.springframework.security.authentication.jaas.DefaultJaasAuthenticationProvider"> <property name="configuration"> <bean class="org.springframework.security.authentication.jaas.memory.InMemoryConfiguration"> <constructor-arg> <map> <!-- SPRINGSECURITY is the default loginContextName for AbstractJaasAuthenticationProvider--> <entry key="SPRINGSECURITY"> <array> <bean class="javax.security.auth.login.AppConfigurationEntry"> <constructor-arg value="sample.SampleLoginModule" /> <constructor-arg> <util:constant static-field="javax.security.auth.login.AppConfigurationEntry$LoginModuleControlFlag.REQUIRED" /> </constructor-arg> <constructor-arg> <map></map> </constructor-arg> </bean> </array> </entry> </map> </constructor-arg> </bean> </property> <property name="authorityGranters"> <list> <!-- You will need to write your own implementation of AuthorityGranter --> <bean class="org.springframework.security.authentication.jaas.TestAuthorityGranter"/> </list> </property> </bean>
-
Field Summary
Fields inherited from class org.springframework.security.authentication.jaas.AbstractJaasAuthenticationProvider
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Validates the required properties are set.protected LoginContext
createLoginContext
(CallbackHandler handler) Creates a LoginContext using the Configuration that was specified insetConfiguration(Configuration)
.protected Configuration
void
setConfiguration
(Configuration configuration) Sets the Configuration to use for Authentication.Methods inherited from class org.springframework.security.authentication.jaas.AbstractJaasAuthenticationProvider
authenticate, getApplicationEventPublisher, handleLogout, onApplicationEvent, publishFailureEvent, publishSuccessEvent, setApplicationEventPublisher, setAuthorityGranters, setCallbackHandlers, setLoginContextName, setLoginExceptionResolver, supports
-
Constructor Details
-
DefaultJaasAuthenticationProvider
public DefaultJaasAuthenticationProvider()
-
-
Method Details
-
afterPropertiesSet
Description copied from class:AbstractJaasAuthenticationProvider
Validates the required properties are set. In addition, ifAbstractJaasAuthenticationProvider.setCallbackHandlers(JaasAuthenticationCallbackHandler[])
has not been called with valid handlers, initializes to useJaasNameCallbackHandler
andJaasPasswordCallbackHandler
.- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Overrides:
afterPropertiesSet
in classAbstractJaasAuthenticationProvider
- Throws:
Exception
-
createLoginContext
Creates a LoginContext using the Configuration that was specified insetConfiguration(Configuration)
.- Specified by:
createLoginContext
in classAbstractJaasAuthenticationProvider
- Parameters:
handler
- The CallbackHandler that should be used for the LoginContext (nevernull
).- Returns:
- the LoginContext to use for authentication.
- Throws:
LoginException
-
getConfiguration
-
setConfiguration
Sets the Configuration to use for Authentication.- Parameters:
configuration
- the Configuration that is used whencreateLoginContext(CallbackHandler)
is called.
-