java - 使用用户名 token 保护 axis2

标签 java web-services apache apache-axis rampart

我正在尝试使用城墙在 axis2 中使用用户名 token 生成安全性。

String securityPolicyPath = "/WEB-INF/policy.xml";

ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("/axis2-1.6.2/repository/", "/WEB-INF/conf/axis2.xml");

CalAddStub stub = new CalAddStub(ctx,"http://localhost:8090/RampartTest/services/CalAdd/");
ServiceClient sc = stub._getServiceClient();
sc.engageModule("rampart");

Options options = sc.getOptions();
options.setUserName("apache");
options.setPassword("password");
        options.setProperty(RampartMessageData.KEY_RAMPART_POLICY,loadPolicy(securityPolicyPath));
Add_cal add = new Add_cal();
add.setX(6);
add.setY(9);
System.out.println("id = " + stub.add_cal(add).get_return());

但我遇到了这个异常。

[INFO] Deploying Web service: version.aar - file:/C:/axis2-1.6.2/repository/services/version.aar
Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/JaxenException
    at org.apache.rampart.handler.WSDoAllSender.processBasic(WSDoAllSender.java:108)
    at org.apache.rampart.handler.WSDoAllSender.processMessage(WSDoAllSender.java:72)
    at org.apache.rampart.handler.WSDoAllHandler.invoke(WSDoAllHandler.java:72)
    at org.apache.axis2.engine.Phase.invokeHandler(Phase.java:340)
    at org.apache.axis2.engine.Phase.invoke(Phase.java:313)
    at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:262)
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:427)

最佳答案

您需要Apache Jaxen类路径中的依赖项。

查看 Rampart Project Dependencies 处的 Rampart 依赖树 部分官方页面。

关于java - 使用用户名 token 保护 axis2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21330263/

相关文章:

Java,NetBean : Access web. 来自 Web 服务方法的 xml 上下文参数?

当应用程序托管在与数据库不同的服务器上时,用户的 MySQL 访问被拒绝错误

apache - 仅在 2 种形式上使用 https,所有其他形式强制返回 http

java - 在 Android 中查找并暂停播放音频的任务

java - Sonar 是否具有计算复杂性测量能力?

java - Bonita Web API - 401 未经授权的错误

php - Zend framework Restful web服务逻辑使用

database - 提高 web2py 性能 - 数据库和 apache

java - Netbeans 无故关闭

java - 将变量从一个类传递到另一个类