Thursday, 22 December 2011

Apache CXF connector to Alfresco

After generating Apache CXF connector to Alfresco using WSDL document, we also have to add security interceptors. Here is a code fragment I have used:

org.apache.cxf.endpoint.Client client = ClientProxy.getClient(service);
Map inProps = new HashMap();
inProps.put(WSHandlerConstants.ACTION, "UsernameToken Timestamp");
inProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
inProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, "com.roche.xp2.content.lowlevel.alfresco.util.AlfrescoRepositoryProviderCallback");
inProps.put(WSHandlerConstants.USER, "ticket");
WSS4JOutInterceptor wssIn = new WSS4JOutInterceptor(inProps);
client.getEndpoint().getOutInterceptors().add( new org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor());
client.getEndpoint().getOutInterceptors().add(wssIn);

No comments: