Class SAML2AssertionFactory


  • @ThreadSafe
    public class SAML2AssertionFactory
    extends Object
    Static SAML 2.0 bearer assertion factory.

    Related specifications:

    • Assertion Framework for OAuth 2.0 Client Authentication and Authorization Grants (RFC 7521).
    • Security Assertion Markup Language (SAML) 2.0 Profile for OAuth 2.0 Client Authentication and Authorization Grants (RFC 7522).
    • Method Detail

      • create

        public static org.opensaml.saml.saml2.core.Assertion create​(SAML2AssertionDetails details,
                                                                    String xmlDsigAlg,
                                                                    org.opensaml.security.credential.Credential credential)
        Creates a new SAML 2.0 assertion.
        Parameters:
        details - The SAML 2.0 bearer assertion details. Must not be null.
        xmlDsigAlg - The XML digital signature algorithm. Must not be null.
        credential - The appropriate credentials to facilitate signing of the assertion.
        Returns:
        The SAML 2.0 bearer assertion.
        Throws:
        SerializeException - If serialisation or signing failed.
      • createAsElement

        public static Element createAsElement​(SAML2AssertionDetails details,
                                              String xmlDsigAlg,
                                              org.opensaml.security.credential.Credential credential)
        Creates a new SAML 2.0 assertion as an XML element.
        Parameters:
        details - The SAML 2.0 bearer assertion details. Must not be null.
        xmlDsigAlg - The XML digital signature algorithm. Must not be null.
        credential - The appropriate credentials to facilitate signing of the assertion.
        Returns:
        The SAML 2.0 bearer assertion as an XML element.
        Throws:
        SerializeException - If serialisation or signing failed.
      • createAsString

        public static String createAsString​(SAML2AssertionDetails details,
                                            String xmlDsigAlg,
                                            org.opensaml.security.credential.Credential credential)
        Creates a new SAML 2.0 assertion as an XML string.
        Parameters:
        details - The SAML 2.0 bearer assertion details. Must not be null.
        xmlDsigAlg - The XML digital signature algorithm. Must not be null.
        credential - The appropriate credentials to facilitate signing of the assertion.
        Returns:
        The SAML 2.0 bearer assertion as an XML string. Note that an XML declaration is not present in the output string.
        Throws:
        SerializeException - If serialisation or signing failed.
      • createAsString

        public static String createAsString​(SAML2AssertionDetails details,
                                            RSAPublicKey rsaPublicKey,
                                            RSAPrivateKey rsaPrivateKey)
        Creates a new SAML 2.0 assertion as an XML string, signed with the RSA-SHA256 XML digital signature algorithm (mandatory to implement).
        Parameters:
        details - The SAML 2.0 bearer assertion details. Must not be null.
        rsaPublicKey - The public RSA key. Must not be null.
        rsaPrivateKey - The private RSA key to sign the assertion. Must not be null.
        Returns:
        The SAML 2.0 bearer assertion as an XML string. Note that an XML declaration is not present in the output string.
        Throws:
        SerializeException - If serialisation or signing failed.