Class HTTPArtifactEncoder
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- org.opensaml.messaging.encoder.AbstractMessageEncoder
-
- org.opensaml.messaging.encoder.servlet.AbstractHttpServletResponseMessageEncoder
-
- org.opensaml.messaging.encoder.servlet.BaseHttpServletResponseXMLMessageEncoder
-
- org.opensaml.saml.saml2.binding.encoding.impl.BaseSAML2MessageEncoder
-
- org.opensaml.saml.saml2.binding.encoding.impl.HTTPArtifactEncoder
-
- All Implemented Interfaces:
net.shibboleth.utilities.java.support.component.Component,net.shibboleth.utilities.java.support.component.DestructableComponent,net.shibboleth.utilities.java.support.component.InitializableComponent,net.shibboleth.utilities.java.support.component.UnmodifiableComponent,org.opensaml.messaging.encoder.MessageEncoder,org.opensaml.messaging.encoder.servlet.HttpServletResponseMessageEncoder,org.opensaml.saml.common.binding.encoding.SAMLMessageEncoder
public class HTTPArtifactEncoder extends BaseSAML2MessageEncoder
SAML 2 Artifact Binding encoder, support both HTTP GET and POST.
-
-
Field Summary
Fields Modifier and Type Field Description private org.opensaml.saml.common.binding.artifact.SAMLArtifactMapartifactMapSAML artifact map used to store created artifacts for later retrieval.static StringDEFAULT_TEMPLATE_IDDefault template ID.private byte[]defaultArtifactTypeDefault artifact type to use when encoding messages.private org.slf4j.LoggerlogClass logger.private booleanpostEncodingWhether the POST encoding should be used, instead of GET.private org.apache.velocity.app.VelocityEnginevelocityEngineVelocity engine used to evaluate the template when performing POST encoding.private StringvelocityTemplateIdID of the velocity template used when performing POST encoding.
-
Constructor Summary
Constructors Constructor Description HTTPArtifactEncoder()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.opensaml.saml.saml2.binding.artifact.SAML2ArtifactbuildArtifact(org.opensaml.messaging.context.MessageContext messageContext)Builds the SAML 2 artifact for the outgoing message.protected voiddoDestroy()protected voiddoEncode()protected voiddoInitialize()org.opensaml.saml.common.binding.artifact.SAMLArtifactMapgetArtifactMap()Get the SAML artifact map to use.StringgetBindingURI()protected voidgetEncode()Performs HTTP GET based encoding.private StringgetInboundMessageIssuer(org.opensaml.messaging.context.MessageContext messageContext)Get the requester.private StringgetOutboundMessageIssuer(org.opensaml.messaging.context.MessageContext messageContext)Get the outbound message issuer.private byte[]getSAMLArtifactType(org.opensaml.messaging.context.MessageContext messageContext)Get the SAML artifact type from the message context.org.apache.velocity.app.VelocityEnginegetVelocityEngine()Get the VelocityEngine instance.StringgetVelocityTemplateId()Get the Velocity template id.booleanisPostEncoding()Get whether the encoder will encode the artifact via POST encoding.protected voidpostEncode()Performs HTTP POST based encoding.voidsetArtifactMap(org.opensaml.saml.common.binding.artifact.SAMLArtifactMap newArtifactMap)Set the SAML artifact map to use.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(org.opensaml.messaging.context.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
getEndpointURL
-
Methods inherited from class org.opensaml.messaging.encoder.servlet.BaseHttpServletResponseXMLMessageEncoder
encode, getMessageToLog, logEncodedMessage, marshallMessage
-
Methods inherited from class org.opensaml.messaging.encoder.servlet.AbstractHttpServletResponseMessageEncoder
getHttpServletResponse, setHttpServletResponse
-
Methods inherited from class org.opensaml.messaging.encoder.AbstractMessageEncoder
getMessageContext, prepareContext, setMessageContext
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, initialize, isDestroyed, isInitialized
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.shibboleth.utilities.java.support.component.DestructableComponent
destroy, isDestroyed
-
-
-
-
Field Detail
-
DEFAULT_TEMPLATE_ID
@Nonnull @NotEmpty public static final String DEFAULT_TEMPLATE_ID
Default template ID.- See Also:
- Constant Field Values
-
log
@Nonnull private final org.slf4j.Logger log
Class logger.
-
postEncoding
private boolean postEncoding
Whether the POST encoding should be used, instead of GET.
-
velocityEngine
@Nullable private org.apache.velocity.app.VelocityEngine velocityEngine
Velocity engine used to evaluate the template when performing POST encoding.
-
velocityTemplateId
@Nonnull @NotEmpty private String velocityTemplateId
ID of the velocity template used when performing POST encoding.
-
artifactMap
@NonnullAfterInit private org.opensaml.saml.common.binding.artifact.SAMLArtifactMap artifactMap
SAML artifact map used to store created artifacts for later retrieval.
-
defaultArtifactType
@Nonnull @NotEmpty private byte[] defaultArtifactType
Default artifact type to use when encoding messages.
-
-
Method Detail
-
getBindingURI
public String getBindingURI()
-
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
@Nonnull @NotEmpty public String getVelocityTemplateId()
Get the Velocity template id.Defaults to
DEFAULT_TEMPLATE_ID.- Returns:
- return the Velocity template id
-
setVelocityTemplateId
public void setVelocityTemplateId(@Nonnull @NotEmpty String newVelocityTemplateId)Set the Velocity template id.Defaults to
DEFAULT_TEMPLATE_ID.- Parameters:
newVelocityTemplateId- the new Velocity template id
-
getArtifactMap
@NonnullAfterInit public org.opensaml.saml.common.binding.artifact.SAMLArtifactMap getArtifactMap()
Get the SAML artifact map to use.- Returns:
- the artifactMap.
-
setArtifactMap
public void setArtifactMap(@Nonnull org.opensaml.saml.common.binding.artifact.SAMLArtifactMap newArtifactMap)Set the SAML artifact map to use.- Parameters:
newArtifactMap- the new artifactMap
-
doInitialize
protected void doInitialize() throws net.shibboleth.utilities.java.support.component.ComponentInitializationException- Overrides:
doInitializein classorg.opensaml.messaging.encoder.servlet.AbstractHttpServletResponseMessageEncoder- Throws:
net.shibboleth.utilities.java.support.component.ComponentInitializationException
-
doDestroy
protected void doDestroy()
- Overrides:
doDestroyin classorg.opensaml.messaging.encoder.servlet.AbstractHttpServletResponseMessageEncoder
-
doEncode
protected void doEncode() throws org.opensaml.messaging.encoder.MessageEncodingException- Specified by:
doEncodein classorg.opensaml.messaging.encoder.AbstractMessageEncoder- Throws:
org.opensaml.messaging.encoder.MessageEncodingException
-
postEncode
protected void postEncode() throws org.opensaml.messaging.encoder.MessageEncodingExceptionPerforms HTTP POST based encoding.- Throws:
org.opensaml.messaging.encoder.MessageEncodingException- thrown if there is a problem POST encoding the artifact
-
getEncode
protected void getEncode() throws org.opensaml.messaging.encoder.MessageEncodingExceptionPerforms HTTP GET based encoding.- Throws:
org.opensaml.messaging.encoder.MessageEncodingException- thrown if there is a problem GET encoding the artifact
-
buildArtifact
@Nonnull protected org.opensaml.saml.saml2.binding.artifact.SAML2Artifact buildArtifact(@Nonnull org.opensaml.messaging.context.MessageContext messageContext) throws org.opensaml.messaging.encoder.MessageEncodingExceptionBuilds the SAML 2 artifact for the outgoing message.- Parameters:
messageContext- current request context- Returns:
- SAML 2 artifact for outgoing message
- Throws:
org.opensaml.messaging.encoder.MessageEncodingException- thrown if the artifact can not be created
-
getOutboundMessageIssuer
@Nullable private String getOutboundMessageIssuer(@Nonnull org.opensaml.messaging.context.MessageContext messageContext)
Get the outbound message issuer.- Parameters:
messageContext- the message context- Returns:
- the outbound message issuer
-
getInboundMessageIssuer
@Nullable private String getInboundMessageIssuer(@Nonnull org.opensaml.messaging.context.MessageContext messageContext)
Get the requester.- Parameters:
messageContext- the message context- Returns:
- the requester
-
storeSAMLArtifactType
private void storeSAMLArtifactType(@Nonnull org.opensaml.messaging.context.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
@Nullable private byte[] getSAMLArtifactType(@Nonnull org.opensaml.messaging.context.MessageContext messageContext)Get the SAML artifact type from the message context.- Parameters:
messageContext- the message context- Returns:
- the artifact type
-
-