Class NimbusResponseEncoder
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.messaging.encoder.AbstractMessageEncoder
org.opensaml.messaging.encoder.servlet.AbstractHttpServletResponseMessageEncoder
net.shibboleth.idp.plugin.oidc.op.encoding.impl.NimbusResponseEncoder
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,UnmodifiableComponent,MessageEncoder,HttpServletResponseMessageEncoder
A message encodes that encodes the Nimbus
Response in the message context inside the attached
HttpServletResponse. All the other headers found from the Response except Locationare included to the
HttpServletResponse. The Location header is ignored, but its value is given as the parameter
to HttpServletResponse.sendRedirect(String). The response is assumed not to committed before this encoder is
used.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringDigesterCSP digester for generating CSP hashes.private IdentifierGenerationStrategyCSP nonce generator.static final StringDefault template ID for using FORM POST response mode.private final org.slf4j.LoggerClass logger.private com.fasterxml.jackson.databind.ObjectMapperObject mapper used for pretty-printing JSON response.private org.apache.velocity.app.VelocityEngineVelocity engine used to evaluate the template when using FORM POST response mode.private StringID of the Velocity template used when using FORM POST response mode.Fields inherited from class org.opensaml.messaging.encoder.AbstractMessageEncoder
BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoEncode()private org.apache.velocity.VelocityContextdoPostEncode(com.nimbusds.oauth2.sdk.AuthorizationResponse message) Set response message to FORM POST velocity context.private booleanimpliesFormPost(Object response) Whether we should use FORM POST response encoding.protected StringprocessHeaders(Map<String, List<String>> headers, HttpServletResponse response) Adds all the other given headers to the givenHttpServletResponseexcept the location header, whose first value is returned by this method if any value exists.protected StringserializeMessageForLogging(Object message) voidsetCSPDigester(StringDigester digester) Sets aStringDigesterto use in computing CSP digests in views.voidSets anIdentifierGenerationStrategyto use in computing CSP nonces in views.voidsetObjectMapper(com.fasterxml.jackson.databind.ObjectMapper mapper) Set the object mapper used for pretty-printing JSON in the request.voidsetVelocityEngine(org.apache.velocity.app.VelocityEngine newVelocityEngine) Set the VelocityEngine instance.voidsetVelocityTemplateId(String newVelocityTemplateId) Set the Velocity template id.Methods inherited from class org.opensaml.messaging.encoder.servlet.AbstractHttpServletResponseMessageEncoder
doInitialize, getHttpServletResponse, getHttpServletResponseSupplier, setHttpServletResponseSupplierMethods inherited from class org.opensaml.messaging.encoder.AbstractMessageEncoder
encode, getMessageContext, getMessageToLog, getProtocolMessageLogger, getProtocolMessageLoggerSubCategory, logEncodedMessage, prepareContext, setMessageContext, setProtocolMessageLoggerSubCategoryMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.DestructableComponent
destroy, isDestroyedMethods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitializedMethods inherited from interface org.opensaml.messaging.encoder.MessageEncoder
encode, prepareContext, setMessageContext
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
DEFAULT_TEMPLATE_ID
Default template ID for using FORM POST response mode.- See Also:
-
velocityEngine
@Nullable private org.apache.velocity.app.VelocityEngine velocityEngineVelocity engine used to evaluate the template when using FORM POST response mode. -
velocityTemplateId
ID of the Velocity template used when using FORM POST response mode. -
objectMapper
Object mapper used for pretty-printing JSON response. -
cspDigester
CSP digester for generating CSP hashes. -
cspNonceGenerator
CSP nonce generator.
-
-
Constructor Details
-
NimbusResponseEncoder
public NimbusResponseEncoder()Constructor.
-
-
Method Details
-
setVelocityTemplateId
Set the Velocity template id.Defaults to
DEFAULT_TEMPLATE_ID.- Parameters:
newVelocityTemplateId- the new Velocity template id
-
setVelocityEngine
public void setVelocityEngine(org.apache.velocity.app.VelocityEngine newVelocityEngine) Set the VelocityEngine instance.- Parameters:
newVelocityEngine- the new VelocityEngine instane
-
setObjectMapper
public void setObjectMapper(@Nonnull com.fasterxml.jackson.databind.ObjectMapper mapper) Set the object mapper used for pretty-printing JSON in the request.- Parameters:
mapper- What to set.- Since:
- 4.1.0
-
impliesFormPost
Whether we should use FORM POST response encoding.- Parameters:
response- response message.- Returns:
- true if DORM POST should be used.
-
doPostEncode
private org.apache.velocity.VelocityContext doPostEncode(@Nonnull com.nimbusds.oauth2.sdk.AuthorizationResponse message) Set response message to FORM POST velocity context.- Parameters:
message- response message.- Returns:
- response message as velocity context.
-
doEncode
- Specified by:
doEncodein classAbstractMessageEncoder- Throws:
MessageEncodingException
-
processHeaders
@Nullable protected String processHeaders(@Nullable Map<String, List<String>> headers, @Nonnull HttpServletResponse response) Adds all the other given headers to the givenHttpServletResponseexcept the location header, whose first value is returned by this method if any value exists.- Parameters:
headers- the headers to be added to the servlet responseresponse- the servlet response for which the headers are populated- Returns:
- the first value of Location header, if any value existed in the given map of headers
-
serializeMessageForLogging
- Overrides:
serializeMessageForLoggingin classAbstractMessageEncoder
-