org.apache.wiki.ui
Class WikiRequestWrapper

java.lang.Object
  extended by javax.servlet.ServletRequestWrapper
      extended by javax.servlet.http.HttpServletRequestWrapper
          extended by org.apache.wiki.ui.WikiRequestWrapper
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest

public class WikiRequestWrapper
extends javax.servlet.http.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

Field Summary
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
WikiRequestWrapper(WikiEngine engine, javax.servlet.http.HttpServletRequest request)
          Constructs a new wrapped request.
 
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
 

Constructor Detail

WikiRequestWrapper

public WikiRequestWrapper(WikiEngine engine,
                          javax.servlet.http.HttpServletRequest request)
Constructs a new wrapped request.

Parameters:
engine - the wiki engine
request - the request to wrap
Method Detail

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 javax.servlet.http.HttpServletRequest
Overrides:
getRemoteUser in class javax.servlet.http.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 javax.servlet.http.HttpServletRequest
Overrides:
getUserPrincipal in class javax.servlet.http.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 javax.servlet.http.HttpServletRequest
Overrides:
isUserInRole in class javax.servlet.http.HttpServletRequestWrapper


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.