Search in sources :

Example 6 with V2Form

use of org.bouncycastle.asn1.x509.V2Form in project XobotOS by xamarin.

the class AttributeCertificateIssuer method match.

public boolean match(Certificate cert) {
    if (!(cert instanceof X509Certificate)) {
        return false;
    }
    X509Certificate x509Cert = (X509Certificate) cert;
    if (form instanceof V2Form) {
        V2Form issuer = (V2Form) form;
        if (issuer.getBaseCertificateID() != null) {
            return issuer.getBaseCertificateID().getSerial().getValue().equals(x509Cert.getSerialNumber()) && matchesDN(x509Cert.getIssuerX500Principal(), issuer.getBaseCertificateID().getIssuer());
        }
        GeneralNames name = issuer.getIssuerName();
        if (matchesDN(x509Cert.getSubjectX500Principal(), name)) {
            return true;
        }
    } else {
        GeneralNames name = (GeneralNames) form;
        if (matchesDN(x509Cert.getSubjectX500Principal(), name)) {
            return true;
        }
    }
    return false;
}
Also used : V2Form(org.bouncycastle.asn1.x509.V2Form) GeneralNames(org.bouncycastle.asn1.x509.GeneralNames) X509Certificate(java.security.cert.X509Certificate)

Aggregations

GeneralNames (org.bouncycastle.asn1.x509.GeneralNames)6 V2Form (org.bouncycastle.asn1.x509.V2Form)6 ArrayList (java.util.ArrayList)3 List (java.util.List)3 GeneralName (org.bouncycastle.asn1.x509.GeneralName)3 IOException (java.io.IOException)2 X509Certificate (java.security.cert.X509Certificate)2 X500Principal (javax.security.auth.x500.X500Principal)2 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)1 X500Name (org.bouncycastle.asn1.x500.X500Name)1