Package javax.servlet.http
Class HttpServletRequestWrapper
- java.lang.Object
-
- javax.servlet.ServletRequestWrapper
-
- javax.servlet.http.HttpServletRequestWrapper
-
- All Implemented Interfaces:
HttpServletRequest
,ServletRequest
public class HttpServletRequestWrapper extends ServletRequestWrapper implements HttpServletRequest
The HttpServletRequestWrapper API.- Author:
- Manfred Riem ([email protected])
-
-
Field Summary
-
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
-
-
Constructor Summary
Constructors Constructor Description HttpServletRequestWrapper(HttpServletRequest request)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
authenticate(HttpServletResponse response)
Authenticate the request.String
changeSessionId()
Change the session id.String
getAuthType()
Get the auth type.String
getContextPath()
Get the context path.Cookie[]
getCookies()
Get the cookies.long
getDateHeader(String name)
Get the date header.String
getHeader(String name)
Get the header.Enumeration<String>
getHeaderNames()
Get the header names.Enumeration<String>
getHeaders(String name)
Get the headers.int
getIntHeader(String name)
Get the int header.String
getMethod()
Get the method.Part
getPart(String name)
Get the part.Collection<Part>
getParts()
Get the parts.String
getPathInfo()
Get the path info.String
getPathTranslated()
Get the path translated.String
getQueryString()
Get the query string.String
getRemoteUser()
Get the remote user.String
getRequestedSessionId()
Get the requested session id.String
getRequestURI()
Get the request URI.StringBuffer
getRequestURL()
Get the request URL.String
getServletPath()
Get the servlet path.HttpSession
getSession()
Get the HTTP session.HttpSession
getSession(boolean create)
Get the HTTP session.Principal
getUserPrincipal()
Get the user principal.boolean
isRequestedSessionIdFromCookie()
Is the requested session id from a cookie.boolean
isRequestedSessionIdFromUrl()
Deprecated.boolean
isRequestedSessionIdFromURL()
Is the requested session id from a URL.boolean
isRequestedSessionIdValid()
Is the requested session id valid.boolean
isUserInRole(String role)
Is the user in the role.void
login(String username, String password)
Login.void
logout()
Logout.<T extends HttpUpgradeHandler>
Tupgrade(Class<T> handlerClass)
Upgrade the request.-
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.http.HttpServletRequest
getHttpServletMapping, getTrailerFields, isTrailerFieldsReady, newPushBuilder
-
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
-
-
-
-
Constructor Detail
-
HttpServletRequestWrapper
public HttpServletRequestWrapper(HttpServletRequest request)
Constructor.- Parameters:
request
- the wrapped request.
-
-
Method Detail
-
authenticate
public boolean authenticate(HttpServletResponse response) throws IOException, ServletException
Authenticate the request.- Specified by:
authenticate
in interfaceHttpServletRequest
- Parameters:
response
- the response.- Returns:
- true if authenticated, false otherwise.
- Throws:
IOException
- when an I/O error occurs.ServletException
- when a Servlet error occurs.
-
changeSessionId
public String changeSessionId()
Change the session id.- Specified by:
changeSessionId
in interfaceHttpServletRequest
- Returns:
- the new session id.
-
getAuthType
public String getAuthType()
Get the auth type.- Specified by:
getAuthType
in interfaceHttpServletRequest
- Returns:
- the auth type.
-
getContextPath
public String getContextPath()
Get the context path.- Specified by:
getContextPath
in interfaceHttpServletRequest
- Returns:
- the context path.
-
getCookies
public Cookie[] getCookies()
Get the cookies.- Specified by:
getCookies
in interfaceHttpServletRequest
- Returns:
- the cookies, or null if none.
-
getDateHeader
public long getDateHeader(String name)
Get the date header.- Specified by:
getDateHeader
in interfaceHttpServletRequest
- Parameters:
name
- the name.- Returns:
- the date, or -1 if not found.
-
getHeader
public String getHeader(String name)
Get the header.- Specified by:
getHeader
in interfaceHttpServletRequest
- Parameters:
name
- the name.- Returns:
- the value, or null if not found.
-
getHeaderNames
public Enumeration<String> getHeaderNames()
Get the header names.- Specified by:
getHeaderNames
in interfaceHttpServletRequest
- Returns:
- the header names.
-
getHeaders
public Enumeration<String> getHeaders(String name)
Get the headers.- Specified by:
getHeaders
in interfaceHttpServletRequest
- Parameters:
name
- the name.- Returns:
- the values.
-
getIntHeader
public int getIntHeader(String name)
Get the int header.- Specified by:
getIntHeader
in interfaceHttpServletRequest
- Parameters:
name
- the name.- Returns:
- the int, or -1 if not found.
-
getMethod
public String getMethod()
Get the method.- Specified by:
getMethod
in interfaceHttpServletRequest
- Returns:
- the method.
-
getPart
public Part getPart(String name) throws IOException, ServletException
Get the part.- Specified by:
getPart
in interfaceHttpServletRequest
- Parameters:
name
- the name.- Returns:
- the part, or null if not found.
- Throws:
IOException
- when an I/O error occurs.ServletException
- when a Servlet error occurs.
-
getParts
public Collection<Part> getParts() throws IOException, ServletException
Get the parts.- Specified by:
getParts
in interfaceHttpServletRequest
- Returns:
- the parts.
- Throws:
IOException
- when an I/O error occurs.ServletException
- when a Servlet error occurs.
-
getPathInfo
public String getPathInfo()
Get the path info.- Specified by:
getPathInfo
in interfaceHttpServletRequest
- Returns:
- the path info.
-
getPathTranslated
public String getPathTranslated()
Get the path translated.- Specified by:
getPathTranslated
in interfaceHttpServletRequest
- Returns:
- the path translated.
-
getQueryString
public String getQueryString()
Get the query string.- Specified by:
getQueryString
in interfaceHttpServletRequest
- Returns:
- the query string.
-
getRemoteUser
public String getRemoteUser()
Get the remote user.- Specified by:
getRemoteUser
in interfaceHttpServletRequest
- Returns:
- the remote user.
-
getRequestURI
public String getRequestURI()
Get the request URI.- Specified by:
getRequestURI
in interfaceHttpServletRequest
- Returns:
- the request URI.
-
getRequestURL
public StringBuffer getRequestURL()
Get the request URL.- Specified by:
getRequestURL
in interfaceHttpServletRequest
- Returns:
- the request URL.
-
getRequestedSessionId
public String getRequestedSessionId()
Get the requested session id.- Specified by:
getRequestedSessionId
in interfaceHttpServletRequest
- Returns:
- the requested session id.
-
getServletPath
public String getServletPath()
Get the servlet path.- Specified by:
getServletPath
in interfaceHttpServletRequest
- Returns:
- the servlet path.
-
getSession
public HttpSession getSession()
Get the HTTP session.- Specified by:
getSession
in interfaceHttpServletRequest
- Returns:
- the HTTP session.
-
getSession
public HttpSession getSession(boolean create)
Get the HTTP session.- Specified by:
getSession
in interfaceHttpServletRequest
- Parameters:
create
- the create flag.- Returns:
- the HTTP session, or null if not able to create.
-
getUserPrincipal
public Principal getUserPrincipal()
Get the user principal.- Specified by:
getUserPrincipal
in interfaceHttpServletRequest
- Returns:
- the user principal.
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()
Is the requested session id from a cookie.- Specified by:
isRequestedSessionIdFromCookie
in interfaceHttpServletRequest
- Returns:
- true if it is, false otherwise.
-
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()
Is the requested session id from a URL.- Specified by:
isRequestedSessionIdFromURL
in interfaceHttpServletRequest
- Returns:
- true if it is, false otherwise.
-
isRequestedSessionIdFromUrl
@Deprecated public boolean isRequestedSessionIdFromUrl()
Deprecated.Is the requested session if from a URL.- Specified by:
isRequestedSessionIdFromUrl
in interfaceHttpServletRequest
- Returns:
- true if it is, false otherwise.
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()
Is the requested session id valid.- Specified by:
isRequestedSessionIdValid
in interfaceHttpServletRequest
- Returns:
- true if it is, false otherwise.
-
isUserInRole
public boolean isUserInRole(String role)
Is the user in the role.- Specified by:
isUserInRole
in interfaceHttpServletRequest
- Parameters:
role
- the role.- Returns:
- true if the user is, false otherwise.
-
login
public void login(String username, String password) throws ServletException
Login.- Specified by:
login
in interfaceHttpServletRequest
- Parameters:
username
- the username.password
- the password.- Throws:
ServletException
- when a Servlet error occurs.
-
logout
public void logout() throws ServletException
Logout.- Specified by:
logout
in interfaceHttpServletRequest
- Throws:
ServletException
- when a Servlet error occurs.
-
upgrade
public <T extends HttpUpgradeHandler> T upgrade(Class<T> handlerClass) throws IOException, ServletException
Upgrade the request.- Specified by:
upgrade
in interfaceHttpServletRequest
- Type Parameters:
T
- the type of HTTP upgrade handler class.- Parameters:
handlerClass
- the handler class.- Returns:
- the HTTP upgrade handler.
- Throws:
IOException
- when an I/O error occurs.ServletException
- when a Servlet error occurs.
-
-