简体   繁体   English

在XSD中使用SAML断言

[英]Using SAML Assertion in XSD

I have a webservice operation where i'll be getting SAML Assertion as part of the request Body. 我有一个webservice操作,我将获取SAML断言作为请求Body的一部分。 I have following XSD: 我有以下XSD:

<xsd:element name="CreateRequest">
    <xsd:complexType>
        <xsd:sequence>
            <xsd:element name="info" type="SomeRequestObj"/>
            <xsd:element ref="saml:Assertion" />
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>

The saml:Assertion refers to: saml:断言是指:

<xsd:import namespace="urn:oasis:names:tc:SAML:2.0:assertion"schemaLocation="../samlv2_0/saml-schema-assertion-2.0.xsd"/>

This saml schema is copied from SAML 2.0 . 此SAM模式是从SAML 2.0复制的。 This generates classes with name * Type.java . 这将生成名为* Type.java类。 And i am having a hard time creating a unit test for this (which is a separate application with UI). 我很难为此创建一个单元测试(这是一个单独的UI应用程序)。

My Request requires a SAML AssertionType element in the request Body. 我的请求需要请求正文中的SAML AssertionType元素。 So, i cannot use OpneSaml for generating that as it gives me a SAML Assertion object and not AssertionType. 所以,我不能使用OpneSaml来生成它,因为它给了我一个SAML Assertion对象而不是AssertionType。

I tried generating the AssertionType object manually but i am having a hard time doing so. 我尝试手动生成AssertionType对象,但我很难这样做。
Is there a way to use OpenSaml for generating this? 有没有办法使用OpenSaml来生成这个?
As i see the xml is going to be the same that i would get in case i just use OpenSaml to generate Assertion object. 正如我所看到的那样,xml将与我在使用OpenSaml生成Assertion对象的情况下相同。 Is there a way to simplify this? 有没有办法简化这个?

EDIT: Added XSD snippet of Assertion 编辑:添加了断言的XSD片段

<element name="Assertion" type="saml:AssertionType"/>
<complexType name="AssertionType">
<sequence>
<element ref="saml:Issuer"/>
<element ref="ds:Signature" minOccurs="0"/>
<element ref="saml:Subject" minOccurs="0"/>
<element ref="saml:Conditions" minOccurs="0"/>
<element ref="saml:Advice" minOccurs="0"/>
<choice minOccurs="0" maxOccurs="unbounded">
<element ref="saml:Statement"/>
<element ref="saml:AuthnStatement"/>
<element ref="saml:AuthzDecisionStatement"/>
<element ref="saml:AttributeStatement"/>
</choice>
</sequence>
<attribute name="Version" type="string" use="required"/>
<attribute name="ID" type="ID" use="required"/>
<attribute name="IssueInstant" type="dateTime" use="required"/>
</complexType>

This generates AssertionType Object. 这会生成AssertionType对象。

SAML Assertions are of complex type "AssertionType", but the element name is "Assertion". SAML断言的类型为“AssertionType”,但元素名称为“Assertion”。 The <Assertion> element generated by OpenSaml should be just fine. OpenSaml生成的<Assertion>元素应该没问题。

The element is defined in section 2.3.3 in the SAML core spec . 该元素在SAML核心规范的 2.3.3节中定义。

Try to use an external binding file when generating the classes from the XSD with JAXB. 使用JAXB从XSD生成类时,尝试使用外部绑定文件。 See this topic (I guess the second answer of it is what you're looking for): JAXB: How to change XJC-generated classes names when attr type is specified in XSD? 看到这个主题(我猜它的第二个答案是你正在寻找的): JAXB:如何在XSD中指定attr类型时更改XJC生成的类名?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM