Class MockHttpServletRequest
- java.lang.Object
-
- com.jalios.servlet.http.MockHttpServletRequest
-
- All Implemented Interfaces:
javax.servlet.http.HttpServletRequest,javax.servlet.ServletRequest
public class MockHttpServletRequest extends java.lang.Object implements javax.servlet.http.HttpServletRequestMock implementation of theHttpServletRequestinterface.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_PROTOCOLThe default protocol: 'http'.static java.lang.StringDEFAULT_REMOTE_ADDRThe default remote address: '127.0.0.1'.static java.lang.StringDEFAULT_REMOTE_HOSTThe default remote host: 'localhost'.static java.lang.StringDEFAULT_SERVER_ADDRThe default server address: '127.0.0.1'.static java.lang.StringDEFAULT_SERVER_NAMEThe default server name: 'localhost'.static intDEFAULT_SERVER_PORTThe default server port: '80'.
-
Constructor Summary
Constructors Constructor Description MockHttpServletRequest()Create a newMockHttpServletRequestwith a defaultMockServletContext.MockHttpServletRequest(java.lang.String method, java.lang.String requestURI)Create a newMockHttpServletRequestwith a defaultMockServletContext.MockHttpServletRequest(javax.servlet.ServletContext servletContext)Create a newMockHttpServletRequestwith the suppliedServletContext.MockHttpServletRequest(javax.servlet.ServletContext servletContext, java.lang.String method, java.lang.String requestURI)Create a newMockHttpServletRequestwith the suppliedServletContext,method, andrequestURI.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddHeader(java.lang.String name, java.lang.Object value)Add a header entry for the given name.voidaddParameter(java.lang.String name, java.lang.String value)Add a single value for the specified HTTP parameter.voidaddParameter(java.lang.String name, java.lang.String[] values)Add an array of values for the specified HTTP parameter.voidaddParameters(java.util.Map<?,?> params)Adds all provided parameters without replacing any existing values.voidaddPart(javax.servlet.http.Part part)voidaddPreferredLocale(java.util.Locale locale)Add a new preferred locale, before any existing locales.voidaddUserRole(java.lang.String role)booleanauthenticate(javax.servlet.http.HttpServletResponse response)java.lang.StringchangeSessionId()The implementation of this (Servlet 3.1+) method callsMockHttpSession.changeSessionId()if the session is a mock session.protected voidcheckActive()Check whether this request is still active (that is, not completed yet), throwing an IllegalStateException if not active anymore.voidclearAttributes()Clear all of this request's attributes.voidclose()Mark this request as completed, keeping its state.javax.servlet.AsyncContextgetAsyncContext()java.lang.ObjectgetAttribute(java.lang.String name)java.util.Enumeration<java.lang.String>getAttributeNames()java.lang.StringgetAuthType()java.lang.StringgetCharacterEncoding()intgetContentLength()longgetContentLengthLong()java.lang.StringgetContentType()java.lang.StringgetContextPath()javax.servlet.http.Cookie[]getCookies()longgetDateHeader(java.lang.String name)Return the long timestamp for the date header with the givenname.javax.servlet.DispatcherTypegetDispatcherType()java.lang.StringgetHeader(java.lang.String name)java.util.Enumeration<java.lang.String>getHeaderNames()java.util.Enumeration<java.lang.String>getHeaders(java.lang.String name)javax.servlet.ServletInputStreamgetInputStream()intgetIntHeader(java.lang.String name)java.lang.StringgetLocalAddr()java.util.LocalegetLocale()Return the first preferred locale configured in this mock request.java.util.Enumeration<java.util.Locale>getLocales()Return an enumeration of the preferred locales configured in this mock request.java.lang.StringgetLocalName()intgetLocalPort()java.lang.StringgetMethod()java.lang.StringgetParameter(java.lang.String name)java.util.Map<java.lang.String,java.lang.String[]>getParameterMap()java.util.Enumeration<java.lang.String>getParameterNames()java.lang.String[]getParameterValues(java.lang.String name)javax.servlet.http.PartgetPart(java.lang.String name)java.util.Collection<javax.servlet.http.Part>getParts()java.lang.StringgetPathInfo()java.lang.StringgetPathTranslated()java.lang.StringgetProtocol()java.lang.StringgetQueryString()java.io.BufferedReadergetReader()java.lang.StringgetRealPath(java.lang.String path)Deprecated.java.lang.StringgetRemoteAddr()java.lang.StringgetRemoteHost()intgetRemotePort()java.lang.StringgetRemoteUser()javax.servlet.RequestDispatchergetRequestDispatcher(java.lang.String path)java.lang.StringgetRequestedSessionId()java.lang.StringgetRequestURI()java.lang.StringBuffergetRequestURL()java.lang.StringgetScheme()java.lang.StringgetServerName()intgetServerPort()javax.servlet.ServletContextgetServletContext()Return the ServletContext that this request is associated with.java.lang.StringgetServletPath()javax.servlet.http.HttpSessiongetSession()javax.servlet.http.HttpSessiongetSession(boolean create)java.security.PrincipalgetUserPrincipal()voidinvalidate()Invalidate this request, clearing its state.booleanisActive()Return whether this request is still active (that is, not completed yet).booleanisAsyncStarted()booleanisAsyncSupported()booleanisRequestedSessionIdFromCookie()booleanisRequestedSessionIdFromUrl()Deprecated.booleanisRequestedSessionIdFromURL()booleanisRequestedSessionIdValid()booleanisSecure()booleanisUserInRole(java.lang.String role)voidlogin(java.lang.String username, java.lang.String password)voidlogout()voidremoveAllParameters()Removes all existing parameters.voidremoveAttribute(java.lang.String name)voidremoveParameter(java.lang.String name)Remove already registered values for the specified HTTP parameter, if any.voidsetAsyncContext(MockAsyncContext asyncContext)voidsetAsyncStarted(boolean asyncStarted)voidsetAsyncSupported(boolean asyncSupported)voidsetAttribute(java.lang.String name, java.lang.Object value)voidsetAuthType(java.lang.String authType)voidsetCharacterEncoding(java.lang.String characterEncoding)voidsetContent(byte[] content)voidsetContentType(java.lang.String contentType)voidsetContextPath(java.lang.String contextPath)voidsetCookies(javax.servlet.http.Cookie... cookies)voidsetDispatcherType(javax.servlet.DispatcherType dispatcherType)voidsetLocalAddr(java.lang.String localAddr)voidsetLocalName(java.lang.String localName)voidsetLocalPort(int localPort)voidsetMethod(java.lang.String method)voidsetParameter(java.lang.String name, java.lang.String value)Set a single value for the specified HTTP parameter.voidsetParameter(java.lang.String name, java.lang.String[] values)Set an array of values for the specified HTTP parameter.voidsetParameters(java.util.Map params)Sets all provided parameters replacing any existing values for the provided parameter names.voidsetPathInfo(java.lang.String pathInfo)voidsetPreferredLocales(java.util.List<java.util.Locale> locales)Set the list of preferred locales, in descending order, effectively replacing any existing locales.voidsetProtocol(java.lang.String protocol)voidsetQueryString(java.lang.String queryString)voidsetRemoteAddr(java.lang.String remoteAddr)voidsetRemoteHost(java.lang.String remoteHost)voidsetRemotePort(int remotePort)voidsetRemoteUser(java.lang.String remoteUser)voidsetRequestedSessionId(java.lang.String requestedSessionId)voidsetRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie)voidsetRequestedSessionIdFromURL(boolean requestedSessionIdFromURL)voidsetRequestedSessionIdValid(boolean requestedSessionIdValid)voidsetRequestURI(java.lang.String requestURI)voidsetScheme(java.lang.String scheme)voidsetSecure(boolean secure)Set the booleansecureflag indicating whether the mock request was made using a secure channel, such as HTTPS.voidsetServerName(java.lang.String serverName)voidsetServerPort(int serverPort)voidsetServletPath(java.lang.String servletPath)voidsetSession(javax.servlet.http.HttpSession session)voidsetUserPrincipal(java.security.Principal userPrincipal)javax.servlet.AsyncContextstartAsync()javax.servlet.AsyncContextstartAsync(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)<T extends javax.servlet.http.HttpUpgradeHandler>
Tupgrade(java.lang.Class<T> arg0)
-
-
-
Field Detail
-
DEFAULT_PROTOCOL
public static final java.lang.String DEFAULT_PROTOCOL
The default protocol: 'http'.- See Also:
- Constant Field Values
-
DEFAULT_SERVER_ADDR
public static final java.lang.String DEFAULT_SERVER_ADDR
The default server address: '127.0.0.1'.- See Also:
- Constant Field Values
-
DEFAULT_SERVER_NAME
public static final java.lang.String DEFAULT_SERVER_NAME
The default server name: 'localhost'.- See Also:
- Constant Field Values
-
DEFAULT_SERVER_PORT
public static final int DEFAULT_SERVER_PORT
The default server port: '80'.- See Also:
- Constant Field Values
-
DEFAULT_REMOTE_ADDR
public static final java.lang.String DEFAULT_REMOTE_ADDR
The default remote address: '127.0.0.1'.- See Also:
- Constant Field Values
-
DEFAULT_REMOTE_HOST
public static final java.lang.String DEFAULT_REMOTE_HOST
The default remote host: 'localhost'.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MockHttpServletRequest
public MockHttpServletRequest()
Create a newMockHttpServletRequestwith a defaultMockServletContext.
-
MockHttpServletRequest
public MockHttpServletRequest(java.lang.String method, java.lang.String requestURI)Create a newMockHttpServletRequestwith a defaultMockServletContext.- Parameters:
method- the request method (may benull)requestURI- the request URI (may benull)- See Also:
setMethod(java.lang.String),setRequestURI(java.lang.String),MockHttpServletRequest(ServletContext, String, String)
-
MockHttpServletRequest
public MockHttpServletRequest(javax.servlet.ServletContext servletContext)
Create a newMockHttpServletRequestwith the suppliedServletContext.- Parameters:
servletContext- the ServletContext that the request runs in (may benullto use a defaultMockServletContext)- See Also:
MockHttpServletRequest(ServletContext, String, String)
-
MockHttpServletRequest
public MockHttpServletRequest(javax.servlet.ServletContext servletContext, java.lang.String method, java.lang.String requestURI)Create a newMockHttpServletRequestwith the suppliedServletContext,method, andrequestURI.The preferred locale will be set to
Locale.ENGLISH.- Parameters:
servletContext- the ServletContext that the request runs in (may benullto use a defaultMockServletContext)method- the request method (may benull)requestURI- the request URI (may benull)- See Also:
setMethod(java.lang.String),setRequestURI(java.lang.String),setPreferredLocales(java.util.List<java.util.Locale>),MockServletContext
-
-
Method Detail
-
getServletContext
public javax.servlet.ServletContext getServletContext()
Return the ServletContext that this request is associated with. (Not available in the standard HttpServletRequest interface for some reason.)- Specified by:
getServletContextin interfacejavax.servlet.ServletRequest- Returns:
- ServletContext
-
isActive
public boolean isActive()
Return whether this request is still active (that is, not completed yet).- Returns:
- boolean
-
close
public void close()
Mark this request as completed, keeping its state.
-
invalidate
public void invalidate()
Invalidate this request, clearing its state.
-
checkActive
protected void checkActive() throws java.lang.IllegalStateExceptionCheck whether this request is still active (that is, not completed yet), throwing an IllegalStateException if not active anymore.- Throws:
java.lang.IllegalStateException
-
getAttribute
public java.lang.Object getAttribute(java.lang.String name)
- Specified by:
getAttributein interfacejavax.servlet.ServletRequest
-
getAttributeNames
public java.util.Enumeration<java.lang.String> getAttributeNames()
- Specified by:
getAttributeNamesin interfacejavax.servlet.ServletRequest
-
getCharacterEncoding
public java.lang.String getCharacterEncoding()
- Specified by:
getCharacterEncodingin interfacejavax.servlet.ServletRequest
-
setCharacterEncoding
public void setCharacterEncoding(java.lang.String characterEncoding)
- Specified by:
setCharacterEncodingin interfacejavax.servlet.ServletRequest
-
setContent
public void setContent(byte[] content)
-
getContentLength
public int getContentLength()
- Specified by:
getContentLengthin interfacejavax.servlet.ServletRequest
-
getContentLengthLong
public long getContentLengthLong()
- Specified by:
getContentLengthLongin interfacejavax.servlet.ServletRequest
-
setContentType
public void setContentType(java.lang.String contentType)
-
getContentType
public java.lang.String getContentType()
- Specified by:
getContentTypein interfacejavax.servlet.ServletRequest
-
getInputStream
public javax.servlet.ServletInputStream getInputStream()
- Specified by:
getInputStreamin interfacejavax.servlet.ServletRequest
-
setParameter
public void setParameter(java.lang.String name, java.lang.String value)Set a single value for the specified HTTP parameter.If there are already one or more values registered for the given parameter name, they will be replaced.
- Parameters:
name- namevalue- value
-
setParameter
public void setParameter(java.lang.String name, java.lang.String[] values)Set an array of values for the specified HTTP parameter.If there are already one or more values registered for the given parameter name, they will be replaced.
- Parameters:
name- namevalues- values
-
setParameters
public void setParameters(java.util.Map params)
Sets all provided parameters replacing any existing values for the provided parameter names. To add without replacing existing values, useaddParameters(java.util.Map).- Parameters:
params- map of params
-
addParameter
public void addParameter(java.lang.String name, java.lang.String value)Add a single value for the specified HTTP parameter.If there are already one or more values registered for the given parameter name, the given value will be added to the end of the list.
- Parameters:
name- namevalue- value
-
addParameter
public void addParameter(java.lang.String name, java.lang.String[] values)Add an array of values for the specified HTTP parameter.If there are already one or more values registered for the given parameter name, the given values will be added to the end of the list.
- Parameters:
name- namevalues- value
-
addParameters
public void addParameters(java.util.Map<?,?> params)
Adds all provided parameters without replacing any existing values. To replace existing values, usesetParameters(java.util.Map).- Parameters:
params- map of params
-
removeParameter
public void removeParameter(java.lang.String name)
Remove already registered values for the specified HTTP parameter, if any.- Parameters:
name- name
-
removeAllParameters
public void removeAllParameters()
Removes all existing parameters.
-
getParameter
public java.lang.String getParameter(java.lang.String name)
- Specified by:
getParameterin interfacejavax.servlet.ServletRequest
-
getParameterNames
public java.util.Enumeration<java.lang.String> getParameterNames()
- Specified by:
getParameterNamesin interfacejavax.servlet.ServletRequest
-
getParameterValues
public java.lang.String[] getParameterValues(java.lang.String name)
- Specified by:
getParameterValuesin interfacejavax.servlet.ServletRequest
-
getParameterMap
public java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
- Specified by:
getParameterMapin interfacejavax.servlet.ServletRequest
-
setProtocol
public void setProtocol(java.lang.String protocol)
-
getProtocol
public java.lang.String getProtocol()
- Specified by:
getProtocolin interfacejavax.servlet.ServletRequest
-
setScheme
public void setScheme(java.lang.String scheme)
-
getScheme
public java.lang.String getScheme()
- Specified by:
getSchemein interfacejavax.servlet.ServletRequest
-
setServerName
public void setServerName(java.lang.String serverName)
-
getServerName
public java.lang.String getServerName()
- Specified by:
getServerNamein interfacejavax.servlet.ServletRequest
-
setServerPort
public void setServerPort(int serverPort)
-
getServerPort
public int getServerPort()
- Specified by:
getServerPortin interfacejavax.servlet.ServletRequest
-
getReader
public java.io.BufferedReader getReader() throws java.io.UnsupportedEncodingException- Specified by:
getReaderin interfacejavax.servlet.ServletRequest- Throws:
java.io.UnsupportedEncodingException
-
setRemoteAddr
public void setRemoteAddr(java.lang.String remoteAddr)
-
getRemoteAddr
public java.lang.String getRemoteAddr()
- Specified by:
getRemoteAddrin interfacejavax.servlet.ServletRequest
-
setRemoteHost
public void setRemoteHost(java.lang.String remoteHost)
-
getRemoteHost
public java.lang.String getRemoteHost()
- Specified by:
getRemoteHostin interfacejavax.servlet.ServletRequest
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)- Specified by:
setAttributein interfacejavax.servlet.ServletRequest
-
removeAttribute
public void removeAttribute(java.lang.String name)
- Specified by:
removeAttributein interfacejavax.servlet.ServletRequest
-
clearAttributes
public void clearAttributes()
Clear all of this request's attributes.
-
addPreferredLocale
public void addPreferredLocale(java.util.Locale locale)
Add a new preferred locale, before any existing locales.- Parameters:
locale- locale- See Also:
setPreferredLocales(java.util.List<java.util.Locale>)
-
setPreferredLocales
public void setPreferredLocales(java.util.List<java.util.Locale> locales)
Set the list of preferred locales, in descending order, effectively replacing any existing locales.- Since:
- 3.2
- See Also:
addPreferredLocale(java.util.Locale)
-
getLocale
public java.util.Locale getLocale()
Return the first preferred locale configured in this mock request.If no locales have been explicitly configured, the default, preferred
Localefor the server mocked by this request isLocale.ENGLISH.In contrast to the Servlet specification, this mock implementation does not take into consideration any locales specified via the
Accept-Languageheader.- Specified by:
getLocalein interfacejavax.servlet.ServletRequest- See Also:
ServletRequest.getLocale(),addPreferredLocale(Locale),setPreferredLocales(List)
-
getLocales
public java.util.Enumeration<java.util.Locale> getLocales()
Return an enumeration of the preferred locales configured in this mock request.If no locales have been explicitly configured, the default, preferred
Localefor the server mocked by this request isLocale.ENGLISH.In contrast to the Servlet specification, this mock implementation does not take into consideration any locales specified via the
Accept-Languageheader.- Specified by:
getLocalesin interfacejavax.servlet.ServletRequest- See Also:
ServletRequest.getLocales(),addPreferredLocale(Locale),setPreferredLocales(List)
-
setSecure
public void setSecure(boolean secure)
Set the booleansecureflag indicating whether the mock request was made using a secure channel, such as HTTPS.- See Also:
isSecure(),getScheme(),setScheme(String)
-
isSecure
public boolean isSecure()
- Specified by:
isSecurein interfacejavax.servlet.ServletRequest- See Also:
ServletRequest.isSecure()
-
getRequestDispatcher
public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
- Specified by:
getRequestDispatcherin interfacejavax.servlet.ServletRequest
-
getRealPath
@Deprecated public java.lang.String getRealPath(java.lang.String path)
Deprecated.- Specified by:
getRealPathin interfacejavax.servlet.ServletRequest
-
setRemotePort
public void setRemotePort(int remotePort)
-
getRemotePort
public int getRemotePort()
- Specified by:
getRemotePortin interfacejavax.servlet.ServletRequest
-
setLocalName
public void setLocalName(java.lang.String localName)
-
getLocalName
public java.lang.String getLocalName()
- Specified by:
getLocalNamein interfacejavax.servlet.ServletRequest
-
setLocalAddr
public void setLocalAddr(java.lang.String localAddr)
-
getLocalAddr
public java.lang.String getLocalAddr()
- Specified by:
getLocalAddrin interfacejavax.servlet.ServletRequest
-
setLocalPort
public void setLocalPort(int localPort)
-
getLocalPort
public int getLocalPort()
- Specified by:
getLocalPortin interfacejavax.servlet.ServletRequest
-
startAsync
public javax.servlet.AsyncContext startAsync()
- Specified by:
startAsyncin interfacejavax.servlet.ServletRequest
-
startAsync
public javax.servlet.AsyncContext startAsync(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)- Specified by:
startAsyncin interfacejavax.servlet.ServletRequest
-
setAsyncStarted
public void setAsyncStarted(boolean asyncStarted)
-
isAsyncStarted
public boolean isAsyncStarted()
- Specified by:
isAsyncStartedin interfacejavax.servlet.ServletRequest
-
setAsyncSupported
public void setAsyncSupported(boolean asyncSupported)
-
isAsyncSupported
public boolean isAsyncSupported()
- Specified by:
isAsyncSupportedin interfacejavax.servlet.ServletRequest
-
setAsyncContext
public void setAsyncContext(MockAsyncContext asyncContext)
-
getAsyncContext
public javax.servlet.AsyncContext getAsyncContext()
- Specified by:
getAsyncContextin interfacejavax.servlet.ServletRequest
-
setDispatcherType
public void setDispatcherType(javax.servlet.DispatcherType dispatcherType)
-
getDispatcherType
public javax.servlet.DispatcherType getDispatcherType()
- Specified by:
getDispatcherTypein interfacejavax.servlet.ServletRequest
-
setAuthType
public void setAuthType(java.lang.String authType)
-
getAuthType
public java.lang.String getAuthType()
- Specified by:
getAuthTypein interfacejavax.servlet.http.HttpServletRequest
-
setCookies
public void setCookies(javax.servlet.http.Cookie... cookies)
-
getCookies
public javax.servlet.http.Cookie[] getCookies()
- Specified by:
getCookiesin interfacejavax.servlet.http.HttpServletRequest
-
addHeader
public void addHeader(java.lang.String name, java.lang.Object value)Add a header entry for the given name.While this method can take any
Objectas a parameter, it is recommended to use the following types:- String or any Object to be converted using
toString(); seegetHeader(java.lang.String). - String, Number, or Date for date headers; see
getDateHeader(java.lang.String). - String or Number for integer headers; see
getIntHeader(java.lang.String). String[]orCollection<String>for multiple values; seegetHeaders(java.lang.String).
- Parameters:
name- namevalue- value- See Also:
getHeaderNames(),getHeaders(java.lang.String),getHeader(java.lang.String),getDateHeader(java.lang.String)
- String or any Object to be converted using
-
getDateHeader
public long getDateHeader(java.lang.String name)
Return the long timestamp for the date header with the givenname.If the internal value representation is a String, this method will try to parse it as a date using the supported date formats:
- "EEE, dd MMM yyyy HH:mm:ss zzz"
- "EEE, dd-MMM-yy HH:mm:ss zzz"
- "EEE MMM dd HH:mm:ss yyyy"
- Specified by:
getDateHeaderin interfacejavax.servlet.http.HttpServletRequest- Parameters:
name- the header name- See Also:
- Section 7.1.1.1 of RFC 7231
-
getHeader
public java.lang.String getHeader(java.lang.String name)
- Specified by:
getHeaderin interfacejavax.servlet.http.HttpServletRequest
-
getHeaders
public java.util.Enumeration<java.lang.String> getHeaders(java.lang.String name)
- Specified by:
getHeadersin interfacejavax.servlet.http.HttpServletRequest
-
getHeaderNames
public java.util.Enumeration<java.lang.String> getHeaderNames()
- Specified by:
getHeaderNamesin interfacejavax.servlet.http.HttpServletRequest
-
getIntHeader
public int getIntHeader(java.lang.String name)
- Specified by:
getIntHeaderin interfacejavax.servlet.http.HttpServletRequest
-
setMethod
public void setMethod(java.lang.String method)
-
getMethod
public java.lang.String getMethod()
- Specified by:
getMethodin interfacejavax.servlet.http.HttpServletRequest
-
setPathInfo
public void setPathInfo(java.lang.String pathInfo)
-
getPathInfo
public java.lang.String getPathInfo()
- Specified by:
getPathInfoin interfacejavax.servlet.http.HttpServletRequest
-
getPathTranslated
public java.lang.String getPathTranslated()
- Specified by:
getPathTranslatedin interfacejavax.servlet.http.HttpServletRequest
-
setContextPath
public void setContextPath(java.lang.String contextPath)
-
getContextPath
public java.lang.String getContextPath()
- Specified by:
getContextPathin interfacejavax.servlet.http.HttpServletRequest
-
setQueryString
public void setQueryString(java.lang.String queryString)
-
getQueryString
public java.lang.String getQueryString()
- Specified by:
getQueryStringin interfacejavax.servlet.http.HttpServletRequest
-
setRemoteUser
public void setRemoteUser(java.lang.String remoteUser)
-
getRemoteUser
public java.lang.String getRemoteUser()
- Specified by:
getRemoteUserin interfacejavax.servlet.http.HttpServletRequest
-
addUserRole
public void addUserRole(java.lang.String role)
-
isUserInRole
public boolean isUserInRole(java.lang.String role)
- Specified by:
isUserInRolein interfacejavax.servlet.http.HttpServletRequest
-
setUserPrincipal
public void setUserPrincipal(java.security.Principal userPrincipal)
-
getUserPrincipal
public java.security.Principal getUserPrincipal()
- Specified by:
getUserPrincipalin interfacejavax.servlet.http.HttpServletRequest
-
setRequestedSessionId
public void setRequestedSessionId(java.lang.String requestedSessionId)
-
getRequestedSessionId
public java.lang.String getRequestedSessionId()
- Specified by:
getRequestedSessionIdin interfacejavax.servlet.http.HttpServletRequest
-
setRequestURI
public void setRequestURI(java.lang.String requestURI)
-
getRequestURI
public java.lang.String getRequestURI()
- Specified by:
getRequestURIin interfacejavax.servlet.http.HttpServletRequest
-
getRequestURL
public java.lang.StringBuffer getRequestURL()
- Specified by:
getRequestURLin interfacejavax.servlet.http.HttpServletRequest
-
setServletPath
public void setServletPath(java.lang.String servletPath)
-
getServletPath
public java.lang.String getServletPath()
- Specified by:
getServletPathin interfacejavax.servlet.http.HttpServletRequest
-
setSession
public void setSession(javax.servlet.http.HttpSession session)
-
getSession
public javax.servlet.http.HttpSession getSession(boolean create)
- Specified by:
getSessionin interfacejavax.servlet.http.HttpServletRequest
-
getSession
public javax.servlet.http.HttpSession getSession()
- Specified by:
getSessionin interfacejavax.servlet.http.HttpServletRequest
-
changeSessionId
public java.lang.String changeSessionId()
The implementation of this (Servlet 3.1+) method callsMockHttpSession.changeSessionId()if the session is a mock session. Otherwise it simply returns the current session id.- Specified by:
changeSessionIdin interfacejavax.servlet.http.HttpServletRequest- Since:
- 4.0.3
-
setRequestedSessionIdValid
public void setRequestedSessionIdValid(boolean requestedSessionIdValid)
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()
- Specified by:
isRequestedSessionIdValidin interfacejavax.servlet.http.HttpServletRequest
-
setRequestedSessionIdFromCookie
public void setRequestedSessionIdFromCookie(boolean requestedSessionIdFromCookie)
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()
- Specified by:
isRequestedSessionIdFromCookiein interfacejavax.servlet.http.HttpServletRequest
-
setRequestedSessionIdFromURL
public void setRequestedSessionIdFromURL(boolean requestedSessionIdFromURL)
-
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()
- Specified by:
isRequestedSessionIdFromURLin interfacejavax.servlet.http.HttpServletRequest
-
isRequestedSessionIdFromUrl
@Deprecated public boolean isRequestedSessionIdFromUrl()
Deprecated.- Specified by:
isRequestedSessionIdFromUrlin interfacejavax.servlet.http.HttpServletRequest
-
authenticate
public boolean authenticate(javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException- Specified by:
authenticatein interfacejavax.servlet.http.HttpServletRequest- Throws:
java.io.IOExceptionjavax.servlet.ServletException
-
login
public void login(java.lang.String username, java.lang.String password) throws javax.servlet.ServletException- Specified by:
loginin interfacejavax.servlet.http.HttpServletRequest- Throws:
javax.servlet.ServletException
-
logout
public void logout() throws javax.servlet.ServletException- Specified by:
logoutin interfacejavax.servlet.http.HttpServletRequest- Throws:
javax.servlet.ServletException
-
addPart
public void addPart(javax.servlet.http.Part part)
-
getPart
public javax.servlet.http.Part getPart(java.lang.String name) throws java.io.IOException, java.lang.IllegalStateException, javax.servlet.ServletException- Specified by:
getPartin interfacejavax.servlet.http.HttpServletRequest- Throws:
java.io.IOExceptionjava.lang.IllegalStateExceptionjavax.servlet.ServletException
-
getParts
public java.util.Collection<javax.servlet.http.Part> getParts() throws java.io.IOException, java.lang.IllegalStateException, javax.servlet.ServletException- Specified by:
getPartsin interfacejavax.servlet.http.HttpServletRequest- Throws:
java.io.IOExceptionjava.lang.IllegalStateExceptionjavax.servlet.ServletException
-
upgrade
public <T extends javax.servlet.http.HttpUpgradeHandler> T upgrade(java.lang.Class<T> arg0) throws java.io.IOException, javax.servlet.ServletException- Specified by:
upgradein interfacejavax.servlet.http.HttpServletRequest- Throws:
java.io.IOExceptionjavax.servlet.ServletException
-
-