【发布时间】: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