Pkcs10Csr { public List<String> getExtensionOIds() { return getExtensions() .map(extensions -> Arrays.stream(extensions.getExtensionOIDs()) .map(ASN1ObjectIdentifier::getId) .collect(toList())) .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_extensions() { X500Principal subject = new X500Principal("CN=subject"); KeyPair keypair = KeyUtils.generateKeypair(KeyAlgorithm.EC, 256); Pkcs10Csr csr = Pkcs10CsrBuilder.fromKeypair(subject, keypair, SignatureAlgorithm.SHA512_WITH_ECDSA) .addSubjectAlternativeName("san") .setBasicConstraints(true, true) .build(); List<String> expected = Arrays.asList(Extension.BASIC_CONSTRAINTS.getOId(), Extension.SUBJECT_ALTERNATIVE_NAMES.getOId()); List<String> actual = csr.getExtensionOIds(); assertEquals(expected, actual); }