我正在尝试在 下开发 SOAP Web 服务Apache CXF 3.0.4,但我无法UsernameToken使用 WS-SecurityPolicy验证每个 SOAP 消息头中包含的 SOAP 消息。根据文档,如果cxf-rt-ws-policy和cxf-rt-ws-security模块在classpath. 在正确配置后,它会完成处理安全性的必要工作。我通过端点属性注释进行配置,方式如下:@WebService(targetNamespace = "http://tempuri.org/", name = "MyService")@EndpointProperties(value = { @EndpointProperty(key = "ws-security.callback-handler", value = "org.tempuri.ServerPasswordCallback") //@EndpointProperty(key = "ws-security.validate.token", value = "false") })public interface MyService {...}ServerPasswordCallback 是:public class ServerPasswordCallback implements CallbackHandler { public ServerPasswordCallback() { System.out.println("Instantiating ServerPasswordCallback"); } public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { System.out.println("Validating on ServerPasswordCallback"); WSPasswordCallback pc = (WSPasswordCallback) callbacks[0]; if (pc.getIdentifier().equals("joe")) { // set the password on the callback. This will be compared to the // password which was sent from the client. pc.setPassword("password"); } }}奇怪的是,它似乎ServerPasswordCallback从未被实例化,handle()也从未被调用。如果在端点属性注释中我设置ws-security.validate.token为false,则抛出前一个异常,即使此属性应阻止令牌验证。这个事实让我认为注释不起作用,但我不知道为什么。这是验证 a 的正确方法UsernameToken吗?端点属性注释是否正确?注意我无法像文档中建议的那样设置端点属性,因为我无法访问端点实例。这里有一个示例项目
添加回答
举报
0/150
提交
取消