what-the-bank/sources/org/jmrtd/cert/CVCAuthorizationTemplate.java

280 lines
10 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.jmrtd.cert;
import o.InterfaceC15241glC;
import o.InterfaceC15243glE;
import o.glF;
import o.glS;
import org.ejbca.cvc.AccessRightEnum;
import org.ejbca.cvc.AuthorizationRoleEnum;
/* loaded from: classes6.dex */
public class CVCAuthorizationTemplate {
private Permission accessRight;
private Role role;
/* loaded from: classes6.dex */
public enum Role {
CVCA(192),
DV_D(128),
DV_F(64),
IS(0);
private byte value;
Role(int i) {
this.value = (byte) i;
}
public final byte getValue() {
return this.value;
}
}
/* loaded from: classes6.dex */
public enum Permission {
READ_ACCESS_NONE(0),
READ_ACCESS_DG3(1),
READ_ACCESS_DG4(2),
READ_ACCESS_DG3_AND_DG4(3);
private byte value;
Permission(int i) {
this.value = (byte) i;
}
public final boolean implies(Permission permission) {
int i = AnonymousClass1.$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission[ordinal()];
if (i == 1) {
return permission == READ_ACCESS_NONE;
}
if (i == 2) {
return permission == READ_ACCESS_DG3;
}
if (i == 3) {
return permission == READ_ACCESS_DG4;
}
if (i != 4) {
return false;
}
return permission == READ_ACCESS_DG3 || permission == READ_ACCESS_DG4 || permission == READ_ACCESS_DG3_AND_DG4;
}
public final byte getValue() {
return this.value;
}
}
/* JADX INFO: Access modifiers changed from: protected */
public CVCAuthorizationTemplate(org.ejbca.cvc.CVCAuthorizationTemplate cVCAuthorizationTemplate) {
try {
int[] iArr = AnonymousClass1.$SwitchMap$org$ejbca$cvc$AuthorizationRoleEnum;
InterfaceC15243glE interfaceC15243glE = ((glF) cVCAuthorizationTemplate.e(glS.ROLE_AND_ACCESS_RIGHTS)).b;
if (interfaceC15243glE instanceof AuthorizationRoleEnum) {
int i = iArr[((AuthorizationRoleEnum) interfaceC15243glE).ordinal()];
if (i == 1) {
this.role = Role.CVCA;
} else if (i == 2) {
this.role = Role.DV_D;
} else if (i == 3) {
this.role = Role.DV_F;
} else if (i == 4) {
this.role = Role.IS;
}
int[] iArr2 = AnonymousClass1.$SwitchMap$org$ejbca$cvc$AccessRightEnum;
InterfaceC15241glC interfaceC15241glC = ((glF) cVCAuthorizationTemplate.e(glS.ROLE_AND_ACCESS_RIGHTS)).e;
if (interfaceC15241glC instanceof AccessRightEnum) {
int i2 = iArr2[((AccessRightEnum) interfaceC15241glC).ordinal()];
if (i2 == 1) {
this.accessRight = Permission.READ_ACCESS_NONE;
return;
}
if (i2 == 2) {
this.accessRight = Permission.READ_ACCESS_DG3;
return;
} else if (i2 == 3) {
this.accessRight = Permission.READ_ACCESS_DG4;
return;
} else {
if (i2 == 4) {
this.accessRight = Permission.READ_ACCESS_DG3_AND_DG4;
return;
}
return;
}
}
throw new UnsupportedOperationException("Attempted to use deprecated getAccessRight method with an AT or ST certificate chain. It handles IS only.");
}
throw new UnsupportedOperationException("Attempted to use deprecated getRole method with in an AT or ST certificate chain. It handles IS only.");
} catch (NoSuchFieldException unused) {
throw new IllegalArgumentException("Error getting role from AuthZ template");
}
}
public CVCAuthorizationTemplate(Role role, Permission permission) {
this.role = role;
this.accessRight = permission;
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(this.role.toString());
sb.append(this.accessRight.toString());
return sb.toString();
}
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj == this) {
return true;
}
if (!getClass().equals(obj.getClass())) {
return false;
}
CVCAuthorizationTemplate cVCAuthorizationTemplate = (CVCAuthorizationTemplate) obj;
return this.role == cVCAuthorizationTemplate.role && this.accessRight == cVCAuthorizationTemplate.accessRight;
}
public int hashCode() {
return (this.role.value << 1) + (this.accessRight.value * 3) + 61;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static AccessRightEnum fromPermission(Permission permission) {
int i;
try {
i = AnonymousClass1.$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission[permission.ordinal()];
} catch (Exception unused) {
}
if (i == 1) {
return AccessRightEnum.READ_ACCESS_NONE;
}
if (i == 2) {
return AccessRightEnum.READ_ACCESS_DG3;
}
if (i == 3) {
return AccessRightEnum.READ_ACCESS_DG4;
}
if (i == 4) {
return AccessRightEnum.READ_ACCESS_DG3_AND_DG4;
}
throw new IllegalArgumentException("Error getting permission from AuthZ template");
}
/* renamed from: org.jmrtd.cert.CVCAuthorizationTemplate$1, reason: invalid class name */
/* loaded from: classes6.dex */
static /* synthetic */ class AnonymousClass1 {
static final int[] $SwitchMap$org$ejbca$cvc$AccessRightEnum;
static final int[] $SwitchMap$org$ejbca$cvc$AuthorizationRoleEnum;
static final int[] $SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission;
static final int[] $SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Role;
static {
int[] iArr = new int[Role.values().length];
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Role = iArr;
try {
iArr[Role.CVCA.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Role[Role.DV_D.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Role[Role.DV_F.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
try {
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Role[Role.IS.ordinal()] = 4;
} catch (NoSuchFieldError unused4) {
}
int[] iArr2 = new int[AccessRightEnum.values().length];
$SwitchMap$org$ejbca$cvc$AccessRightEnum = iArr2;
try {
iArr2[AccessRightEnum.READ_ACCESS_NONE.ordinal()] = 1;
} catch (NoSuchFieldError unused5) {
}
try {
$SwitchMap$org$ejbca$cvc$AccessRightEnum[AccessRightEnum.READ_ACCESS_DG3.ordinal()] = 2;
} catch (NoSuchFieldError unused6) {
}
try {
$SwitchMap$org$ejbca$cvc$AccessRightEnum[AccessRightEnum.READ_ACCESS_DG4.ordinal()] = 3;
} catch (NoSuchFieldError unused7) {
}
try {
$SwitchMap$org$ejbca$cvc$AccessRightEnum[AccessRightEnum.READ_ACCESS_DG3_AND_DG4.ordinal()] = 4;
} catch (NoSuchFieldError unused8) {
}
int[] iArr3 = new int[AuthorizationRoleEnum.values().length];
$SwitchMap$org$ejbca$cvc$AuthorizationRoleEnum = iArr3;
try {
iArr3[AuthorizationRoleEnum.CVCA.ordinal()] = 1;
} catch (NoSuchFieldError unused9) {
}
try {
$SwitchMap$org$ejbca$cvc$AuthorizationRoleEnum[AuthorizationRoleEnum.DV_D.ordinal()] = 2;
} catch (NoSuchFieldError unused10) {
}
try {
$SwitchMap$org$ejbca$cvc$AuthorizationRoleEnum[AuthorizationRoleEnum.DV_F.ordinal()] = 3;
} catch (NoSuchFieldError unused11) {
}
try {
$SwitchMap$org$ejbca$cvc$AuthorizationRoleEnum[AuthorizationRoleEnum.IS.ordinal()] = 4;
} catch (NoSuchFieldError unused12) {
}
int[] iArr4 = new int[Permission.values().length];
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission = iArr4;
try {
iArr4[Permission.READ_ACCESS_NONE.ordinal()] = 1;
} catch (NoSuchFieldError unused13) {
}
try {
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission[Permission.READ_ACCESS_DG3.ordinal()] = 2;
} catch (NoSuchFieldError unused14) {
}
try {
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission[Permission.READ_ACCESS_DG4.ordinal()] = 3;
} catch (NoSuchFieldError unused15) {
}
try {
$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Permission[Permission.READ_ACCESS_DG3_AND_DG4.ordinal()] = 4;
} catch (NoSuchFieldError unused16) {
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
public static AuthorizationRoleEnum fromRole(Role role) {
int i;
try {
i = AnonymousClass1.$SwitchMap$org$jmrtd$cert$CVCAuthorizationTemplate$Role[role.ordinal()];
} catch (Exception unused) {
}
if (i == 1) {
return AuthorizationRoleEnum.CVCA;
}
if (i == 2) {
return AuthorizationRoleEnum.DV_D;
}
if (i == 3) {
return AuthorizationRoleEnum.DV_F;
}
if (i == 4) {
return AuthorizationRoleEnum.IS;
}
throw new IllegalArgumentException("Error getting role from AuthZ template");
}
public Role getRole() {
return this.role;
}
public Permission getAccessRight() {
return this.accessRight;
}
}