简体   繁体   English

WSO2 ESB-Rampart密码回调类-WSPasswordCallback无法强制转换

[英]WSO2 ESB - Rampart Password Callback class - WSPasswordCallback cannot be cast

I want to to invoke a secured backend service in WSO2 ESB 5.0.0 with rampart configuration and Password Callback class 我想使用垒配置和密码回调类在WSO2 ESB 5.0.0中调用安全的后端服务

package com.yenlo.wso2.services;
import org.apache.ws.security.WSPasswordCallback;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.UnsupportedCallbackException;
import java.io.IOException;

public class PWCBHandler implements CallbackHandler {

public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    WSPasswordCallback pc = (WSPasswordCallback) callbacks[0]; 

    // set the password for our message.
    pc.setPassword("YENLO_TEST");       

   }
}

When i call the proxy service this error occurs: 当我致电代理服务时,会发生此错误:

org.apache.ws.security.WSPasswordCallback cannot be cast to org.apache.ws.security.WSPasswordCallback

I have compiled my source code with wss4j 1.6.17 and 1.5.12. 我已经用wss4j 1.6.17和1.5.12编译了我的源代码。 Nothing's Changed. 没什么改变。

Have a look at the available version of wss4j inside "wso2esb-5.0.0/repository/components/plugins" folder. 在“ wso2esb-5.0.0 / repository / components / plugins”文件夹中查看wss4j的可用版本。 It looks like you are using a different version in the compile time, that may lead to this kind of issue. 看起来您在编译时使用的是其他版本,这可能会导致这种问题。

Try to use wss4j with the following dependency version when compiling. 编译时,尝试将wss4j与以下依赖项版本一起使用。

version=1.5.11.wso2v14
groupId=org.apache.ws.security.wso2
artifactId=wss4j

I've created a new callbackhandler project from scratch and got it working with a few sidenodes: - I've used the following dependency in the main pom.xml: 我从头开始创建了一个新的callbackhandler项目,并使其与几个sidenodes一起工作:-我在主pom.xml中使用了以下依赖项:

<dependency>
    <groupId>org.apache.ws.security</groupId>
    <artifactId>wss4j</artifactId>
    <version>1.5.11</version>
</dependency>

I put the resulting '.jar' in repository/components/lib. 我将生成的“ .jar”放入存储库/ components / lib中。 Also I removed the .jar from repository/components/dropins when redeploying to be sure(ESB creates a file there during startup when processing the .jar) 另外,在进行重新部署时,我从存储库/组件/ dropins中删除了.jar(ESB在处理.jar时在启动过程中在那里创建了一个文件)

I've put the entire project here . 我把整个项目都放在这里了 Build using 'mvn clean package'. 使用“ mvn clean package”进行构建。

Good luck! 祝好运! I'd like to hear back if you succeeded! 如果您成功了,我想听听!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM