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
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:
getUserPrincipal()— returns the authenticated principal.isUserInRole(String)— checks the aggregated role set.getRemoteUser()— returnsPrincipal.getName().getAttribute(String)— for the key"juneau.principal", returns the principal so the@Autharg-resolver can find it.
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
ConstructorsConstructorDescriptionAuthenticatedRequestWrapper(jakarta.servlet.http.HttpServletRequest req, AuthResult result) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute(String name) Intercepts"juneau.principal"so the@Autharg-resolver can pick up the filter-stashed principal without any extra wiring.booleanisUserInRole(String role) 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, upgradeMethods 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, startAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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
Constructor.- Parameters:
req- The underlying request. Must not benull .result- The authentication result. Must not benull .
-
-
Method Details
-
getUserPrincipal
- Specified by:
getUserPrincipalin interfacejakarta.servlet.http.HttpServletRequest- Overrides:
getUserPrincipalin classjakarta.servlet.http.HttpServletRequestWrapper
-
isUserInRole
- Specified by:
isUserInRolein interfacejakarta.servlet.http.HttpServletRequest- Overrides:
isUserInRolein classjakarta.servlet.http.HttpServletRequestWrapper
-
getRemoteUser
- Specified by:
getRemoteUserin interfacejakarta.servlet.http.HttpServletRequest- Overrides:
getRemoteUserin classjakarta.servlet.http.HttpServletRequestWrapper
-
getAttribute
Intercepts"juneau.principal"so the@Autharg-resolver can pick up the filter-stashed principal without any extra wiring.All other attribute names delegate to the wrapped request.
- Specified by:
getAttributein interfacejakarta.servlet.ServletRequest- Overrides:
getAttributein classjakarta.servlet.ServletRequestWrapper
-