what-the-bank/sources/com/google/firebase/auth/FirebaseAuth.java

309 lines
12 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.google.firebase.auth;
import android.text.TextUtils;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.internal.p002firebaseauthapi.zzwy;
import com.google.android.gms.internal.p002firebaseauthapi.zzxc;
import com.google.android.gms.internal.p002firebaseauthapi.zzzy;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.FirebaseApp;
import com.google.firebase.auth.internal.InternalAuthProvider;
import com.google.firebase.auth.internal.zzay;
import com.google.firebase.auth.internal.zzbg;
import com.google.firebase.auth.internal.zzbi;
import com.google.firebase.auth.internal.zzbj;
import com.google.firebase.auth.internal.zzbm;
import com.google.firebase.inject.Provider;
import com.google.firebase.internal.InternalTokenResult;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
/* loaded from: classes2.dex */
public abstract class FirebaseAuth implements InternalAuthProvider {
private FirebaseApp zza;
private final List zzb;
private final List zzc;
private List zzd;
private zzwy zze;
private FirebaseUser zzf;
private com.google.firebase.auth.internal.zzw zzg;
private final Object zzh;
private String zzi;
private final Object zzj;
private String zzk;
private final zzbg zzl;
private final zzbm zzm;
private final com.google.firebase.auth.internal.zzf zzn;
private final Provider zzo;
private zzbi zzp;
private zzbj zzq;
/* loaded from: classes2.dex */
public interface AuthStateListener {
void onAuthStateChanged(FirebaseAuth firebaseAuth);
}
/* loaded from: classes2.dex */
public interface IdTokenListener {
void onIdTokenChanged(FirebaseAuth firebaseAuth);
}
public FirebaseAuth(FirebaseApp firebaseApp, Provider provider) {
zzzy zzb;
zzwy zzwyVar = new zzwy(firebaseApp);
zzbg zzbgVar = new zzbg(firebaseApp.getApplicationContext(), firebaseApp.getPersistenceKey());
zzbm zzc = zzbm.zzc();
com.google.firebase.auth.internal.zzf zzb2 = com.google.firebase.auth.internal.zzf.zzb();
this.zzb = new CopyOnWriteArrayList();
this.zzc = new CopyOnWriteArrayList();
this.zzd = new CopyOnWriteArrayList();
this.zzh = new Object();
this.zzj = new Object();
this.zzq = zzbj.zza();
this.zza = (FirebaseApp) Preconditions.checkNotNull(firebaseApp);
this.zze = (zzwy) Preconditions.checkNotNull(zzwyVar);
zzbg zzbgVar2 = (zzbg) Preconditions.checkNotNull(zzbgVar);
this.zzl = zzbgVar2;
this.zzg = new com.google.firebase.auth.internal.zzw();
zzbm zzbmVar = (zzbm) Preconditions.checkNotNull(zzc);
this.zzm = zzbmVar;
this.zzn = (com.google.firebase.auth.internal.zzf) Preconditions.checkNotNull(zzb2);
this.zzo = provider;
FirebaseUser zza = zzbgVar2.zza();
this.zzf = zza;
if (zza != null && (zzb = zzbgVar2.zzb(zza)) != null) {
zzH(this, this.zzf, zzb, false, false);
}
zzbmVar.zze(this);
}
public static FirebaseAuth getInstance() {
return (FirebaseAuth) FirebaseApp.getInstance().get(FirebaseAuth.class);
}
public static void zzF(FirebaseAuth firebaseAuth, FirebaseUser firebaseUser) {
if (firebaseUser != null) {
firebaseUser.getUid();
}
firebaseAuth.zzq.execute(new zzm(firebaseAuth));
}
public static void zzG(FirebaseAuth firebaseAuth, FirebaseUser firebaseUser) {
if (firebaseUser != null) {
firebaseUser.getUid();
}
firebaseAuth.zzq.execute(new zzl(firebaseAuth, new InternalTokenResult(firebaseUser != null ? firebaseUser.zze() : null)));
}
/* JADX INFO: Access modifiers changed from: package-private */
public static void zzH(FirebaseAuth firebaseAuth, FirebaseUser firebaseUser, zzzy zzzyVar, boolean z, boolean z2) {
boolean z3;
Preconditions.checkNotNull(firebaseUser);
Preconditions.checkNotNull(zzzyVar);
boolean z4 = true;
boolean z5 = firebaseAuth.zzf != null && firebaseUser.getUid().equals(firebaseAuth.zzf.getUid());
if (z5 || !z2) {
FirebaseUser firebaseUser2 = firebaseAuth.zzf;
if (firebaseUser2 == null) {
z3 = true;
} else {
boolean z6 = !z5 || (firebaseUser2.zzd().zze().equals(zzzyVar.zze()) ^ true);
z3 = true ^ z5;
z4 = z6;
}
Preconditions.checkNotNull(firebaseUser);
FirebaseUser firebaseUser3 = firebaseAuth.zzf;
if (firebaseUser3 == null) {
firebaseAuth.zzf = firebaseUser;
} else {
firebaseUser3.zzc(firebaseUser.getProviderData());
if (!firebaseUser.isAnonymous()) {
firebaseAuth.zzf.zzb();
}
firebaseAuth.zzf.zzi(firebaseUser.getMultiFactor().getEnrolledFactors());
}
if (z) {
firebaseAuth.zzl.zzd(firebaseAuth.zzf);
}
if (z4) {
FirebaseUser firebaseUser4 = firebaseAuth.zzf;
if (firebaseUser4 != null) {
firebaseUser4.zzh(zzzyVar);
}
zzG(firebaseAuth, firebaseAuth.zzf);
}
if (z3) {
zzF(firebaseAuth, firebaseAuth.zzf);
}
if (z) {
firebaseAuth.zzl.zze(firebaseUser, zzzyVar);
}
FirebaseUser firebaseUser5 = firebaseAuth.zzf;
if (firebaseUser5 != null) {
zzx(firebaseAuth).zze(firebaseUser5.zzd());
}
}
}
private final boolean zzM(String str) {
ActionCodeUrl parseLink = ActionCodeUrl.parseLink(str);
return (parseLink == null || TextUtils.equals(this.zzk, parseLink.zza())) ? false : true;
}
public static zzbi zzx(FirebaseAuth firebaseAuth) {
if (firebaseAuth.zzp == null) {
firebaseAuth.zzp = new zzbi((FirebaseApp) Preconditions.checkNotNull(firebaseAuth.zza));
}
return firebaseAuth.zzp;
}
@Override // com.google.firebase.auth.internal.InternalAuthProvider
public final Task getAccessToken(boolean z) {
return zzc(this.zzf, z);
}
public String getLanguageCode() {
String str;
synchronized (this.zzh) {
str = this.zzi;
}
return str;
}
@Override // com.google.firebase.auth.internal.InternalAuthProvider
public final String getUid() {
FirebaseUser firebaseUser = this.zzf;
if (firebaseUser == null) {
return null;
}
return firebaseUser.getUid();
}
public void setTenantId(String str) {
Preconditions.checkNotEmpty(str);
synchronized (this.zzj) {
this.zzk = str;
}
}
public Task<AuthResult> signInWithCredential(AuthCredential authCredential) {
Preconditions.checkNotNull(authCredential);
AuthCredential zza = authCredential.zza();
if (zza instanceof EmailAuthCredential) {
EmailAuthCredential emailAuthCredential = (EmailAuthCredential) zza;
if (!emailAuthCredential.zzg()) {
return this.zze.zzA(this.zza, emailAuthCredential.zzd(), Preconditions.checkNotEmpty(emailAuthCredential.zze()), this.zzk, new zzs(this));
}
if (zzM(Preconditions.checkNotEmpty(emailAuthCredential.zzf()))) {
return Tasks.forException(zzxc.zza(new Status(17072)));
}
return this.zze.zzB(this.zza, emailAuthCredential, new zzs(this));
}
if (zza instanceof PhoneAuthCredential) {
return this.zze.zzC(this.zza, (PhoneAuthCredential) zza, this.zzk, new zzs(this));
}
return this.zze.zzy(this.zza, zza, this.zzk, new zzs(this));
}
public Task<AuthResult> signInWithCustomToken(String str) {
Preconditions.checkNotEmpty(str);
return this.zze.zzz(this.zza, str, this.zzk, new zzs(this));
}
public void signOut() {
zzD();
zzbi zzbiVar = this.zzp;
if (zzbiVar != null) {
zzbiVar.zzc();
}
}
public final void zzD() {
Preconditions.checkNotNull(this.zzl);
FirebaseUser firebaseUser = this.zzf;
if (firebaseUser != null) {
zzbg zzbgVar = this.zzl;
Preconditions.checkNotNull(firebaseUser);
zzbgVar.zzc(String.format("com.google.firebase.auth.GET_TOKEN_RESPONSE.%s", firebaseUser.getUid()));
this.zzf = null;
}
this.zzl.zzc("com.google.firebase.auth.FIREBASE_USER");
zzG(this, null);
zzF(this, null);
}
public final void zzE(FirebaseUser firebaseUser, zzzy zzzyVar, boolean z) {
zzH(this, firebaseUser, zzzyVar, true, false);
}
public final Task zzc(FirebaseUser firebaseUser, boolean z) {
if (firebaseUser == null) {
return Tasks.forException(zzxc.zza(new Status(17495)));
}
zzzy zzd = firebaseUser.zzd();
if (!zzd.zzj() || z) {
return this.zze.zzi(this.zza, firebaseUser, zzd.zzf(), new zzn(this));
}
return Tasks.forResult(zzay.zza(zzd.zze()));
}
public final Task zzd(FirebaseUser firebaseUser, AuthCredential authCredential) {
Preconditions.checkNotNull(authCredential);
Preconditions.checkNotNull(firebaseUser);
return this.zze.zzj(this.zza, firebaseUser, authCredential.zza(), new zzt(this));
}
public final Task zzf(FirebaseUser firebaseUser, AuthCredential authCredential) {
Preconditions.checkNotNull(firebaseUser);
Preconditions.checkNotNull(authCredential);
AuthCredential zza = authCredential.zza();
if (zza instanceof EmailAuthCredential) {
EmailAuthCredential emailAuthCredential = (EmailAuthCredential) zza;
if ("password".equals(emailAuthCredential.getSignInMethod())) {
return this.zze.zzp(this.zza, firebaseUser, emailAuthCredential.zzd(), Preconditions.checkNotEmpty(emailAuthCredential.zze()), firebaseUser.getTenantId(), new zzt(this));
}
if (zzM(Preconditions.checkNotEmpty(emailAuthCredential.zzf()))) {
return Tasks.forException(zzxc.zza(new Status(17072)));
}
return this.zze.zzn(this.zza, firebaseUser, emailAuthCredential, new zzt(this));
}
if (zza instanceof PhoneAuthCredential) {
return this.zze.zzr(this.zza, firebaseUser, (PhoneAuthCredential) zza, this.zzk, new zzt(this));
}
return this.zze.zzl(this.zza, firebaseUser, zza, firebaseUser.getTenantId(), new zzt(this));
}
public final zzbi zzw() {
zzbi zzx;
synchronized (this) {
zzx = zzx(this);
}
return zzx;
}
public static FirebaseAuth getInstance(FirebaseApp firebaseApp) {
return (FirebaseAuth) firebaseApp.get(FirebaseAuth.class);
}
@Override // com.google.firebase.auth.internal.InternalAuthProvider
public void addIdTokenListener(com.google.firebase.auth.internal.IdTokenListener idTokenListener) {
Preconditions.checkNotNull(idTokenListener);
this.zzc.add(idTokenListener);
zzw().zzd(this.zzc.size());
}
public final Provider zzy() {
return this.zzo;
}
public FirebaseUser getCurrentUser() {
return this.zzf;
}
public FirebaseApp getApp() {
return this.zza;
}
}