Package org.apache.wiki.ui

# Class WikiRequestWrapper

java.lang.Object
jakarta.servlet.ServletRequestWrapper
jakarta.servlet.http.HttpServletRequestWrapper
org.apache.wiki.ui.WikiRequestWrapper

All Implemented Interfaces:
  `jakarta.servlet.http.HttpServletRequest`, `jakarta.servlet.ServletRequest`

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

`BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH`

## Constructor Summary

Constructors
Constructor
Description
`WikiRequestWrapper(org.apache.wiki.api.core.Engine engine, jakarta.servlet.http.HttpServletRequest request)`
Constructs a new wrapped request.

## Method Summary

Modifier and Type
Method
Description
`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 jakarta.servlet.http.HttpServletRequestWrapper

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

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

`getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, 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 jakarta.servlet.ServletRequest

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

## Constructor Details

### WikiRequestWrapper

public WikiRequestWrapper(org.apache.wiki.api.core.Engine engine, jakarta.servlet.http.HttpServletRequest request)
Constructs a new wrapped request.

Parameters:
  `engine` - the wiki engine
  `request` - the request to wrap

## Method Details

### 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 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 `jakarta.servlet.http.HttpServletRequest`
Overrides:
  `getRemoteUser` in class `jakarta.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 Session is an authenticated session (that is, `Session.isAuthenticated()` returns `true`, this method returns the value of `Session.getLoginPrincipal()`.

Specified by:
  `getUserPrincipal` in interface `jakarta.servlet.http.HttpServletRequest`
Overrides:
  `getUserPrincipal` in class `jakarta.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 `Session.getRoles()` and checks to see if any of these principals' names match the supplied role.

Specified by:
  `isUserInRole` in interface `jakarta.servlet.http.HttpServletRequest`
Overrides:
  `isUserInRole` in class `jakarta.servlet.http.HttpServletRequestWrapper`