Search in sources :

Example 61 with RDN

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;
    }
}
Also used : ASN1String(org.openecard.bouncycastle.asn1.ASN1String) ASN1String(org.openecard.bouncycastle.asn1.ASN1String) ASN1OctetString(org.openecard.bouncycastle.asn1.ASN1OctetString) RDN(org.openecard.bouncycastle.asn1.x500.RDN) AttributeTypeAndValue(org.openecard.bouncycastle.asn1.x500.AttributeTypeAndValue)

Example 62 with RDN

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());
}
Also used : X500Name(org.bouncycastle.asn1.x500.X500Name) RDN(org.bouncycastle.asn1.x500.RDN)

Aggregations

RDN (org.bouncycastle.asn1.x500.RDN)55 X500Name (org.bouncycastle.asn1.x500.X500Name)33 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)18 ArrayList (java.util.ArrayList)15 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)15 X509Certificate (java.security.cert.X509Certificate)13 DERIA5String (org.bouncycastle.asn1.DERIA5String)13 AttributeTypeAndValue (org.bouncycastle.asn1.x500.AttributeTypeAndValue)13 IOException (java.io.IOException)12 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)12 DERPrintableString (org.bouncycastle.asn1.DERPrintableString)12 LinkedList (java.util.LinkedList)10 DEROctetString (org.bouncycastle.asn1.DEROctetString)10 JcaX509CertificateHolder (org.bouncycastle.cert.jcajce.JcaX509CertificateHolder)10 KeyStoreException (java.security.KeyStoreException)8 List (java.util.List)8 InputStream (java.io.InputStream)7 KeyStore (java.security.KeyStore)7 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)7 CertificateException (java.security.cert.CertificateException)7