Java OpenSaml读取元数据

Java OpenSaml读取元数据,java,single-sign-on,saml,saml-2.0,opensaml,Java,Single Sign On,Saml,Saml 2.0,Opensaml,我尝试使用OpenSAML2从Idp读取元数据。当我尝试解组元数据openSaml时,只显示属性getUnknownatributes()的这个getter。看起来我遗漏了一些要点,因为在读取Idp响应SAML时,代码运行得非常好。(它显示返回断言列表的getAssertions() 我需要解析元数据并查找有关Idp的信息 这里是方法 public Metadata metadataReader() { ByteArrayInputStream bytesIn = n

我尝试使用OpenSAML2从Idp读取元数据。当我尝试解组元数据openSaml时,只显示属性getUnknownatributes()的这个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;

    }

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


我有一个例子来解释如何使用它。

当我尝试使用您的代码时,我发现元数据提供程序未能正确初始化,fail fast=true,停止org.opensaml.saml2.Metadata.provider.MetadataProviderException:看到一个类型为“java.lang.NoClassDefFoundError”的错误,消息为“org/w3c/dom/ElementTraversal”。我也无法理解如何获取SingleLogoutService信息。这看起来像是一个依赖性问题。获取SLO与在post中获取SSO是一样的。只需获取SingleLogoutService而不是SingleSignOnService