导航菜单

页面标题

页面副标题

Sandridge Go v2025.2.170190457 - c.java 源代码

正在查看: Sandridge Go v2025.2.170190457 应用的 c.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package V4;

import J3.AbstractC0450q;
import P3.g;
import Q4.c;
import V4.d;
import V4.e;
import X4.h;
import android.content.Context;
import android.content.pm.PackageManager;
import android.util.JsonReader;
import android.util.Log;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.regex.Pattern;
import java.util.zip.GZIPOutputStream;
import org.json.JSONException;
import org.json.JSONObject;

public class c {

    private static final Pattern f5443d = Pattern.compile("[0-9]+s");

    private static final Charset f5444e = Charset.forName("UTF-8");

    private final Context f5445a;

    private final h f5446b;

    private final Q4.c f5447c;

    public c(Context context, h hVar, Q4.c cVar) {
        this.f5445a = context;
        this.f5446b = hVar;
        this.f5447c = cVar;
    }

    private static JSONObject a(String str, String str2) {
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("fid", str);
        jSONObject.put("appId", str2);
        jSONObject.put("authVersion", "FIS_v2");
        jSONObject.put("sdkVersion", "a:16.2.1");
        return jSONObject;
    }

    private static JSONObject b() {
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("sdkVersion", "a:16.2.1");
        JSONObject jSONObject2 = new JSONObject();
        jSONObject2.put("installation", jSONObject);
        return jSONObject2;
    }

    private String e() {
        try {
            Context context = this.f5445a;
            byte[] a6 = P3.a.a(context, context.getPackageName());
            if (a6 != null) {
                return g.a(a6, false);
            }
            Log.e("ContentValues", "Could not get fingerprint hash for package: " + this.f5445a.getPackageName());
            return null;
        } catch (PackageManager.NameNotFoundException e6) {
            Log.e("ContentValues", "No such package: " + this.f5445a.getPackageName(), e6);
            return null;
        }
    }

    private HttpURLConnection f(URL url, String str) {
        c.a a6;
        HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
        httpURLConnection.setConnectTimeout(10000);
        httpURLConnection.setReadTimeout(10000);
        httpURLConnection.addRequestProperty("Content-Type", "application/json");
        httpURLConnection.addRequestProperty("Accept", "application/json");
        httpURLConnection.addRequestProperty("Content-Encoding", "gzip");
        httpURLConnection.addRequestProperty("X-Android-Package", this.f5445a.getPackageName());
        Q4.c cVar = this.f5447c;
        if (cVar != null && this.f5446b != null && (a6 = cVar.a("fire-installations-id")) != c.a.NONE) {
            httpURLConnection.addRequestProperty("x-firebase-client", this.f5446b.a());
            httpURLConnection.addRequestProperty("x-firebase-client-log-type", Integer.toString(a6.a()));
        }
        httpURLConnection.addRequestProperty("X-Android-Cert", e());
        httpURLConnection.addRequestProperty("x-goog-api-key", str);
        return httpURLConnection;
    }

    static long g(String str) {
        AbstractC0450q.b(f5443d.matcher(str).matches(), "Invalid Expiration Timestamp.");
        if (str == null || str.length() == 0) {
            return 0L;
        }
        return Long.parseLong(str.substring(0, str.length() - 1));
    }

    private d h(HttpURLConnection httpURLConnection) {
        JsonReader jsonReader = new JsonReader(new InputStreamReader(httpURLConnection.getInputStream(), f5444e));
        e.a a6 = e.a();
        d.a a7 = d.a();
        jsonReader.beginObject();
        while (jsonReader.hasNext()) {
            String nextName = jsonReader.nextName();
            if (nextName.equals("name")) {
                a7.f(jsonReader.nextString());
            } else if (nextName.equals("fid")) {
                a7.c(jsonReader.nextString());
            } else if (nextName.equals("refreshToken")) {
                a7.d(jsonReader.nextString());
            } else if (nextName.equals("authToken")) {
                jsonReader.beginObject();
                while (jsonReader.hasNext()) {
                    String nextName2 = jsonReader.nextName();
                    if (nextName2.equals("token")) {
                        a6.c(jsonReader.nextString());
                    } else if (nextName2.equals("expiresIn")) {
                        a6.d(g(jsonReader.nextString()));
                    } else {
                        jsonReader.skipValue();
                    }
                }
                a7.b(a6.a());
                jsonReader.endObject();
            } else {
                jsonReader.skipValue();
            }
        }
        jsonReader.endObject();
        jsonReader.close();
        return a7.e(d.b.OK).a();
    }

    private e i(HttpURLConnection httpURLConnection) {
        JsonReader jsonReader = new JsonReader(new InputStreamReader(httpURLConnection.getInputStream(), f5444e));
        e.a a6 = e.a();
        jsonReader.beginObject();
        while (jsonReader.hasNext()) {
            String nextName = jsonReader.nextName();
            if (nextName.equals("token")) {
                a6.c(jsonReader.nextString());
            } else if (nextName.equals("expiresIn")) {
                a6.d(g(jsonReader.nextString()));
            } else {
                jsonReader.skipValue();
            }
        }
        jsonReader.endObject();
        jsonReader.close();
        return a6.b(e.b.OK).a();
    }

    private void j(HttpURLConnection httpURLConnection, String str, String str2) {
        OutputStream outputStream = httpURLConnection.getOutputStream();
        if (outputStream == null) {
            throw new IOException("Cannot send CreateInstallation request to FIS. No OutputStream available.");
        }
        GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(outputStream);
        try {
            try {
                gZIPOutputStream.write(a(str, str2).toString().getBytes("UTF-8"));
            } catch (JSONException e6) {
                throw new IllegalStateException(e6);
            }
        } finally {
            gZIPOutputStream.close();
        }
    }

    private void k(HttpURLConnection httpURLConnection) {
        OutputStream outputStream = httpURLConnection.getOutputStream();
        if (outputStream == null) {
            throw new IOException("Cannot send GenerateAuthToken request to FIS. No OutputStream available.");
        }
        GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(outputStream);
        try {
            try {
                gZIPOutputStream.write(b().toString().getBytes("UTF-8"));
            } catch (JSONException e6) {
                throw new IllegalStateException(e6);
            }
        } finally {
            gZIPOutputStream.close();
        }
    }

    public d c(String str, String str2, String str3, String str4, String str5) {
        URL url = new URL(String.format("https://%s/%s/%s", "firebaseinstallations.googleapis.com", "v1", String.format("projects/%s/installations", str3)));
        int i5 = 0;
        while (i5 <= 1) {
            HttpURLConnection f6 = f(url, str);
            try {
                f6.setRequestMethod("POST");
                f6.setDoOutput(true);
                if (str5 != null) {
                    f6.addRequestProperty("x-goog-fis-android-iid-migration-auth", str5);
                }
                j(f6, str2, str4);
                int responseCode = f6.getResponseCode();
                if (responseCode == 200) {
                    d h5 = h(f6);
                    f6.disconnect();
                    return h5;
                }
                if (responseCode != 429 && (responseCode < 500 || responseCode >= 600)) {
                    d a6 = d.a().e(d.b.BAD_CONFIG).a();
                    f6.disconnect();
                    return a6;
                }
                i5++;
                f6.disconnect();
            } catch (Throwable th) {
                f6.disconnect();
                throw th;
            }
        }
        throw new IOException();
    }

    public e d(String str, String str2, String str3, String str4) {
        URL url = new URL(String.format("https://%s/%s/%s", "firebaseinstallations.googleapis.com", "v1", String.format("projects/%s/installations/%s/authTokens:generate", str3, str2)));
        int i5 = 0;
        while (i5 <= 1) {
            HttpURLConnection f6 = f(url, str);
            try {
                f6.setRequestMethod("POST");
                f6.addRequestProperty("Authorization", "FIS_v2 " + str4);
                k(f6);
                int responseCode = f6.getResponseCode();
                if (responseCode == 200) {
                    return i(f6);
                }
                if (responseCode == 401 || responseCode == 404) {
                    return e.a().b(e.b.AUTH_ERROR).a();
                }
                if (responseCode != 429 && (responseCode < 500 || responseCode >= 600)) {
                    return e.a().b(e.b.BAD_CONFIG).a();
                }
                i5++;
            } finally {
                f6.disconnect();
            }
        }
        throw new IOException();
    }
}