@Test public void testGenerateValidationCertPathSelfSigned() throws Exception { CertPath generateCertPath = CertPathUtil.generateValidatableCertPath(clientSelfsignedList, null); assertEquals(clientSelfsignedList, generateCertPath.getCertificates()); }
public static CertPath generateValidatableCertPath(List<X509Certificate> certificateChain, List<X500Principal> certificateAuthorities) { if (certificateChain == null) { throw new NullPointerException("Certificate chain must not be null!"); } int size = certificateChain.size(); if (size > 0) { int truncate = size; if (certificateAuthorities != null && !certificateAuthorities.isEmpty()) { truncate = 0; for (int index = 0; index < size; ++index) { X509Certificate certificate = certificateChain.get(index); if (certificateAuthorities.contains(certificate.getIssuerX500Principal())) { truncate = index + 1; break; } } } if (size > 1 && truncate == size) { int last = size - 1; X509Certificate cert = certificateChain.get(last); if (cert.getIssuerX500Principal().equals(cert.getSubjectX500Principal())) { truncate = last; } } size = truncate; } return generateCertPath(certificateChain, size); }
CertPathUtil { public static CertPath generateValidatableCertPath(List<X509Certificate> certificateChain, List<X500Principal> certificateAuthorities) { if (certificateChain == null) { throw new NullPointerException("Certificate chain must not be null!"); } int size = certificateChain.size(); if (size > 0) { int truncate = size; if (certificateAuthorities != null && !certificateAuthorities.isEmpty()) { truncate = 0; for (int index = 0; index < size; ++index) { X509Certificate certificate = certificateChain.get(index); if (certificateAuthorities.contains(certificate.getIssuerX500Principal())) { truncate = index + 1; break; } } } if (size > 1 && truncate == size) { int last = size - 1; X509Certificate cert = certificateChain.get(last); if (cert.getIssuerX500Principal().equals(cert.getSubjectX500Principal())) { truncate = last; } } size = truncate; } return generateCertPath(certificateChain, size); } }
CertPathUtil { public static CertPath generateValidatableCertPath(List<X509Certificate> certificateChain, List<X500Principal> certificateAuthorities) { if (certificateChain == null) { throw new NullPointerException("Certificate chain must not be null!"); } int size = certificateChain.size(); if (size > 0) { int truncate = size; if (certificateAuthorities != null && !certificateAuthorities.isEmpty()) { truncate = 0; for (int index = 0; index < size; ++index) { X509Certificate certificate = certificateChain.get(index); if (certificateAuthorities.contains(certificate.getIssuerX500Principal())) { truncate = index + 1; break; } } } if (size > 1 && truncate == size) { int last = size - 1; X509Certificate cert = certificateChain.get(last); if (cert.getIssuerX500Principal().equals(cert.getSubjectX500Principal())) { truncate = last; } } size = truncate; } return generateCertPath(certificateChain, size); }  }
CertPathUtil { public static CertPath generateValidatableCertPath(List<X509Certificate> certificateChain, List<X500Principal> certificateAuthorities) { if (certificateChain == null) { throw new NullPointerException("Certificate chain must not be null!"); } int size = certificateChain.size(); if (size > 0) { int truncate = size; if (certificateAuthorities != null && !certificateAuthorities.isEmpty()) { truncate = 0; for (int index = 0; index < size; ++index) { X509Certificate certificate = certificateChain.get(index); if (certificateAuthorities.contains(certificate.getIssuerX500Principal())) { truncate = index + 1; break; } } } if (size > 1 && truncate == size) { int last = size - 1; X509Certificate cert = certificateChain.get(last); if (cert.getIssuerX500Principal().equals(cert.getSubjectX500Principal())) { truncate = last; } } size = truncate; } return generateCertPath(certificateChain, size); }  static boolean canBeUsedToVerifySignature(X509Certificate cert); static boolean canBeUsedForAuthentication(X509Certificate cert, boolean client); static CertPath generateCertPath(List<X509Certificate> certificateChain); static CertPath generateCertPath(List<X509Certificate> certificateChain, int size); static CertPath generateValidatableCertPath(List<X509Certificate> certificateChain,
			List<X500Principal> certificateAuthorities); static CertPath validateCertificatePath(boolean truncateCertificatePath, CertPath certPath,
			X509Certificate[] trustedCertificates); static List<X509Certificate> toX509CertificatesList(List<? extends Certificate> certificates); static List<X500Principal> toSubjects(List<X509Certificate> certificates); }
CertPathUtil { public static CertPath generateValidatableCertPath(List<X509Certificate> certificateChain, List<X500Principal> certificateAuthorities) { if (certificateChain == null) { throw new NullPointerException("Certificate chain must not be null!"); } int size = certificateChain.size(); if (size > 0) { int truncate = size; if (certificateAuthorities != null && !certificateAuthorities.isEmpty()) { truncate = 0; for (int index = 0; index < size; ++index) { X509Certificate certificate = certificateChain.get(index); if (certificateAuthorities.contains(certificate.getIssuerX500Principal())) { truncate = index + 1; break; } } } if (size > 1 && truncate == size) { int last = size - 1; X509Certificate cert = certificateChain.get(last); if (cert.getIssuerX500Principal().equals(cert.getSubjectX500Principal())) { truncate = last; } } size = truncate; } return generateCertPath(certificateChain, size); }  static boolean canBeUsedToVerifySignature(X509Certificate cert); static boolean canBeUsedForAuthentication(X509Certificate cert, boolean client); static CertPath generateCertPath(List<X509Certificate> certificateChain); static CertPath generateCertPath(List<X509Certificate> certificateChain, int size); static CertPath generateValidatableCertPath(List<X509Certificate> certificateChain,
			List<X500Principal> certificateAuthorities); static CertPath validateCertificatePath(boolean truncateCertificatePath, CertPath certPath,
			X509Certificate[] trustedCertificates); static List<X509Certificate> toX509CertificatesList(List<? extends Certificate> certificates); static List<X500Principal> toSubjects(List<X509Certificate> certificates);  }