JSecurity

org.jsecurity.web.attr
Class AbstractWebAttribute<T>

java.lang.Object
  extended by org.jsecurity.web.attr.AbstractWebAttribute<T>
All Implemented Interfaces:
WebAttribute<T>
Direct Known Subclasses:
CookieAttribute, RequestParamAttribute

public abstract class AbstractWebAttribute<T>
extends Object
implements WebAttribute<T>

Convenient superclass for implementations of the WebAttribute interface. This class encapsulates converting values from a String form to Object form and vice versa through the use of a PropertyEditor configured using setEditorClass(Class). Subclasses are expected to implement the onStoreValue(Object, javax.servlet.ServletRequest, javax.servlet.ServletResponse) and onRetrieveValue(javax.servlet.ServletRequest, javax.servlet.ServletResponse) methods that perform the actual storing and retrieving of a String value. This class also contains convenience methods for retrieving the value of a request parameter to be stored.

Since:
0.2
Author:
Les Hazlewood

Field Summary
protected  boolean checkRequestParams
           
protected  boolean checkRequestParamsFirst
           
static String DEFAULT_NAME
           
protected  boolean mutable
           
protected  String name
           
 
Constructor Summary
AbstractWebAttribute()
           
AbstractWebAttribute(String name)
           
AbstractWebAttribute(String name, boolean checkRequestParams)
           
AbstractWebAttribute(String name, boolean checkRequestParams, Class<? extends PropertyEditor> editorClass)
           
AbstractWebAttribute(String name, Class<? extends PropertyEditor> editorClass)
           
 
Method Summary
protected  T fromStringValue(String stringValue)
           
 Class<? extends PropertyEditor> getEditorClass()
           
protected  T getFromRequestParam(ServletRequest request)
           
 String getName()
           
 boolean isCheckRequestParams()
           
 boolean isCheckRequestParamsFirst()
           
 boolean isMutable()
          Returns true if the value stored can be changed once it has been set, false if it cannot.
protected abstract  T onRetrieveValue(ServletRequest request, ServletResponse response)
           
protected abstract  void onStoreValue(T value, ServletRequest request, ServletResponse response)
           
 T retrieveValue(ServletRequest request, ServletResponse response)
           
 void setCheckRequestParams(boolean checkRequestParams)
           
 void setCheckRequestParamsFirst(boolean checkRequestParamsFirst)
           
 void setEditorClass(Class<? extends PropertyEditor> editorClass)
          If set, an instance of this class will be used to convert a the object value to a string value (and vice versa) when reading and populating values in HttpServletRequests, Cookies or HttpSessions.
 void setMutable(boolean mutable)
           
 void setName(String name)
           
 void storeValue(T value, ServletRequest request, ServletResponse response)
           
protected  String toStringValue(T value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jsecurity.web.attr.WebAttribute
removeValue
 

Field Detail

DEFAULT_NAME

public static final String DEFAULT_NAME
See Also:
Constant Field Values

name

protected String name

checkRequestParams

protected boolean checkRequestParams

checkRequestParamsFirst

protected boolean checkRequestParamsFirst

mutable

protected boolean mutable
Constructor Detail

AbstractWebAttribute

public AbstractWebAttribute()

AbstractWebAttribute

public AbstractWebAttribute(String name)

AbstractWebAttribute

public AbstractWebAttribute(String name,
                            boolean checkRequestParams)

AbstractWebAttribute

public AbstractWebAttribute(String name,
                            Class<? extends PropertyEditor> editorClass)

AbstractWebAttribute

public AbstractWebAttribute(String name,
                            boolean checkRequestParams,
                            Class<? extends PropertyEditor> editorClass)
Method Detail

getName

public String getName()

setName

public void setName(String name)

isCheckRequestParams

public boolean isCheckRequestParams()

setCheckRequestParams

public void setCheckRequestParams(boolean checkRequestParams)

isCheckRequestParamsFirst

public boolean isCheckRequestParamsFirst()

setCheckRequestParamsFirst

public void setCheckRequestParamsFirst(boolean checkRequestParamsFirst)

getEditorClass

public Class<? extends PropertyEditor> getEditorClass()

setEditorClass

public void setEditorClass(Class<? extends PropertyEditor> editorClass)
If set, an instance of this class will be used to convert a the object value to a string value (and vice versa) when reading and populating values in HttpServletRequests, Cookies or HttpSessions.

If not set, the string itself will be used.

Parameters:
editorClass - PropertyEditor implementation used to convert between string values and sessionId objects.

isMutable

public boolean isMutable()
Returns true if the value stored can be changed once it has been set, false if it cannot.

Default is true.

Returns:
true if the value stored can be changed once it has been set, false if it cannot.

setMutable

public void setMutable(boolean mutable)

fromStringValue

protected T fromStringValue(String stringValue)

toStringValue

protected String toStringValue(T value)

getFromRequestParam

protected T getFromRequestParam(ServletRequest request)

retrieveValue

public final T retrieveValue(ServletRequest request,
                             ServletResponse response)
Specified by:
retrieveValue in interface WebAttribute<T>

onRetrieveValue

protected abstract T onRetrieveValue(ServletRequest request,
                                     ServletResponse response)

storeValue

public void storeValue(T value,
                       ServletRequest request,
                       ServletResponse response)
Specified by:
storeValue in interface WebAttribute<T>

onStoreValue

protected abstract void onStoreValue(T value,
                                     ServletRequest request,
                                     ServletResponse response)

JSecurity

Copyright © 2004-2008 JSecurity.