throw new CertPathValidatorException("CVC certificate chain can not be of length longer than two.");
}
} else {
// Normal X509 certificates
HashSet<TrustAnchor> trustancors = new HashSet<TrustAnchor>();
TrustAnchor trustanchor = null;
trustanchor = new TrustAnchor((X509Certificate)rootcert, null);
trustancors.add(trustanchor);
// Create the parameters for the validator
PKIXParameters params = new PKIXParameters(trustancors);
// Disable CRL checking since we are not supplying any CRLs
params.setRevocationEnabled(false);
params.setDate( new Date() );
// Create the validator and validate the path
CertPathValidator certPathValidator = CertPathValidator.getInstance(CertPathValidator.getDefaultType(), "BC");
CertificateFactory fact = CertTools.getCertificateFactory();
CertPath certpath = fact.generateCertPath(calist);
CertPathValidatorResult result = certPathValidator.validate(certpath, params);
// Get the certificates validate in the path
PKIXCertPathValidatorResult pkixResult = (PKIXCertPathValidatorResult)result;
returnval.addAll(certpath.getCertificates());
// Get the CA used to validate this path
TrustAnchor ta = pkixResult.getTrustAnchor();
X509Certificate cert = ta.getTrustedCert();
returnval.add(cert);
}
}
return returnval;
} // createCertChain