public class SpnegoAuthenticationProcessingFilter
extends org.springframework.web.filter.GenericFilterBean
KerberosServiceRequestToken
out if it. It will then
call the AuthenticationManager
.
A typical Spring Security configuration might look like this:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://www.springframework.org/schema/security" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> <sec:http entry-point-ref="spnegoEntryPoint"> <sec:intercept-url pattern="/secure/**" access="IS_AUTHENTICATED_FULLY" /> <sec:custom-filter ref="spnegoAuthenticationProcessingFilter" position="BASIC_AUTH_FILTER" /> </sec:http> <bean id="spnegoEntryPoint" class="org.springframework.security.kerberos.web.authentication.SpnegoEntryPoint" /> <bean id="spnegoAuthenticationProcessingFilter" class="org.springframework.security.kerberos.web.authentication.SpnegoAuthenticationProcessingFilter"> <property name="authenticationManager" ref="authenticationManager" /> </bean> <sec:authentication-manager alias="authenticationManager"> <sec:authentication-provider ref="kerberosServiceAuthenticationProvider" /> </sec:authentication-manager> <bean id="kerberosServiceAuthenticationProvider" class="org.springframework.security.kerberos.authenitcation.KerberosServiceAuthenticationProvider"> <property name="ticketValidator"> <bean class="org.springframework.security.kerberos.authentication.sun.SunJaasKerberosTicketValidator"> <property name="servicePrincipal" value="HTTP/web.springsource.com" /> <property name="keyTabLocation" value="classpath:http-java.keytab" /> </bean> </property> <property name="userDetailsService" ref="inMemoryUserDetailsService" /> </bean> <bean id="inMemoryUserDetailsService" class="org.springframework.security.core.userdetails.memory.InMemoryDaoImpl"> <property name="userProperties"> <value> [email protected]=notUsed,ROLE_ADMIN </value> </property> </bean> </beans>
If you get a "GSSException: Channel binding mismatch (Mechanism level:ChannelBinding not provided!) have a look at this bug.
A workaround unti this is fixed in the JVM is to change
HKEY_LOCAL_MACHINE\System \CurrentControlSet\Control\LSA\SuppressExtendedProtection to 0x02KerberosServiceAuthenticationProvider
,
SpnegoEntryPoint
Constructor and Description |
---|
SpnegoAuthenticationProcessingFilter() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
doFilter(javax.servlet.ServletRequest req,
javax.servlet.ServletResponse res,
javax.servlet.FilterChain chain) |
void |
setAuthenticationDetailsSource(org.springframework.security.authentication.AuthenticationDetailsSource<javax.servlet.http.HttpServletRequest,?> authenticationDetailsSource)
Sets the authentication details source.
|
void |
setAuthenticationManager(org.springframework.security.authentication.AuthenticationManager authenticationManager)
The authentication manager for validating the ticket.
|
void |
setFailureHandler(org.springframework.security.web.authentication.AuthenticationFailureHandler failureHandler)
This handler is called after a failure authentication.
|
void |
setSessionAuthenticationStrategy(org.springframework.security.web.authentication.session.SessionAuthenticationStrategy sessionStrategy)
The session handling strategy which will be invoked immediately after an
authentication request is successfully processed by the
AuthenticationManager.
|
void |
setSkipIfAlreadyAuthenticated(boolean skipIfAlreadyAuthenticated)
Should Kerberos authentication be skipped if a user is already authenticated
for this request (e.g.
|
void |
setSuccessHandler(org.springframework.security.web.authentication.AuthenticationSuccessHandler successHandler)
This handler is called after a successful authentication.
|
public SpnegoAuthenticationProcessingFilter()
public void doFilter(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain) throws java.io.IOException, javax.servlet.ServletException
java.io.IOException
javax.servlet.ServletException
public void afterPropertiesSet() throws javax.servlet.ServletException
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
in class org.springframework.web.filter.GenericFilterBean
javax.servlet.ServletException
public void setAuthenticationManager(org.springframework.security.authentication.AuthenticationManager authenticationManager)
authenticationManager
- the authentication managerpublic void setSuccessHandler(org.springframework.security.web.authentication.AuthenticationSuccessHandler successHandler)
This handler is called after a successful authentication. One can add additional authentication behavior by setting this.
Default is null, which means nothing additional happens
successHandler
- the authentication success handlerpublic void setFailureHandler(org.springframework.security.web.authentication.AuthenticationFailureHandler failureHandler)
This handler is called after a failure authentication. In most cases you only get Kerberos/SPNEGO failures with a wrong server or network configurations and not during runtime. If the client encounters an error, he will just stop the communication with server and therefore this handler will not be called in this case.
Default is null, which means that the Filter returns the HTTP 500 code
failureHandler
- the authentication failure handlerpublic void setSkipIfAlreadyAuthenticated(boolean skipIfAlreadyAuthenticated)
skipIfAlreadyAuthenticated
- default is truepublic void setSessionAuthenticationStrategy(org.springframework.security.web.authentication.session.SessionAuthenticationStrategy sessionStrategy)
sessionStrategy
- the implementation to use. If not set a null
implementation is used.public void setAuthenticationDetailsSource(org.springframework.security.authentication.AuthenticationDetailsSource<javax.servlet.http.HttpServletRequest,?> authenticationDetailsSource)
authenticationDetailsSource
- the authentication details source