Package org.pac4j.core.context
Interface WebContext
public interface WebContext
This interface represents the web context to use HTTP request and response.
- Since:
- 1.4.0
- Author:
- Jerome Leleu
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addResponseCookie
(Cookie cookie) Adds cookies to the responseReturn the full URL (with query string) the client used to request the server.getPath()
Get the "servlet path" (in a JEE style).default String
Get the protocol version.Get the query string.Return the remote address.getRequestAttribute
(String name) Return a request attribute.default <T> Optional<T>
getRequestAttribute
(String name, Class<T> clazz) Return a request attribute typed to a strong type.default String
Gets content body of the original request.Retrieves request cookies.getRequestHeader
(String name) Return a request header.Return the request method.getRequestParameter
(String name) Return a request parameter.Return all request parameters.default String
Return the full URL (without the query string) the client used to request the server.getResponseHeader
(String name) Get a header from the response.Return the scheme.Return the server name.int
Return the server port.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 Details
-
getRequestParameter
Return a request parameter.- Parameters:
name
- name of the parameter- Returns:
- the request parameter
-
getRequestParameters
Return all request parameters.- Returns:
- all request parameters
-
getRequestAttribute
Return a request attribute.- Parameters:
name
- the name of the attribute- Returns:
- the attribute
-
getRequestAttribute
Return a request attribute typed to a strong type. The attribute, if found, will be casted down to the given type.- Type Parameters:
T
- the type parameter- Parameters:
name
- the name of the attributeclazz
- the clazz- Returns:
- the attribute
-
setRequestAttribute
Save a request attribute.- Parameters:
name
- the name of the attributevalue
- the attribute
-
getRequestHeader
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
Add a header to the response.- Parameters:
name
- name of the headervalue
- value of the header
-
getResponseHeader
Get a header from the response.- Parameters:
name
- name of the header- Returns:
- the value of the header
-
setResponseContentType
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
-
getRequestURL
Return the full URL (without the query string) the client used to request the server.- Returns:
- the URL
- Since:
- 5.1.2
-
getRequestCookies
Collection<Cookie> getRequestCookies()Retrieves request cookies.- Returns:
- the request cookies
- Since:
- 1.8.0
-
addResponseCookie
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
Gets content body of the original request.- Returns:
- the request content
- Since:
- 1.9.2
-
getProtocol
Get the protocol version.- Returns:
- the protocol version
-
getQueryString
Get the query string.- Returns:
- the query string
-