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 theAbstractMessageEncoder
as intermediate classes use the J2E 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 String
DEFAULT_TEMPLATE_ID
Default template ID.
-
Constructor Summary
Constructors Constructor Description Pac4jHTTPPostEncoder(Pac4jSAMLResponse responseAdapter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doDestroy()
protected void
doEncode()
protected void
doInitialize()
String
getBindingURI()
protected URI
getEndpointURL(org.opensaml.messaging.context.MessageContext<org.opensaml.saml.common.SAMLObject> messageContext)
Gets the response URL from the message context.org.apache.velocity.app.VelocityEngine
getVelocityEngine()
Get the VelocityEngine instance.String
getVelocityTemplateId()
Get the Velocity template id.protected Element
marshallMessage(org.opensaml.core.xml.XMLObject message)
Helper method that marshalls the given message.protected void
populateVelocityContext(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 void
postEncode(org.opensaml.messaging.context.MessageContext<org.opensaml.saml.common.SAMLObject> messageContext, String endpointURL)
void
setVelocityEngine(org.apache.velocity.app.VelocityEngine newVelocityEngine)
Set the VelocityEngine instance.void
setVelocityTemplateId(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:
doDestroy
in classorg.opensaml.messaging.encoder.AbstractMessageEncoder<org.opensaml.saml.common.SAMLObject>
-
doInitialize
protected void doInitialize() throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
- Overrides:
doInitialize
in 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:
doEncode
in 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.MessageEncodingException
Populate 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
-
-