org.springframework.security.web.authentication
Class AnonymousAuthenticationFilter

java.lang.Object
  extended by org.springframework.web.filter.GenericFilterBean
      extended by org.springframework.security.web.authentication.AnonymousAuthenticationFilter
All Implemented Interfaces:
Filter, BeanNameAware, DisposableBean, InitializingBean, ServletContextAware

public class AnonymousAuthenticationFilter
extends GenericFilterBean
implements InitializingBean

Detects if there is no Authentication object in the SecurityContextHolder, and populates it with one if needed.

Version:
$Id: AnonymousAuthenticationFilter.java 4030 2009-12-07 13:54:39Z ltaylor $
Author:
Ben Alex

Field Summary
 
Fields inherited from class org.springframework.web.filter.GenericFilterBean
logger
 
Constructor Summary
AnonymousAuthenticationFilter()
           
 
Method Summary
 void afterPropertiesSet()
           
protected  boolean applyAnonymousForThisRequest(HttpServletRequest request)
          Enables subclasses to determine whether or not an anonymous authentication token should be setup for this request.
protected  Authentication createAuthentication(HttpServletRequest request)
           
 void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
           
 String getKey()
           
 UserAttribute getUserAttribute()
           
 void setAuthenticationDetailsSource(AuthenticationDetailsSource authenticationDetailsSource)
           
 void setKey(String key)
           
 void setUserAttribute(UserAttribute userAttributeDefinition)
           
 
Methods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setServletContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnonymousAuthenticationFilter

public AnonymousAuthenticationFilter()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean
Overrides:
afterPropertiesSet in class GenericFilterBean

doFilter

public void doFilter(ServletRequest req,
                     ServletResponse res,
                     FilterChain chain)
              throws IOException,
                     ServletException
Specified by:
doFilter in interface Filter
Throws:
IOException
ServletException

applyAnonymousForThisRequest

protected boolean applyAnonymousForThisRequest(HttpServletRequest request)
Enables subclasses to determine whether or not an anonymous authentication token should be setup for this request. This is useful if anonymous authentication should be allowed only for specific IP subnet ranges etc.

Parameters:
request - to assist the method determine request details
Returns:
true if the anonymous token should be setup for this request (provided that the request doesn't already have some other Authentication inside it), or false if no anonymous token should be setup for this request

createAuthentication

protected Authentication createAuthentication(HttpServletRequest request)

getKey

public String getKey()

getUserAttribute

public UserAttribute getUserAttribute()

setAuthenticationDetailsSource

public void setAuthenticationDetailsSource(AuthenticationDetailsSource authenticationDetailsSource)

setKey

public void setKey(String key)

setUserAttribute

public void setUserAttribute(UserAttribute userAttributeDefinition)


Copyright © 2004-2009 SpringSource, Inc. All Rights Reserved.