Class HTTPPostSimpleSignEncoder

  • 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 HTTPPostSimpleSignEncoder
    extends HTTPPostEncoder
    SAML 2.0 HTTP-POST-SimpleSign binding message encoder.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String DEFAULT_TEMPLATE_ID
      Default template ID.
      private org.slf4j.Logger log
      Class logger.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected String buildFormDataToSign​(org.apache.velocity.VelocityContext velocityContext, org.opensaml.messaging.context.MessageContext messageContext, String sigAlgURI)
      Build the form control data string over which the signature is computed.
      protected String buildKeyInfo​(org.opensaml.security.credential.Credential signingCredential, org.opensaml.xmlsec.keyinfo.KeyInfoGenerator kiGenerator)
      Build the KeyInfo from the signing credential.
      protected String generateSignature​(org.opensaml.security.credential.Credential signingCredential, String algorithmURI, String formData)
      Generates the signature over the string of concatenated form control data as indicated by the SimpleSign spec.
      String getBindingURI()
      protected String getSignatureAlgorithmURI​(org.opensaml.xmlsec.SignatureSigningParameters signingParameters)
      Gets the signature algorithm URI to use.
      protected void populateVelocityContext​(org.apache.velocity.VelocityContext velocityContext, org.opensaml.messaging.context.MessageContext messageContext, String endpointURL)
      Populate the Velocity context instance which will be used to render the POST body.
      • 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 interface net.shibboleth.utilities.java.support.component.DestructableComponent

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

        initialize, isInitialized
      • Methods inherited from interface org.opensaml.messaging.encoder.MessageEncoder

        encode, prepareContext, setMessageContext
    • Field Detail

      • log

        private final org.slf4j.Logger log
        Class logger.
    • Constructor Detail

      • HTTPPostSimpleSignEncoder

        public HTTPPostSimpleSignEncoder()
        Constructor.
    • Method Detail

      • getBindingURI

        public String getBindingURI()
        Specified by:
        getBindingURI in interface org.opensaml.saml.common.binding.encoding.SAMLMessageEncoder
        Overrides:
        getBindingURI in class HTTPPostEncoder
      • populateVelocityContext

        protected void populateVelocityContext​(org.apache.velocity.VelocityContext velocityContext,
                                               org.opensaml.messaging.context.MessageContext messageContext,
                                               String endpointURL)
                                        throws org.opensaml.messaging.encoder.MessageEncodingException
        Populate the Velocity context instance which will be used to render the POST body.
        Overrides:
        populateVelocityContext in class HTTPPostEncoder
        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
      • buildKeyInfo

        protected String buildKeyInfo​(org.opensaml.security.credential.Credential signingCredential,
                                      org.opensaml.xmlsec.keyinfo.KeyInfoGenerator kiGenerator)
                               throws org.opensaml.messaging.encoder.MessageEncodingException
        Build the KeyInfo from the signing credential.
        Parameters:
        signingCredential - the credential used for signing
        kiGenerator - the generator for the KeyInfo
        Returns:
        the marshalled, serialized and base64-encoded KeyInfo, or null if none was generated
        Throws:
        org.opensaml.messaging.encoder.MessageEncodingException - thrown if there is an error generating or marshalling the KeyInfo
      • buildFormDataToSign

        protected String buildFormDataToSign​(org.apache.velocity.VelocityContext velocityContext,
                                             org.opensaml.messaging.context.MessageContext messageContext,
                                             String sigAlgURI)
                                      throws org.opensaml.messaging.encoder.MessageEncodingException
        Build the form control data string over which the signature is computed.
        Parameters:
        velocityContext - the Velocity context which is already populated with the values for SAML message and relay state
        messageContext - the SAML message context being processed
        sigAlgURI - the signature algorithm URI
        Returns:
        the form control data string for signature computation
        Throws:
        org.opensaml.messaging.encoder.MessageEncodingException - if there is an issue building the form to sign.
      • getSignatureAlgorithmURI

        protected String getSignatureAlgorithmURI​(org.opensaml.xmlsec.SignatureSigningParameters signingParameters)
                                           throws org.opensaml.messaging.encoder.MessageEncodingException
        Gets the signature algorithm URI to use.
        Parameters:
        signingParameters - the signing parameters to use
        Returns:
        signature algorithm to use with the associated signing credential
        Throws:
        org.opensaml.messaging.encoder.MessageEncodingException - thrown if the algorithm URI is not supplied explicitly and could not be derived from the supplied credential
      • generateSignature

        protected String generateSignature​(org.opensaml.security.credential.Credential signingCredential,
                                           String algorithmURI,
                                           String formData)
                                    throws org.opensaml.messaging.encoder.MessageEncodingException
        Generates the signature over the string of concatenated form control data as indicated by the SimpleSign spec.
        Parameters:
        signingCredential - credential that will be used to sign
        algorithmURI - algorithm URI of the signing credential
        formData - form control data to be signed
        Returns:
        base64 encoded signature of form control data
        Throws:
        org.opensaml.messaging.encoder.MessageEncodingException - there is an error computing the signature