what-the-bank/sources/com/google/android/gms/internal/p002firebaseauthapi/zzxe.java

141 lines
6.2 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.google.android.gms.internal.p002firebaseauthapi;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.text.TextUtils;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.logging.Logger;
import com.google.common.net.HttpHeaders;
import com.google.firebase.FirebaseApp;
import com.google.firebase.auth.internal.zzai;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import java.net.URL;
/* loaded from: classes2.dex */
public final class zzxe extends AsyncTask {
private static final Logger zza = new Logger("FirebaseAuth", "GetAuthDomainTask");
private final String zzb;
private final String zzc;
private final WeakReference zzd;
private final Uri.Builder zze;
private final String zzf;
private final FirebaseApp zzg;
public zzxe(String str, String str2, Intent intent, FirebaseApp firebaseApp, zzxg zzxgVar) {
this.zzb = Preconditions.checkNotEmpty(str);
this.zzg = (FirebaseApp) Preconditions.checkNotNull(firebaseApp);
Preconditions.checkNotEmpty(str2);
Preconditions.checkNotNull(intent);
String checkNotEmpty = Preconditions.checkNotEmpty(intent.getStringExtra("com.google.firebase.auth.KEY_API_KEY"));
Uri.Builder buildUpon = Uri.parse(zzxgVar.zzc(checkNotEmpty)).buildUpon();
buildUpon.appendPath("getProjectConfig").appendQueryParameter("key", checkNotEmpty).appendQueryParameter("androidPackageName", str).appendQueryParameter("sha1Cert", (String) Preconditions.checkNotNull(str2));
this.zzc = buildUpon.build().toString();
this.zzd = new WeakReference(zzxgVar);
this.zze = zzxgVar.zzb(intent, str, str2);
this.zzf = intent.getStringExtra("com.google.firebase.auth.KEY_CUSTOM_AUTH_DOMAIN");
}
/* JADX INFO: Access modifiers changed from: private */
@Override // android.os.AsyncTask
/* renamed from: zza, reason: merged with bridge method [inline-methods] */
public final void onPostExecute(zzxd zzxdVar) {
String str;
String str2;
Uri.Builder builder;
zzxg zzxgVar = (zzxg) this.zzd.get();
if (zzxdVar != null) {
str = zzxdVar.zzc();
str2 = zzxdVar.zzd();
} else {
str = null;
str2 = null;
}
if (zzxgVar == null) {
zza.e("An error has occurred: the handler reference has returned null.", new Object[0]);
} else if (TextUtils.isEmpty(str) || (builder = this.zze) == null) {
zzxgVar.zze(this.zzb, zzai.zza(str2));
} else {
builder.authority(str);
zzxgVar.zzf(this.zze.build(), this.zzb);
}
}
private static byte[] zzb(InputStream inputStream, int i) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
byte[] bArr = new byte[128];
while (true) {
int read = inputStream.read(bArr);
if (read != -1) {
byteArrayOutputStream.write(bArr, 0, read);
} else {
return byteArrayOutputStream.toByteArray();
}
}
} finally {
byteArrayOutputStream.close();
}
}
@Override // android.os.AsyncTask
protected final /* synthetic */ Object doInBackground(Object[] objArr) {
String str;
if (!TextUtils.isEmpty(this.zzf)) {
return zzxd.zza(this.zzf);
}
try {
try {
URL url = new URL(this.zzc);
zzxg zzxgVar = (zzxg) this.zzd.get();
HttpURLConnection zzd = zzxgVar.zzd(url);
zzd.addRequestProperty(HttpHeaders.CONTENT_TYPE, "application/json; charset=UTF-8");
zzd.setConnectTimeout(60000);
new zzxq(zzxgVar.zza(), this.zzg, zzxo.zza().zzb()).zza(zzd);
int responseCode = zzd.getResponseCode();
if (responseCode != 200) {
try {
} catch (IOException e) {
zza.w("Error parsing error message from response body in getErrorMessageFromBody. ".concat(e.toString()), new Object[0]);
}
if (zzd.getResponseCode() >= 400) {
InputStream errorStream = zzd.getErrorStream();
str = errorStream == null ? "WEB_INTERNAL_ERROR:Could not retrieve the authDomain for this project but did not receive an error response from the network request. Please try again." : (String) zzxl.zza(new String(zzb(errorStream, 128)), String.class);
zza.e(String.format("Error getting project config. Failed with %s %s", str, Integer.valueOf(responseCode)), new Object[0]);
return zzxd.zzb(str);
}
str = null;
zza.e(String.format("Error getting project config. Failed with %s %s", str, Integer.valueOf(responseCode)), new Object[0]);
return zzxd.zzb(str);
}
zzzx zzzxVar = new zzzx();
zzzxVar.zzb(new String(zzb(zzd.getInputStream(), 128)));
for (String str2 : zzzxVar.zzc()) {
if (str2.endsWith("firebaseapp.com") || str2.endsWith("web.app")) {
return zzxd.zza(str2);
}
}
return null;
} catch (IOException e2) {
zza.e("IOException occurred: ".concat(String.valueOf(e2.getMessage())), new Object[0]);
return null;
}
} catch (zzvg e3) {
zza.e("ConversionException encountered: ".concat(String.valueOf(e3.getMessage())), new Object[0]);
return null;
} catch (NullPointerException e4) {
zza.e("Null pointer encountered: ".concat(String.valueOf(e4.getMessage())), new Object[0]);
return null;
}
}
@Override // android.os.AsyncTask
protected final /* synthetic */ void onCancelled(Object obj) {
onPostExecute(null);
}
}