【问题标题】:OpenSaml retrieving wrong RoleDescriptor objectOpenSaml 检索错误的 RoleDescriptor 对象
【发布时间】:2015-05-10 09:16:11
【问题描述】:

我正在尝试使用以下代码和 OpenSaml 库从服务提供者元数据文件 (SAML 2.0) 中检索 RoleDescriptor 节点:

EntitiesDescriptor entityDescriptors = getConfiguration(providerId);
List<RoleDescriptor> roleDescriptors = (List<RoleDescriptor>) entityDescriptors.getEntityDescriptors().get(0).
            getRoleDescriptors();
EntityDescriptor ed = entityDescriptors.getEntityDescriptors().get(0);
if(roleDescriptors != null && !roleDescriptors.isEmpty()){
    RoleDescriptor r = (RoleDescriptor) roleDescriptors.get(0); 
    return roleDescriptors.get(0).getErrorURL();
}

我的问题是变量r 的结尾是org.opensaml.saml2.metadata.impl.SPSSODescriptorImpl 而不是org.opensaml.saml2.metadata.impl.RoleDescriptorImpl

这是我正在使用的元数据 xml 文件:

<EntityDescriptor entityID="http://mysp.com/resource">

    <RoleDescriptor errorURL="http://localhost:8080/dummy-sp/error.jsp">
    </RoleDescriptor>

    <SPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
        <KeyDescriptor use="encryption">
            <EncryptionMethod Algorithm=
                "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256">
            </EncryptionMethod>
        </KeyDescriptor>

        <AssertionConsumerService index="1"
            isDefault="true" Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
            Location="http://localhost:8080/dummy-sp/dummysp" />

    </SPSSODescriptor>

    <Organization>
        <OrganizationName xml:lang="en">Your Service
        </OrganizationName>
        <OrganizationDisplayName xml:lang="en">Your
            Service
        </OrganizationDisplayName>
        <OrganizationURL xml:lang="en">http://sp.example.org/
        </OrganizationURL>
    </Organization>
    <ContactPerson contactType="technical">
        <GivenName>Your</GivenName>
        <SurName>Admin</SurName>
        <EmailAddress>admin@example.org</EmailAddress>
    </ContactPerson>

</EntityDescriptor>

最后扫描了我的 Eclipse 调试屏幕:

http://imgur.com/01xRD5f

【问题讨论】:

  • 对这个问题有什么见解吗?

标签: java object casting shibboleth opensaml


【解决方案1】:

我尝试使用此处描述的方法验证您的元数据 xml。 https://wiki.surfnet.nl/display/OpenConext/Validating+SAML2+metadata

它说那个元素(在添加元数据命名空间之后)

RoleDescriptor: Schemas validity error : Element '{urn:oasis:names:tc:SAML:2.0:metadata}RoleDescriptor': The type definition is abstract.

正如 saml 元数据规范所说,

RoleDescriptor 元素是一个抽象扩展点,其中包含旨在提供跨不同角色的处理通用性的通用描述信息。可以通过扩展其抽象 RoleDescriptorType 复杂类型来定义新角色

因此,您的元数据 xml 中不能有 RoleDescriptor 元素。您要么必须使用规范中描述的具体角色(SSO 身份提供者、SSO 服务提供者、身份验证机构、属性机构、策略决策点、附属机构),要么扩展抽象的 RoleDescriptor。

所以由于上述原因,org.opensaml.saml2.metadata.impl.RoleDescriptorImpl是opensaml中的一个抽象类,具体角色的实现扩展了这个抽象类。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-31
    • 2020-06-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多