Pkcs10Csr { public List<SubjectAlternativeName> getSubjectAlternativeNames() { return getExtensions() .map(extensions -> GeneralNames.fromExtensions(extensions, Extension.subjectAlternativeName)) .map(SubjectAlternativeName::fromGeneralNames) .orElse(emptyList()); } Pkcs10Csr(PKCS10CertificationRequest csr); X500Principal getSubject(); List<SubjectAlternativeName> getSubjectAlternativeNames(); Optional<Boolean> getBasicConstraints(); List<String> getExtensionOIds(); @Override boolean equals(Object o); @Override int hashCode();  }
@Test public void can_read_subject_alternative_names() { X500Principal subject = new X500Principal("CN=subject"); KeyPair keypair = KeyUtils.generateKeypair(KeyAlgorithm.EC, 256); SubjectAlternativeName san1 = new SubjectAlternativeName(DNS_NAME, "san1.com"); SubjectAlternativeName san2 = new SubjectAlternativeName(DNS_NAME, "san2.com"); Pkcs10Csr csr = Pkcs10CsrBuilder.fromKeypair(subject, keypair, SignatureAlgorithm.SHA512_WITH_ECDSA) .addSubjectAlternativeName(san1) .addSubjectAlternativeName(san2) .build(); assertEquals(Arrays.asList(san1, san2), csr.getSubjectAlternativeNames()); }