I'm trying to clean up my code and wanted to define the signature properties in 
an existing config file rather than in their own file.

So, following the few examples I was able to find I create a 
java.util.Properties object and insert the same entries I had in my file and 
then add this to my properties to configure the WSS4JOutInterceptor.  I'm 
trying to setup an interceptor to sign my requests.

Original:
Map<String, Object> outProps = new HashMap<String, Object>();
/* other property configuration */
outProps.put(WSHandlerConstants.SIG_PROP_FILE, 'path_to_signature_properties');
WSS4JOutInterceptor  mySigInterceptor = new WSS4JOutInterceptor(outProps);

SignatureProperties File:
org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=abcdefg
org.apache.ws.security.crypto.merlin.file=path_to_truststore



New:
Map<String, Object> outProps = new HashMap<String, Object>();
/* other property configuration */
java.util.Properties sig_props = new java.util.Properties();
/* Trying to pull these values in from my config file, but wrote them out 
explicitly trying to get this working */
sig_props.put('org.apache.ws.security.crypto.provider', 
'org.apache.ws.security.components.crypto.Merlin');
sig_props.put('org.apache.ws.security.crypto.merlin.keystore.type', 'jks');
sig_props.put('org.apache.ws.security.crypto.merlin.keystore.password', 
'abcdefg');
sig_props.put('org.apache.ws.security.crypto.merlin.file', 
'path_to_truststore');
outProps.put('cryptoProperties', sig_props);
outProps.put(WSHandlerConstants.SIG_PROP_REF_ID, 'cryptoProperties');
WSS4JOutInterceptor  mySigInterceptor = new WSS4JOutInterceptor(outProps);

When I try to use the SIG_PROP_REF_ID I get 
"java.security.UnrecoverableKeyException: Cannot recover key" but everything 
works fine using SIG_PROP_FILE.  All other code remains the same.

Anyone have any ideas as to why this doesn't work?

Thanks,
Kyle

Reply via email to