I need to validate a signed SOAP message, extract the certificate and authenticate the certificate against a LDAP directory, which makes a trust store unnecessary. I have being using the WSS4J for a while now, but always with a local trust store. Taking a look on the official documentation and googling around, I couldn't find any reference to a scenario similar to mine. I was wondering if it would be possible to keep using the WSS4J in that case.
Asked
Active
Viewed 1,005 times
2 Answers
1
Yes you can use WSS4J for this use-case. WSS4J uses the SignatureTrustValidator by default to validate trust in signing certificates:
You can plug your own implementation in there instead via:
If you are using CXF with WSS4J, there is a custom configuration constant that you can set that points to the Validator implementation for Signatures.

beat
- 1,857
- 1
- 22
- 36

Colm O hEigeartaigh
- 1,882
- 1
- 12
- 7
-
Really cool! But it still requires a Crypto instance. Which one should I use? – Andre Silva Nov 22 '17 at 15:32
1
I faced the same problem and solved it in this way:
@EnableWs
@Configuration
public class WsConfiguration extends WsConfigurerAdapter {
@Bean
public Wss4jSecurityInterceptor securityInterceptor() throws Exception {
Wss4jSecurityInterceptor securityInterceptor = new Wss4jSecurityInterceptor();
securityInterceptor.setValidationActions("Signature");
WSSConfig wssConfig = WSSConfig.getNewInstance();
wssConfig.setValidator(new QName("http://www.w3.org/2000/09/xmldsig#", "Signature"), MySignatureTrustValidator.class);
securityInterceptor.setWssConfig(wssConfig);
//the rest of configuration
}
Note, that MySignatureTrustValidator must implement Validator

Bartek Góral
- 11
- 4