Package org.pac4j.core.context
Interface WebContext
-
- All Known Implementing Classes:
JEEContext
public interface WebContext
This interface represents the web context to use HTTP request and session.- Since:
- 1.4.0
- Author:
- Jerome Leleu
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addResponseCookie(Cookie cookie)
Adds cookies to the responseString
getFullRequestURL()
Return the full URL (with query string) the client used to request the server.String
getPath()
Get the "servlet path" (in a JEE style).default String
getProtocol()
Get the protocol version.String
getRemoteAddr()
Return the remote address.Optional
getRequestAttribute(String name)
Return a request attribute.default String
getRequestContent()
Gets content body of the original request.Collection<Cookie>
getRequestCookies()
Retrieves request cookies.Optional<String>
getRequestHeader(String name)
Return a request header.String
getRequestMethod()
Return the request method.Optional<String>
getRequestParameter(String name)
Return a request parameter.Map<String,String[]>
getRequestParameters()
Return all request parameters.String
getScheme()
Return the scheme.String
getServerName()
Return the server name.int
getServerPort()
Return the server port.SessionStore
getSessionStore()
Get the session store.boolean
isSecure()
Return whether the request is secure.void
setRequestAttribute(String name, Object value)
Save a request attribute.void
setResponseContentType(String content)
Sets the response content type.void
setResponseHeader(String name, String value)
Add a header to the response.
-
-
-
Method Detail
-
getSessionStore
SessionStore getSessionStore()
Get the session store.- Returns:
- the session store
-
getRequestParameter
Optional<String> getRequestParameter(String name)
Return a request parameter.- Parameters:
name
- name of the parameter- Returns:
- the request parameter
-
getRequestParameters
Map<String,String[]> getRequestParameters()
Return all request parameters.- Returns:
- all request parameters
-
getRequestAttribute
Optional getRequestAttribute(String name)
Return a request attribute.- Parameters:
name
- the name of the attribute- Returns:
- the attribute
-
setRequestAttribute
void setRequestAttribute(String name, Object value)
Save a request attribute.- Parameters:
name
- the name of the attributevalue
- the attribute
-
getRequestHeader
Optional<String> getRequestHeader(String name)
Return a request header.- Parameters:
name
- name of the header- Returns:
- the request header
-
getRequestMethod
String getRequestMethod()
Return the request method.- Returns:
- the request method
-
getRemoteAddr
String getRemoteAddr()
Return the remote address.- Returns:
- the remote address.
-
setResponseHeader
void setResponseHeader(String name, String value)
Add a header to the response.- Parameters:
name
- name of the headervalue
- value of the header
-
setResponseContentType
void setResponseContentType(String content)
Sets the response content type.- Parameters:
content
- the content type
-
getServerName
String getServerName()
Return the server name.- Returns:
- the server name
-
getServerPort
int getServerPort()
Return the server port.- Returns:
- the server port
-
getScheme
String getScheme()
Return the scheme.- Returns:
- the scheme
-
isSecure
boolean isSecure()
Return whether the request is secure.- Returns:
- whether the request is secure
-
getFullRequestURL
String getFullRequestURL()
Return the full URL (with query string) the client used to request the server.- Returns:
- the URL
- Since:
- 1.5.0
-
getRequestCookies
Collection<Cookie> getRequestCookies()
Retrieves request cookies.- Returns:
- the request cookies
- Since:
- 1.8.0
-
addResponseCookie
void addResponseCookie(Cookie cookie)
Adds cookies to the response- Parameters:
cookie
- a cookie to add to the response- Since:
- 1.8.0
-
getPath
String getPath()
Get the "servlet path" (in a JEE style).- Returns:
- the "servlet path"
- Since:
- 1.8.1
-
getRequestContent
default String getRequestContent()
Gets content body of the original request.- Returns:
- the request content
- Since:
- 1.9.2
-
getProtocol
default String getProtocol()
Get the protocol version.- Returns:
- the protocol version
-
-