You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Boxiong Ding <bo...@yahoo.com> on 2008/06/06 02:56:38 UTC
Use WSS4JOutInterceptor to add header is broken with 2.1
I am writing a CXF client and using interceptor to add security headers in Java code. It used to work fine with 2.0.4, but broken when I upgrade to 2.1 jar (the only thing changed is cxf-2.1.jar). In the following getSecurityHeader() method, it now returns null but used to return header element.
Does any one have any clue?
// This method add interceptor: AuthenticationInterceptor extends WSS4JOutInterceptor
private static void addHeaders(MyService port) throws Exception {
Client cli = ClientProxy.getClient(port);
Endpoint endpoint = cli.getEndpoint();
Map<String, Object> outprops = new HashMap<String, Object>();
outprops.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN);
outprops.put(WSHandlerConstants.USER, "myname");
outprops.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
outprops.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordCallbackHandler.class.getName());
AuthenticationInterceptor wssout = new AuthenticationInterceptor(outprops);
endpoint.getOutInterceptors().add(new SAAJOutInterceptor());
endpoint.getOutInterceptors().add(wssout);
}
// This method try to get security header, and I will do something with it later. This is in AuthenticationInterceptor
private Element getSecurityHeader(SoapMessage message) throws SOAPException
{
SOAPMessage doc = message.getContent(SOAPMessage.class);
String actor = (String)getOption(WSHandlerConstants.ACTOR);
SOAPConstants sc = WSSecurityUtil.getSOAPConstants(doc.getSOAPPart().getDocumentElement());
return WSSecurityUtil.getSecurityHeader(doc.getSOAPPart(), actor, sc);
}
Thanks,
Boxiong