Class ServletHttpRequest
- java.lang.Object
-
- org.keycloak.adapters.authorization.integration.elytron.ServletHttpRequest
-
- All Implemented Interfaces:
HttpRequest
public class ServletHttpRequest extends Object implements HttpRequest
- Author:
- Pedro Igor
-
-
Constructor Summary
Constructors Constructor Description ServletHttpRequest(jakarta.servlet.http.HttpServletRequest request, TokenPrincipal tokenPrincipal)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetCookieValue(String name)Get the first value for a cookie with the givenname.StringgetFirstParam(String name)Get the first value for a parameter with the givennameStringgetHeader(String name)Get the first value for a HEADER with the givenname.List<String>getHeaders(String name)Get a list of all of the values set for the specified header within the HTTP request.InputStreamgetInputStream(boolean buffered)Returns the request input streamStringgetMethod()Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.TokenPrincipalgetPrincipal()Returns aTokenPrincipalassociated with the request.StringgetRelativePath()Get the request path.StringgetRemoteAddr()Returns the client address.StringgetURI()Get the URI representation for the current request.booleanisSecure()Indicates if the request is coming from a secure channel through HTTPS.
-
-
-
Constructor Detail
-
ServletHttpRequest
public ServletHttpRequest(jakarta.servlet.http.HttpServletRequest request, TokenPrincipal tokenPrincipal)
-
-
Method Detail
-
getRelativePath
public String getRelativePath()
Description copied from interface:HttpRequestGet the request path. This is the path relative to the context path. E.g.: for a HTTP GET request to http://my.appserver.com/my-application/path/sub-path this method is going to return /path/sub-path.- Specified by:
getRelativePathin interfaceHttpRequest- Returns:
- the relative path
-
getMethod
public String getMethod()
Description copied from interface:HttpRequestReturns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.- Specified by:
getMethodin interfaceHttpRequest- Returns:
- a
Stringspecifying the name of the method with which this request was made
-
getURI
public String getURI()
Description copied from interface:HttpRequestGet the URI representation for the current request.- Specified by:
getURIin interfaceHttpRequest- Returns:
- a
Stringrepresentation for the current request
-
getHeaders
public List<String> getHeaders(String name)
Description copied from interface:HttpRequestGet a list of all of the values set for the specified header within the HTTP request.- Specified by:
getHeadersin interfaceHttpRequest- Parameters:
name- the header name- Returns:
- a list of the values set for this header, if the header is not set on the request then null should be returned
-
getFirstParam
public String getFirstParam(String name)
Description copied from interface:HttpRequestGet the first value for a parameter with the givenname- Specified by:
getFirstParamin interfaceHttpRequest- Parameters:
name- the parameter name- Returns:
- the value of the parameter
-
getCookieValue
public String getCookieValue(String name)
Description copied from interface:HttpRequestGet the first value for a cookie with the givenname.- Specified by:
getCookieValuein interfaceHttpRequest- Parameters:
name- the parameter name- Returns:
- the value of the cookie
-
getRemoteAddr
public String getRemoteAddr()
Description copied from interface:HttpRequestReturns the client address.- Specified by:
getRemoteAddrin interfaceHttpRequest- Returns:
- the client address.
-
isSecure
public boolean isSecure()
Description copied from interface:HttpRequestIndicates if the request is coming from a secure channel through HTTPS.- Specified by:
isSecurein interfaceHttpRequest- Returns:
trueif the HTTP scheme is set to 'https'. Otherwise,false
-
getHeader
public String getHeader(String name)
Description copied from interface:HttpRequestGet the first value for a HEADER with the givenname.- Specified by:
getHeaderin interfaceHttpRequest- Parameters:
name- the HEADER name- Returns:
- the value of the HEADER
-
getInputStream
public InputStream getInputStream(boolean buffered)
Description copied from interface:HttpRequestReturns the request input stream- Specified by:
getInputStreamin interfaceHttpRequest- Parameters:
buffered- if the input stream should be buffered and support for multiple reads- Returns:
- the request input stream
-
getPrincipal
public TokenPrincipal getPrincipal()
Description copied from interface:HttpRequestReturns aTokenPrincipalassociated with the request.- Specified by:
getPrincipalin interfaceHttpRequest- Returns:
- the principal
-
-