Package org.apache.wiki.ui

## Class WikiRequestWrapper

- java.lang.Object
- - javax.servlet.ServletRequestWrapper
  - - javax.servlet.http.HttpServletRequestWrapper
    - - 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

Constructors
`WikiRequestWrapper​(Engine engine, javax.servlet.http.HttpServletRequest request)` Constructs a new wrapped request.

### Method Summary

All Methods Instance Methods Concrete Methods
`java.lang.String` `getRemoteUser()` Returns the remote user for the HTTP request, taking into account both container and JSPWiki custom authentication status.
`java.security.Principal` `getUserPrincipal()` Returns the user principal for the HTTP request, taking into account both container and JSPWiki custom authentication status.
`boolean` `isUserInRole​(java.lang.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

`authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, login, logout, upgrade`

### Methods inherited from class javax.servlet.ServletRequestWrapper

`getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsync`

### 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

`getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync`

### Constructor Detail

#### WikiRequestWrapper

    public WikiRequestWrapper​(Engine 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 java.lang.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 Session is an authenticated session (that is, `Session.isAuthenticated()` returns `true`, this method returns the name of the principal returned by `Session.getLoginPrincipal()`.

Specified by:
  `getRemoteUser` in interface `javax.servlet.http.HttpServletRequest`
Overrides:
  `getRemoteUser` in class `javax.servlet.http.HttpServletRequestWrapper`

#### getUserPrincipal

    public java.security.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 Session is an authenticated session (that is, `Session.isAuthenticated()` returns `true`, this method returns the value of `Session.getLoginPrincipal()`.

Specified by:
  `getUserPrincipal` in interface `javax.servlet.http.HttpServletRequest`
Overrides:
  `getUserPrincipal` in class `javax.servlet.http.HttpServletRequestWrapper`

#### isUserInRole

    public boolean isUserInRole​(java.lang.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 `Session.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`