Class DefaultJaasAuthenticationProvider
- java.lang.Object
-
- org.springframework.security.authentication.jaas.AbstractJaasAuthenticationProvider
-
- org.springframework.security.authentication.jaas.DefaultJaasAuthenticationProvider
-
- All Implemented Interfaces:
java.util.EventListener
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.ApplicationEventPublisherAware
,org.springframework.context.ApplicationListener<SessionDestroyedEvent>
,AuthenticationProvider
public class DefaultJaasAuthenticationProvider extends AbstractJaasAuthenticationProvider
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
Constructors Constructor Description DefaultJaasAuthenticationProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
afterPropertiesSet()
Validates the required properties are set.protected javax.security.auth.login.LoginContext
createLoginContext(javax.security.auth.callback.CallbackHandler handler)
Creates a LoginContext using the Configuration that was specified insetConfiguration(Configuration)
.protected javax.security.auth.login.Configuration
getConfiguration()
void
setConfiguration(javax.security.auth.login.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
-
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet() throws java.lang.Exception
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:
java.lang.Exception
-
createLoginContext
protected javax.security.auth.login.LoginContext createLoginContext(javax.security.auth.callback.CallbackHandler handler) throws javax.security.auth.login.LoginException
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:
javax.security.auth.login.LoginException
-
getConfiguration
protected javax.security.auth.login.Configuration getConfiguration()
-
setConfiguration
public void setConfiguration(javax.security.auth.login.Configuration configuration)
Sets the Configuration to use for Authentication.- Parameters:
configuration
- the Configuration that is used whencreateLoginContext(CallbackHandler)
is called.
-
-