Package com.nimbusds.oauth2.sdk.http
Class JakartaServletUtils
java.lang.Object
com.nimbusds.oauth2.sdk.http.JakartaServletUtils
HTTP Jakarta Servlet utilities.
Requires the optional jakarta.servlet
dependency (or newer):
jakarta.servlet:jakarta.servlet-api:5.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
applyHTTPResponse
(HTTPResponse httpResponse, jakarta.servlet.http.HttpServletResponse servletResponse) Applies the status code, headers and content of the specified HTTP response to a HTTP servlet response.static HTTPRequest
createHTTPRequest
(jakarta.servlet.http.HttpServletRequest sr) Creates a new HTTP request from the specified HTTP servlet request.static HTTPRequest
createHTTPRequest
(jakarta.servlet.http.HttpServletRequest sr, long maxEntityLength) Creates a new HTTP request from the specified HTTP servlet request.static X509Certificate
extractClientX509Certificate
(jakarta.servlet.ServletRequest servletRequest) Extracts the client's X.509 certificate from the specified servlet request.
-
Method Details
-
createHTTPRequest
public static HTTPRequest createHTTPRequest(jakarta.servlet.http.HttpServletRequest sr) throws IOException Creates a new HTTP request from the specified HTTP servlet request.Warning about servlet filters: Processing of HTTP POST and PUT requests requires the entity body to be available for reading from the
HttpServletRequest
. If you're getting unexpected exceptions, please ensure the entity body is not consumed or modified by an upstream servlet filter.- Parameters:
sr
- The servlet request. Must not benull
.- Returns:
- The HTTP request.
- Throws:
IllegalArgumentException
- The the servlet request method is not GET, POST, PUT or DELETE or the content type header value couldn't be parsed.IOException
- For a POST or PUT body that couldn't be read due to an I/O exception.
-
createHTTPRequest
public static HTTPRequest createHTTPRequest(jakarta.servlet.http.HttpServletRequest sr, long maxEntityLength) throws IOException Creates a new HTTP request from the specified HTTP servlet request.Warning about servlet filters: Processing of HTTP POST and PUT requests requires the entity body to be available for reading from the
HttpServletRequest
. If you're getting unexpected exceptions, please ensure the entity body is not consumed or modified by an upstream servlet filter.- Parameters:
sr
- The servlet request. Must not benull
.maxEntityLength
- The maximum entity length to accept, -1 for no limit.- Returns:
- The HTTP request.
- Throws:
IllegalArgumentException
- The the servlet request method is not GET, POST, PUT or DELETE or the content type header value couldn't be parsed.IOException
- For a POST or PUT body that couldn't be read due to an I/O exception.
-
applyHTTPResponse
public static void applyHTTPResponse(HTTPResponse httpResponse, jakarta.servlet.http.HttpServletResponse servletResponse) throws IOException Applies the status code, headers and content of the specified HTTP response to a HTTP servlet response.- Parameters:
httpResponse
- The HTTP response. Must not benull
.servletResponse
- The HTTP servlet response. Must not benull
.- Throws:
IOException
- If the response content couldn't be written.
-
extractClientX509Certificate
public static X509Certificate extractClientX509Certificate(jakarta.servlet.ServletRequest servletRequest) Extracts the client's X.509 certificate from the specified servlet request. The first found certificate is returned, if any.- Parameters:
servletRequest
- The HTTP servlet request. Must not benull
.- Returns:
- The first client X.509 certificate,
null
if none is found.
-