用Inclusivenamespace封装XML签名



用4D语言编写时,我必须编写低级别的规范化函数来检查XML上的签名。在十几个案例中工作得很好,现在我遇到了一个新的困难:XML包括"InclusiveNamespaces";转型我想这就是破坏我的签名检查算法的原因,我不知道它应该如何工作。我的初始XML看起来像:

<saml2:Assertion ID="1234"
xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<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/2001/04/xmldsig-more#rsa-sha256"/>
<ds:Reference URI="#1234">
<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#">
<ec:InclusiveNamespaces PrefixList="xs"
xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>xxx</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
</ds:Signature>
<saml2:AttributeStatement xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">
<saml2:Attribute Name="myAttribute"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
<saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="xs:string">STRING</saml2:AttributeValue>
</saml2:Attribute>
</saml2:AttributeStatement>
</saml2:Assertion>

所以我有一个";Inclusive Namespace";对于";xs";,用于saml2:AttributeValue的xsi:type属性值。我的问题是:在我的规范化算法中,我应该如何处理它?在我目前的算法中,它被简单地删除了,因为它没有被任何元素或属性明显使用,但我不确定它应该放在哪里。RFC确实提到了这个案例,但没有足够的细节让我弄清楚。。。如果您有自己的代码,可以规范化我的示例XML并返回正确的值,我们将不胜感激。:(

通过包容性规范化,您应该将所有父命名空间都包括到规范化节点中,即使该命名空间没有在节点本身或其子节点中使用。有关更多详细信息,请参阅规范。

最新更新