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 response.- 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 responsejava.lang.String
getFullRequestURL()
Return the full URL (with query string) the client used to request the server.java.lang.String
getPath()
Get the "servlet path" (in a JEE style).default java.lang.String
getProtocol()
Get the protocol version.java.lang.String
getRemoteAddr()
Return the remote address.java.util.Optional
getRequestAttribute(java.lang.String name)
Return a request attribute.default java.lang.String
getRequestContent()
Gets content body of the original request.java.util.Collection<Cookie>
getRequestCookies()
Retrieves request cookies.java.util.Optional<java.lang.String>
getRequestHeader(java.lang.String name)
Return a request header.java.lang.String
getRequestMethod()
Return the request method.java.util.Optional<java.lang.String>
getRequestParameter(java.lang.String name)
Return a request parameter.java.util.Map<java.lang.String,java.lang.String[]>
getRequestParameters()
Return all request parameters.default java.lang.String
getRequestURL()
Return the full URL (without the query string) the client used to request the server.java.util.Optional<java.lang.String>
getResponseHeader(java.lang.String name)
Get a header from the response.java.lang.String
getScheme()
Return the scheme.java.lang.String
getServerName()
Return the server name.int
getServerPort()
Return the server port.boolean
isSecure()
Return whether the request is secure.void
setRequestAttribute(java.lang.String name, java.lang.Object value)
Save a request attribute.void
setResponseContentType(java.lang.String content)
Sets the response content type.void
setResponseHeader(java.lang.String name, java.lang.String value)
Add a header to the response.
-
-
-
Method Detail
-
getRequestParameter
java.util.Optional<java.lang.String> getRequestParameter(java.lang.String name)
Return a request parameter.- Parameters:
name
- name of the parameter- Returns:
- the request parameter
-
getRequestParameters
java.util.Map<java.lang.String,java.lang.String[]> getRequestParameters()
Return all request parameters.- Returns:
- all request parameters
-
getRequestAttribute
java.util.Optional getRequestAttribute(java.lang.String name)
Return a request attribute.- Parameters:
name
- the name of the attribute- Returns:
- the attribute
-
setRequestAttribute
void setRequestAttribute(java.lang.String name, java.lang.Object value)
Save a request attribute.- Parameters:
name
- the name of the attributevalue
- the attribute
-
getRequestHeader
java.util.Optional<java.lang.String> getRequestHeader(java.lang.String name)
Return a request header.- Parameters:
name
- name of the header- Returns:
- the request header
-
getRequestMethod
java.lang.String getRequestMethod()
Return the request method.- Returns:
- the request method
-
getRemoteAddr
java.lang.String getRemoteAddr()
Return the remote address.- Returns:
- the remote address.
-
setResponseHeader
void setResponseHeader(java.lang.String name, java.lang.String value)
Add a header to the response.- Parameters:
name
- name of the headervalue
- value of the header
-
getResponseHeader
java.util.Optional<java.lang.String> getResponseHeader(java.lang.String name)
Get a header from the response.- Parameters:
name
- name of the header- Returns:
- the value of the header
-
setResponseContentType
void setResponseContentType(java.lang.String content)
Sets the response content type.- Parameters:
content
- the content type
-
getServerName
java.lang.String getServerName()
Return the server name.- Returns:
- the server name
-
getServerPort
int getServerPort()
Return the server port.- Returns:
- the server port
-
getScheme
java.lang.String getScheme()
Return the scheme.- Returns:
- the scheme
-
isSecure
boolean isSecure()
Return whether the request is secure.- Returns:
- whether the request is secure
-
getFullRequestURL
java.lang.String getFullRequestURL()
Return the full URL (with query string) the client used to request the server.- Returns:
- the URL
- Since:
- 1.5.0
-
getRequestURL
default java.lang.String getRequestURL()
Return the full URL (without the query string) the client used to request the server.- Returns:
- the URL
- Since:
- 5.1.2
-
getRequestCookies
java.util.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
java.lang.String getPath()
Get the "servlet path" (in a JEE style).- Returns:
- the "servlet path"
- Since:
- 1.8.1
-
getRequestContent
default java.lang.String getRequestContent()
Gets content body of the original request.- Returns:
- the request content
- Since:
- 1.9.2
-
getProtocol
default java.lang.String getProtocol()
Get the protocol version.- Returns:
- the protocol version
-
-