public XElement Serialize() { var result = new XElement(Constants.XMLNamespaces.DS + "SignedInfo", CanonicalizationMethod.Serialize(), SignatureMethod.Serialize()); foreach (var reference in References) { result.Add(reference.Serialize()); } return(result); }
public void ShouldSerializeAuthnResponseSignatureElement() { #region Arrange string x509Cert = "MIICajCCAdOgAwIBAgIBADANBgkqhkiG9w0BAQ0FADBSMQswCQYDVQQGEwJ1czETMBEGA1UECAwKQ2FsaWZvcm5pYTEVMBMGA1UECgwMT25lbG9naW4gSW5jMRcwFQYDVQQDDA5zcC5leGFtcGxlLmNvbTAeFw0xNDA3MTcxNDEyNTZaFw0xNTA3MTcxNDEyNTZaMFIxCzAJBgNVBAYTAnVzMRMwEQYDVQQIDApDYWxpZm9ybmlhMRUwEwYDVQQKDAxPbmVsb2dpbiBJbmMxFzAVBgNVBAMMDnNwLmV4YW1wbGUuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDZx+ON4IUoIWxgukTb1tOiX3bMYzYQiwWPUNMp+Fq82xoNogso2bykZG0yiJm5o8zv/sd6pGouayMgkx/2FSOdc36T0jGbCHuRSbtia0PEzNIRtmViMrt3AeoWBidRXmZsxCNLwgIV6dn2WpuE5Az0bHgpZnQxTKFek0BMKU/d8wIDAQABo1AwTjAdBgNVHQ4EFgQUGHxYqZYyX7cTxKVODVgZwSTdCnwwHwYDVR0jBBgwFoAUGHxYqZYyX7cTxKVODVgZwSTdCnwwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQ0FAAOBgQByFOl+hMFICbd3DJfnp2Rgd/dqttsZG/tyhILWvErbio/DEe98mXpowhTkC04ENprOyXi7ZbUqiicF89uAGyt1oqgTUCD1VsLahqIcmrzgumNyTwLGWo17WDAa1/usDhetWAMhgzF/Cnf5ek0nK00m0YZGyc4LzgD0CROMASTWNg=="; string signatureValue = "d9QXcvDyn+7R8ZMha1W1XcSKctmS+tz5X75ktZRWQ7QHqqkG2h3+wvrtDAIXtzbvolH6+sP0qfcVbBD5XjYuUsqtarnHKmaPwttRKoX2P1tJHKxbpGXbB6e7NoePjqpA211Pjfr0YPrLx2ZfXkkmbYOpDV/yHtg1YwmtJcUo9NY="; string responseWithSignature = @$ " <samlp:Response xmlns:samlp='urn:oasis:names:tc:SAML:2.0:protocol' xmlns:saml='urn:oasis:names:tc:SAML:2.0:assertion' ID='pfx185f69c9-c006-ddeb-ce3b-5f0d0f51a1b2' Version='2.0' IssueInstant='2014-07-17T01:01:48Z' Destination='http://sp.example.com/demo1/index.php?acs' InResponseTo='ONELOGIN_4fee3b046395c4e751011e97f8900b5273d56685'> <ds:Signature xmlns:ds='http://www.w3.org/2000/09/xmldsig#'> <ds:SignedInfo> <ds:CanonicalizationMethod Algorithm='http://www.w3.org/2001/10/xml-exc-c14n#'/> <ds:SignatureMethod Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/> <ds:Reference URI='#pfx185f69c9-c006-ddeb-ce3b-5f0d0f51a1b2'> <ds:Transforms> <ds:Transform Algorithm='http://www.w3.org/2000/09/xmldsig#enveloped-signature'/> <ds:Transform Algorithm='http://www.w3.org/2001/10/xml-exc-c14n#'/> </ds:Transforms> <ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/> <ds:DigestValue>Ldgd30/+CCun6XlBOeiJUnpgPJo=</ds:DigestValue> </ds:Reference> </ds:SignedInfo> <ds:SignatureValue>{signatureValue}</ds:SignatureValue>
/// <summary> /// Devuelve el XML de entrada canonicalizado. /// </summary> /// <param name="xmlDoc">Documento XML a canonicalizar.</param> /// <returns>XML de entrada canonicalizado.</returns> protected string GetCanonical(XmlDocument xmlDoc) { return(CanonicalizationMethod.GetCanonicalString(xmlDoc)); }
/// <summary> /// Devuelve el XML de entrada canonicalizado. /// </summary> /// <param name="xmlContent">XML a canonicalizar.</param> /// <returns>XML de entrada canonicalizado.</returns> protected string GetCanonical(string xmlContent) { return(CanonicalizationMethod.GetCanonicalString(xmlContent)); }
/** * Creates a <code>SignedInfo</code> with the specified parameters. * * @param cm the canonicalization method * @param sm the signature method * @param references a list of one or more {@link Reference}s. The list is * defensively copied to protect against subsequent modification. * @param id the id (may be <code>null</code>) * @return a <code>SignedInfo</code> * @throws ClassCastException if any of the references are not of * type <code>Reference</code> * @throws IllegalArgumentException if <code>references</code> is empty * @throws NullPointerException if <code>cm</code>, <code>sm</code>, or * <code>references</code> are <code>null</code> */ public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, java.util.List <Object> references, String id);
/** * Creates a <code>SignedInfo</code> with the specified parameters. * * @param cm the canonicalization method * @param sm the signature method * @param references a list of one or more {@link Reference}s. The list is * defensively copied to protect against subsequent modification. * @param id the id (may be <code>null</code>) * @return a <code>SignedInfo</code> * @throws ClassCastException if any of the references are not of * type <code>Reference</code> * @throws IllegalArgumentException if <code>references</code> is empty * @throws NullPointerException if <code>cm</code>, <code>sm</code>, or * <code>references</code> are <code>null</code> */ public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, java.util.List<Object> references, String id);