Class HTTPArtifactEncoder
java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.messaging.encoder.AbstractMessageEncoder
org.opensaml.messaging.encoder.servlet.AbstractHttpServletResponseMessageEncoder
org.opensaml.messaging.encoder.servlet.BaseHttpServletResponseXMLMessageEncoder
org.opensaml.saml.common.binding.impl.BaseSAMLHttpServletResponseEncoder
org.opensaml.saml.saml2.binding.encoding.impl.BaseSAML2MessageEncoder
org.opensaml.saml.saml2.binding.encoding.impl.HTTPArtifactEncoder
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,UnmodifiableComponent,HTMLMessageEncoder,MessageEncoder,HttpServletResponseMessageEncoder,SAMLMessageEncoder
SAML 2 Artifact Binding encoder, support both HTTP GET and POST.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate SAMLArtifactMapSAML artifact map used to store created artifacts for later retrieval.private StringDigesterDigester for CSP hashes.private IdentifierGenerationStrategyGenerator for CSP nonces.static final StringDefault template ID.private byte[]Default artifact type to use when encoding messages.private final org.slf4j.LoggerClass logger.private booleanWhether the POST encoding should be used, instead of GET.private org.apache.velocity.app.VelocityEngineVelocity engine used to evaluate the template when performing POST encoding.private StringID of the velocity template used when performing POST encoding.Fields inherited from class org.opensaml.messaging.encoder.AbstractMessageEncoder
BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SAML2ArtifactbuildArtifact(MessageContext messageContext) Builds the SAML 2 artifact for the outgoing message.protected voiddoEncode()Performs the encoding logic.protected voidGet the SAML artifact map to use.Gets the SAML binding URI supported by this encoder.protected voidPerforms HTTP GET based encoding.private StringgetInboundMessageIssuer(MessageContext messageContext) Get the requester.private StringgetOutboundMessageIssuer(MessageContext messageContext) Get the outbound message issuer.private byte[]getSAMLArtifactType(MessageContext messageContext) Get the SAML artifact type from the message context.org.apache.velocity.app.VelocityEngineGet the VelocityEngine instance.Get the Velocity template id.booleanGet whether the encoder will encode the artifact via POST encoding.protected voidPerforms HTTP POST based encoding.voidsetArtifactMap(SAMLArtifactMap newArtifactMap) Set the SAML artifact map to use.voidsetCSPDigester(StringDigester digester) Set aStringDigesterto use to generate CSP hashes.voidSet aIdentifierGenerationStrategyto use to generate CSP nonces.voidsetPostEncoding(boolean post) Set whether the encoder will encode the artifact via POST encoding.voidsetVelocityEngine(org.apache.velocity.app.VelocityEngine newVelocityEngine) Set the VelocityEngine instance.voidsetVelocityTemplateId(String newVelocityTemplateId) Set the Velocity template id.private voidstoreSAMLArtifactType(MessageContext messageContext, byte[] artifactType) Store the SAML artifact type in the message context.Methods inherited from class org.opensaml.saml.saml2.binding.encoding.impl.BaseSAML2MessageEncoder
getEndpointURLMethods inherited from class org.opensaml.messaging.encoder.servlet.BaseHttpServletResponseXMLMessageEncoder
encode, marshallMessage, serializeMessageForLoggingMethods inherited from class org.opensaml.messaging.encoder.servlet.AbstractHttpServletResponseMessageEncoder
getHttpServletResponse, getHttpServletResponseSupplier, setHttpServletResponseSupplierMethods inherited from class org.opensaml.messaging.encoder.AbstractMessageEncoder
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
-
DEFAULT_TEMPLATE_ID
Default template ID.- See Also:
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
postEncoding
private boolean postEncodingWhether the POST encoding should be used, instead of GET. -
velocityEngine
@Nullable private org.apache.velocity.app.VelocityEngine velocityEngineVelocity engine used to evaluate the template when performing POST encoding. -
velocityTemplateId
ID of the velocity template used when performing POST encoding. -
cspDigester
Digester for CSP hashes. -
cspNonceGenerator
Generator for CSP nonces. -
artifactMap
SAML artifact map used to store created artifacts for later retrieval. -
defaultArtifactType
Default artifact type to use when encoding messages.
-
-
Constructor Details
-
HTTPArtifactEncoder
public HTTPArtifactEncoder()Constructor.
-
-
Method Details
-
getBindingURI
Gets the SAML binding URI supported by this encoder.- Specified by:
getBindingURIin interfaceSAMLMessageEncoder- Returns:
- SAML binding URI supported by this encoder
-
isPostEncoding
public boolean isPostEncoding()Get whether the encoder will encode the artifact via POST encoding.- Returns:
- true if POST encoding will be used, false if GET encoding will be used
-
setPostEncoding
public void setPostEncoding(boolean post) Set whether the encoder will encode the artifact via POST encoding.- Parameters:
post- true if POST encoding will be used, false if GET encoding will be used
-
getVelocityEngine
@Nullable public org.apache.velocity.app.VelocityEngine getVelocityEngine()Get the VelocityEngine instance.- Returns:
- return the VelocityEngine instance
-
setVelocityEngine
public void setVelocityEngine(@Nullable org.apache.velocity.app.VelocityEngine newVelocityEngine) Set the VelocityEngine instance.- Parameters:
newVelocityEngine- the new VelocityEngine instane
-
getVelocityTemplateId
Get the Velocity template id.Defaults to
DEFAULT_TEMPLATE_ID.- Returns:
- return the Velocity template id
-
setVelocityTemplateId
Set the Velocity template id.Defaults to
DEFAULT_TEMPLATE_ID.- Parameters:
newVelocityTemplateId- the new Velocity template id
-
getArtifactMap
Get the SAML artifact map to use.- Returns:
- the artifactMap.
-
setArtifactMap
Set the SAML artifact map to use.- Parameters:
newArtifactMap- the new artifactMap
-
doInitialize
- Overrides:
doInitializein classAbstractHttpServletResponseMessageEncoder- Throws:
ComponentInitializationException
-
doEncode
Performs the encoding logic. By the time this is called, this encoder has already been initialized and checked to ensure that it has not been destroyed.- Specified by:
doEncodein classAbstractMessageEncoder- Throws:
MessageEncodingException- thrown if there is a problem encoding the message
-
postEncode
Performs HTTP POST based encoding.- Throws:
MessageEncodingException- thrown if there is a problem POST encoding the artifact
-
getEncode
Performs HTTP GET based encoding.- Throws:
MessageEncodingException- thrown if there is a problem GET encoding the artifact
-
buildArtifact
@Nonnull protected SAML2Artifact buildArtifact(@Nonnull MessageContext messageContext) throws MessageEncodingException Builds the SAML 2 artifact for the outgoing message.- Parameters:
messageContext- current request context- Returns:
- SAML 2 artifact for outgoing message
- Throws:
MessageEncodingException- thrown if the artifact can not be created
-
getOutboundMessageIssuer
Get the outbound message issuer.- Parameters:
messageContext- the message context- Returns:
- the outbound message issuer
-
getInboundMessageIssuer
Get the requester.- Parameters:
messageContext- the message context- Returns:
- the requester
-
storeSAMLArtifactType
private void storeSAMLArtifactType(@Nonnull MessageContext messageContext, @Nonnull @NotEmpty byte[] artifactType) Store the SAML artifact type in the message context.- Parameters:
messageContext- the message contextartifactType- the artifact type to store
-
getSAMLArtifactType
Get the SAML artifact type from the message context.- Parameters:
messageContext- the message context- Returns:
- the artifact type
-