PKIXCertPathBuilderResult cpbResult =
(PKIXCertPathBuilderResult) cpb.build(cpbParams);
CertPath certPath = cpbResult.getCertPath();
// Validate path
final CertPathValidator cpv = CertPathValidator.getInstance("PKIX");
final PKIXParameters params = new PKIXParameters(anchors);
params.setSigProvider("BC");
params.setRevocationEnabled(false);
// X509CertSelector targetCertConstraints = new X509CertSelector();
// targetCertConstraints.setKeyUsage(keyUsage)
// params.setTargetCertConstraints(targetCertConstraints);
PKIXCertPathValidatorResult result =
(PKIXCertPathValidatorResult) cpv.validate(certPath, params);
// PolicyNode policyTree = result.getPolicyTree();
// PublicKey subjectPublicKey = result.getPublicKey();
if (LOG.isDebugEnabled()) {
LOG.debug("Found trust anchor: " + result.getTrustAnchor());
}