Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.acegisecurity.providers.anonymous
Class AnonymousProcessingFilter  view AnonymousProcessingFilter download AnonymousProcessingFilter.java

java.lang.Object
  extended byorg.acegisecurity.providers.anonymous.AnonymousProcessingFilter
All Implemented Interfaces:
javax.servlet.Filter, org.springframework.beans.factory.InitializingBean

public class AnonymousProcessingFilter
extends java.lang.Object
implements javax.servlet.Filter, org.springframework.beans.factory.InitializingBean

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

Do not use this class directly. Instead configure web.xml to use the org.acegisecurity.util.FilterToBeanProxy.

Version:
$Id: AnonymousProcessingFilter.java,v 1.9 2005/11/29 13:10:13 benalex Exp $

Field Summary
private  java.lang.String key
           
private static org.apache.commons.logging.Log logger
           
private  boolean removeAfterRequest
           
private  org.acegisecurity.userdetails.memory.UserAttribute userAttribute
           
 
Constructor Summary
AnonymousProcessingFilter()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
protected  boolean applyAnonymousForThisRequest(javax.servlet.ServletRequest request)
          Enables subclasses to determine whether or not an anonymous authentication token should be setup for this request.
protected  org.acegisecurity.Authentication createAuthentication(javax.servlet.ServletRequest request)
           
 void destroy()
          Does nothing - we reply on IoC lifecycle services instead.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
          The doFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain.
 java.lang.String getKey()
           
 org.acegisecurity.userdetails.memory.UserAttribute getUserAttribute()
           
 void init(javax.servlet.FilterConfig ignored)
          Does nothing - we reply on IoC lifecycle services instead.
 boolean isRemoveAfterRequest()
           
 void setKey(java.lang.String key)
           
 void setRemoveAfterRequest(boolean removeAfterRequest)
          Controls whether the filter will remove the Anonymous token after the request is complete.
 void setUserAttribute(org.acegisecurity.userdetails.memory.UserAttribute userAttributeDefinition)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.apache.commons.logging.Log logger

key

private java.lang.String key

userAttribute

private org.acegisecurity.userdetails.memory.UserAttribute userAttribute

removeAfterRequest

private boolean removeAfterRequest
Constructor Detail

AnonymousProcessingFilter

public AnonymousProcessingFilter()
Method Detail

setKey

public void setKey(java.lang.String key)

getKey

public java.lang.String getKey()

setRemoveAfterRequest

public void setRemoveAfterRequest(boolean removeAfterRequest)
Controls whether the filter will remove the Anonymous token after the request is complete. Generally this is desired to avoid the expense of a session being created by HttpSessionContextIntegrationFilter simply to store the Anonymous authentication token.

Defaults to true, being the most optimal and appropriate option (ie AnonymousProcessingFilter will clear the token at the end of each request, thus avoiding the session creation overhead in a typical configuration.


isRemoveAfterRequest

public boolean isRemoveAfterRequest()

setUserAttribute

public void setUserAttribute(org.acegisecurity.userdetails.memory.UserAttribute userAttributeDefinition)

getUserAttribute

public org.acegisecurity.userdetails.memory.UserAttribute getUserAttribute()

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Description copied from interface: org.springframework.beans.factory.InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

destroy

public void destroy()
Does nothing - we reply on IoC lifecycle services instead.

Specified by:
destroy in interface javax.servlet.Filter

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Description copied from interface: javax.servlet.Filter
The doFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. The FilterChain passed in to this method allows the Filter to pass on the request and response to the next entity in the chain.

A typical implementation of this method would follow the following pattern:-
1. Examine the request
2. Optionally wrap the request object with a custom implementation to filter content or headers for input filtering
3. Optionally wrap the response object with a custom implementation to filter content or headers for output filtering
4. a) Either invoke the next entity in the chain using the FilterChain object (chain.doFilter()),
4. b) or not pass on the request/response pair to the next entity in the filter chain to block the request processing
5. Directly set headers on the response after invocation of the next entity in the filter chain.

Specified by:
doFilter in interface javax.servlet.Filter

init

public void init(javax.servlet.FilterConfig ignored)
          throws javax.servlet.ServletException
Does nothing - we reply on IoC lifecycle services instead.

Specified by:
init in interface javax.servlet.Filter

applyAnonymousForThisRequest

protected boolean applyAnonymousForThisRequest(javax.servlet.ServletRequest 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.


createAuthentication

protected org.acegisecurity.Authentication createAuthentication(javax.servlet.ServletRequest request)