Class AbstractJSONResponseDecoderFunction<T>
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
net.shibboleth.oidc.profile.decoding.impl.AbstractJSONResponseDecoderFunction<T>
- Type Parameters:
T- the return type of the function.
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,org.apache.hc.core5.http.io.HttpClientResponseHandler<T>
- Direct Known Subclasses:
AccessTokenResponseDecoder,UserInfoResponseDecoder
@NotThreadSafe
public abstract class AbstractJSONResponseDecoderFunction<T>
extends AbstractInitializableComponent
implements org.apache.hc.core5.http.io.HttpClientResponseHandler<T>
Abstract class for JSON based Http client response decoders.
Note, any input stream obtained by the decoder MUST ensure the stream is closed.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TdoHandleResponse(org.apache.hc.core5.http.ClassicHttpResponse httpResponse) Do the actual response processing and return a result.protected voidprotected com.fasterxml.jackson.databind.ObjectMapperGet the object mapper.protected static StringgetProtocolMessageForErrorObject(com.nimbusds.oauth2.sdk.ErrorObject errorObject) Helper method for getting protocol message for error object.protected StringGet the configured logging sub-category for protocol messages.final ThandleResponse(org.apache.hc.core5.http.ClassicHttpResponse httpResponse) protected voidlogDecodedMessage(T response) Log the decoded message to the protocol message logger.protected StringserializeMessageForLogging(T response) Serialize the message for logging purposes.voidsetObjectMapper(com.fasterxml.jackson.databind.ObjectMapper mapper) Set the JSON Object Mapper to use.protected voidsetProtocolMessageLoggerSubCategory(String category) Set the configured logging sub-category for protocol messages.Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized
-
Field Details
-
BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY
- See Also:
-
protocolMessageLog
@Nonnull private org.slf4j.Logger protocolMessageLogUsed to log protocol messages. -
protocolMessageLoggerSubCategory
The configured logging sub-category for protocol messages. -
objectMapper
JSON object mapper.
-
-
Constructor Details
-
AbstractJSONResponseDecoderFunction
public AbstractJSONResponseDecoderFunction()
-
-
Method Details
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
setObjectMapper
public void setObjectMapper(@Nonnull com.fasterxml.jackson.databind.ObjectMapper mapper) Set the JSON Object Mapper to use.- Parameters:
mapper- the object mapper.
-
getObjectMapper
Get the object mapper.- Returns:
- the object mapper.
-
getProtocolMessageLoggerSubCategory
Get the configured logging sub-category for protocol messages.- Returns:
- the logging sub-category
-
setProtocolMessageLoggerSubCategory
Set the configured logging sub-category for protocol messages.- Parameters:
category- the logging sub-category
-
logDecodedMessage
Log the decoded message to the protocol message logger. -
serializeMessageForLogging
Serialize the message for logging purposes.Default implementation is to return the message object's
Object.toString(), but subclasses should override if a better message-specific serialization mechanism exists.- Parameters:
response- the response message to serialize- Returns:
- the serialized message, or null if message can not be serialized
-
handleResponse
public final T handleResponse(org.apache.hc.core5.http.ClassicHttpResponse httpResponse) throws org.apache.hc.core5.http.HttpException, IOException - Specified by:
handleResponsein interfaceorg.apache.hc.core5.http.io.HttpClientResponseHandler<T>- Throws:
org.apache.hc.core5.http.HttpExceptionIOException
-
getProtocolMessageForErrorObject
@Nullable protected static String getProtocolMessageForErrorObject(@Nullable com.nimbusds.oauth2.sdk.ErrorObject errorObject) Helper method for getting protocol message for error object.- Parameters:
errorObject- The error object- Returns:
- The log message
-
doHandleResponse
protected abstract T doHandleResponse(org.apache.hc.core5.http.ClassicHttpResponse httpResponse) throws org.apache.hc.core5.http.HttpException, IOException Do the actual response processing and return a result. Overridden by implementation classes.- Parameters:
httpResponse- the http response- Throws:
org.apache.hc.core5.http.HttpExceptionIOException
-