Package org.apache.shiro.web.servlet
Class ShiroHttpServletRequest
- java.lang.Object
-
- javax.servlet.ServletRequestWrapper
-
- javax.servlet.http.HttpServletRequestWrapper
-
- org.apache.shiro.web.servlet.ShiroHttpServletRequest
-
- All Implemented Interfaces:
javax.servlet.http.HttpServletRequest,javax.servlet.ServletRequest
public class ShiroHttpServletRequest extends javax.servlet.http.HttpServletRequestWrapperAShiroHttpServletRequestwraps the Servlet container's originalServletRequestinstance, but ensures that allHttpServletRequestinvocations that require Shiro's support (getRemoteUser,getSession, etc) can be executed first by Shiro as necessary before allowing the underlying Servlet container instance's method to be invoked.- Since:
- 0.2
-
-
Field Summary
Fields Modifier and Type Field Description static StringCOOKIE_SESSION_ID_SOURCEprotected booleanhttpSessionsstatic StringIDENTITY_REMOVED_KEYstatic StringREFERENCED_SESSION_IDstatic StringREFERENCED_SESSION_ID_IS_VALIDstatic StringREFERENCED_SESSION_ID_SOURCEstatic StringREFERENCED_SESSION_IS_NEWprotected javax.servlet.ServletContextservletContextprotected javax.servlet.http.HttpSessionsessionstatic StringSESSION_ID_URL_REWRITING_ENABLEDstatic StringURL_SESSION_ID_SOURCE
-
Constructor Summary
Constructors Constructor Description ShiroHttpServletRequest(javax.servlet.http.HttpServletRequest wrapped, javax.servlet.ServletContext servletContext, boolean httpSessions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetRemoteUser()StringgetRequestedSessionId()javax.servlet.http.HttpSessiongetSession()javax.servlet.http.HttpSessiongetSession(boolean create)protected org.apache.shiro.subject.SubjectgetSubject()protected ObjectgetSubjectPrincipal()PrincipalgetUserPrincipal()booleanisHttpSessions()booleanisRequestedSessionIdFromCookie()booleanisRequestedSessionIdFromUrl()booleanisRequestedSessionIdFromURL()booleanisRequestedSessionIdValid()booleanisUserInRole(String s)-
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRequestURI, getRequestURL, getServletPath, 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
-
-
-
-
Field Detail
-
COOKIE_SESSION_ID_SOURCE
public static final String COOKIE_SESSION_ID_SOURCE
- See Also:
- Constant Field Values
-
URL_SESSION_ID_SOURCE
public static final String URL_SESSION_ID_SOURCE
- See Also:
- Constant Field Values
-
REFERENCED_SESSION_ID
public static final String REFERENCED_SESSION_ID
-
REFERENCED_SESSION_ID_IS_VALID
public static final String REFERENCED_SESSION_ID_IS_VALID
-
REFERENCED_SESSION_IS_NEW
public static final String REFERENCED_SESSION_IS_NEW
-
REFERENCED_SESSION_ID_SOURCE
public static final String REFERENCED_SESSION_ID_SOURCE
-
IDENTITY_REMOVED_KEY
public static final String IDENTITY_REMOVED_KEY
-
SESSION_ID_URL_REWRITING_ENABLED
public static final String SESSION_ID_URL_REWRITING_ENABLED
-
servletContext
protected javax.servlet.ServletContext servletContext
-
session
protected javax.servlet.http.HttpSession session
-
httpSessions
protected boolean httpSessions
-
-
Method Detail
-
isHttpSessions
public boolean isHttpSessions()
-
getRemoteUser
public String getRemoteUser()
- Specified by:
getRemoteUserin interfacejavax.servlet.http.HttpServletRequest- Overrides:
getRemoteUserin classjavax.servlet.http.HttpServletRequestWrapper
-
getSubject
protected org.apache.shiro.subject.Subject getSubject()
-
getSubjectPrincipal
protected Object getSubjectPrincipal()
-
isUserInRole
public boolean isUserInRole(String s)
- Specified by:
isUserInRolein interfacejavax.servlet.http.HttpServletRequest- Overrides:
isUserInRolein classjavax.servlet.http.HttpServletRequestWrapper
-
getUserPrincipal
public Principal getUserPrincipal()
- Specified by:
getUserPrincipalin interfacejavax.servlet.http.HttpServletRequest- Overrides:
getUserPrincipalin classjavax.servlet.http.HttpServletRequestWrapper
-
getRequestedSessionId
public String getRequestedSessionId()
- Specified by:
getRequestedSessionIdin interfacejavax.servlet.http.HttpServletRequest- Overrides:
getRequestedSessionIdin classjavax.servlet.http.HttpServletRequestWrapper
-
getSession
public javax.servlet.http.HttpSession getSession(boolean create)
- Specified by:
getSessionin interfacejavax.servlet.http.HttpServletRequest- Overrides:
getSessionin classjavax.servlet.http.HttpServletRequestWrapper
-
getSession
public javax.servlet.http.HttpSession getSession()
- Specified by:
getSessionin interfacejavax.servlet.http.HttpServletRequest- Overrides:
getSessionin classjavax.servlet.http.HttpServletRequestWrapper
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()
- Specified by:
isRequestedSessionIdValidin interfacejavax.servlet.http.HttpServletRequest- Overrides:
isRequestedSessionIdValidin classjavax.servlet.http.HttpServletRequestWrapper
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()
- Specified by:
isRequestedSessionIdFromCookiein interfacejavax.servlet.http.HttpServletRequest- Overrides:
isRequestedSessionIdFromCookiein classjavax.servlet.http.HttpServletRequestWrapper
-
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()
- Specified by:
isRequestedSessionIdFromURLin interfacejavax.servlet.http.HttpServletRequest- Overrides:
isRequestedSessionIdFromURLin classjavax.servlet.http.HttpServletRequestWrapper
-
isRequestedSessionIdFromUrl
public boolean isRequestedSessionIdFromUrl()
- Specified by:
isRequestedSessionIdFromUrlin interfacejavax.servlet.http.HttpServletRequest- Overrides:
isRequestedSessionIdFromUrlin classjavax.servlet.http.HttpServletRequestWrapper
-
-