小编bro*_*eef的帖子

CXF 3.X和WSS4J 2.X中的CallbackHandler

我正在尝试将当前的应用程序升级到CXF 3和WSS4J 2.这让我非常头疼.

客户端的当前应用程序代码:

private void secureWebService( Client client, final Credentials credentials ) {

  // set some WS-Security information
  Map<String,Object> outProps = new HashMap<String,Object>();
  outProps.put( WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN );
  outProps.put( WSHandlerConstants.USER, credentials.getUsername() );
  outProps.put( WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT );

  // Callback used to retrieve password for given user.
  outProps.put( WSHandlerConstants.PW_CALLBACK_REF, new CallbackHandler() {
     @Override
     public void handle( Callback[] callbacks ) throws IOException, UnsupportedCallbackException {
        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
        pc.setPassword( credentials.getPassword() );
     }
  });

  WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor( outProps );
  client.getOutInterceptors().clear();
  client.getOutInterceptors().add( …
Run Code Online (Sandbox Code Playgroud)

apache ws-security web-services cxf wss4j

3
推荐指数
1
解决办法
4376
查看次数

标签 统计

apache ×1

cxf ×1

web-services ×1

ws-security ×1

wss4j ×1