WS-Security Support for WebService Clients?
The Spring-WS manual talks about security only in the context of the service producer and never in the context of the service client.
Shouldn't there be an equivalent to the XwsSecurityInterceptor (= EndpointInterceptor) on the client which lets me add authentication information (UsernameToken or a BinarySecurityToken) to the outgoing SOAP message and sign and encrypt it? Do I have to do this manually?
signing with a X509 certificate
Yes, that article is helpful, since there's nothing in the Spring-WS manual about it.
I too would like to sign my messages with a X509 certificate instead of using a username/password. I think I have my securityPolicy.xml file correct, but I can't figure out how to tell my app what keystore to use since there's no client-side way to specify that in Spring like there is on the server side with KeyStoreCallbackHandler.
Quote:
I developed a call back bean to sign the message using my keystore.
ghazouli: I would be interested to see how you're managing to use KeyStoreCallbackHandler on the client.
I have generated a keystore in my classpath using keytool, but when I run my app I get exceptions that make me think my app isn't reading the correct keystore and is defaulting to somewhere else. Therefore it can't find a certificate with the alias "myCertAlias" as specified in my securityPolicy.xml.
Here's my securityPolicy.xml:
Code:
<xwss:SecurityConfiguration dumpMessages="true"
xmlns:xwss="http://java.sun.com/xml/ns/xwss/config">
<xwss:Sign>
<xwss:X509Token certificateAlias="myCertAlias" />
<xwss:CanonicalizationMethod
algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<xwss:SignatureMethod
algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<!-- Sign the message body. -->
<xwss:SignatureTarget type="xpath" value="./SOAP-ENV:Envelope/SOAP-ENV:Body">
<xwss:DigestMethod
algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<xwss:Transform
algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116">
<xwss:AlgorithmParameter name="XPATH"
value="./SOAP-ENV:Envelope/SOAP-ENV:Header/wsse:Security/ds:Signature[1]/ds:KeyInfo/wsse:SecurityTokenReference" />
</xwss:Transform>
<xwss:Transform
algorithm="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#STR-Transform">
<xwss:AlgorithmParameter name="CanonicalizationMethod"
value="http://www.w3.org/2001/10/xml-exc-c14n#" />
</xwss:Transform>
</xwss:SignatureTarget>
</xwss:Sign>
</xwss:SecurityConfiguration>
Here's the exception:
Code:
Feb 5, 2008 11:25:38 AM com.sun.xml.wss.impl.misc.DefaultSecurityEnvironmentImpl getAliasPrivKeyCertRequest
SEVERE: WSS0216: Callback Handler failed for SignatureKeyCallback.AliasPrivKeyCertRequest
Feb 5, 2008 11:25:38 AM com.sun.xml.wss.impl.misc.DefaultSecurityEnvironmentImpl getAliasPrivKeyCertRequest
SEVERE: WSS0217: Exception in Callback Handler handle()
java.lang.NullPointerException
at com.sun.xml.wss.impl.misc.DefaultSecurityEnvironmentImpl.getAliasPrivKeyCertRequest(DefaultSecurityEnvironmentImpl.java:205)
at com.sun.xml.wss.impl.filter.SignatureFilter.process(SignatureFilter.java:146)
at com.sun.xml.wss.impl.HarnessUtil.processWSSPolicy(HarnessUtil.java:64)
at com.sun.xml.wss.impl.HarnessUtil.processDeep(HarnessUtil.java:218)
at com.sun.xml.wss.impl.SecurityAnnotator.processMessagePolicy(SecurityAnnotator.java:143)
at com.sun.xml.wss.impl.SecurityAnnotator.secureMessage(SecurityAnnotator.java:118)
at com.sun.xml.wss.impl.misc.XWSSProcessor2_0Impl.secureOutboundMessage(XWSSProcessor2_0Impl.java:77)
yada, yada, yada...
My client code is almost exactly what's in cafebabe's article.
There's nothing of note in my application context xml because there's no client-side security support. It's just a basic WebServiceTemplate and some XmlBeans config that has nothing to do with the security.
Any help or suggestions would be greatly appreciated. I'm going to try putting that keystore in my home directory instead, in case that's the default location it's looking in. Then I might get adventurous and try out Spring-WS 1.5 M1 which is supposed to have client security support baked in.