我正在尝试使用现有断言元素通过 OpenSAML 创建 SAML 2.0 断言以进行 token 更新过程。
// Obtain the token
Token tk = tkStorage.getToken(data.getTokenId());
OMElement assertionOMElement = tk.getToken();
int samlRstversion = data.getSamlRstVersion();
if(samlRstversion == 2) {
DefaultBootstrap.bootstrap();
UnmarshallerFactory unmarshallerFactory = Configuration.getUnmarshallerFactory();
Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller((Element)assertionOMElement);
Element x1 = (Element)assertionOMElement;
Assertion samlAssertion = (Assertion) unmarshaller
.unmarshall(x1);
//Add conditions to the assertion
}
我收到两个错误。
- 当使用
DefaultBootstrap.bootstrap();
时,它会抛出一个 异常java.lang.UnsupportedOperationException:此解析器不支持规范“null”版本“null”
- 当
DefaultBootstrap.bootstrap()
被删除时,它会抛出 断言 samlAssertion =(断言) unmarshaller.unmarshall(x1);
有什么我错过的吗?
最佳答案
首先,您始终必须运行 Bootstrap ,否则会出现错误。
第一个错误似乎是因为您的 JAXP 实现太旧了 https://lists.internet2.edu/sympa/arc/mace-opensaml-users/2010-01/msg00015.html
OpenSAML 团队建议使用 Apache Xerces 或 Xalan。
关于java - 通过 OpenSAML 中的现有元素创建 SAML 2.0 断言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25453508/