java - 通过 OpenSAML 中的现有元素创建 SAML 2.0 断言

标签 java opensaml ws-trust

我正在尝试使用现有断言元素通过 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
}

我收到两个错误。

  1. 当使用 DefaultBootstrap.bootstrap(); 时,它会抛出一个 异常java.lang.UnsupportedOperationException:此解析器不支持规范“null”版本“null”
  2. 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/

相关文章:

java - 如何在java中使用纬度和经度获取位置?

java - 如何重试Spring WebClient根据响应重试操作?

java - 如何使用 HTMLParser 获取标签之间的值

java - 如何从 Java 与 ADFS 通信?

saml-2.0 - WS-Trust、WS-Fed 和 SAML 1.1/2.0 协议(protocol)之间的区别

java - 使用 CSS 在 tabpane 中居中选项卡

java - 在 servlet 环境(Tomcat Web 服务器)中使用 OPENSAML2 时出现编码错误

Eclipse 中的 Android 错误 : "Unable to execute dex: Cannot merge new index 65799 into a non-jumbo instruction!"

asp.net - WS-Federation 真正做了什么(深入并且通过一个简单易懂的例子)?

curl - 使用 cURL 对 SharePoint Online 进行身份验证(使用 ADFS 2.1 作为 IP-STS)