繁体   English   中英

OpenSaml读取元数据

[英]OpenSaml read metadata

我正在尝试使用Open Saml 2从Idp读取元数据。当我尝试解组元数据openSaml时,仅显示该属性的getter以获得Unknown Atrributes()。 似乎我遗漏了一点,因为在读取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;

    }

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

我有一篇博客文章介绍了如何使用它。

暂无
暂无

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

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