Search in sources :

Example 21 with AttributeTypeAndValue

use of org.apache.harmony.security.x501.AttributeTypeAndValue 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)

Aggregations

AttributeTypeAndValue (org.bouncycastle.asn1.x500.AttributeTypeAndValue)13 RDN (org.bouncycastle.asn1.x500.RDN)12 IOException (java.io.IOException)8 ArrayList (java.util.ArrayList)8 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)7 AttributeTypeAndValue (org.apache.harmony.security.x501.AttributeTypeAndValue)6 X500Name (org.bouncycastle.asn1.x500.X500Name)6 BigInteger (java.math.BigInteger)5 List (java.util.List)5 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)5 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)4 GeneralSecurityException (java.security.GeneralSecurityException)3 MessageDigest (java.security.MessageDigest)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 Signature (java.security.Signature)3 Certificate (java.security.cert.Certificate)3 X509Certificate (java.security.cert.X509Certificate)3 LinkedList (java.util.LinkedList)3 X500Principal (javax.security.auth.x500.X500Principal)3 BerInputStream (org.apache.harmony.security.asn1.BerInputStream)3