|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.web.filter.GenericFilterBean
org.jasig.services.persondir.support.web.RequestAttributeSourceFilter
public class RequestAttributeSourceFilter
Filter that can provide HttpServletRequest headers and other properties on the request
as person attributes. The filter sets attributes on a IAdditionalDescriptors which it is configured with. To
work correctly the IAdditionalDescriptors object needs to be a session scoped Spring bean so that each user
gets only their own attributes correctly.
Configuration:
| Property | Description | Required | Default |
|---|---|---|---|
| usernameAttribute | The name of the attribute from the request (header or property) to use as the username. This is required so that Person Directory can later associate these attributes with the user correctly during queries. | Yes | null |
| cookieAttributeMapping |
Set the Map to use for mapping from a cookie name to an attribute name or Set of attribute
names. Cookie names that are specified but have null mappings will use the column name for the attribute
name. Cookie names that are not specified as keys in this Map will be ignored.
The passed Map must have keys of type String and values of type String or a Set
of String.
|
Yes | null |
| headerAttributeMapping |
Set the Map to use for mapping from a header name to an attribute name or Set of attribute
names. Header names that are specified but have null mappings will use the column name for the attribute
name. Header names that are not specified as keys in this Map will be ignored.
The passed Map must have keys of type String and values of type String or a Set
of String.
|
Yes | null |
| additionalDescriptors |
The IAdditionalDescriptors object to set attributes found on the request into. The provided object
should be a Spring session scoped bean which will allow each user to have their own version attached to
their session.
|
Yes | null |
| remoteUserAttribute |
If specified HttpServletRequest.getRemoteUser() is called and the returned value is stored as
an attribute using the value specified for this property.
|
No | null |
| remoteAddrAttribute |
If specified ServletRequest.getRemoteAddr() is called and the returned value is stored as
an attribute using the value specified for this property.
|
No | null |
| serverNameAttribute |
If specified ServletRequest.getServerName() is called and the returned value is stored as
an attribute using the value specified for this property.
|
No | null |
| serverPortAttribute |
If specified ServletRequest.getServerPort() is called and the returned value is stored as
an attribute using the value specified for this property.
|
No | null |
| clearExistingAttributes |
If true when attributes are found on the request any existing attributes in the provided IAdditionalDescriptors
object will cleared and replaced with the new attributes. If false the new attributes overwrite existing
attributes of the same name but attributes in IAdditionalDescriptors not found on the current request
are not touched.
|
No | false |
| Nested Class Summary | |
|---|---|
static class |
RequestAttributeSourceFilter.ProcessingPosition
|
| Field Summary |
|---|
| Fields inherited from class org.springframework.web.filter.GenericFilterBean |
|---|
logger |
| Constructor Summary | |
|---|---|
RequestAttributeSourceFilter()
|
|
| Method Summary | |
|---|---|
protected void |
addRequestCookies(javax.servlet.http.HttpServletRequest httpServletRequest,
Map<String,List<Object>> attributes)
Add request cookies to the attributes map |
protected void |
addRequestHeaders(javax.servlet.http.HttpServletRequest httpServletRequest,
Map<String,List<Object>> attributes)
Add request headers to the attributes map |
protected void |
addRequestProperties(javax.servlet.http.HttpServletRequest httpServletRequest,
Map<String,List<Object>> attributes)
Add other properties from the request to the attributes map |
void |
doFilter(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse,
javax.servlet.FilterChain chain)
|
IAdditionalDescriptors |
getAdditionalDescriptors()
|
Map<String,Set<String>> |
getCookieAttributeMapping()
|
Map<String,Set<String>> |
getHeaderAttributeMapping()
|
RequestAttributeSourceFilter.ProcessingPosition |
getProcessingPosition()
|
String |
getRemoteAddrAttribute()
|
String |
getRemoteHostAttribute()
|
String |
getRemoteUserAttribute()
|
String |
getServerNameAttribute()
|
String |
getServerPortAttribute()
|
String |
getUsernameAttribute()
|
boolean |
isClearExistingAttributes()
|
void |
setAdditionalDescriptors(IAdditionalDescriptors additionalDescriptors)
The AdditionalDescriptors instance to set request attributes on. |
void |
setClearExistingAttributes(boolean clearExistingAttributes)
|
void |
setCookieAttributeMapping(Map<String,?> cookieAttributeMapping)
Set the Map to use for mapping from a cookie name to an attribute name or Set of attribute
names. |
void |
setHeaderAttributeMapping(Map<String,?> headerAttributeMapping)
Set the Map to use for mapping from a header name to an attribute name or Set of attribute
names. |
void |
setProcessingPosition(RequestAttributeSourceFilter.ProcessingPosition processingPosition)
Sets the pre/post/both position of the processing relative to the doFilter call. |
void |
setRemoteAddrAttribute(String remoteAddrAttribute)
If specified ServletRequest.getRemoteAddr() is added as an attribute under the provided name |
void |
setRemoteHostAttribute(String remoteHostAttribute)
If specified ServletRequest.getRemoteHost() is added as an attribute under the provided name |
void |
setRemoteUserAttribute(String remoteUserAttribute)
If specified HttpServletRequest.getRemoteUser() is added as an attribute under the provided name |
void |
setServerNameAttribute(String serverNameAttribute)
If specified ServletRequest.getServerName() is added as an attribute under the provided name |
void |
setServerPortAttribute(String serverPortAttribute)
If specified ServletRequest.getServerPort() is added as an attribute under the provided name |
void |
setUsernameAttribute(String usernameAttribute)
The name of the attribute from the request to use as the username |
| Methods inherited from class org.springframework.web.filter.GenericFilterBean |
|---|
addRequiredProperty, afterPropertiesSet, 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 |
|---|
public RequestAttributeSourceFilter()
| Method Detail |
|---|
public String getUsernameAttribute()
public void setUsernameAttribute(String usernameAttribute)
public String getRemoteUserAttribute()
public void setRemoteUserAttribute(String remoteUserAttribute)
HttpServletRequest.getRemoteUser() is added as an attribute under the provided name
public String getRemoteAddrAttribute()
public void setRemoteAddrAttribute(String remoteAddrAttribute)
ServletRequest.getRemoteAddr() is added as an attribute under the provided name
public String getRemoteHostAttribute()
public void setRemoteHostAttribute(String remoteHostAttribute)
ServletRequest.getRemoteHost() is added as an attribute under the provided name
public String getServerNameAttribute()
public void setServerNameAttribute(String serverNameAttribute)
ServletRequest.getServerName() is added as an attribute under the provided name
public String getServerPortAttribute()
public void setServerPortAttribute(String serverPortAttribute)
ServletRequest.getServerPort() is added as an attribute under the provided name
public IAdditionalDescriptors getAdditionalDescriptors()
public void setAdditionalDescriptors(IAdditionalDescriptors additionalDescriptors)
AdditionalDescriptors instance to set request attributes on. This should be a Spring session-scoped
proxy to allow each session to have its own set of request-populated attributes.
public boolean isClearExistingAttributes()
public void setClearExistingAttributes(boolean clearExistingAttributes)
clearExistingAttributes - If existing all attributes should be cleared when any new attributes are found.
Defaults to false.public RequestAttributeSourceFilter.ProcessingPosition getProcessingPosition()
public void setProcessingPosition(RequestAttributeSourceFilter.ProcessingPosition processingPosition)
public Map<String,Set<String>> getCookieAttributeMapping()
public void setCookieAttributeMapping(Map<String,?> cookieAttributeMapping)
Map to use for mapping from a cookie name to an attribute name or Set of attribute
names. Cookie names that are specified but have null mappings will use the column name for the attribute
name. Cookie names that are not specified as keys in this Map will be ignored.
Map must have keys of type String and values of type String or a Set
of String.
cookieAttributeMapping - Map from cookie names to attribute names, may not be null.
IllegalArgumentException - If the Map doesn't follow the rules stated above.MultivaluedPersonAttributeUtils.parseAttributeToAttributeMapping(Map)public Map<String,Set<String>> getHeaderAttributeMapping()
public void setHeaderAttributeMapping(Map<String,?> headerAttributeMapping)
Map to use for mapping from a header name to an attribute name or Set of attribute
names. Header names that are specified but have null mappings will use the column name for the attribute
name. Header names that are not specified as keys in this Map will be ignored.
Map must have keys of type String and values of type String or a Set
of String.
headerAttributeMapping - Map from column names to attribute names, may not be null.
IllegalArgumentException - If the Map doesn't follow the rules stated above.MultivaluedPersonAttributeUtils.parseAttributeToAttributeMapping(Map)
public final void doFilter(javax.servlet.ServletRequest servletRequest,
javax.servlet.ServletResponse servletResponse,
javax.servlet.FilterChain chain)
throws IOException,
javax.servlet.ServletException
IOException
javax.servlet.ServletException
protected void addRequestProperties(javax.servlet.http.HttpServletRequest httpServletRequest,
Map<String,List<Object>> attributes)
protected void addRequestCookies(javax.servlet.http.HttpServletRequest httpServletRequest,
Map<String,List<Object>> attributes)
protected void addRequestHeaders(javax.servlet.http.HttpServletRequest httpServletRequest,
Map<String,List<Object>> attributes)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||