Package com.nimbusds.oauth2.sdk.http
Class ServletUtils
- java.lang.Object
-
- com.nimbusds.oauth2.sdk.http.ServletUtils
-
@ThreadSafe public class ServletUtils extends Object
HTTP servlet utilities.Require the optional javax.servlet dependency (or newer):
javax.servlet:javax.servlet-api:3.0.1
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
applyHTTPResponse(HTTPResponse httpResponse, javax.servlet.http.HttpServletResponse servletResponse)
Applies the status code, headers and content of the specified HTTP response to a HTTP servlet response.static HTTPRequest
createHTTPRequest(javax.servlet.http.HttpServletRequest sr)
Creates a new HTTP request from the specified HTTP servlet request.static HTTPRequest
createHTTPRequest(javax.servlet.http.HttpServletRequest sr, long maxEntityLength)
Creates a new HTTP request from the specified HTTP servlet request.static X509Certificate
extractClientX509Certificate(javax.servlet.ServletRequest servletRequest)
Extracts the client's X.509 certificate from the specified servlet request.
-
-
-
Method Detail
-
createHTTPRequest
public static HTTPRequest createHTTPRequest(javax.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(javax.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, javax.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(javax.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.
-
-