import org.apache.wss4j.dom.validate.SignatureTrustValidator;
public class TrustValidator {
public void validateTrust(Crypto crypto, X509Certificate cert, PublicKey publicKey)
throws WSSecurityException {
SignatureTrustValidator validator = new SignatureTrustValidator();
RequestData data = new RequestData();
data.setSigVerCrypto(crypto);
Credential trustCredential = new Credential();
trustCredential.setPublicKey(publicKey);
if (cert != null) {
trustCredential.setCertificates(new X509Certificate[]{cert});
}
validator.validate(trustCredential, data);
}