package o; import java.io.IOException; import java.math.BigInteger; import java.security.Principal; import java.security.cert.CertSelector; import java.security.cert.Certificate; import java.security.cert.X509Certificate; import java.util.ArrayList; import javax.security.auth.x500.X500Principal; /* renamed from: o.gsa, reason: case insensitive filesystem */ /* loaded from: classes6.dex */ public final class C15505gsa implements CertSelector, InterfaceC15467grM { private InterfaceC15342gnr b; private C15505gsa(C15421gpx c15421gpx) { this.b = c15421gpx.d; } private Object[] d() { gpP gpp; InterfaceC15342gnr interfaceC15342gnr = this.b; if (!(interfaceC15342gnr instanceof C15438gqg)) { gpp = (gpP) interfaceC15342gnr; } else { gpp = ((C15438gqg) interfaceC15342gnr).c; } gpO[] gpoArr = gpp.b; int length = gpoArr.length; gpO[] gpoArr2 = new gpO[length]; System.arraycopy(gpoArr, 0, gpoArr2, 0, gpoArr.length); ArrayList arrayList = new ArrayList(length); for (int i = 0; i != length; i++) { if (gpoArr2[i].e == 4) { try { arrayList.add(new X500Principal(gpoArr2[i].d.i().l())); } catch (IOException unused) { throw new RuntimeException("badly formed Name object"); } } } return arrayList.toArray(new Object[arrayList.size()]); } public final Principal[] e() { Object[] d = d(); ArrayList arrayList = new ArrayList(); for (int i = 0; i != d.length; i++) { Object obj = d[i]; if (obj instanceof Principal) { arrayList.add(obj); } } return (Principal[]) arrayList.toArray(new Principal[arrayList.size()]); } private static boolean d(X500Principal x500Principal, gpP gpp) { gpO[] gpoArr = gpp.b; int length = gpoArr.length; gpO[] gpoArr2 = new gpO[length]; System.arraycopy(gpoArr, 0, gpoArr2, 0, gpoArr.length); for (int i = 0; i != length; i++) { gpO gpo = gpoArr2[i]; if (gpo.e == 4) { try { if (new X500Principal(gpo.d.i().l()).equals(x500Principal)) { return true; } } catch (IOException unused) { continue; } } } return false; } @Override // java.security.cert.CertSelector, o.InterfaceC15467grM public final Object clone() { C15421gpx c15421gpx; InterfaceC15342gnr interfaceC15342gnr = this.b; if (interfaceC15342gnr == null || (interfaceC15342gnr instanceof C15421gpx)) { c15421gpx = (C15421gpx) interfaceC15342gnr; } else { boolean z = interfaceC15342gnr instanceof C15438gqg; gpP gpp = null; C15438gqg c15438gqg = null; if (z) { if (z) { c15438gqg = (C15438gqg) interfaceC15342gnr; } else if (interfaceC15342gnr != null) { c15438gqg = new C15438gqg(AbstractC15317gnH.a(interfaceC15342gnr)); } c15421gpx = new C15421gpx(c15438gqg); } else { boolean z2 = interfaceC15342gnr instanceof gpP; if (z2) { c15421gpx = new C15421gpx((gpP) interfaceC15342gnr); } else if (!(interfaceC15342gnr instanceof AbstractC15321gnP)) { if (interfaceC15342gnr instanceof AbstractC15317gnH) { if (z2) { gpp = (gpP) interfaceC15342gnr; } else if (interfaceC15342gnr != null) { gpp = new gpP(AbstractC15317gnH.a(interfaceC15342gnr)); } c15421gpx = new C15421gpx(gpp); } else { StringBuilder sb = new StringBuilder("unknown object in factory: "); sb.append(interfaceC15342gnr.getClass().getName()); throw new IllegalArgumentException(sb.toString()); } } else { AbstractC15317gnH b = AbstractC15317gnH.b((AbstractC15321gnP) interfaceC15342gnr, false); c15421gpx = new C15421gpx(b != null ? new C15438gqg(AbstractC15317gnH.a(b)) : null); } } } return new C15505gsa(c15421gpx); } @Override // java.security.cert.CertSelector public final boolean match(Certificate certificate) { if (!(certificate instanceof X509Certificate)) { return false; } X509Certificate x509Certificate = (X509Certificate) certificate; InterfaceC15342gnr interfaceC15342gnr = this.b; if (interfaceC15342gnr instanceof C15438gqg) { C15438gqg c15438gqg = (C15438gqg) interfaceC15342gnr; if (c15438gqg.e != null) { return new BigInteger(c15438gqg.e.e.b).equals(x509Certificate.getSerialNumber()) && d(x509Certificate.getIssuerX500Principal(), c15438gqg.e.c); } if (d(x509Certificate.getSubjectX500Principal(), c15438gqg.c)) { return true; } } else { if (d(x509Certificate.getSubjectX500Principal(), (gpP) interfaceC15342gnr)) { return true; } } return false; } public final boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof C15505gsa) { return this.b.equals(((C15505gsa) obj).b); } return false; } public final int hashCode() { return this.b.hashCode(); } }