我正在尝试使用openSaml 2从Idp读取元数据。看来我遗漏了一点,因为当阅读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;
}发布于 2015-09-25 08:18:07
我建议使用元数据提供程序为您做繁重的工作。FilesystemMetadataProvider通常是一个很好的选择。
我有一个博客帖子来解释如何使用它。
https://stackoverflow.com/questions/32777171
复制相似问题