package org.bouncycastle.asn1.x500;

/* JADX INFO: loaded from: E:\ios\vf_dex\classes4.dex */
public class X500Name extends org.bouncycastle.asn1.ASN1Object implements org.bouncycastle.asn1.ASN1Choice {
    private static org.bouncycastle.asn1.x500.X500NameStyle f = org.bouncycastle.asn1.x500.style.BCStyle.T;
    private boolean a;
    private int b;
    private org.bouncycastle.asn1.x500.X500NameStyle c;
    private org.bouncycastle.asn1.x500.RDN[] d;
    private org.bouncycastle.asn1.DERSequence e;

    public X500Name(java.lang.String str) {
        this(f, str);
    }

    public static org.bouncycastle.asn1.x500.X500Name n(java.lang.Object obj) {
        if (obj instanceof org.bouncycastle.asn1.x500.X500Name) {
            return (org.bouncycastle.asn1.x500.X500Name) obj;
        }
        if (obj != null) {
            return new org.bouncycastle.asn1.x500.X500Name(org.bouncycastle.asn1.ASN1Sequence.z(obj));
        }
        return null;
    }

    public static org.bouncycastle.asn1.x500.X500Name o(org.bouncycastle.asn1.ASN1TaggedObject aSN1TaggedObject, boolean z) {
        return n(org.bouncycastle.asn1.ASN1Sequence.A(aSN1TaggedObject, true));
    }

    public static org.bouncycastle.asn1.x500.X500Name p(org.bouncycastle.asn1.x500.X500NameStyle x500NameStyle, java.lang.Object obj) {
        if (obj instanceof org.bouncycastle.asn1.x500.X500Name) {
            return new org.bouncycastle.asn1.x500.X500Name(x500NameStyle, (org.bouncycastle.asn1.x500.X500Name) obj);
        }
        if (obj != null) {
            return new org.bouncycastle.asn1.x500.X500Name(x500NameStyle, org.bouncycastle.asn1.ASN1Sequence.z(obj));
        }
        return null;
    }

    @Override // org.bouncycastle.asn1.ASN1Object
    public boolean equals(java.lang.Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof org.bouncycastle.asn1.x500.X500Name) && !(obj instanceof org.bouncycastle.asn1.ASN1Sequence)) {
            return false;
        }
        if (j().t(((org.bouncycastle.asn1.ASN1Encodable) obj).j())) {
            return true;
        }
        try {
            return this.c.a(this, n(obj));
        } catch (java.lang.Exception unused) {
            return false;
        }
    }

    @Override // org.bouncycastle.asn1.ASN1Object
    public int hashCode() {
        if (this.a) {
            return this.b;
        }
        this.a = true;
        int iC = this.c.c(this);
        this.b = iC;
        return iC;
    }

    @Override // org.bouncycastle.asn1.ASN1Object, org.bouncycastle.asn1.ASN1Encodable
    public org.bouncycastle.asn1.ASN1Primitive j() {
        return this.e;
    }

    public org.bouncycastle.asn1.x500.RDN[] q() {
        return (org.bouncycastle.asn1.x500.RDN[]) this.d.clone();
    }

    public org.bouncycastle.asn1.x500.RDN[] r(org.bouncycastle.asn1.ASN1ObjectIdentifier aSN1ObjectIdentifier) {
        int length = this.d.length;
        org.bouncycastle.asn1.x500.RDN[] rdnArr = new org.bouncycastle.asn1.x500.RDN[length];
        int i = 0;
        int i2 = 0;
        while (true) {
            org.bouncycastle.asn1.x500.RDN[] rdnArr2 = this.d;
            if (i == rdnArr2.length) {
                break;
            }
            org.bouncycastle.asn1.x500.RDN rdn = rdnArr2[i];
            if (rdn.n(aSN1ObjectIdentifier)) {
                rdnArr[i2] = rdn;
                i2++;
            }
            i++;
        }
        if (i2 >= length) {
            return rdnArr;
        }
        org.bouncycastle.asn1.x500.RDN[] rdnArr3 = new org.bouncycastle.asn1.x500.RDN[i2];
        java.lang.System.arraycopy(rdnArr, 0, rdnArr3, 0, i2);
        return rdnArr3;
    }

    public int size() {
        return this.d.length;
    }

    public java.lang.String toString() {
        return this.c.f(this);
    }

    private X500Name(org.bouncycastle.asn1.ASN1Sequence aSN1Sequence) {
        this(f, aSN1Sequence);
    }

    public X500Name(org.bouncycastle.asn1.x500.X500NameStyle x500NameStyle, java.lang.String str) {
        this(x500NameStyle.b(str));
        this.c = x500NameStyle;
    }

    private X500Name(org.bouncycastle.asn1.x500.X500NameStyle x500NameStyle, org.bouncycastle.asn1.ASN1Sequence aSN1Sequence) {
        int size = aSN1Sequence.size();
        this.c = x500NameStyle;
        this.d = new org.bouncycastle.asn1.x500.RDN[size];
        boolean z = true;
        for (int i = 0; i < size; i++) {
            org.bouncycastle.asn1.ASN1Encodable aSN1EncodableB = aSN1Sequence.B(i);
            org.bouncycastle.asn1.x500.RDN rdnP = org.bouncycastle.asn1.x500.RDN.p(aSN1EncodableB);
            z &= rdnP == aSN1EncodableB;
            this.d[i] = rdnP;
        }
        this.e = z ? org.bouncycastle.asn1.DERSequence.J(aSN1Sequence) : new org.bouncycastle.asn1.DERSequence(this.d);
    }

    public X500Name(org.bouncycastle.asn1.x500.X500NameStyle x500NameStyle, org.bouncycastle.asn1.x500.X500Name x500Name) {
        this.c = x500NameStyle;
        this.d = x500Name.d;
        this.e = x500Name.e;
    }

    public X500Name(org.bouncycastle.asn1.x500.X500NameStyle x500NameStyle, org.bouncycastle.asn1.x500.RDN[] rdnArr) {
        this.c = x500NameStyle;
        this.d = (org.bouncycastle.asn1.x500.RDN[]) rdnArr.clone();
        this.e = new org.bouncycastle.asn1.DERSequence(this.d);
    }

    public X500Name(org.bouncycastle.asn1.x500.RDN[] rdnArr) {
        this(f, rdnArr);
    }
}
