Class AuthenticatedRequestWrapper

java.lang.Object
jakarta.servlet.ServletRequestWrapper
jakarta.servlet.http.HttpServletRequestWrapper
org.apache.juneau.rest.server.auth.AuthenticatedRequestWrapper
All Implemented Interfaces:
jakarta.servlet.http.HttpServletRequest, jakarta.servlet.ServletRequest

public class AuthenticatedRequestWrapper extends jakarta.servlet.http.HttpServletRequestWrapper
An HttpServletRequestWrapper that surfaces the filter-resolved Principal and aggregated roles via the standard servlet API surface.

Created by AuthFilter.doFilter(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse, jakarta.servlet.FilterChain) (standalone mode) and AuthFilterChain.doFilter(jakarta.servlet.ServletRequest, jakarta.servlet.ServletResponse, jakarta.servlet.FilterChain) (chain mode) after successful authentication. Overrides three servlet-API methods so downstream code — including RoleBasedRestGuard and the AuthArg arg-resolver — sees the filter-resolved identity without any extra wiring:

See Also:
Since:
10.0.0
  • Field Summary

    Fields inherited from interface jakarta.servlet.http.HttpServletRequest

    BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
  • Constructor Summary

    Constructors
    Constructor
    Description
    AuthenticatedRequestWrapper(jakarta.servlet.http.HttpServletRequest req, AuthResult result)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Intercepts "juneau.principal" so the @Auth arg-resolver can pick up the filter-stashed principal without any extra wiring.
     
     
    boolean
     

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

    • AuthenticatedRequestWrapper

      public AuthenticatedRequestWrapper(jakarta.servlet.http.HttpServletRequest req, AuthResult result)
      Constructor.
      Parameters:
      req - The underlying request. Must not be null.
      result - The authentication result. Must not be null.
  • Method Details

    • getUserPrincipal

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

      public boolean isUserInRole(String role)
      Specified by:
      isUserInRole in interface jakarta.servlet.http.HttpServletRequest
      Overrides:
      isUserInRole in class jakarta.servlet.http.HttpServletRequestWrapper
    • getRemoteUser

      Specified by:
      getRemoteUser in interface jakarta.servlet.http.HttpServletRequest
      Overrides:
      getRemoteUser in class jakarta.servlet.http.HttpServletRequestWrapper
    • getAttribute

      public Object getAttribute(String name)
      Intercepts "juneau.principal" so the @Auth arg-resolver can pick up the filter-stashed principal without any extra wiring.

      All other attribute names delegate to the wrapped request.

      Specified by:
      getAttribute in interface jakarta.servlet.ServletRequest
      Overrides:
      getAttribute in class jakarta.servlet.ServletRequestWrapper