95 lines
4.2 KiB
Java
95 lines
4.2 KiB
Java
package com.google.firebase.firestore.auth;
|
|
|
|
import com.google.android.gms.tasks.Continuation;
|
|
import com.google.android.gms.tasks.Task;
|
|
import com.google.android.gms.tasks.Tasks;
|
|
import com.google.firebase.FirebaseApiNotAvailableException;
|
|
import com.google.firebase.appcheck.AppCheckTokenResult;
|
|
import com.google.firebase.appcheck.interop.AppCheckTokenListener;
|
|
import com.google.firebase.appcheck.interop.InternalAppCheckTokenProvider;
|
|
import com.google.firebase.firestore.util.Executors;
|
|
import com.google.firebase.firestore.util.Listener;
|
|
import com.google.firebase.inject.Deferred;
|
|
import com.google.firebase.inject.Provider;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class FirebaseAppCheckTokenProvider extends CredentialsProvider<String> {
|
|
private Listener<String> changeListener;
|
|
private boolean forceRefresh;
|
|
private InternalAppCheckTokenProvider internalAppCheckTokenProvider;
|
|
private final AppCheckTokenListener tokenListener = new AppCheckTokenListener(this) { // from class: com.google.firebase.firestore.auth.FirebaseAppCheckTokenProvider$$ExternalSyntheticLambda0
|
|
public final FirebaseAppCheckTokenProvider f$0;
|
|
|
|
{
|
|
this.f$0 = this;
|
|
}
|
|
};
|
|
|
|
public FirebaseAppCheckTokenProvider(Deferred<InternalAppCheckTokenProvider> deferred) {
|
|
deferred.whenAvailable(new Deferred.DeferredHandler(this) { // from class: com.google.firebase.firestore.auth.FirebaseAppCheckTokenProvider$$ExternalSyntheticLambda1
|
|
public final FirebaseAppCheckTokenProvider f$0;
|
|
|
|
@Override // com.google.firebase.inject.Deferred.DeferredHandler
|
|
public final void handle(Provider provider) {
|
|
this.f$0.m171x16263f8b(provider);
|
|
}
|
|
|
|
{
|
|
this.f$0 = this;
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: lambda$new$1$com-google-firebase-firestore-auth-FirebaseAppCheckTokenProvider, reason: not valid java name */
|
|
public final /* synthetic */ void m171x16263f8b(Provider provider) {
|
|
synchronized (this) {
|
|
InternalAppCheckTokenProvider internalAppCheckTokenProvider = (InternalAppCheckTokenProvider) provider.get();
|
|
this.internalAppCheckTokenProvider = internalAppCheckTokenProvider;
|
|
if (internalAppCheckTokenProvider != null) {
|
|
internalAppCheckTokenProvider.addAppCheckTokenListener(this.tokenListener);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.google.firebase.firestore.auth.CredentialsProvider
|
|
public final Task<String> getToken() {
|
|
synchronized (this) {
|
|
InternalAppCheckTokenProvider internalAppCheckTokenProvider = this.internalAppCheckTokenProvider;
|
|
if (internalAppCheckTokenProvider == null) {
|
|
return Tasks.forException(new FirebaseApiNotAvailableException("AppCheck is not available"));
|
|
}
|
|
Task<AppCheckTokenResult> token = internalAppCheckTokenProvider.getToken(this.forceRefresh);
|
|
this.forceRefresh = false;
|
|
return token.continueWithTask(Executors.DIRECT_EXECUTOR, new Continuation() { // from class: com.google.firebase.firestore.auth.FirebaseAppCheckTokenProvider$$ExternalSyntheticLambda2
|
|
@Override // com.google.android.gms.tasks.Continuation
|
|
public final Object then(Task task) {
|
|
return FirebaseAppCheckTokenProvider.lambda$getToken$2(task);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static /* synthetic */ Task lambda$getToken$2(Task task) throws Exception {
|
|
if (task.isSuccessful()) {
|
|
return Tasks.forResult(((AppCheckTokenResult) task.getResult()).getToken());
|
|
}
|
|
return Tasks.forException(task.getException());
|
|
}
|
|
|
|
@Override // com.google.firebase.firestore.auth.CredentialsProvider
|
|
public final void invalidateToken() {
|
|
synchronized (this) {
|
|
this.forceRefresh = true;
|
|
}
|
|
}
|
|
|
|
@Override // com.google.firebase.firestore.auth.CredentialsProvider
|
|
public final void setChangeListener(Listener<String> listener) {
|
|
synchronized (this) {
|
|
this.changeListener = listener;
|
|
}
|
|
}
|
|
}
|