Class 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

    public class Pac4jHTTPPostEncoder
    extends org.opensaml.messaging.encoder.AbstractMessageEncoder
    Pac4j implementation extending directly the AbstractMessageEncoder as 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 java.lang.String DEFAULT_TEMPLATE_ID
      Default template ID.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void doDestroy()  
      protected void doEncode()  
      protected void doInitialize()  
      java.lang.String getBindingURI()  
      protected java.net.URI getEndpointURL​(org.opensaml.messaging.context.MessageContext messageContext)
      Gets the response URL from the message context.
      org.apache.velocity.app.VelocityEngine getVelocityEngine()
      Get the VelocityEngine instance.
      java.lang.String getVelocityTemplateId()
      Get the Velocity template id.
      protected org.w3c.dom.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 messageContext, java.lang.String endpointURL)
      Populate the Velocity context instance which will be used to render the POST body.
      protected void postEncode​(org.opensaml.messaging.context.MessageContext messageContext, java.lang.String endpointURL)  
      void setVelocityEngine​(org.apache.velocity.app.VelocityEngine newVelocityEngine)
      Set the VelocityEngine instance.
      void setVelocityTemplateId​(java.lang.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
      • Methods inherited from interface net.shibboleth.utilities.java.support.component.DestructableComponent

        destroy, isDestroyed
      • Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent

        initialize, isInitialized
    • Field Detail

      • DEFAULT_TEMPLATE_ID

        public static final java.lang.String DEFAULT_TEMPLATE_ID
        Default template ID.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Pac4jHTTPPostEncoder

        public Pac4jHTTPPostEncoder​(Pac4jSAMLResponse responseAdapter)
    • Method Detail

      • doDestroy

        protected void doDestroy()
        Overrides:
        doDestroy in class org.opensaml.messaging.encoder.AbstractMessageEncoder
      • doInitialize

        protected void doInitialize()
                             throws net.shibboleth.utilities.java.support.component.ComponentInitializationException
        Overrides:
        doInitialize in class org.opensaml.messaging.encoder.AbstractMessageEncoder
        Throws:
        net.shibboleth.utilities.java.support.component.ComponentInitializationException
      • doEncode

        protected void doEncode()
                         throws org.opensaml.messaging.encoder.MessageEncodingException
        Specified by:
        doEncode in class org.opensaml.messaging.encoder.AbstractMessageEncoder
        Throws:
        org.opensaml.messaging.encoder.MessageEncodingException
      • getEndpointURL

        protected java.net.URI getEndpointURL​(org.opensaml.messaging.context.MessageContext 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 messageContext,
                                  java.lang.String endpointURL)
                           throws org.opensaml.messaging.encoder.MessageEncodingException
        Throws:
        org.opensaml.messaging.encoder.MessageEncodingException
      • getVelocityTemplateId

        public java.lang.String getVelocityTemplateId()
        Get the Velocity template id.

        Defaults to DEFAULT_TEMPLATE_ID.

        Returns:
        return the Velocity template id
      • setVelocityTemplateId

        public void setVelocityTemplateId​(java.lang.String newVelocityTemplateId)
        Set the Velocity template id.

        Defaults to DEFAULT_TEMPLATE_ID.

        Parameters:
        newVelocityTemplateId - the new Velocity template id
      • getVelocityEngine

        public org.apache.velocity.app.VelocityEngine getVelocityEngine()
        Get the VelocityEngine instance.
        Returns:
        return the VelocityEngine instance
      • setVelocityEngine

        public void setVelocityEngine​(org.apache.velocity.app.VelocityEngine newVelocityEngine)
        Set the VelocityEngine instance.
        Parameters:
        newVelocityEngine - the new VelocityEngine instane
      • populateVelocityContext

        protected void populateVelocityContext​(org.apache.velocity.VelocityContext velocityContext,
                                               org.opensaml.messaging.context.MessageContext messageContext,
                                               java.lang.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 data
        messageContext - the SAML message context source of data
        endpointURL - endpoint URL to which to encode message
        Throws:
        org.opensaml.messaging.encoder.MessageEncodingException - thrown if there is a problem encoding the message
      • getBindingURI

        public java.lang.String getBindingURI()
      • marshallMessage

        protected org.w3c.dom.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