use of org.openecard.bouncycastle.asn1.x500.RDN in project athenz by yahoo.
the class Crypto method extractX509CSRCommonName.
public static String extractX509CSRCommonName(PKCS10CertificationRequest certReq) {
String cn = null;
X500Name x500name = certReq.getSubject();
RDN cnRdn = x500name.getRDNs(BCStyle.CN)[0];
if (cnRdn != null) {
cn = IETFUtils.valueToString(cnRdn.getFirst().getValue());
}
return cn;
}
use of org.openecard.bouncycastle.asn1.x500.RDN in project athenz by yahoo.
the class Crypto method extractX509CertCommonName.
public static String extractX509CertCommonName(X509Certificate x509Cert) {
// in case there are multiple CNs, we're only looking at the first one
String cn = null;
String principalName = x509Cert.getSubjectX500Principal().getName();
if (principalName != null && !principalName.isEmpty()) {
X500Name x500name = new X500Name(principalName);
RDN cnRdn = x500name.getRDNs(BCStyle.CN)[0];
if (cnRdn != null) {
cn = IETFUtils.valueToString(cnRdn.getFirst().getValue());
}
}
return cn;
}
use of org.openecard.bouncycastle.asn1.x500.RDN in project xabber-android by redsolution.
the class CustomDomainVerifier method getCommonNames.
private static List<String> getCommonNames(X509Certificate certificate) {
List<String> domains = new ArrayList<>();
try {
X500Name x500name = new JcaX509CertificateHolder(certificate).getSubject();
RDN[] rdns = x500name.getRDNs(BCStyle.CN);
for (int i = 0; i < rdns.length; ++i) {
domains.add(IETFUtils.valueToString(x500name.getRDNs(BCStyle.CN)[i].getFirst().getValue()));
}
return domains;
} catch (CertificateEncodingException e) {
return domains;
}
}
use of org.openecard.bouncycastle.asn1.x500.RDN in project xipki by xipki.
the class X509Ca method removeEmptyRdns.
// remove the RDNs with empty content
private static X500Name removeEmptyRdns(X500Name name) {
RDN[] rdns = name.getRDNs();
List<RDN> tmpRdns = new ArrayList<>(rdns.length);
boolean changed = false;
for (RDN rdn : rdns) {
String textValue = X509Util.rdnValueToString(rdn.getFirst().getValue());
if (StringUtil.isBlank(textValue)) {
changed = true;
} else {
tmpRdns.add(rdn);
}
}
return changed ? new X500Name(tmpRdns.toArray(new RDN[0])) : name;
}
use of org.openecard.bouncycastle.asn1.x500.RDN in project xipki by xipki.
the class CaUtil method sortX509Name.
public static X500Name sortX509Name(X500Name name) {
ParamUtil.requireNonNull("name", name);
RDN[] requstedRdns = name.getRDNs();
List<RDN> rdns = new LinkedList<>();
List<ASN1ObjectIdentifier> sortedDNs = SubjectDnSpec.getForwardDNs();
int size = sortedDNs.size();
for (int i = 0; i < size; i++) {
ASN1ObjectIdentifier type = sortedDNs.get(i);
RDN[] thisRdns = getRdns(requstedRdns, type);
if (thisRdns == null) {
continue;
}
if (thisRdns.length == 0) {
continue;
}
for (RDN m : thisRdns) {
rdns.add(m);
}
}
return new X500Name(rdns.toArray(new RDN[0]));
}
Aggregations