【问题标题】:OpenSaml read metadataOpenSaml 读取元数据
【发布时间】:2015-09-25 07:41:15
【问题描述】:

我正在尝试使用 Open Saml 2 从 Idp 读取元数据。当我尝试解组元数据时,openSaml 仅显示属性 getUnknownAtrributes() 的这个 getter。看起来我错过了一些观点,因为在读取 Idp 响应 SAML 时,代码运行良好。 (它显示了返回断言列表的 getAssertions())。

我需要解析元数据并查找有关 Idp 的信息。

这里方法

     public Metadata metadataReader() {

        ByteArrayInputStream bytesIn = new ByteArrayInputStream(ISSUER_METADATA_URL.getBytes());
        BasicParserPool ppMgr = new BasicParserPool();

        ppMgr.setNamespaceAware(true);
        // grab the xml file
//      File xmlFile = new File(this.file);
        Metadata metadata = null;
        try {
            Document document = ppMgr.parse(bytesIn);
            Element metadataRoot = document.getDocumentElement();
            QName qName = new QName(metadataRoot.getNamespaceURI(), metadataRoot.getLocalName(),
                    metadataRoot.getPrefix());
            Unmarshaller unmarshaller = Configuration.getUnmarshallerFactory().getUnmarshaller(qName);
            metadata = (Metadata) unmarshaller.unmarshall(metadataRoot);


            return metadata;

        } catch (XMLParserException e) {
            e.printStackTrace();
        } catch (UnmarshallingException e) {
            e.printStackTrace();
        }

        return null;

    }

【问题讨论】:

    标签: java single-sign-on saml saml-2.0 opensaml


    【解决方案1】:

    我建议使用元数据提供程序为您完成繁重的工作。 FilesystemMetadataProvider 通常很合适。

    我有一个blog post,它解释了如何使用它。

    【讨论】:

    • 当我尝试使用您的代码时,我得到 Metadata provider failed to proper initialize, fail-fast=true, halting org.opensaml.saml2.metadata.provider.MetadataProviderException: Saw an error of type 'java .lang.NoClassDefFoundError' 带有消息 'org/w3c/dom/ElementTraversal'。我也无法理解如何获取 SingleLogoutService 信息。
    • 看起来像一个依赖问题。获得 SLO 与在帖子中获得 SSO 相同。只需获取 SingleLogoutService 而不是 SingleSignOnService
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-14
    • 2019-07-31
    • 2022-11-21
    • 1970-01-01
    相关资源
    最近更新 更多