Class AnonymousAuthenticationFilter

  • 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 AnonymousAuthenticationFilter
    extends org.springframework.web.filter.GenericFilterBean
    implements org.springframework.beans.factory.InitializingBean
    Detects if there is no Authentication object in the SecurityContextHolder, and populates it with one if needed.
    • Field Summary

      • Fields inherited from class org.springframework.web.filter.GenericFilterBean

        logger
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterPropertiesSet()  
      protected Authentication createAuthentication​(javax.servlet.http.HttpServletRequest request)  
      void doFilter​(javax.servlet.ServletRequest req, javax.servlet.ServletResponse res, javax.servlet.FilterChain chain)  
      java.util.List<GrantedAuthority> getAuthorities()  
      java.lang.Object getPrincipal()  
      void setAuthenticationDetailsSource​(AuthenticationDetailsSource<javax.servlet.http.HttpServletRequest,​?> authenticationDetailsSource)  
      • Methods inherited from class org.springframework.web.filter.GenericFilterBean

        addRequiredProperty, createEnvironment, destroy, getEnvironment, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setEnvironment, setServletContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AnonymousAuthenticationFilter

        public AnonymousAuthenticationFilter​(java.lang.String key)
        Creates a filter with a principal named "anonymousUser" and the single authority "ROLE_ANONYMOUS".
        Parameters:
        key - the key to identify tokens created by this filter
      • AnonymousAuthenticationFilter

        public AnonymousAuthenticationFilter​(java.lang.String key,
                                             java.lang.Object principal,
                                             java.util.List<GrantedAuthority> authorities)
        Parameters:
        key - key the key to identify tokens created by this filter
        principal - the principal which will be used to represent anonymous users
        authorities - the authority list for anonymous users
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Overrides:
        afterPropertiesSet in class org.springframework.web.filter.GenericFilterBean
      • doFilter

        public void doFilter​(javax.servlet.ServletRequest req,
                             javax.servlet.ServletResponse res,
                             javax.servlet.FilterChain chain)
                      throws java.io.IOException,
                             javax.servlet.ServletException
        Specified by:
        doFilter in interface javax.servlet.Filter
        Throws:
        java.io.IOException
        javax.servlet.ServletException
      • createAuthentication

        protected Authentication createAuthentication​(javax.servlet.http.HttpServletRequest request)
      • setAuthenticationDetailsSource

        public void setAuthenticationDetailsSource​(AuthenticationDetailsSource<javax.servlet.http.HttpServletRequest,​?> authenticationDetailsSource)
      • getPrincipal

        public java.lang.Object getPrincipal()