Package org.pac4j.saml.transport
Class Pac4jHTTPPostEncoder
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- org.opensaml.messaging.encoder.AbstractMessageEncoder<org.opensaml.saml.common.SAMLObject>
-
- org.pac4j.saml.transport.Pac4jHTTPPostEncoder
-
- 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.saml.common.SAMLObject>
public class Pac4jHTTPPostEncoder extends org.opensaml.messaging.encoder.AbstractMessageEncoder<org.opensaml.saml.common.SAMLObject>Pac4j implementation extending directly theAbstractMessageEncoderas intermediate classes use the JEE HTTP response. It's mostly a copy/paste of the source code of these intermediate opensaml classes.- Since:
- 1.8
- Author:
- Misagh Moayyed
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_TEMPLATE_IDDefault template ID.
-
Constructor Summary
Constructors Constructor Description Pac4jHTTPPostEncoder(Pac4jSAMLResponse responseAdapter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoDestroy()protected voiddoEncode()protected voiddoInitialize()StringgetBindingURI()protected URIgetEndpointURL(org.opensaml.messaging.context.MessageContext<org.opensaml.saml.common.SAMLObject> messageContext)Gets the response URL from the message context.org.apache.velocity.app.VelocityEnginegetVelocityEngine()Get the VelocityEngine instance.StringgetVelocityTemplateId()Get the Velocity template id.protected ElementmarshallMessage(org.opensaml.core.xml.XMLObject message)Helper method that marshalls the given message.protected voidpopulateVelocityContext(org.apache.velocity.VelocityContext velocityContext, org.opensaml.messaging.context.MessageContext<org.opensaml.saml.common.SAMLObject> messageContext, String endpointURL)Populate the Velocity context instance which will be used to render the POST body.protected voidpostEncode(org.opensaml.messaging.context.MessageContext<org.opensaml.saml.common.SAMLObject> messageContext, String endpointURL)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.AbstractMessageEncoder
encode, 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
-
-
-
-
Field Detail
-
DEFAULT_TEMPLATE_ID
public static final String DEFAULT_TEMPLATE_ID
Default template ID.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Pac4jHTTPPostEncoder
public Pac4jHTTPPostEncoder(Pac4jSAMLResponse responseAdapter)
-
-
Method Detail
-
setVelocityTemplateId
public void setVelocityTemplateId(String newVelocityTemplateId)
Set the Velocity template id.Defaults to
DEFAULT_TEMPLATE_ID.- Parameters:
newVelocityTemplateId- the new Velocity template id
-
doDestroy
protected void doDestroy()
- Overrides:
doDestroyin classorg.opensaml.messaging.encoder.AbstractMessageEncoder<org.opensaml.saml.common.SAMLObject>
-
doInitialize
protected void doInitialize() throws net.shibboleth.utilities.java.support.component.ComponentInitializationException- Overrides:
doInitializein classorg.opensaml.messaging.encoder.AbstractMessageEncoder<org.opensaml.saml.common.SAMLObject>- Throws:
net.shibboleth.utilities.java.support.component.ComponentInitializationException
-
doEncode
protected void doEncode() throws org.opensaml.messaging.encoder.MessageEncodingException- Specified by:
doEncodein classorg.opensaml.messaging.encoder.AbstractMessageEncoder<org.opensaml.saml.common.SAMLObject>- Throws:
org.opensaml.messaging.encoder.MessageEncodingException
-
getEndpointURL
protected URI getEndpointURL(org.opensaml.messaging.context.MessageContext<org.opensaml.saml.common.SAMLObject> messageContext) throws org.opensaml.messaging.encoder.MessageEncodingException
Gets the response URL from the message context.- Parameters:
messageContext- current message context- Returns:
- response URL from the message context
- Throws:
org.opensaml.messaging.encoder.MessageEncodingException- throw if no relying party endpoint is available
-
postEncode
protected void postEncode(org.opensaml.messaging.context.MessageContext<org.opensaml.saml.common.SAMLObject> messageContext, String endpointURL) throws org.opensaml.messaging.encoder.MessageEncodingException- Throws:
org.opensaml.messaging.encoder.MessageEncodingException
-
getVelocityTemplateId
public String getVelocityTemplateId()
Get the Velocity template id.Defaults to
DEFAULT_TEMPLATE_ID.- Returns:
- return the Velocity template id
-
getVelocityEngine
public org.apache.velocity.app.VelocityEngine getVelocityEngine()
Get the VelocityEngine instance.- Returns:
- return the VelocityEngine instance
-
populateVelocityContext
protected void populateVelocityContext(org.apache.velocity.VelocityContext velocityContext, org.opensaml.messaging.context.MessageContext<org.opensaml.saml.common.SAMLObject> messageContext, String endpointURL) throws org.opensaml.messaging.encoder.MessageEncodingExceptionPopulate the Velocity context instance which will be used to render the POST body.- Parameters:
velocityContext- the Velocity context instance to populate with datamessageContext- the SAML message context source of dataendpointURL- endpoint URL to which to encode message- Throws:
org.opensaml.messaging.encoder.MessageEncodingException- thrown if there is a problem encoding the message
-
setVelocityEngine
public void setVelocityEngine(org.apache.velocity.app.VelocityEngine newVelocityEngine)
Set the VelocityEngine instance.- Parameters:
newVelocityEngine- the new VelocityEngine instane
-
getBindingURI
public String getBindingURI()
-
marshallMessage
protected Element marshallMessage(org.opensaml.core.xml.XMLObject message) throws org.opensaml.messaging.encoder.MessageEncodingException
Helper method that marshalls the given message.- Parameters:
message- message the marshall and serialize- Returns:
- marshalled message
- Throws:
org.opensaml.messaging.encoder.MessageEncodingException- thrown if the give message can not be marshalled into its DOM representation
-
-