Maybe I can find some helpe here. I need to access web service but first I need to authenticate my client using keystore. I cant use spring. In spring-ws.xml such configuration works for clients of my colleagues:
<bean class="org.springframework.ws.soap.security.wss4j.support.CryptoFactoryBean" id="clientCrypto">
<property name="configuration">
<util:properties>
<prop key="org.apache.ws.security.crypto.provider">org.apache.ws.security.components.crypto.Merlin</prop>
<prop key="org.apache.ws.security.crypto.merlin.keystore.type">jks</prop>
<prop key="org.apache.ws.security.crypto.merlin.keystore.password">${esb.keystore.password}</prop>
<prop key="org.apache.ws.security.crypto.merlin.keystore.alias">${esb.keystore.user}</prop>
<prop key="org.apache.ws.security.crypto.merlin.file">src\main\resources\${esb.keystore.location}</prop>
</util:properties>
</property>
</bean>
My client is like this:
PortalCustomerService service = new PortalCustomerService();
PortalCustomerPortType port = service.getSomethingHttpPort();
BindingProvider bindingProvider = (BindingProvider) port;
Binding binding = bindingProvider.getBinding();
List<Handler> handlerList = binding.getHandlerChain();
handlerList.add(new MyHandler());
binding.setHandlerChain(handlerList);
//calling webmethod
MyResponse response = port.checkClients(getRequest());
and MyHandler has a method handleMessage like this:
public boolean handleMessage(SOAPMessageContext messageContext) {
Boolean outboundProperty = (Boolean) messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
if (outboundProperty.booleanValue()) {
// I think I need to add something here but I dont know what
} else {}
return true;
}
I have private key: myportal.key, public key: portal.cer .
Without authentication I got:
javax.xml.ws.soap.SOAPFaultException: An error was discovered processing the <wsse:Security> header
You may get some help by following
System.setProperty("javax.net.debug","all");
If the key is self-signed, so you may need to set the TrustStore
properties too.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.