what-the-bank/sources/com/facetec/sdk/kc.java

694 lines
24 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.facetec.sdk;
import com.google.common.primitives.UnsignedBytes;
import io.grpc.internal.GrpcUtil;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import okhttp3.HttpUrl;
/* loaded from: classes.dex */
public final class kc {
private static final char[] c = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
final String a;
final String b;
public final List<String> d;
final int e;
private final String f;
private final String g;
private final List<String> h;
private final String i;
private final String j;
kc(c cVar) {
this.b = cVar.a;
this.g = a(cVar.c, false);
this.f = a(cVar.d, false);
this.a = cVar.b;
this.e = cVar.c();
this.h = b(cVar.j, false);
this.d = cVar.i != null ? b(cVar.i, true) : null;
this.j = cVar.f != null ? a(cVar.f, false) : null;
this.i = cVar.toString();
}
public final boolean a() {
return this.b.equals("https");
}
public final String c() {
if (this.g.isEmpty()) {
return "";
}
int length = this.b.length() + 3;
String str = this.i;
return this.i.substring(length, km.b(str, length, str.length(), ":@"));
}
public final String d() {
if (this.f.isEmpty()) {
return "";
}
int indexOf = this.i.indexOf(58, this.b.length() + 3);
return this.i.substring(indexOf + 1, this.i.indexOf(64));
}
public static int c(String str) {
if (str.equals("http")) {
return 80;
}
if (str.equals("https")) {
return GrpcUtil.DEFAULT_PORT_SSL;
}
return -1;
}
public final String f() {
int indexOf = this.i.indexOf(47, this.b.length() + 3);
String str = this.i;
return this.i.substring(indexOf, km.b(str, indexOf, str.length(), "?#"));
}
static void d(StringBuilder sb, List<String> list) {
int size = list.size();
for (int i = 0; i < size; i++) {
sb.append('/');
sb.append(list.get(i));
}
}
public final List<String> g() {
int indexOf = this.i.indexOf(47, this.b.length() + 3);
String str = this.i;
int b = km.b(str, indexOf, str.length(), "?#");
ArrayList arrayList = new ArrayList();
while (indexOf < b) {
int i = indexOf + 1;
int d = km.d(this.i, i, b, '/');
arrayList.add(this.i.substring(i, d));
indexOf = d;
}
return arrayList;
}
public final String h() {
if (this.d == null) {
return null;
}
int indexOf = this.i.indexOf(63) + 1;
String str = this.i;
return this.i.substring(indexOf, km.d(str, indexOf, str.length(), '#'));
}
public static void b(StringBuilder sb, List<String> list) {
int size = list.size();
for (int i = 0; i < size; i += 2) {
String str = list.get(i);
String str2 = list.get(i + 1);
if (i > 0) {
sb.append('&');
}
sb.append(str);
if (str2 != null) {
sb.append('=');
sb.append(str2);
}
}
}
static List<String> e(String str) {
ArrayList arrayList = new ArrayList();
int i = 0;
while (i <= str.length()) {
int indexOf = str.indexOf(38, i);
if (indexOf == -1) {
indexOf = str.length();
}
int indexOf2 = str.indexOf(61, i);
if (indexOf2 == -1 || indexOf2 > indexOf) {
arrayList.add(str.substring(i, indexOf));
arrayList.add(null);
} else {
arrayList.add(str.substring(i, indexOf2));
arrayList.add(str.substring(indexOf2 + 1, indexOf));
}
i = indexOf + 1;
}
return arrayList;
}
public final c a(String str) {
try {
return new c().c(this, str);
} catch (IllegalArgumentException unused) {
return null;
}
}
public static kc b(String str) {
return new c().c(null, str).b();
}
public final boolean equals(Object obj) {
return (obj instanceof kc) && ((kc) obj).i.equals(this.i);
}
public final int hashCode() {
return this.i.hashCode();
}
/* loaded from: classes.dex */
public static final class c {
String a;
String b;
String c = "";
String d = "";
int e = -1;
String f;
List<String> i;
final List<String> j;
public c() {
ArrayList arrayList = new ArrayList();
this.j = arrayList;
arrayList.add("");
}
final int c() {
int i = this.e;
return i != -1 ? i : kc.c(this.a);
}
public final c c(String str) {
this.i = str != null ? kc.e(kc.c(str, HttpUrl.QUERY_ENCODE_SET, true, false, true, true)) : null;
return this;
}
public final kc b() {
if (this.a == null) {
throw new IllegalStateException("scheme == null");
}
if (this.b == null) {
throw new IllegalStateException("host == null");
}
return new kc(this);
}
public final String toString() {
StringBuilder sb = new StringBuilder();
String str = this.a;
if (str != null) {
sb.append(str);
sb.append("://");
} else {
sb.append("//");
}
if (!this.c.isEmpty() || !this.d.isEmpty()) {
sb.append(this.c);
if (!this.d.isEmpty()) {
sb.append(':');
sb.append(this.d);
}
sb.append('@');
}
String str2 = this.b;
if (str2 != null) {
if (str2.indexOf(58) != -1) {
sb.append('[');
sb.append(this.b);
sb.append(']');
} else {
sb.append(this.b);
}
}
if (this.e != -1 || this.a != null) {
int c = c();
String str3 = this.a;
if (str3 == null || c != kc.c(str3)) {
sb.append(':');
sb.append(c);
}
}
kc.d(sb, this.j);
if (this.i != null) {
sb.append('?');
kc.b(sb, this.i);
}
if (this.f != null) {
sb.append('#');
sb.append(this.f);
}
return sb.toString();
}
final c c(kc kcVar, String str) {
int b;
int i;
int d = km.d(str, 0, str.length());
int e = km.e(str, d, str.length());
int c = c(str, d, e);
if (c != -1) {
if (str.regionMatches(true, d, "https:", 0, 6)) {
this.a = "https";
d += 6;
} else {
if (!str.regionMatches(true, d, "http:", 0, 5)) {
StringBuilder sb = new StringBuilder("Expected URL scheme 'http' or 'https' but was '");
sb.append(str.substring(0, c));
sb.append("'");
throw new IllegalArgumentException(sb.toString());
}
this.a = "http";
d += 5;
}
} else if (kcVar != null) {
this.a = kcVar.b;
} else {
throw new IllegalArgumentException("Expected URL scheme 'http' or 'https' but no colon was found");
}
int e2 = e(str, d, e);
char c2 = '?';
char c3 = '#';
if (e2 >= 2 || kcVar == null || !kcVar.b.equals(this.a)) {
boolean z = false;
boolean z2 = false;
int i2 = d + e2;
while (true) {
b = km.b(str, i2, e, "@/\\?#");
char charAt = b != e ? str.charAt(b) : (char) 65535;
if (charAt == 65535 || charAt == c3 || charAt == '/' || charAt == '\\' || charAt == c2) {
break;
}
if (charAt == '@') {
if (!z) {
int d2 = km.d(str, i2, b, ':');
i = b;
String e3 = kc.e(str, i2, d2, " \"':;<=>@[]^`{}|/\\?#", true, false, false, true, null);
if (z2) {
StringBuilder sb2 = new StringBuilder();
sb2.append(this.c);
sb2.append("%40");
sb2.append(e3);
e3 = sb2.toString();
}
this.c = e3;
if (d2 != i) {
this.d = kc.e(str, d2 + 1, i, " \"':;<=>@[]^`{}|/\\?#", true, false, false, true, null);
z = true;
}
z2 = true;
} else {
i = b;
StringBuilder sb3 = new StringBuilder();
sb3.append(this.d);
sb3.append("%40");
sb3.append(kc.e(str, i2, i, " \"':;<=>@[]^`{}|/\\?#", true, false, false, true, null));
this.d = sb3.toString();
}
i2 = i + 1;
c2 = '?';
c3 = '#';
}
}
int b2 = b(str, i2, b);
int i3 = b2 + 1;
if (i3 < b) {
this.b = d(str, i2, b2);
int i4 = i(str, i3, b);
this.e = i4;
if (i4 == -1) {
StringBuilder sb4 = new StringBuilder("Invalid URL port: \"");
sb4.append(str.substring(i3, b));
sb4.append('\"');
throw new IllegalArgumentException(sb4.toString());
}
} else {
this.b = d(str, i2, b2);
this.e = kc.c(this.a);
}
if (this.b == null) {
StringBuilder sb5 = new StringBuilder("Invalid URL host: \"");
sb5.append(str.substring(i2, b2));
sb5.append('\"');
throw new IllegalArgumentException(sb5.toString());
}
d = b;
} else {
this.c = kcVar.c();
this.d = kcVar.d();
this.b = kcVar.a;
this.e = kcVar.e;
this.j.clear();
this.j.addAll(kcVar.g());
if (d == e || str.charAt(d) == '#') {
c(kcVar.h());
}
}
int b3 = km.b(str, d, e, "?#");
a(str, d, b3);
if (b3 < e && str.charAt(b3) == '?') {
int d3 = km.d(str, b3, e, '#');
this.i = kc.e(kc.e(str, b3 + 1, d3, HttpUrl.QUERY_ENCODE_SET, true, false, true, true, null));
b3 = d3;
}
if (b3 < e && str.charAt(b3) == '#') {
this.f = kc.e(str, 1 + b3, e, "", true, false, false, false, null);
}
return this;
}
private void a(String str, int i, int i2) {
if (i == i2) {
return;
}
char charAt = str.charAt(i);
if (charAt == '/' || charAt == '\\') {
this.j.clear();
this.j.add("");
i++;
} else {
List<String> list = this.j;
list.set(list.size() - 1, "");
}
while (i < i2) {
int b = km.b(str, i, i2, "/\\");
boolean z = b < i2;
a(str, i, b, z);
if (z) {
b++;
}
i = b;
}
}
private void a(String str, int i, int i2, boolean z) {
String e = kc.e(str, i, i2, HttpUrl.PATH_SEGMENT_ENCODE_SET, true, false, false, true, null);
if (d(e)) {
return;
}
if (e(e)) {
d();
return;
}
if (this.j.get(r11.size() - 1).isEmpty()) {
this.j.set(r11.size() - 1, e);
} else {
this.j.add(e);
}
if (z) {
this.j.add("");
}
}
private static boolean d(String str) {
return str.equals(".") || str.equalsIgnoreCase("%2e");
}
private static boolean e(String str) {
return str.equals("..") || str.equalsIgnoreCase("%2e.") || str.equalsIgnoreCase(".%2e") || str.equalsIgnoreCase("%2e%2e");
}
private void d() {
if (this.j.remove(r0.size() - 1).isEmpty() && !this.j.isEmpty()) {
this.j.set(r0.size() - 1, "");
} else {
this.j.add("");
}
}
private static int c(String str, int i, int i2) {
if (i2 - i < 2) {
return -1;
}
char charAt = str.charAt(i);
if ((charAt >= 'a' && charAt <= 'z') || (charAt >= 'A' && charAt <= 'Z')) {
while (true) {
i++;
if (i >= i2) {
break;
}
char charAt2 = str.charAt(i);
if (charAt2 < 'a' || charAt2 > 'z') {
if (charAt2 < 'A' || charAt2 > 'Z') {
if (charAt2 < '0' || charAt2 > '9') {
if (charAt2 != '+' && charAt2 != '-' && charAt2 != '.') {
if (charAt2 == ':') {
return i;
}
}
}
}
}
}
}
return -1;
}
private static int e(String str, int i, int i2) {
int i3 = 0;
while (i < i2) {
char charAt = str.charAt(i);
if (charAt != '\\' && charAt != '/') {
break;
}
i3++;
i++;
}
return i3;
}
private static int b(String str, int i, int i2) {
while (i < i2) {
char charAt = str.charAt(i);
if (charAt == ':') {
return i;
}
if (charAt != '[') {
i++;
}
do {
i++;
if (i < i2) {
}
i++;
} while (str.charAt(i) != ']');
i++;
}
return i2;
}
/* JADX INFO: Access modifiers changed from: package-private */
public static String d(String str, int i, int i2) {
return km.c(kc.c(str, i, i2, false));
}
private static int i(String str, int i, int i2) {
try {
int parseInt = Integer.parseInt(kc.e(str, i, i2, "", false, false, false, true, null));
if (parseInt <= 0 || parseInt > 65535) {
return -1;
}
return parseInt;
} catch (NumberFormatException unused) {
return -1;
}
}
}
private static String a(String str, boolean z) {
return c(str, 0, str.length(), z);
}
private static List<String> b(List<String> list, boolean z) {
int size = list.size();
ArrayList arrayList = new ArrayList(size);
for (int i = 0; i < size; i++) {
String str = list.get(i);
arrayList.add(str != null ? a(str, z) : null);
}
return Collections.unmodifiableList(arrayList);
}
static String c(String str, int i, int i2, boolean z) {
for (int i3 = i; i3 < i2; i3++) {
char charAt = str.charAt(i3);
if (charAt == '%' || (charAt == '+' && z)) {
ms msVar = new ms();
msVar.c(str, i, i3);
c(msVar, str, i3, i2, z);
return msVar.k();
}
}
return str.substring(i, i2);
}
private static void c(ms msVar, String str, int i, int i2, boolean z) {
int i3;
while (i < i2) {
int codePointAt = str.codePointAt(i);
if (codePointAt == 37 && (i3 = i + 2) < i2) {
int d = km.d(str.charAt(i + 1));
int d2 = km.d(str.charAt(i3));
if (d != -1 && d2 != -1) {
msVar.h((d << 4) + d2);
i = i3;
}
msVar.c(codePointAt);
} else {
if (codePointAt == 43 && z) {
msVar.h(32);
}
msVar.c(codePointAt);
}
i += Character.charCount(codePointAt);
}
}
private static boolean c(String str, int i, int i2) {
int i3 = i + 2;
return i3 < i2 && str.charAt(i) == '%' && km.d(str.charAt(i + 1)) != -1 && km.d(str.charAt(i3)) != -1;
}
static String e(String str, int i, int i2, String str2, boolean z, boolean z2, boolean z3, boolean z4, Charset charset) {
int i3 = i;
while (i3 < i2) {
int codePointAt = str.codePointAt(i3);
int i4 = 43;
if (codePointAt >= 32 && codePointAt != 127 && ((codePointAt < 128 || !z4) && str2.indexOf(codePointAt) == -1 && ((codePointAt != 37 || (z && (!z2 || c(str, i3, i2)))) && (codePointAt != 43 || !z3)))) {
i3 += Character.charCount(codePointAt);
} else {
ms msVar = new ms();
msVar.c(str, i, i3);
ms msVar2 = null;
while (i3 < i2) {
int codePointAt2 = str.codePointAt(i3);
if (!z || (codePointAt2 != 9 && codePointAt2 != 10 && codePointAt2 != 12 && codePointAt2 != 13)) {
if (codePointAt2 == i4 && z3) {
msVar.e(z ? "+" : "%2B");
} else if (codePointAt2 < 32 || codePointAt2 == 127 || ((codePointAt2 >= 128 && z4) || str2.indexOf(codePointAt2) != -1 || (codePointAt2 == 37 && (!z || (z2 && !c(str, i3, i2)))))) {
if (msVar2 == null) {
msVar2 = new ms();
}
if (charset == null || charset.equals(km.c)) {
msVar2.c(codePointAt2);
} else {
int charCount = Character.charCount(codePointAt2) + i3;
if (str == null) {
throw new IllegalArgumentException("string == null");
}
if (i3 < 0) {
throw new IllegalAccessError("beginIndex < 0: ".concat(String.valueOf(i3)));
}
if (charCount < i3) {
StringBuilder sb = new StringBuilder("endIndex < beginIndex: ");
sb.append(charCount);
sb.append(" < ");
sb.append(i3);
throw new IllegalArgumentException(sb.toString());
}
if (charCount > str.length()) {
StringBuilder sb2 = new StringBuilder("endIndex > string.length: ");
sb2.append(charCount);
sb2.append(" > ");
sb2.append(str.length());
throw new IllegalArgumentException(sb2.toString());
}
if (charset == null) {
throw new IllegalArgumentException("charset == null");
}
if (charset.equals(ng.e)) {
msVar2.c(str, i3, charCount);
} else {
byte[] bytes = str.substring(i3, charCount).getBytes(charset);
msVar2.d(bytes, 0, bytes.length);
}
}
while (!msVar2.a()) {
byte g = msVar2.g();
msVar.h(37);
char[] cArr = c;
msVar.h((int) cArr[((g & UnsignedBytes.MAX_VALUE) >> 4) & 15]);
msVar.h((int) cArr[g & 15]);
}
} else {
msVar.c(codePointAt2);
}
}
i3 += Character.charCount(codePointAt2);
i4 = 43;
}
return msVar.k();
}
}
return str.substring(i, i2);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static String b(String str, String str2, Charset charset) {
return e(str, 0, str.length(), str2, false, false, true, true, charset);
}
/* JADX INFO: Access modifiers changed from: package-private */
public static String c(String str, String str2, boolean z, boolean z2, boolean z3, boolean z4) {
return e(str, 0, str.length(), str2, z, z2, z3, z4, null);
}
public final URI e() {
c cVar = new c();
cVar.a = this.b;
cVar.c = c();
cVar.d = d();
cVar.b = this.a;
cVar.e = this.e != c(this.b) ? this.e : -1;
cVar.j.clear();
cVar.j.addAll(g());
cVar.c(h());
cVar.f = this.j == null ? null : this.i.substring(this.i.indexOf(35) + 1);
int size = cVar.j.size();
for (int i = 0; i < size; i++) {
cVar.j.set(i, c(cVar.j.get(i), HttpUrl.PATH_SEGMENT_ENCODE_SET_URI, true, true, false, true));
}
if (cVar.i != null) {
int size2 = cVar.i.size();
for (int i2 = 0; i2 < size2; i2++) {
String str = cVar.i.get(i2);
if (str != null) {
cVar.i.set(i2, c(str, HttpUrl.QUERY_COMPONENT_ENCODE_SET_URI, true, true, true, true));
}
}
}
if (cVar.f != null) {
cVar.f = c(cVar.f, HttpUrl.FRAGMENT_ENCODE_SET_URI, true, true, false, false);
}
String obj = cVar.toString();
try {
return new URI(obj);
} catch (URISyntaxException e) {
try {
return URI.create(obj.replaceAll("[\\u0000-\\u001F\\u007F-\\u009F\\p{javaWhitespace}]", ""));
} catch (Exception unused) {
throw new RuntimeException(e);
}
}
}
public final String toString() {
return this.i;
}
public final int j() {
return this.e;
}
public final String i() {
return this.a;
}
public final String b() {
return this.b;
}
}