511 lines
17 KiB
Java
511 lines
17 KiB
Java
|
package o;
|
||
|
|
||
|
import com.google.common.primitives.UnsignedBytes;
|
||
|
import java.util.Collection;
|
||
|
import java.util.HashSet;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.Set;
|
||
|
import org.spongycastle.jce.provider.PKIXNameConstraintValidatorException;
|
||
|
|
||
|
/* renamed from: o.grn, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public final class C15486grn {
|
||
|
Set f;
|
||
|
Set g;
|
||
|
Set h;
|
||
|
Set i;
|
||
|
Set j;
|
||
|
Set a = new HashSet();
|
||
|
Set b = new HashSet();
|
||
|
Set d = new HashSet();
|
||
|
Set c = new HashSet();
|
||
|
Set e = new HashSet();
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static boolean e(AbstractC15317gnH abstractC15317gnH, AbstractC15317gnH abstractC15317gnH2) {
|
||
|
if (abstractC15317gnH2.e() <= 0 || abstractC15317gnH2.e() > abstractC15317gnH.e()) {
|
||
|
return false;
|
||
|
}
|
||
|
for (int e = abstractC15317gnH2.e() - 1; e >= 0; e--) {
|
||
|
if (!abstractC15317gnH2.d(e).equals(abstractC15317gnH.d(e))) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static void b(Set set, AbstractC15317gnH abstractC15317gnH) throws PKIXNameConstraintValidatorException {
|
||
|
if (set == null) {
|
||
|
return;
|
||
|
}
|
||
|
if (set.isEmpty() && abstractC15317gnH.e() == 0) {
|
||
|
return;
|
||
|
}
|
||
|
Iterator it = set.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
if (e(abstractC15317gnH, (AbstractC15317gnH) it.next())) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
throw new PKIXNameConstraintValidatorException("Subject distinguished name is not from a permitted subtree");
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static void c(Set set, AbstractC15317gnH abstractC15317gnH) throws PKIXNameConstraintValidatorException {
|
||
|
if (set.isEmpty()) {
|
||
|
return;
|
||
|
}
|
||
|
Iterator it = set.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
if (e(abstractC15317gnH, (AbstractC15317gnH) it.next())) {
|
||
|
throw new PKIXNameConstraintValidatorException("Subject distinguished name is from an excluded subtree");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private static boolean b(byte[] bArr, byte[] bArr2) {
|
||
|
int length = bArr.length;
|
||
|
if (length != bArr2.length / 2) {
|
||
|
return false;
|
||
|
}
|
||
|
byte[] bArr3 = new byte[length];
|
||
|
System.arraycopy(bArr2, length, bArr3, 0, length);
|
||
|
byte[] bArr4 = new byte[length];
|
||
|
byte[] bArr5 = new byte[length];
|
||
|
for (int i = 0; i < length; i++) {
|
||
|
bArr4[i] = (byte) (bArr2[i] & bArr3[i]);
|
||
|
bArr5[i] = (byte) (bArr[i] & bArr3[i]);
|
||
|
}
|
||
|
return grK.b(bArr4, bArr5);
|
||
|
}
|
||
|
|
||
|
private static boolean b(String str, String str2) {
|
||
|
String substring = str.substring(str.indexOf(64) + 1);
|
||
|
if (str2.indexOf(64) != -1) {
|
||
|
if (str.equalsIgnoreCase(str2) || substring.equalsIgnoreCase(str2.substring(1))) {
|
||
|
return true;
|
||
|
}
|
||
|
} else if (str2.charAt(0) != '.') {
|
||
|
if (substring.equalsIgnoreCase(str2)) {
|
||
|
return true;
|
||
|
}
|
||
|
} else if (d(substring, str2)) {
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static boolean d(String str, String str2) {
|
||
|
if (str2.startsWith(".")) {
|
||
|
str2 = str2.substring(1);
|
||
|
}
|
||
|
String[] a = grR.a(str2);
|
||
|
String[] a2 = grR.a(str);
|
||
|
if (a2.length <= a.length) {
|
||
|
return false;
|
||
|
}
|
||
|
int length = a2.length - a.length;
|
||
|
for (int i = -1; i < a.length; i++) {
|
||
|
if (i == -1) {
|
||
|
if (a2[i + length].equals("")) {
|
||
|
return false;
|
||
|
}
|
||
|
} else if (!a[i].equalsIgnoreCase(a2[i + length])) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public static byte[] a(byte[] bArr, byte[] bArr2) {
|
||
|
for (int i = 0; i < bArr.length; i++) {
|
||
|
if ((bArr[i] & UnsignedBytes.MAX_VALUE) > (65535 & bArr2[i])) {
|
||
|
return bArr;
|
||
|
}
|
||
|
}
|
||
|
return bArr2;
|
||
|
}
|
||
|
|
||
|
public final int hashCode() {
|
||
|
int d = d(this.a);
|
||
|
int d2 = d(this.b);
|
||
|
int d3 = d(this.d);
|
||
|
int d4 = d(this.e);
|
||
|
int d5 = d(this.c);
|
||
|
int d6 = d(this.g);
|
||
|
int d7 = d(this.f);
|
||
|
int d8 = d(this.j);
|
||
|
return d + d2 + d3 + d4 + d5 + d6 + d7 + d8 + d(this.i) + d(this.h);
|
||
|
}
|
||
|
|
||
|
private static int d(Collection collection) {
|
||
|
int hashCode;
|
||
|
int i = 0;
|
||
|
if (collection == null) {
|
||
|
return 0;
|
||
|
}
|
||
|
for (Object obj : collection) {
|
||
|
if (obj instanceof byte[]) {
|
||
|
hashCode = grK.c((byte[]) obj);
|
||
|
} else {
|
||
|
hashCode = obj.hashCode();
|
||
|
}
|
||
|
i += hashCode;
|
||
|
}
|
||
|
return i;
|
||
|
}
|
||
|
|
||
|
public final boolean equals(Object obj) {
|
||
|
if (!(obj instanceof C15486grn)) {
|
||
|
return false;
|
||
|
}
|
||
|
C15486grn c15486grn = (C15486grn) obj;
|
||
|
return b(c15486grn.a, this.a) && b(c15486grn.b, this.b) && b(c15486grn.d, this.d) && b(c15486grn.e, this.e) && b(c15486grn.c, this.c) && b(c15486grn.g, this.g) && b(c15486grn.f, this.f) && b(c15486grn.j, this.j) && b(c15486grn.i, this.i) && b(c15486grn.h, this.h);
|
||
|
}
|
||
|
|
||
|
private static boolean b(Collection collection, Collection collection2) {
|
||
|
boolean equals;
|
||
|
if (collection == collection2) {
|
||
|
return true;
|
||
|
}
|
||
|
if (collection == null || collection2 == null || collection.size() != collection2.size()) {
|
||
|
return false;
|
||
|
}
|
||
|
for (Object obj : collection) {
|
||
|
for (Object obj2 : collection2) {
|
||
|
if (obj != obj2) {
|
||
|
if (obj != null && obj2 != null) {
|
||
|
if ((obj instanceof byte[]) && (obj2 instanceof byte[])) {
|
||
|
equals = grK.b((byte[]) obj, (byte[]) obj2);
|
||
|
} else {
|
||
|
equals = obj.equals(obj2);
|
||
|
}
|
||
|
if (equals) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
private static String b(Set set) {
|
||
|
Iterator it = set.iterator();
|
||
|
String str = "[";
|
||
|
while (it.hasNext()) {
|
||
|
StringBuilder sb = new StringBuilder();
|
||
|
sb.append(str);
|
||
|
byte[] bArr = (byte[]) it.next();
|
||
|
String str2 = "";
|
||
|
for (int i = 0; i < bArr.length / 2; i++) {
|
||
|
StringBuilder sb2 = new StringBuilder();
|
||
|
sb2.append(str2);
|
||
|
sb2.append(Integer.toString(bArr[i] & UnsignedBytes.MAX_VALUE));
|
||
|
sb2.append(".");
|
||
|
str2 = sb2.toString();
|
||
|
}
|
||
|
String substring = str2.substring(0, str2.length() - 1);
|
||
|
StringBuilder sb3 = new StringBuilder();
|
||
|
sb3.append(substring);
|
||
|
sb3.append("/");
|
||
|
String obj = sb3.toString();
|
||
|
for (int length = bArr.length / 2; length < bArr.length; length++) {
|
||
|
StringBuilder sb4 = new StringBuilder();
|
||
|
sb4.append(obj);
|
||
|
sb4.append(Integer.toString(bArr[length] & UnsignedBytes.MAX_VALUE));
|
||
|
sb4.append(".");
|
||
|
obj = sb4.toString();
|
||
|
}
|
||
|
sb.append(obj.substring(0, obj.length() - 1));
|
||
|
sb.append(",");
|
||
|
str = sb.toString();
|
||
|
}
|
||
|
if (str.length() > 1) {
|
||
|
str = str.substring(0, str.length() - 1);
|
||
|
}
|
||
|
StringBuilder sb5 = new StringBuilder();
|
||
|
sb5.append(str);
|
||
|
sb5.append("]");
|
||
|
return sb5.toString();
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
String str;
|
||
|
if (this.g != null) {
|
||
|
StringBuilder sb = new StringBuilder("permitted:\nDN:\n");
|
||
|
sb.append(this.g.toString());
|
||
|
sb.append("\n");
|
||
|
str = sb.toString();
|
||
|
} else {
|
||
|
str = "permitted:\n";
|
||
|
}
|
||
|
if (this.f != null) {
|
||
|
StringBuilder sb2 = new StringBuilder();
|
||
|
sb2.append(str);
|
||
|
sb2.append("DNS:\n");
|
||
|
String obj = sb2.toString();
|
||
|
StringBuilder sb3 = new StringBuilder();
|
||
|
sb3.append(obj);
|
||
|
sb3.append(this.f.toString());
|
||
|
sb3.append("\n");
|
||
|
str = sb3.toString();
|
||
|
}
|
||
|
if (this.j != null) {
|
||
|
StringBuilder sb4 = new StringBuilder();
|
||
|
sb4.append(str);
|
||
|
sb4.append("Email:\n");
|
||
|
String obj2 = sb4.toString();
|
||
|
StringBuilder sb5 = new StringBuilder();
|
||
|
sb5.append(obj2);
|
||
|
sb5.append(this.j.toString());
|
||
|
sb5.append("\n");
|
||
|
str = sb5.toString();
|
||
|
}
|
||
|
if (this.h != null) {
|
||
|
StringBuilder sb6 = new StringBuilder();
|
||
|
sb6.append(str);
|
||
|
sb6.append("URI:\n");
|
||
|
String obj3 = sb6.toString();
|
||
|
StringBuilder sb7 = new StringBuilder();
|
||
|
sb7.append(obj3);
|
||
|
sb7.append(this.h.toString());
|
||
|
sb7.append("\n");
|
||
|
str = sb7.toString();
|
||
|
}
|
||
|
if (this.i != null) {
|
||
|
StringBuilder sb8 = new StringBuilder();
|
||
|
sb8.append(str);
|
||
|
sb8.append("IP:\n");
|
||
|
String obj4 = sb8.toString();
|
||
|
StringBuilder sb9 = new StringBuilder();
|
||
|
sb9.append(obj4);
|
||
|
sb9.append(b(this.i));
|
||
|
sb9.append("\n");
|
||
|
str = sb9.toString();
|
||
|
}
|
||
|
StringBuilder sb10 = new StringBuilder();
|
||
|
sb10.append(str);
|
||
|
sb10.append("excluded:\n");
|
||
|
String obj5 = sb10.toString();
|
||
|
if (!this.a.isEmpty()) {
|
||
|
StringBuilder sb11 = new StringBuilder();
|
||
|
sb11.append(obj5);
|
||
|
sb11.append("DN:\n");
|
||
|
String obj6 = sb11.toString();
|
||
|
StringBuilder sb12 = new StringBuilder();
|
||
|
sb12.append(obj6);
|
||
|
sb12.append(this.a.toString());
|
||
|
sb12.append("\n");
|
||
|
obj5 = sb12.toString();
|
||
|
}
|
||
|
if (!this.b.isEmpty()) {
|
||
|
StringBuilder sb13 = new StringBuilder();
|
||
|
sb13.append(obj5);
|
||
|
sb13.append("DNS:\n");
|
||
|
String obj7 = sb13.toString();
|
||
|
StringBuilder sb14 = new StringBuilder();
|
||
|
sb14.append(obj7);
|
||
|
sb14.append(this.b.toString());
|
||
|
sb14.append("\n");
|
||
|
obj5 = sb14.toString();
|
||
|
}
|
||
|
if (!this.d.isEmpty()) {
|
||
|
StringBuilder sb15 = new StringBuilder();
|
||
|
sb15.append(obj5);
|
||
|
sb15.append("Email:\n");
|
||
|
String obj8 = sb15.toString();
|
||
|
StringBuilder sb16 = new StringBuilder();
|
||
|
sb16.append(obj8);
|
||
|
sb16.append(this.d.toString());
|
||
|
sb16.append("\n");
|
||
|
obj5 = sb16.toString();
|
||
|
}
|
||
|
if (!this.c.isEmpty()) {
|
||
|
StringBuilder sb17 = new StringBuilder();
|
||
|
sb17.append(obj5);
|
||
|
sb17.append("URI:\n");
|
||
|
String obj9 = sb17.toString();
|
||
|
StringBuilder sb18 = new StringBuilder();
|
||
|
sb18.append(obj9);
|
||
|
sb18.append(this.c.toString());
|
||
|
sb18.append("\n");
|
||
|
obj5 = sb18.toString();
|
||
|
}
|
||
|
if (this.e.isEmpty()) {
|
||
|
return obj5;
|
||
|
}
|
||
|
StringBuilder sb19 = new StringBuilder();
|
||
|
sb19.append(obj5);
|
||
|
sb19.append("IP:\n");
|
||
|
String obj10 = sb19.toString();
|
||
|
StringBuilder sb20 = new StringBuilder();
|
||
|
sb20.append(obj10);
|
||
|
sb20.append(b(this.e));
|
||
|
sb20.append("\n");
|
||
|
return sb20.toString();
|
||
|
}
|
||
|
|
||
|
private static boolean c(String str, String str2) {
|
||
|
String substring = str.substring(str.indexOf(58) + 1);
|
||
|
if (substring.indexOf("//") != -1) {
|
||
|
substring = substring.substring(substring.indexOf("//") + 2);
|
||
|
}
|
||
|
if (substring.lastIndexOf(58) != -1) {
|
||
|
substring = substring.substring(0, substring.lastIndexOf(58));
|
||
|
}
|
||
|
String substring2 = substring.substring(substring.indexOf(58) + 1);
|
||
|
String substring3 = substring2.substring(substring2.indexOf(64) + 1);
|
||
|
if (substring3.indexOf(47) != -1) {
|
||
|
substring3 = substring3.substring(0, substring3.indexOf(47));
|
||
|
}
|
||
|
if (!str2.startsWith(".")) {
|
||
|
if (substring3.equalsIgnoreCase(str2)) {
|
||
|
return true;
|
||
|
}
|
||
|
} else if (d(substring3, str2)) {
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public final void c(gpO gpo) throws PKIXNameConstraintValidatorException {
|
||
|
int i = gpo.e;
|
||
|
if (i == 1) {
|
||
|
Set set = this.d;
|
||
|
String j = C15376gop.b(gpo.d).j();
|
||
|
if (set.isEmpty()) {
|
||
|
return;
|
||
|
}
|
||
|
Iterator it = set.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
if (b(j, (String) it.next())) {
|
||
|
throw new PKIXNameConstraintValidatorException("Email address is from an excluded subtree.");
|
||
|
}
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
if (i == 2) {
|
||
|
Set<String> set2 = this.b;
|
||
|
String j2 = C15376gop.b(gpo.d).j();
|
||
|
if (set2.isEmpty()) {
|
||
|
return;
|
||
|
}
|
||
|
for (String str : set2) {
|
||
|
if (d(j2, str) || j2.equalsIgnoreCase(str)) {
|
||
|
throw new PKIXNameConstraintValidatorException("DNS is from an excluded subtree.");
|
||
|
}
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
if (i == 4) {
|
||
|
c(this.a, AbstractC15317gnH.a(gpo.d.i()));
|
||
|
return;
|
||
|
}
|
||
|
if (i == 6) {
|
||
|
Set set3 = this.c;
|
||
|
String j3 = C15376gop.b(gpo.d).j();
|
||
|
if (set3.isEmpty()) {
|
||
|
return;
|
||
|
}
|
||
|
Iterator it2 = set3.iterator();
|
||
|
while (it2.hasNext()) {
|
||
|
if (c(j3, (String) it2.next())) {
|
||
|
throw new PKIXNameConstraintValidatorException("URI is from an excluded subtree.");
|
||
|
}
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
if (i == 7) {
|
||
|
byte[] b = gnD.b(gpo.d).b();
|
||
|
Set set4 = this.e;
|
||
|
if (set4.isEmpty()) {
|
||
|
return;
|
||
|
}
|
||
|
Iterator it3 = set4.iterator();
|
||
|
while (it3.hasNext()) {
|
||
|
if (b(b, (byte[]) it3.next())) {
|
||
|
throw new PKIXNameConstraintValidatorException("IP is from an excluded subtree.");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public final void e(gpO gpo) throws PKIXNameConstraintValidatorException {
|
||
|
int i = gpo.e;
|
||
|
if (i == 1) {
|
||
|
Set set = this.j;
|
||
|
String j = C15376gop.b(gpo.d).j();
|
||
|
if (set != null) {
|
||
|
Iterator it = set.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
if (b(j, (String) it.next())) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
if (j.length() != 0 || set.size() != 0) {
|
||
|
throw new PKIXNameConstraintValidatorException("Subject email address is not from a permitted subtree.");
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
if (i == 2) {
|
||
|
Set<String> set2 = this.f;
|
||
|
String j2 = C15376gop.b(gpo.d).j();
|
||
|
if (set2 != null) {
|
||
|
for (String str : set2) {
|
||
|
if (d(j2, str) || j2.equalsIgnoreCase(str)) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
if (j2.length() != 0 || set2.size() != 0) {
|
||
|
throw new PKIXNameConstraintValidatorException("DNS is not from a permitted subtree.");
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
if (i == 4) {
|
||
|
b(this.g, AbstractC15317gnH.a(gpo.d.i()));
|
||
|
return;
|
||
|
}
|
||
|
if (i == 6) {
|
||
|
Set set3 = this.h;
|
||
|
String j3 = C15376gop.b(gpo.d).j();
|
||
|
if (set3 != null) {
|
||
|
Iterator it2 = set3.iterator();
|
||
|
while (it2.hasNext()) {
|
||
|
if (c(j3, (String) it2.next())) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
if (j3.length() != 0 || set3.size() != 0) {
|
||
|
throw new PKIXNameConstraintValidatorException("URI is not from a permitted subtree.");
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
if (i == 7) {
|
||
|
byte[] b = gnD.b(gpo.d).b();
|
||
|
Set set4 = this.i;
|
||
|
if (set4 != null) {
|
||
|
Iterator it3 = set4.iterator();
|
||
|
while (it3.hasNext()) {
|
||
|
if (b(b, (byte[]) it3.next())) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
if (b.length != 0 || set4.size() != 0) {
|
||
|
throw new PKIXNameConstraintValidatorException("IP is not from a permitted subtree.");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|