com.tonbeller.wcf.controller
Class RequestContextImpl

java.lang.Object
  extended bycom.tonbeller.wcf.controller.RequestContext
      extended bycom.tonbeller.wcf.controller.RequestContextImpl
All Implemented Interfaces:
ExprContext

public class RequestContextImpl
extends RequestContext
implements ExprContext

Author:
av

Field Summary
protected static org.apache.log4j.Logger logger
           
protected  RequestContextFactory rcf
           
protected  javax.servlet.http.HttpServletRequest request
           
protected  javax.servlet.http.HttpServletResponse response
           
 
Constructor Summary
RequestContextImpl(RequestContextFactory rcf, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 
Method Summary
 java.lang.Object findBean(java.lang.String name)
          same as JSP PageContext.findAttribute() except it does not search in page scope.
 Converter getConverter()
           
 java.util.Map getFileParameters()
           
 Formatter getFormatter()
           
 java.util.Locale getLocale()
          the locale preferred by the user
protected  java.lang.String getMappedRole(java.lang.String role)
          maps a role to another role.
 java.lang.Object getModelReference(java.lang.String expr)
          evaluates a JSP EL expression.
 java.lang.String getParameter(java.lang.String name)
           
 java.util.Map getParameters()
          returns the request parameters
 java.lang.String[] getParameters(java.lang.String name)
           
 java.lang.String getRemoteDomain()
           
 java.lang.String getRemoteUser()
          returns the remote User Name without its domain name.
 javax.servlet.http.HttpServletRequest getRequest()
           
 Resources getResources()
           
 Resources getResources(java.lang.Class clasz)
           
 Resources getResources(java.lang.String bundleName)
           
 javax.servlet.http.HttpServletResponse getResponse()
           
 javax.servlet.ServletContext getServletContext()
           
 javax.servlet.http.HttpSession getSession()
           
protected  boolean internalIsUserInRole(java.lang.String role)
          allows derived classes to use another authentification framework.
 void invalidate()
          invalidate context after request processing is complete.
 boolean isAdmin()
          allows derived classes to specify a root user who may do everything.
 boolean isUserInRole(java.lang.String roleExpr)
          evaluates a role expression.
 void setBean(java.lang.String name, java.lang.Object bean)
          places bean into session context
 void setLocale(java.util.Locale locale)
          change the Locale for this session including the Locale for JSTL <fmt:message > tag
 void setModelReference(java.lang.String expr, java.lang.Object value)
           
 
Methods inherited from class com.tonbeller.wcf.controller.RequestContext
instance, instance, isResponseComplete, setInstance, setResponseComplete
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rcf

protected RequestContextFactory rcf

request

protected javax.servlet.http.HttpServletRequest request

response

protected javax.servlet.http.HttpServletResponse response

logger

protected static org.apache.log4j.Logger logger
Constructor Detail

RequestContextImpl

public RequestContextImpl(RequestContextFactory rcf,
                          javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)
Method Detail

invalidate

public void invalidate()
Description copied from class: RequestContext
invalidate context after request processing is complete. This must be called exactly as many times RequestContextFactoryFinder.createContext is called.

Overrides:
invalidate in class RequestContext
See Also:
RequestContextFactoryFinder.createContext(HttpServletRequest, HttpServletResponse, boolean)

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Specified by:
getRequest in class RequestContext

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Specified by:
getResponse in class RequestContext

getServletContext

public javax.servlet.ServletContext getServletContext()
Specified by:
getServletContext in class RequestContext

getSession

public javax.servlet.http.HttpSession getSession()
Specified by:
getSession in class RequestContext

getLocale

public java.util.Locale getLocale()
Description copied from class: RequestContext
the locale preferred by the user

Specified by:
getLocale in class RequestContext

getFormatter

public Formatter getFormatter()
Specified by:
getFormatter in class RequestContext

getConverter

public Converter getConverter()
Specified by:
getConverter in class RequestContext

getParameters

public java.util.Map getParameters()
Description copied from class: RequestContext
returns the request parameters

Specified by:
getParameters in class RequestContext
Returns:
same as servlet 2.3 HttpServletRequest.getParameterMap()

getParameters

public java.lang.String[] getParameters(java.lang.String name)
Specified by:
getParameters in class RequestContext

getParameter

public java.lang.String getParameter(java.lang.String name)
Specified by:
getParameter in class RequestContext

getModelReference

public java.lang.Object getModelReference(java.lang.String expr)
Description copied from class: RequestContext
evaluates a JSP EL expression. Example #{user.profile}

Specified by:
getModelReference in class RequestContext

setModelReference

public void setModelReference(java.lang.String expr,
                              java.lang.Object value)
Specified by:
setModelReference in class RequestContext

findBean

public java.lang.Object findBean(java.lang.String name)
same as JSP PageContext.findAttribute() except it does not search in page scope.

Specified by:
findBean in interface ExprContext

setBean

public void setBean(java.lang.String name,
                    java.lang.Object bean)
Description copied from interface: ExprContext
places bean into session context

Specified by:
setBean in interface ExprContext
Parameters:
name - name of the session attribute
bean - the bean. If null, the attribute will be removed.

isUserInRole

public boolean isUserInRole(java.lang.String roleExpr)
Description copied from class: RequestContext
evaluates a role expression.

If roleExpr is a JSP EL expression (e.g. ${bean.stringProperty}), then the result of the EL is used as the role name.

If roleExpr starts with "!" the result is inverted, e.g. all users except members of the role will be allowed to access the component.

Roles may be mapped in resources.properties (or in System.properties or user.properties - see Resources for details). The format is role.[role1]=[role2] (not including the brackets). If such an entry is present, role2 will be checked instead of role1.

If roleExpr == null, returns true (i.e. everybody is member of the null role).

Specified by:
isUserInRole in class RequestContext

internalIsUserInRole

protected boolean internalIsUserInRole(java.lang.String role)
allows derived classes to use another authentification framework. Roles may be looked up in a database for example.

Parameters:
role - the role to test

getMappedRole

protected java.lang.String getMappedRole(java.lang.String role)
maps a role to another role. The application may define fine grained, virtual roles for buttons, components etc. These roles may be mapped to a few real roles like "user", "expert" etc.

Parameters:
role - name of the virtual fine grained role, e.g. "mayPressButton23role"
Returns:
a real role, e.g. "expertUser" to allow only experts to press button23 or null, if no such mapping exists and the role is defined elsewhere. May return a comma separated list of roles, e.g. "expertUser,adminUser" to allow access to any of the roles.

getResources

public Resources getResources()
Specified by:
getResources in class RequestContext

getResources

public Resources getResources(java.lang.String bundleName)
Specified by:
getResources in class RequestContext

getResources

public Resources getResources(java.lang.Class clasz)
Specified by:
getResources in class RequestContext

getRemoteUser

public java.lang.String getRemoteUser()
Description copied from class: RequestContext
returns the remote User Name without its domain name. In Oracle AS the HttpServletRequest.getRemoteUser() will return a String like "domain\\user". This function returns the name part only.

Specified by:
getRemoteUser in class RequestContext
Returns:
name without domain

getRemoteDomain

public java.lang.String getRemoteDomain()
Specified by:
getRemoteDomain in class RequestContext

isAdmin

public boolean isAdmin()
Description copied from class: RequestContext
allows derived classes to specify a root user who may do everything. The default implementation returns false always.

Specified by:
isAdmin in class RequestContext
Returns:

setLocale

public void setLocale(java.util.Locale locale)
Description copied from class: RequestContext
change the Locale for this session including the Locale for JSTL <fmt:message > tag

Specified by:
setLocale in class RequestContext

getFileParameters

public java.util.Map getFileParameters()
Specified by:
getFileParameters in class RequestContext