【问题标题】:Apache WSS4J Failing to InitializeApache WSS4J 无法初始化
【发布时间】:2019-06-27 14:49:17
【问题描述】:

我正在尝试让 Apache WSS4J 库工作以验证 Spring Boot Web 服务中的 BinarySecurityToken。我们可以正常启动服务,但是当我们发送 SOAP 请求时,我们会收到以下错误:

No message with ID "invalidSAMLsecurity" found in resource bundle "org/apache/xml/security/resource/xmlsecurity"; nested exception is org.apache.wss4j.common.ext.WSSecurityException: No message with ID "invalidSAMLsecurity" found in resource bundle "org/apache/xml/security/resource/xmlsecurity"

现在,据我了解,当您没有调用 WSSec.init() 方法时会发生这种情况。但是,Apache WSS4J 中唯一的 WSSec 类位于 org.apache.wss4j.stax 包中,使用 Maven 下载 WSS4J 2.2.3 似乎无法访问 stax 包。

我很确定我只是在找错地方,但当前的 Apache WSS4J API 是针对 2.3.0-SNAPSHOT,所以我什至不确定我使用的版本是否可以访问这些包,而且我似乎找不到 2.2.3 版的 API。

我确信这只是找到正确初始化的问题,我只是不确定这些初始化将在哪里配置。

【问题讨论】:

    标签: java apache spring-boot security wss4j


    【解决方案1】:

    为了能够使用标头中存在的 binarySecurityToken 验证签名的 xml - 您需要确保使用

    对 xml 进行签名

    "WSHandlerConstants.SIG_KEY_ID" = "DirectReference"

     List<WSSecurityEngineResult> res = engine.processSecurityHeader(signedDoc, null, null, crypto); 
    

    signedDoc - SOAP 信封作为文档

    使用此方法来验证签名。此外,设置 Crypto 的实例,如下所示。

    加密crypto = CryptoFactory.getInstance("validator.properties");

    尝试以下 Maven 依赖项(这是我拥有的一个工作示例)

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <version>2.1.5.RELEASE</version>
        </dependency>
    
        <dependency>
            <groupId>org.apache.wss4j</groupId>
            <type>pom</type>
            <artifactId>wss4j</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.wss4j</groupId>
            <artifactId>wss4j-ws-security-dom</artifactId>
            <version>2.0.0</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
            <type>jar</type>
        </dependency>
    
        <dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis</artifactId>
            <version>1.4</version>
        </dependency>
    
        <dependency>
            <groupId>org.apache.ws.security</groupId>
            <artifactId>wss4j</artifactId>
            <version>1.6.19</version>
        </dependency>
    
        <dependency>
            <groupId>org.apache.wss4j</groupId>
            <artifactId>wss4j-ws-security-common</artifactId>
            <version>2.0.2</version>
        </dependency>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-15
      • 2020-01-22
      相关资源
      最近更新 更多