public class SecurityContextHolderAwareRequestWrapper
extends javax.servlet.http.HttpServletRequestWrapper
HttpServletRequestWrapper, which uses the
SecurityContext-defined Authentication object for isUserInRole(java.lang.String) and HttpServletRequestWrapper.getRemoteUser() responses.SecurityContextHolderAwareRequestFilter| Constructor and Description |
|---|
SecurityContextHolderAwareRequestWrapper(javax.servlet.http.HttpServletRequest request,
PortResolver portResolver,
java.lang.String rolePrefix) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getRemoteUser()
Returns the principal's name, as obtained from the
SecurityContextHolder. |
java.security.Principal |
getUserPrincipal()
Returns the
Authentication (which is a subclass of Principal), or
null if unavailable. |
boolean |
isUserInRole(java.lang.String role)
Simple searches for an exactly matching
GrantedAuthority.getAuthority(). |
authenticate, 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, logoutgetAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, 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, startAsyncclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, 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, startAsyncpublic SecurityContextHolderAwareRequestWrapper(javax.servlet.http.HttpServletRequest request,
PortResolver portResolver,
java.lang.String rolePrefix)
public java.lang.String getRemoteUser()
SecurityContextHolder. Properly handles
both String-based and UserDetails-based principals.getRemoteUser in interface javax.servlet.http.HttpServletRequestgetRemoteUser in class javax.servlet.http.HttpServletRequestWrappernull if unavailablepublic java.security.Principal getUserPrincipal()
Authentication (which is a subclass of Principal), or
null if unavailable.getUserPrincipal in interface javax.servlet.http.HttpServletRequestgetUserPrincipal in class javax.servlet.http.HttpServletRequestWrapperAuthentication, or nullpublic boolean isUserInRole(java.lang.String role)
GrantedAuthority.getAuthority().Will
always return false if the SecurityContextHolder contains an
Authentication with nullprincipal and/or GrantedAuthority[]
objects.
isUserInRole in interface javax.servlet.http.HttpServletRequestisUserInRole in class javax.servlet.http.HttpServletRequestWrapperrole - the GrantedAuthorityString representation to check fortrue if an exact (case sensitive) matching granted authority is located,
false otherwise