我正在使用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工具 - &gt; XML操作 - &gt;验证)
,也会出现错误。看起来xenc-schema.xsd中的xml架构无效(应该包含inlcude而不是import)。此代码来自xmltooling-1.4.4.jar库(最新版本)。
这是Spring SAML或xmltooling架构文件中的错误,还是我做错了什么?
我的业务案例是身份提供商发起的SSO。 如https://en.wikipedia.org/wiki/SAML_2.0#HTTP_POST_Binding中所述,指出 5.在SP请求断言消费者服务 我在POST请求中使用SAML断言(正文包含SAMLResponse =
Bellow all errors
&lt; ...&gt; \ xmltooling-1.4.4.jar!\ schema \ xmldsig-core-schema.xsd错误:(2,360)src-import.3.1:名称空间属性, &#39; http://www.w3.org/2000/09/xmldsig#&#39;,一个元素 信息项必须与targetNamespace属性相同, &#39; urn:oasis:名称:tc:SAML:2.0:断言&#39;,导入的文档。
&lt; ...&gt; \ xmltooling-1.4.4.jar!\ schema \ xenc-schema.xsd错误:(2,360)src-import.3.1:名称空间属性, &#39; http://www.w3.org/2001/04/xmlenc#&#39;,一个元素 信息项必须与targetNamespace属性相同, &#39; urn:oasis:名称:tc:SAML:2.0:断言&#39;,导入的文档。
&lt; ...&gt; \ opensaml-2.6.4.jar!\ schema \ saml-schema-assertion-2.0.xsd错误:(34,48)src-resolve:无法解析名称 &#39; xenc:的EncryptedData&#39;到(n)&#39;元素声明&#39;零件。 错误:(46,56)src-resolve:无法解析名称&#39; ds:签名&#39;至 a(n)&#39;元素声明&#39;成分
&lt; ...&gt; \ wikipediaExample.xml错误:(11,59)cvc-complex-type.2.4.a:找到以元素&#39; ds:Signature&#39开头的无效内容;。之一 &#39; {&#34;瓮:绿洲:名称:TC:SAML:2.0:断言&#34;:主题, &#34;瓮:绿洲:名称:TC:SAML:2.0:断言&#34;:条件, &#34;瓮:绿洲:名称:TC:SAML:2.0:断言&#34;:建议, &#34;瓮:绿洲:名称:TC:SAML:2.0:断言&#34;:语句, &#34;瓮:绿洲:名称:TC:SAML:2.0:断言&#34;:AuthnStatement, &#34;瓮:绿洲:名称:TC:SAML:2.0:断言&#34;:AuthzDecisionStatement, &#34;瓮:绿洲:名称:TC:SAML:2.0:断言&#34;:AttributeStatement}&#39;是 预期。错误:(11,77)cvc-complex-type.2.3:元素&#39; ds:签名&#39; 不能有字符[children],因为type的内容类型是 元素而已。错误:(11,77)cvc-complex-type.2.4.b:的内容 元素&#39; ds:签名&#39;不完整。之一 &#39; {&#34; http://www.w3.org/2000/09/xmldsig#&#34;:SignedInfo中}&#39;预计会有。
答案 0 :(得分:4)
As you can see in your XML, the Signature content is ommited with triple dots:
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">...</ds:Signature>
The XML validation is correctly telling you about this problem.