package org.ejbca.cvc; import net.sf.scuba.smartcards.ISO7816; import o.AbstractC15245glT; import o.C15271glz; import o.C15288gmc; import o.InterfaceC15241glC; import o.InterfaceC15243glE; import o.glA; import o.glB; import o.glF; import o.glI; import o.glN; import o.glS; import o.glU; import org.ejbca.cvc.exception.ConstructionException; /* loaded from: classes6.dex */ public class CVCAuthorizationTemplate extends glA { private static glS[] d = {glS.OID, glS.ROLE_AND_ACCESS_RIGHTS}; public CVCAuthorizationTemplate() { super(glS.HOLDER_AUTH_TEMPLATE); } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r1v11, types: [org.ejbca.cvc.AccessRightEnum[]] */ /* JADX WARN: Type inference failed for: r1v9, types: [o.glB[]] */ /* JADX WARN: Type inference failed for: r3v1, types: [o.glB] */ /* JADX WARN: Type inference failed for: r3v2 */ /* JADX WARN: Type inference failed for: r3v3, types: [org.ejbca.cvc.AccessRightEnum] */ @Override // o.glA public final void c(AbstractC15245glT abstractC15245glT) throws ConstructionException { InterfaceC15243glE[] values; C15271glz c15271glz; InterfaceC15243glE interfaceC15243glE; ?? r3; super.c(abstractC15245glT); if (abstractC15245glT instanceof glF) { try { glF glf = (glF) abstractC15245glT; C15288gmc c15288gmc = (C15288gmc) e(glS.OID); byte c = (byte) (glf.b.c() & ISO7816.INS_GET_RESPONSE); if (glU.c.equals(c15288gmc)) { values = AuthorizationRoleEnum.values(); } else if (glU.e.equals(c15288gmc)) { values = glN.values(); } else if (glU.d.equals(c15288gmc)) { values = glI.values(); } else { throw new IllegalArgumentException("incorrect or unsupported OID"); } int length = values.length; int i = 0; int i2 = 0; while (true) { c15271glz = null; if (i2 >= length) { interfaceC15243glE = null; break; } interfaceC15243glE = values[i2]; if (c == interfaceC15243glE.c()) { break; } else { i2++; } } glf.b = interfaceC15243glE; byte[] b = glf.e.b(); if (glU.c.equals(c15288gmc)) { if (b.length != 1) { StringBuilder sb = new StringBuilder("byte array length must be 1, was "); sb.append(b.length); throw new IllegalArgumentException(sb.toString()); } byte b2 = (byte) (b[0] & 3); ?? values2 = AccessRightEnum.values(); int length2 = values2.length; while (i < length2) { r3 = values2[i]; if (b2 == r3.value) { c15271glz = r3; break; } i++; } glf.e = c15271glz; } if (glU.e.equals(c15288gmc)) { if (b.length != 1) { StringBuilder sb2 = new StringBuilder("byte array length must be 1, was "); sb2.append(b.length); throw new IllegalArgumentException(sb2.toString()); } byte b3 = (byte) (b[0] & 3); ?? values3 = glB.values(); int length3 = values3.length; while (i < length3) { r3 = values3[i]; if (b3 == r3.value) { c15271glz = r3; break; } i++; } } else if (glU.d.equals(c15288gmc)) { if (b.length != 5) { StringBuilder sb3 = new StringBuilder("byte array length must be 5, was "); sb3.append(b.length); throw new IllegalArgumentException(sb3.toString()); } c15271glz = new C15271glz(b); } else { throw new IllegalArgumentException("incorrect or unsupported OID"); } glf.e = c15271glz; } catch (NoSuchFieldException e) { throw new ConstructionException("Tried to add an AuthorizationField without an OID", e); } } } public CVCAuthorizationTemplate(InterfaceC15243glE interfaceC15243glE, InterfaceC15241glC interfaceC15241glC) throws ConstructionException { this(); C15288gmc c15288gmc; if ((interfaceC15243glE instanceof AuthorizationRoleEnum) && (interfaceC15241glC instanceof AccessRightEnum)) { c15288gmc = glU.c; } else if ((interfaceC15243glE instanceof glI) && (interfaceC15241glC instanceof C15271glz)) { c15288gmc = glU.d; } else if ((interfaceC15243glE instanceof glN) && (interfaceC15241glC instanceof glB)) { c15288gmc = glU.e; } else { StringBuilder sb = new StringBuilder("Unsupported roles/rights type (or mismatch). Got role of type "); sb.append(interfaceC15243glE.getClass().getSimpleName()); sb.append(", but rights of type "); sb.append(interfaceC15241glC.getClass().getSimpleName()); throw new IllegalArgumentException(sb.toString()); } c(c15288gmc); c(new glF(interfaceC15243glE, interfaceC15241glC)); } @Override // o.glA public final glS[] a() { return d; } }