public class AuthnApiSupport extends Object
| Constructor and Description |
|---|
AuthnApiSupport(com.fasterxml.jackson.databind.ObjectMapper mapper)
Create an instance.
|
| Modifier and Type | Method and Description |
|---|---|
Map<String,Object> |
deserializeAsMap(javax.servlet.http.HttpServletRequest request)
Deserialize the JSON body of an API request into a Map.
|
<ModelType> |
deserializeAsModel(javax.servlet.http.HttpServletRequest request,
Class<ModelType> modelClass)
Deserialize the JSON body of an API request into an instance of the specified class.
|
String |
getActionId(javax.servlet.http.HttpServletRequest req)
Extracts an action ID from the content type of a request.
|
static AuthnApiSupport |
getDefault()
Get the default instance.
|
String |
getFlowId(String pathInfo)
Gets the flow ID embedded in the path of an API request.
|
String |
getLocalizedMessage(javax.servlet.http.HttpServletRequest request,
String resourceBundleBaseName,
String messageKey)
Looks up a localized message from a properties file using its key.
|
String |
getLocalizedMessage(javax.servlet.http.HttpServletRequest request,
String resourceBundleBaseName,
String messageKey,
String[] params)
Looks up a localized message from a properties file using its key.
|
boolean |
isApiRequest(javax.servlet.http.HttpServletRequest request)
Determine whether the provided request originated via the API.
|
boolean |
isValidAuthnApiPostRequest(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
Map<String,Class<?>> expectedActionIdToModelMapping)
Perform basic authentication API POST request validations.
|
<ModelType> |
makeAuthnState(javax.servlet.http.HttpServletRequest request,
AuthnStateSpec<ModelType> stateSpec,
ModelType stateModel)
Create an
AuthnState instance based on an
AuthnStateSpec instance. |
void |
setApiRequest(javax.servlet.http.HttpServletRequest request)
Set the flag indicating that this request originated via the API.
|
String |
toActionId(String contentType)
Extracts an action ID from the content type of a request.
|
String |
toContentType(String actionId)
Converts an action ID to the corresponding content type.
|
void |
writeAuthnStateResponse(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
AuthnState<?> authnState)
Writes an
AuthnState to the servlet response. |
void |
writeErrorResponse(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
AuthnError authnError)
Writes an
AuthnError to the servlet response. |
void |
writeResponse(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
int status,
Object model)
Serializes a Java object to JSON and writes it to the servlet response.
|
void |
writeResumeResponse(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
String resumePath)
Writes an
AuthnState with a
RESUME status to the servlet response. |
public AuthnApiSupport(com.fasterxml.jackson.databind.ObjectMapper mapper)
mapper - The ObjectMapper for JSON serialization and deserialization.public static AuthnApiSupport getDefault()
public boolean isApiRequest(javax.servlet.http.HttpServletRequest request)
request - The servlet request.public void setApiRequest(javax.servlet.http.HttpServletRequest request)
request - The servlet request.public Map<String,Object> deserializeAsMap(javax.servlet.http.HttpServletRequest request) throws IOException
request - The servlet request.IOException - If an error occurred during deserialization.public <ModelType> ModelType deserializeAsModel(javax.servlet.http.HttpServletRequest request,
Class<ModelType> modelClass)
throws AuthnErrorException,
IOException
request - The servlet request.modelClass - The expected class for the result.AuthnErrorException - If an error occurred during validation of the JSON body against the expected API model classIOException - If an error occurred while attempting to deserialize the request.public <ModelType> AuthnState<ModelType> makeAuthnState(javax.servlet.http.HttpServletRequest request, AuthnStateSpec<ModelType> stateSpec, ModelType stateModel)
AuthnState instance based on an
AuthnStateSpec instance.request - The servlet request.stateSpec - The spec to use in creating the state instance.stateModel - An instance of the model for the state (optional).public void writeAuthnStateResponse(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
AuthnState<?> authnState)
throws IOException
AuthnState to the servlet response.req - The servlet request.resp - The servlet response.authnState - The state instance.IOException - If an error occurs while writing the response.public void writeResumeResponse(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
String resumePath)
throws IOException
AuthnState with a
RESUME status to the servlet response.req - The servlet request.resp - The servlet response.resumePath - The current resume path.IOException - If an error occurs while writing the response.public void writeErrorResponse(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
AuthnError authnError)
throws IOException
AuthnError to the servlet response.req - The servlet request.resp - The servlet response.authnError - The error to write.IOException - If an error occurs while writing the response.public void writeResponse(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
int status,
Object model)
throws IOException
req - The servlet request.resp - The servlet response.status - The HTTP status code.model - The object to write.IOException - If an error occurs while writing the response.public String getFlowId(String pathInfo)
pathInfo - The relative request path, beginning with the flow ID.public String toContentType(String actionId)
public String toActionId(String contentType)
contentType - The incoming content type.public String getActionId(javax.servlet.http.HttpServletRequest req)
req - The servlet request.public String getLocalizedMessage(javax.servlet.http.HttpServletRequest request, String resourceBundleBaseName, String messageKey)
request parameter.request - The servlet request. This is used to determine the user's locale.resourceBundleBaseName - The base name of the properties file (leaving out the extension), or null for pingfederate-messages.messageKey - The message key to look up.public String getLocalizedMessage(javax.servlet.http.HttpServletRequest request, String resourceBundleBaseName, String messageKey, String[] params)
request parameter.request - The servlet request. This is used to determine the user's locale.resourceBundleBaseName - The base name of the properties file (leaving out the extension), or null for pingfederate-messages.messageKey - The message key to look up.params - String substitution parameters.public boolean isValidAuthnApiPostRequest(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
Map<String,Class<?>> expectedActionIdToModelMapping)
throws IOException
req - The servlet request.resp - The servlet response.expectedActionIdToModelMapping - The expected valid action ID to action model mapping.IOException - If an error occurs while writing the response.Copyright 2019 Ping Identity Corp. All rights reserved.