private PKIXBuilderParameters CreatePKIXBuilderParameters(X509Certificate endCert) throws CertificatePathBuildingException {
  X509CertSelector targetConstraints=new X509CertSelector();
  targetConstraints.setCertificate(endCert);
  PKIXBuilderParameters params;
  try {
    params=new PKIXBuilderParameters(trustStore,targetConstraints);
    params.setRevocationEnabled(false);
  }
 catch (  KeyStoreException e) {
    throw new CertificatePathBuildingException("Error creating PKIXBuilderParameters: Please check trust store" + e.getMessage(),e);
  }
catch (  InvalidAlgorithmParameterException e) {
    throw new CertificatePathBuildingException("Error creating PKIXBuilderParameters:" + e.getMessage(),e);
  }
catch (  Throwable e) {
    throw new CertificatePathBuildingException("Error creating PKIXBuilderParameters:" + e.getMessage(),e);
  }
  Collection<Object> certCollection=new ArrayList<Object>();
  addCertificateCandidates(endCert,certCollection);
  if (!certCollection.isEmpty()) {
    try {
      CertStore certStore=CertStore.getInstance("Collection",new CollectionCertStoreParameters(certCollection));
      params.addCertStore(certStore);
    }
 catch (    InvalidAlgorithmParameterException e) {
      throw new CertificatePathBuildingException("Error creating CertStore for PKIXBuilderParameters:" + e.getMessage(),e);
    }
catch (    NoSuchAlgorithmException e) {
      throw new CertificatePathBuildingException("Error creating CertStore for  PKIXBuilderParameters:" + e.getMessage(),e);
    }
  }
 else {
    logger.debug("Revocation check: CRL list empty");
  }
  return params;
}

private PKIXBuilderParameters CreatePKIXBuilderParameters ( X509Certificate endCert ) throws CertificatePathBuildingException { X509CertSelector targetConstraints = new X509CertSelector ( ) ; targetConstraints . setCertificate ( endCert ) ; PKIXBuilderParameters params ; try { params = new PKIXBuilderParameters ( trustStore , targetConstraints ) ; params . setRevocationEnabled ( false ) ; } catch ( KeyStoreException e ) { throw new CertificatePathBuildingException ( "Error creating PKIXBuilderParameters: Please check trust store" + e . getMessage ( ) , e ) ; } catch ( InvalidAlgorithmParameterException e ) { throw new CertificatePathBuildingException ( "Error creating PKIXBuilderParameters:" + e . getMessage ( ) , e ) ; } catch ( Throwable e ) { throw new CertificatePathBuildingException ( "Error creating PKIXBuilderParameters:" + e . getMessage ( ) , e ) ; } Collection < Object > certCollection = new ArrayList < Object > ( ) ; addCertificateCandidates ( endCert , certCollection ) ; if ( ! certCollection . isEmpty ( ) ) { try { CertStore certStore = CertStore . getInstance ( "Collection" , new CollectionCertStoreParameters ( certCollection ) ) ; params . addCertStore ( certStore ) ; } catch ( InvalidAlgorithmParameterException e ) { throw new CertificatePathBuildingException ( "Error creating CertStore for PKIXBuilderParameters:" + e . getMessage ( ) , e ) ; } catch ( NoSuchAlgorithmException e ) { throw new CertificatePathBuildingException ( "Error creating CertStore for  PKIXBuilderParameters:" + e . getMessage ( ) , e ) ; } } else { logger . debug ( "Revocation check: CRL list empty" ) ; } return params ; }
create and init pkixbuilderparameters for certpathbuilder .
