从sts收到Saml-token后创建SamlAssertion和token

时间:2015-08-11 11:40:06

标签: saml

我很擅长使用网络服务,所以我希望我的问题有道理 我需要使用WS-Security SAML令牌配置文件/ Holder-of-Key原则来使用Web服务。我成功地从STS获得了一个“samlAssertion”xml:

<saml:Assertion xmlns="" xmlns:ns10="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol" AssertionID="ID_ab1a7c5f-a0cb-4e6f-9342-d623b2095d3b" IssueInstant="2015-08-11T10:44:39.989Z" ...>
    <saml:Conditions NotBefore="2015-08-11T10:44:39.927Z" NotOnOrAfter="2015-08-11T11:44:39.927Z" />
    <saml:AuthenticationStatement ...>
        <saml:Subject>
            <saml:NameIdentifier ...>
            <saml:SubjectConfirmation>
                <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</saml:ConfirmationMethod>
                <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                    <ds:X509Data>
                        <ds:X509Certificate>
                            ...
                        </ds:X509Certificate>
                    </ds:X509Data>
                </ds:KeyInfo>
            </saml:SubjectConfirmation>
        </saml:Subject>
    </saml:AuthenticationStatement>
    <saml:AttributeStatement>
        <saml:Subject>
            <saml:NameIdentifier Format="urn:oasis:names:tc:SAML:1.1:nameidformat:X509SubjectName">...</saml:NameIdentifier>
            <saml:SubjectConfirmation>
                <saml:ConfirmationMethod>urn:oasis:names:tc:SAML:1.0:cm:holder-of-key</saml:ConfirmationMethod>
                <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
                    <ds:X509Data>
                        <ds:X509Certificate>
                            ...
                        </ds:X509Certificate>
                    </ds:X509Data>
                </ds:KeyInfo>
            </saml:SubjectConfirmation>
        </saml:Subject>
        <saml:Attribute ...>
                ...
        </saml:Attribute>
    </saml:AttributeStatement>
    <dsig:Signature xmlns:dsig="http://www.w3.org/2000/09/xmldsig#">
        <dsig:SignedInfo>
            <dsig:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            <dsig:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
            <dsig:Reference URI="#ID_ab1a7c5f-a0cb-4e6f-9342-d623b2095d3b">
                <dsig:Transforms>
                    <dsig:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                    <dsig:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                </dsig:Transforms>
                <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
                <dsig:DigestValue>...</dsig:DigestValue>
            </dsig:Reference>
        </dsig:SignedInfo>
        <dsig:SignatureValue>...</dsig:SignatureValue>
    </dsig:Signature>
</saml:Assertion>

我想我现在需要继续使用WIF,所以我想从收到的xml中创建一个SamlAssertion对象。

这是我的代码:

 XmlReader reader = XmlReader.Create(new StringReader(recievedXml));
 assertion.ReadXml(XmlDictionaryReader.CreateDictionaryReader(reader),
                new SamlSerializer(),
                new WSSecurityTokenSerializer(),
                null);

但是,此代码导致以下错误:

值不能为空。 参数名称:ski

  • 这是什么意思?
  • 有没有其他方法可以创建SamlAssertion?
  • 我真的需要Samlassertion继续吗?

0 个答案:

没有答案
相关问题