use of org.openecard.bouncycastle.asn1.x500.RDN in project open-ecard by ecsec.
the class ListCertificates method matchesRdn.
private boolean matchesRdn(Pattern searchPattern, X500Name name, ASN1ObjectIdentifier rdnIdentifier) {
RDN[] rdns = name.getRDNs(rdnIdentifier);
if (rdns.length >= 1) {
// only compare first as everything else would be non standard in X509 certs
AttributeTypeAndValue rdnAttr = rdns[0].getFirst();
ASN1String attrStr = (ASN1String) rdnAttr.getValue().toASN1Primitive();
String rdnStr = attrStr.getString();
return searchPattern.matcher(rdnStr).matches();
} else {
return false;
}
}
use of org.openecard.bouncycastle.asn1.x500.RDN in project TLS-Scanner by RUB-NDS.
the class CertificateReportGenerator method setCommonNames.
private static void setCommonNames(CertificateReportImplementation report, org.bouncycastle.asn1.x509.Certificate cert) {
StringBuilder commonNames = new StringBuilder();
X500Name x500name = cert.getSubject();
if (x500name != null) {
RDN[] rdNs = x500name.getRDNs(BCStyle.CN);
for (int i = 0; i < rdNs.length; i++) {
commonNames.append(IETFUtils.valueToString(rdNs[i]));
if (i < rdNs.length - 1) {
commonNames.append(" ,");
}
}
}
report.setCommonNames(commonNames.toString());
}
Aggregations