Class SamlResponseBuilder

java.lang.Object
org.mockserver.saml.SamlResponseBuilder

public class SamlResponseBuilder extends Object
Builds and enveloped-signs a SAML 2.0 <Response> document using only the JDK XML APIs (javax.xml DOM) and the JDK XML Digital Signature API (javax.xml.crypto.dsig.*) — no OpenSAML/Shibboleth dependency.

The <Assertion> is enveloped-signed (the signature element is inserted into the Assertion immediately after its <Issuer>, as required by the SAML schema), with an exclusive-canonicalised Reference to the Assertion's ID and the signing certificate embedded in <ds:KeyInfo>/<ds:X509Data>. Signing the Assertion (rather than the Response envelope) is the most widely interoperable choice for the Web-Browser-SSO POST profile.

  • Constructor Details

    • SamlResponseBuilder

      public SamlResponseBuilder()
  • Method Details

    • buildSignedResponse

      public String buildSignedResponse(SamlAssertionStore.Provider provider, String inResponseTo)
      Builds a signed SAML Response and returns its serialized XML string.
      Parameters:
      provider - the mock IdP provider state
      relayState - the SP RelayState (echoed by the caller, not embedded in the assertion)
      Returns:
      the serialized, signed <Response> XML