@Test void testGetTrustDomain() throws Exception { val rootCa = createRootCA("C = US, O = SPIFFE", "spiffe: val intermediate = createCertificate("C = US, O = SPIRE", "C = US, O = SPIRE", "spiffe: val leaf = createCertificate("C = US, O = SPIRE", "C = US, O = SPIRE", "spiffe: val chain = Arrays.asList(leaf.getCertificate(), intermediate.getCertificate()); try { TrustDomain trustDomain = CertificateUtils.getTrustDomain(chain); assertNotNull(trustDomain); assertEquals(TrustDomain.of("domain.test"), trustDomain); } catch (CertificateException e) { fail(e); } }
public static TrustDomain getTrustDomain(final List<X509Certificate> chain) throws CertificateException { val spiffeId = getSpiffeId(chain.get(0)); return spiffeId.getTrustDomain(); }
CertificateUtils { public static TrustDomain getTrustDomain(final List<X509Certificate> chain) throws CertificateException { val spiffeId = getSpiffeId(chain.get(0)); return spiffeId.getTrustDomain(); } }
CertificateUtils { public static TrustDomain getTrustDomain(final List<X509Certificate> chain) throws CertificateException { val spiffeId = getSpiffeId(chain.get(0)); return spiffeId.getTrustDomain(); } private  CertificateUtils(); }
CertificateUtils { public static TrustDomain getTrustDomain(final List<X509Certificate> chain) throws CertificateException { val spiffeId = getSpiffeId(chain.get(0)); return spiffeId.getTrustDomain(); } private  CertificateUtils(); static List<X509Certificate> generateCertificates(final byte[] input); static PrivateKey generatePrivateKey(final byte[] privateKeyBytes, AsymmetricKeyAlgorithm algorithm, KeyFileFormat keyFileFormat); static void validate(final List<X509Certificate> chain, final Collection<X509Certificate> trustedCerts); static SpiffeId getSpiffeId(final X509Certificate certificate); static TrustDomain getTrustDomain(final List<X509Certificate> chain); static void validatePrivateKey(final PrivateKey privateKey, final X509Certificate x509Certificate); static boolean isCA(final X509Certificate cert); static boolean hasKeyUsageCertSign(final X509Certificate cert); static boolean hasKeyUsageDigitalSignature(final X509Certificate cert); static boolean hasKeyUsageCRLSign(final X509Certificate cert); }
CertificateUtils { public static TrustDomain getTrustDomain(final List<X509Certificate> chain) throws CertificateException { val spiffeId = getSpiffeId(chain.get(0)); return spiffeId.getTrustDomain(); } private  CertificateUtils(); static List<X509Certificate> generateCertificates(final byte[] input); static PrivateKey generatePrivateKey(final byte[] privateKeyBytes, AsymmetricKeyAlgorithm algorithm, KeyFileFormat keyFileFormat); static void validate(final List<X509Certificate> chain, final Collection<X509Certificate> trustedCerts); static SpiffeId getSpiffeId(final X509Certificate certificate); static TrustDomain getTrustDomain(final List<X509Certificate> chain); static void validatePrivateKey(final PrivateKey privateKey, final X509Certificate x509Certificate); static boolean isCA(final X509Certificate cert); static boolean hasKeyUsageCertSign(final X509Certificate cert); static boolean hasKeyUsageDigitalSignature(final X509Certificate cert); static boolean hasKeyUsageCRLSign(final X509Certificate cert);  }