Class PostRequestHttpObject<T extends org.opensaml.saml.saml2.core.RequestAbstractType>

java.lang.Object
se.swedenconnect.opensaml.saml2.request.PostRequestHttpObject<T>
Type Parameters:
T - the type of the request
All Implemented Interfaces:
RequestHttpObject<T>

public class PostRequestHttpObject<T extends org.opensaml.saml.saml2.core.RequestAbstractType> extends Object implements RequestHttpObject<T>
A RequestHttpObject for sending using HTTP POST.

If signature credentials are supplied when creating the object the request will be signed.

Author:
Martin Lindström (martin@idsec.se)
  • Constructor Summary

    Constructors
    Constructor
    Description
    PostRequestHttpObject(T request, String relayState, org.opensaml.security.x509.X509Credential signatureCredentials, String endpoint, org.opensaml.saml.saml2.metadata.EntityDescriptor recipientMetadata)
    Constructor that puts together the resulting object.
    PostRequestHttpObject(T request, String relayState, org.opensaml.security.x509.X509Credential signatureCredentials, String endpoint, org.opensaml.saml.saml2.metadata.EntityDescriptor recipientMetadata, org.opensaml.xmlsec.SignatureSigningConfiguration defaultSignatureSigningConfiguration)
    Constructor that puts together the resulting object.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the URL to where we are sending the request.
    Returns a mapping of header names and values that should be used when sending the request.
    Returns the HTTP method that should be used to send the request, via the user agent, to the Identity Provider.
    Returns the actual request (for easy access to its elements).
    If the RequestHttpObject.getMethod() returns "POST" the request should be posted to the Identity Provider.
    Returns the complete URL that the SP application should use when the user agent is sent to the Identity Provider.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PostRequestHttpObject

      public PostRequestHttpObject(T request, String relayState, org.opensaml.security.x509.X509Credential signatureCredentials, String endpoint, org.opensaml.saml.saml2.metadata.EntityDescriptor recipientMetadata) throws org.opensaml.messaging.encoder.MessageEncodingException, org.opensaml.xmlsec.signature.support.SignatureException
      Constructor that puts together the resulting object.
      Parameters:
      request - the request object
      relayState - the relay state
      signatureCredentials - optional signature credentials
      endpoint - the endpoint where we send this request to
      recipientMetadata - the recipient metadata (may be null)
      Throws:
      org.opensaml.messaging.encoder.MessageEncodingException - for encoding errors
      org.opensaml.xmlsec.signature.support.SignatureException - for signature errors
    • PostRequestHttpObject

      public PostRequestHttpObject(T request, String relayState, org.opensaml.security.x509.X509Credential signatureCredentials, String endpoint, org.opensaml.saml.saml2.metadata.EntityDescriptor recipientMetadata, org.opensaml.xmlsec.SignatureSigningConfiguration defaultSignatureSigningConfiguration) throws org.opensaml.messaging.encoder.MessageEncodingException, org.opensaml.xmlsec.signature.support.SignatureException
      Constructor that puts together the resulting object.
      Parameters:
      request - the request object
      relayState - the relay state
      signatureCredentials - optional signature credentials
      endpoint - the endpoint where we send this request to
      recipientMetadata - the recipient metadata (may be null)
      defaultSignatureSigningConfiguration - the default signature configuration for the application. If null, the value returned from SecurityConfigurationSupport.getGlobalSignatureSigningConfiguration() will be used
      Throws:
      org.opensaml.messaging.encoder.MessageEncodingException - for encoding errors
      org.opensaml.xmlsec.signature.support.SignatureException - for signature errors
  • Method Details

    • getSendUrl

      public String getSendUrl()
      Returns the complete URL that the SP application should use when the user agent is sent to the Identity Provider.

      For a redirect, this URL could look something like: https://www.theidp.com/auth?SAMLRequest=<encoded request>&RelayState=abcd.

      Note: Additional query parameters may be added to the URL by the using system.

      Specified by:
      getSendUrl in interface RequestHttpObject<T extends org.opensaml.saml.saml2.core.RequestAbstractType>
      Returns:
      the URL to use when sending the user to the Identity Provider
    • getDestinationUrl

      public String getDestinationUrl()
      Returns the URL to where we are sending the request. If the method is "POST", this will be the same value as for RequestHttpObject.getSendUrl(), and if the method is "GET", the value is just the destination and not the query parameters.
      Specified by:
      getDestinationUrl in interface RequestHttpObject<T extends org.opensaml.saml.saml2.core.RequestAbstractType>
      Returns:
      the destination URL
    • getMethod

      public String getMethod()
      Returns the HTTP method that should be used to send the request, via the user agent, to the Identity Provider. Possible values for this implementation is "GET" (redirect) and "POST".
      Specified by:
      getMethod in interface RequestHttpObject<T extends org.opensaml.saml.saml2.core.RequestAbstractType>
      Returns:
      the HTTP method to use
    • getRequestParameters

      public Map<String,String> getRequestParameters()
      If the RequestHttpObject.getMethod() returns "POST" the request should be posted to the Identity Provider. The request parameters are represented using a Map where the entries represent parameter names and values.

      Note: for the "GET" method this method returns the query parameters that are part of RequestHttpObject.getSendUrl().

      The parameter values are not URL-encoded.

      Specified by:
      getRequestParameters in interface RequestHttpObject<T extends org.opensaml.saml.saml2.core.RequestAbstractType>
      Returns:
      a Map holding the request parameters (POST body or query parameters)
    • getHttpHeaders

      public Map<String,String> getHttpHeaders()
      Returns a mapping of header names and values that should be used when sending the request.
      Specified by:
      getHttpHeaders in interface RequestHttpObject<T extends org.opensaml.saml.saml2.core.RequestAbstractType>
      Returns:
      HTTP headers
    • getRequest

      public T getRequest()
      Returns the actual request (for easy access to its elements).
      Specified by:
      getRequest in interface RequestHttpObject<T extends org.opensaml.saml.saml2.core.RequestAbstractType>
      Returns:
      the request
    • toString

      public String toString()
      Overrides:
      toString in class Object