com.ecyrd.jspwiki.ui
Class WikiRequestWrapper
java.lang.Object
javax.servlet.ServletRequestWrapper
javax.servlet.http.HttpServletRequestWrapper
com.ecyrd.jspwiki.ui.WikiRequestWrapper
- All Implemented Interfaces:
- HttpServletRequest, ServletRequest
public class WikiRequestWrapper
- extends HttpServletRequestWrapper
Servlet request wrapper that encapsulates an incoming HTTP request and
overrides its security methods so that the request returns JSPWiki-specific
values.
- Since:
- 2.8
- Author:
- Andrew Jaquith
Method Summary |
String |
getRemoteUser()
Returns the remote user for the HTTP request, taking into account both
container and JSPWiki custom authentication status. |
Principal |
getUserPrincipal()
Returns the user principal for the HTTP request, taking into account both
container and JSPWiki custom authentication status. |
boolean |
isUserInRole(String role)
Determines whether the current user possesses a supplied role, taking
into account both container and JSPWIki custom authentication status. |
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper |
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid |
Methods inherited from class javax.servlet.ServletRequestWrapper |
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequest |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.servlet.ServletRequest |
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding |
WikiRequestWrapper
public WikiRequestWrapper(WikiEngine engine,
HttpServletRequest request)
- Constructs a new wrapped request.
- Parameters:
engine
- the wiki enginerequest
- the request to wrap
getRemoteUser
public String getRemoteUser()
- Returns the remote user for the HTTP request, taking into account both
container and JSPWiki custom authentication status. Specifically, if the
wrapped request contains a remote user, this method returns that remote
user. Otherwise, if the user's WikiSession is an authenticated session
(that is,
WikiSession.isAuthenticated()
returns true
,
this method returns the name of the principal returned by
WikiSession.getLoginPrincipal()
.
- Specified by:
getRemoteUser
in interface HttpServletRequest
- Overrides:
getRemoteUser
in class HttpServletRequestWrapper
getUserPrincipal
public Principal getUserPrincipal()
- Returns the user principal for the HTTP request, taking into account both
container and JSPWiki custom authentication status. Specifically, if the
wrapped request contains a user principal, this method returns that
principal. Otherwise, if the user's WikiSession is an authenticated
session (that is,
WikiSession.isAuthenticated()
returns
true
, this method returns the value of
WikiSession.getLoginPrincipal()
.
- Specified by:
getUserPrincipal
in interface HttpServletRequest
- Overrides:
getUserPrincipal
in class HttpServletRequestWrapper
isUserInRole
public boolean isUserInRole(String role)
- Determines whether the current user possesses a supplied role, taking
into account both container and JSPWIki custom authentication status.
Specifically, if the wrapped request shows that the user possesses the
role, this method returns
true
. If not, this method
iterates through the built-in Role objects (e.g., ANONYMOUS,
ASSERTED, AUTHENTICATED) returned by WikiSession.getRoles()
and
checks to see if any of these principals' names match the supplied role.
- Specified by:
isUserInRole
in interface HttpServletRequest
- Overrides:
isUserInRole
in class HttpServletRequestWrapper