CXF Client Security

后端 未结 4 2146
一整个雨季
一整个雨季 2021-02-15 15:23

I am creating a client to a Java soap web service, but am having trouble figuring out how to properly pass the password. Here is my \"hardcoded\" password exam

4条回答
  •  时光取名叫无心
    2021-02-15 16:16

    I was also able to do the following:

        org.apache.cxf.endpoint.Client client = ClientProxy.getClient(obj);
        org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
    
        Map outProps = new HashMap();
    
        outProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
    
        System.out.println("initialize security for user " + this.username);
        outProps.put(WSHandlerConstants.USER, this.username);
        outProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
    
        Map ctx = ((BindingProvider) obj).getRequestContext();
        ctx.put("password", this.password);
    
        WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
        cxfEndpoint.getOutInterceptors().add(wssOut);
    

提交回复
热议问题