/** * Returns the CNs from the supplied certificate. * * @param cert to get CNs from * * @return CNs */ private String[] getCNs(final X509Certificate cert) { final List<String> names = new ArrayList<>(); final byte[] encodedDn = cert.getSubjectX500Principal().getEncoded(); if (encodedDn != null && encodedDn.length > 0) { final DN dn = DN.decode(ByteBuffer.wrap(encodedDn)); for (RDN rdn : dn.getRDNs()) { // for multi value RDNs the first value is used final String value = rdn.getAttributeValue("2.5.4.3", new StringValueTranscoder()); if (value != null) { names.add(value); } } } return names.toArray(new String[names.size()]); }
/** * Returns the CNs from the supplied certificate. * * @param cert to get CNs from * * @return CNs */ private String[] getCNs(final X509Certificate cert) { final List<String> names = new ArrayList<>(); final byte[] encodedDn = cert.getSubjectX500Principal().getEncoded(); if (encodedDn != null && encodedDn.length > 0) { final DN dn = DN.decode(ByteBuffer.wrap(encodedDn)); for (RDN rdn : dn.getRDNs()) { // for multi value RDNs the first value is used final String value = rdn.getAttributeValue("2.5.4.3", new StringValueTranscoder()); if (value != null) { names.add(value); } } } return names.toArray(new String[names.size()]); }
/** * Returns the CNs from the supplied certificate. * * @param cert to get CNs from * * @return CNs */ private String[] getCNs(final X509Certificate cert) { final List<String> names = new ArrayList<>(); final byte[] encodedDn = cert.getSubjectX500Principal().getEncoded(); if (encodedDn != null && encodedDn.length > 0) { final DN dn = DN.decode(ByteBuffer.wrap(encodedDn)); for (RDN rdn : dn.getRDNs()) { // for multi value RDNs the first value is used final String value = rdn.getAttributeValue("2.5.4.3", new StringValueTranscoder()); if (value != null) { names.add(value); } } } return names.toArray(new String[names.size()]); }