Class JaasApiIntegrationFilter
- java.lang.Object
-
- org.springframework.web.filter.GenericFilterBean
-
- org.springframework.security.web.jaasapi.JaasApiIntegrationFilter
-
- All Implemented Interfaces:
javax.servlet.Filter,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.EnvironmentAware,org.springframework.core.env.EnvironmentCapable,org.springframework.web.context.ServletContextAware
public class JaasApiIntegrationFilter extends org.springframework.web.filter.GenericFilterBeanA
Filterwhich attempts to obtain a JAASSubjectand continue theFilterChainrunning as thatSubject.By using this
Filterin conjunction with Spring'sJaasAuthenticationProviderboth Spring'sSecurityContextand a JAASSubjectcan be populated simultaneously. This is useful when integrating with code that requires a JAASSubjectto be populated.
-
-
Constructor Summary
Constructors Constructor Description JaasApiIntegrationFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddoFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)Attempts to obtain and run as a JAASSubjectusingobtainSubject(ServletRequest).protected javax.security.auth.SubjectobtainSubject(javax.servlet.ServletRequest request)Obtains theSubjectto run as ornullif noSubjectis available.voidsetCreateEmptySubject(boolean createEmptySubject)SetscreateEmptySubject.
-
-
-
Method Detail
-
doFilter
public final void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws javax.servlet.ServletException, java.io.IOExceptionAttempts to obtain and run as a JAAS
SubjectusingobtainSubject(ServletRequest).If the
Subjectisnulland createEmptySubject istrue, an empty, writeableSubjectis used. This allows for theSubjectto be populated at the time of login. If theSubjectisnull, theFilterChaincontinues with no additional processing. If theSubjectis notnull, theFilterChainis ran withSubject.doAs(Subject, PrivilegedExceptionAction)in conjunction with theSubjectobtained.- Throws:
javax.servlet.ServletExceptionjava.io.IOException
-
obtainSubject
protected javax.security.auth.Subject obtainSubject(javax.servlet.ServletRequest request)
Obtains the
Subjectto run as ornullif noSubjectis available.The default implementation attempts to obtain the
Subjectfrom theSecurityContext'sAuthentication. If it is of typeJaasAuthenticationTokenand is authenticated, theSubjectis returned from it. Otherwise,nullis returned.- Parameters:
request- the currentServletRequest- Returns:
- the Subject to run as or
nullif noSubjectis available.
-
setCreateEmptySubject
public final void setCreateEmptySubject(boolean createEmptySubject)
SetscreateEmptySubject. If the value istrue, andobtainSubject(ServletRequest)returnsnull, an empty, writeableSubjectis created instead. Otherwise noSubjectis used. The default isfalse.- Parameters:
createEmptySubject- the new value
-
-