Picsart v24.6版本的 MD5 值为:21a61631d94e54da68d2ad9268b8b9d9
以下内容为反编译后的 f.java 源代码,内容仅作参考
package com.snapchat.kit.sdk;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.text.TextUtils;
import android.util.Base64;
import androidx.annotation.NonNull;
import com.google.gson.Gson;
import com.snapchat.kit.sdk.a.a;
import com.snapchat.kit.sdk.core.controller.OAuthFailureReason;
import com.snapchat.kit.sdk.core.metrics.model.KitPluginType;
import com.snapchat.kit.sdk.core.metrics.model.OpMetric;
import com.snapchat.kit.sdk.core.metrics.model.ServerEvent;
import com.snapchat.kit.sdk.core.models.AuthToken;
import com.snapchat.kit.sdk.core.models.AuthorizationRequest;
import com.snapchat.kit.sdk.core.security.SecureSharedPreferences;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import myobfuscated.cf2.g;
import myobfuscated.cf2.j;
import myobfuscated.ef2.h;
import myobfuscated.ef2.i;
import myobfuscated.ff2.b;
import myobfuscated.ko2.n;
import myobfuscated.lf2.d;
import myobfuscated.th.r;
import okhttp3.f;
import okhttp3.k;
import okhttp3.p;
import okhttp3.q;
public final class f implements myobfuscated.lf2.a, d {
public static final Set<String> s = new HashSet<String>() {
{
add("invalid_grant");
add("invalid_request");
add("invalid_scope");
add("unsupported_grant_type");
}
};
public final String a;
public final String b;
public final List<String> c;
public final Context d;
public final i e;
public final n f;
public final myobfuscated.ak2.a<myobfuscated.lf2.i> g;
public final Gson h;
public final myobfuscated.ak2.a<b<ServerEvent>> i;
public final myobfuscated.if2.f j;
public final com.snapchat.kit.sdk.a.a k;
public final KitPluginType l;
public final boolean m;
public AuthorizationRequest n;
public final g o;
public final AtomicBoolean p = new AtomicBoolean(false);
public int q = 0;
public boolean r;
public static class a extends AsyncTask<Void, Void, Void> {
public final WeakReference<f> a;
public a(f fVar) {
this.a = new WeakReference<>(fVar);
}
@Override
public final Void doInBackground(Void[] voidArr) {
f fVar = this.a.get();
if (fVar == null) {
return null;
}
fVar.g();
return null;
}
}
public static final class c {
public static final int a = 1;
public static final int b = 2;
public static final int c = 3;
public static final int d = 4;
public static final int e = 5;
public static final int f = 6;
public static final int[] g = {1, 2, 3, 4, 5, 6};
public static int[] a() {
return (int[]) g.clone();
}
}
public f(String str, String str2, List<String> list, Context context, SecureSharedPreferences secureSharedPreferences, j jVar, i iVar, n nVar, myobfuscated.ak2.a<myobfuscated.lf2.i> aVar, Gson gson, myobfuscated.ak2.a<b<ServerEvent>> aVar2, myobfuscated.if2.f fVar, myobfuscated.ak2.a<b<OpMetric>> aVar3, KitPluginType kitPluginType, boolean z) {
this.a = str;
this.b = str2;
this.c = list;
this.d = context;
this.e = iVar;
this.f = nVar;
this.g = aVar;
this.h = gson;
this.i = aVar2;
this.j = fVar;
this.k = new com.snapchat.kit.sdk.a.a(aVar3);
g gVar = new g(secureSharedPreferences, jVar);
this.o = gVar;
this.l = kitPluginType;
this.m = z;
synchronized (gVar) {
if (gVar.a != null) {
if (!gVar.a.isComplete()) {
new a(this).execute(new Void[0]);
}
}
}
}
public static k d(@NonNull okhttp3.f fVar) {
k.a aVar = new k.a();
aVar.d("Content-Type", "application/x-www-form-urlencoded");
aVar.j(String.format("%s%s", "https://accounts.snapchat.com", "/accounts/oauth2/token"));
aVar.g(fVar);
return aVar.b();
}
@Override
public final void a() {
this.r = true;
f(new r());
}
@Override
public final void b() {
this.r = false;
f(new r());
}
public final String c() {
g gVar = this.o;
synchronized (gVar) {
if (gVar.a == null) {
return null;
}
return gVar.a.getAccessToken();
}
}
public final void e(OAuthFailureReason oAuthFailureReason) {
this.i.get().a(this.j.c(false, true));
i iVar = this.e;
iVar.getClass();
iVar.d.post(new h(iVar, oAuthFailureReason));
}
public final void f(@NonNull r rVar) {
String str;
String str2 = this.b;
if (TextUtils.isEmpty(str2)) {
throw new IllegalStateException("Redirect URL must be set!");
}
List<String> list = this.c;
if (list == null || list.isEmpty()) {
throw new IllegalStateException("Valid scopes must be set");
}
boolean z = this.r;
byte[] bArr = new byte[32];
new SecureRandom().nextBytes(bArr);
String encodeToString = Base64.encodeToString(bArr, 11);
byte[] bArr2 = new byte[32];
new SecureRandom().nextBytes(bArr2);
String encodeToString2 = Base64.encodeToString(bArr2, 11);
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
messageDigest.update(encodeToString.getBytes("US-ASCII"));
str = Base64.encodeToString(messageDigest.digest(), 11);
} catch (Exception unused) {
str = encodeToString;
}
AuthorizationRequest withIsForFirebaseAuthentication = new AuthorizationRequest().withResponseType("code").withClientId(this.a).withScope(TextUtils.join(" ", list)).withRedirectUri(str2).withCodeChallengeMethod("S256").withCodeVerifier(encodeToString).withCodeChallenge(str).withState(encodeToString2).withFeatures(rVar.b ? "com.snapchat.snap-kit.feature.toggle.profile-link" : null).withKitPluginType(this.l).withSdkIsFromReactNativePlugin(this.m).withIsForFirebaseAuthentication(z);
this.n = withIsForFirebaseAuthentication;
Context context = this.d;
PackageManager packageManager = context.getPackageManager();
int i = this.q;
com.snapchat.kit.sdk.a.a aVar = this.k;
myobfuscated.if2.f fVar = this.j;
myobfuscated.ak2.a<b<ServerEvent>> aVar2 = this.i;
if (i < 3 && myobfuscated.wf2.a.a(packageManager)) {
Intent intent = new Intent("android.intent.action.VIEW", withIsForFirebaseAuthentication.toUri("snapchat://", "oauth2", context.getPackageName(), null));
intent.setPackage("com.snapchat.android");
intent.setFlags(268435456);
if (intent.resolveActivity(packageManager) != null) {
context.startActivity(intent);
if (this.r) {
aVar.c("authSnapchatForFirebase");
} else {
aVar.c("authSnapchat");
}
aVar2.get().a(fVar.b(rVar, this.r));
this.q++;
return;
}
}
Uri uri = withIsForFirebaseAuthentication.toUri("https://accounts.snapchat.com/accounts", "/oauth2/auth", null, "snapkit_web");
if (this.r) {
aVar.c("authWebForFirebase");
} else {
aVar.c("authWeb");
}
try {
Intent intent2 = new Intent("android.intent.action.VIEW", uri);
intent2.setFlags(268435456);
context.startActivity(intent2);
} catch (Exception unused2) {
}
aVar2.get().a(fVar.b(rVar, this.r));
}
@NonNull
public final int g() {
p execute;
q qVar;
myobfuscated.kf2.c cVar;
Gson gson;
AuthToken authToken;
g gVar = this.o;
String b = gVar.b();
if (b == null) {
return c.a;
}
f.a aVar = new f.a();
aVar.a("grant_type", "refresh_token");
aVar.a("refresh_token", b);
aVar.a("client_id", this.a);
k d = d(new okhttp3.f(aVar.b, aVar.c));
AtomicBoolean atomicBoolean = this.p;
if (atomicBoolean.compareAndSet(false, true)) {
a.EnumC0861a enumC0861a = a.EnumC0861a.REFRESH;
com.snapchat.kit.sdk.a.a aVar2 = this.k;
aVar2.a(enumC0861a);
int i = c.e;
try {
try {
execute = this.f.a(d).execute();
boolean d2 = execute.d();
qVar = execute.g;
cVar = null;
gson = this.h;
authToken = (!d2 || qVar == null || qVar.charStream() == null) ? null : (AuthToken) gson.fromJson(qVar.charStream(), (Class<Object>) AuthToken.class);
} catch (IOException unused) {
i = c.d;
}
if (authToken != null) {
if (TextUtils.isEmpty(authToken.getRefreshToken())) {
authToken.setRefreshToken(gVar.b());
}
authToken.setLastUpdated(System.currentTimeMillis());
if (authToken.isComplete()) {
gVar.a(authToken);
aVar2.b(enumC0861a, true);
atomicBoolean.set(false);
return i;
}
}
if (!execute.d() && execute.d == 400) {
cVar = (myobfuscated.kf2.c) gson.fromJson(qVar.charStream(), (Class<Object>) myobfuscated.kf2.c.class);
}
if (cVar != null && !TextUtils.isEmpty(cVar.a())) {
if (((HashSet) s).contains(cVar.a().toLowerCase())) {
gVar.c();
}
}
aVar2.b(enumC0861a, false);
i = c.b;
atomicBoolean.set(false);
return i;
} catch (Throwable th) {
atomicBoolean.set(false);
throw th;
}
}
return c.c;
}
public final void h() {
g gVar = this.o;
boolean z = !TextUtils.isEmpty(gVar.b());
gVar.c();
if (z) {
i iVar = this.e;
iVar.getClass();
iVar.d.post(new myobfuscated.ef2.f(iVar));
}
}
public final void i() {
this.i.get().a(this.j.c(false, false));
i iVar = this.e;
iVar.getClass();
iVar.d.post(new myobfuscated.ef2.d(iVar));
}
public final String j() {
g gVar = this.o;
synchronized (gVar) {
if (gVar.a != null && !gVar.a.isExpired() && !gVar.a.willBeExpiredAfter(300000L)) {
return gVar.a.getAccessToken();
}
return null;
}
}
public final boolean k() {
return !TextUtils.isEmpty(this.o.b());
}
}