【发布时间】:2015-06-29 20:16:49
【问题描述】:
我正在使用 Spring SAML,但在使用 SAML 断言时遇到问题(来自 Wikipedia article 的示例断言
<saml:Assertion
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
ID="b07b804c-7c29-ea16-7300-4f3d6f7928ac"
Version="2.0"
IssueInstant="2004-12-05T09:22:05">
<saml:Issuer>https://idp.example.org/SAML2</saml:Issuer>
<ds:Signature
xmlns:ds="http://www.w3.org/2000/09/xmldsig#">...</ds:Signature>
<saml:Subject>
<saml:NameID
Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient">
3f7b3dcf-1674-4ecd-92c8-1544f346baf8
</saml:NameID>
<saml:SubjectConfirmation
Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml:SubjectConfirmationData
InResponseTo="aaf23196-1773-2113-474a-fe114412ab72"
Recipient="https://sp.example.com/SAML2/SSO/POST"
NotOnOrAfter="2004-12-05T09:27:05"/>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Conditions
NotBefore="2004-12-05T09:17:05"
NotOnOrAfter="2004-12-05T09:27:05">
<saml:AudienceRestriction>
<saml:Audience>https://sp.example.com/SAML2</saml:Audience>
</saml:AudienceRestriction>
</saml:Conditions>
<saml:AuthnStatement
AuthnInstant="2004-12-05T09:22:00"
SessionIndex="b07b804c-7c29-ea16-7300-4f3d6f7928ac">
<saml:AuthnContext>
<saml:AuthnContextClassRef>
urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport
</saml:AuthnContextClassRef>
</saml:AuthnContext>
</saml:AuthnStatement>
<saml:AttributeStatement>
<saml:Attribute
xmlns:x500="urn:oasis:names:tc:SAML:2.0:profiles:attribute:X500"
x500:Encoding="LDAP"
NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri"
Name="urn:oid:1.3.6.1.4.1.5923.1.1.1.1"
FriendlyName="eduPersonAffiliation">
<saml:AttributeValue
xsi:type="xs:string">member</saml:AttributeValue>
<saml:AttributeValue
xsi:type="xs:string">staff</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>
我收到来自 XML 验证的错误。即使我从 IDE (Intelij IDEA tools->XML Actions->Validate) 执行架构验证,也会出现错误
看起来 xenc-schema.xsd 中的 xml 架构无效(应该包含而不是导入)。此代码来自 xmltooling-1.4.4.jar 库(最新版本)。
这是 Spring SAML 或 xmltooling 架构文件中的错误,还是我做错了什么?
我的业务案例是身份提供商发起的 SSO。 如https://en.wikipedia.org/wiki/SAML_2.0#HTTP_POST_Binding 中所述,点 5. 在 SP 处请求 Assertion Consumer Service 我在 POST 请求中使用 SAML 断言(正文包含 SAMLResponse=
列出所有错误
<...>\xmltooling-1.4.4.jar!\schema\xmldsig-core-schema.xsd 错误:(2, 360) src-import.3.1: 命名空间属性, 'http://www.w3.org/2000/09/xmldsig#',一个元素 信息项必须与 targetNamespace 属性相同, 'urn:oasis:names:tc:SAML:2.0:assertion', 导入文档。
<...>\xmltooling-1.4.4.jar!\schema\xenc-schema.xsd 错误:(2, 360) src-import.3.1: 命名空间属性, 'http://www.w3.org/2001/04/xmlenc#',一个元素 信息项必须与 targetNamespace 属性相同, 'urn:oasis:names:tc:SAML:2.0:assertion', 导入文档。
<...>\opensaml-2.6.4.jar!\schema\saml-schema-assertion-2.0.xsd 错误:(34, 48) src-resolve: 无法解析名称 'xenc:EncryptedData' 到一个(n)'元素声明'组件。 错误:(46, 56) src-resolve: 无法将名称 'ds:Signature' 解析为 a(n) '元素声明' 组件。
<...>\wikipediaExample.xml 错误:(11, 59) cvc-complex-type.2.4.a:发现以元素“ds:Signature”开头的无效内容。之一 '{"urn:oasis:names:tc:SAML:2.0:assertion":Subject, "urn:oasis:names:tc:SAML:2.0:assertion":条件, “urn:oasis:names:tc:SAML:2.0:assertion”:建议, “urn:oasis:names:tc:SAML:2.0:assertion”:声明, "urn:oasis:names:tc:SAML:2.0:assertion":AuthnStatement, "urn:oasis:names:tc:SAML:2.0:assertion":AuthzDecisionStatement, "urn:oasis:names:tc:SAML:2.0:assertion":AttributeStatement}' 是 预期的。错误:(11, 77) cvc-complex-type.2.3: 元素 'ds:Signature' 不能有字符 [children],因为类型的内容类型是 仅元素。错误:(11, 77) cvc-complex-type.2.4.b: 的内容 元素“ds:Signature”不完整。之一 '{"http://www.w3.org/2000/09/xmldsig#":SignedInfo}' 是预期的。
【问题讨论】:
标签: xsd saml xml-validation spring-saml