Wolves Themes v1.0版本的 MD5 值为:cddc92b47f6b7c4a195c9625507eb51c

以下内容为反编译后的 t.java 源代码,内容仅作参考


package com.flurry.sdk;

import android.os.Build;
import android.text.TextUtils;
import android.util.Base64;
import com.amazon.device.ads.WebRequest;
import com.flurry.sdk.l;
import com.ironsource.sdk.constants.Constants;
import com.tapjoy.TapjoyConstants;
import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.security.KeyFactory;
import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.Signature;
import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap;
import java.util.Locale;
import java.util.UUID;
import javax.net.ssl.HttpsURLConnection;
public class t extends w {
    private static final String g = "t";
    private static String h;
    private HttpsURLConnection i;
    private String j;

    public t(String str) {
        this.a = str;
        h = "Flurry-Config/1.0 (Android " + Build.VERSION.RELEASE + "/" + Build.ID + ")";
    }

    @Override
    protected final InputStream a() throws IOException {
        OutputStream outputStream;
        this.i = (HttpsURLConnection) new URL(this.a).openConnection();
        this.i.setReadTimeout(10000);
        this.i.setConnectTimeout(15000);
        this.i.setRequestMethod("POST");
        this.i.setRequestProperty("User-Agent", h);
        this.i.setRequestProperty("Content-Type", WebRequest.CONTENT_TYPE_JSON);
        this.i.setDoInput(true);
        this.i.setDoOutput(true);
        this.c = UUID.randomUUID().toString().toUpperCase(Locale.ENGLISH);
        BufferedWriter bufferedWriter = null;
        try {
            outputStream = this.i.getOutputStream();
            try {
                BufferedWriter bufferedWriter2 = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
                try {
                    bufferedWriter2.write(v.a(this.c));
                    bufferedWriter2.close();
                    if (outputStream != null) {
                        outputStream.close();
                    }
                    int responseCode = this.i.getResponseCode();
                    if (responseCode >= 400) {
                        throw new IOException("Server response code is " + responseCode);
                    }
                    if (responseCode == 304) {
                        String headerField = this.i.getHeaderField(TapjoyConstants.TJC_GUID);
                        if (!this.c.equals(headerField)) {
                            this.b = new l(l.a.AUTHENTICATE, "Guid: " + this.c + ", payload: " + headerField);
                            String str = g;
                            StringBuilder sb = new StringBuilder("Authentication error: ");
                            sb.append(this.b);
                            kx.b(str, sb.toString());
                        } else {
                            this.b = l.b;
                            kx.a(g, "Empty payload; No Change.");
                        }
                    }
                    this.j = this.i.getHeaderField("Content-Signature");
                    this.e = this.i.getHeaderField("ETag");
                    if (this.e != null && this.e.startsWith("\"") && this.e.endsWith("\"")) {
                        this.e = this.e.substring(1, this.e.length() - 1);
                    }
                    kx.a(g, "Content-Signature: " + this.j + ", ETag: " + this.e);
                    return this.i.getInputStream();
                } catch (Throwable th) {
                    th = th;
                    bufferedWriter = bufferedWriter2;
                    if (bufferedWriter != null) {
                        bufferedWriter.close();
                    }
                    if (outputStream != null) {
                        outputStream.close();
                    }
                    throw th;
                }
            } catch (Throwable th2) {
                th = th2;
            }
        } catch (Throwable th3) {
            th = th3;
            outputStream = null;
        }
    }

    @Override
    protected final void b() {
        if (this.i != null) {
            this.i.disconnect();
        }
    }

    @Override
    public final boolean c() {
        return "https://cfg.flurry.com/sdk/v1/config".equals(this.a);
    }

    @Override
    protected final boolean a(ByteArrayOutputStream byteArrayOutputStream) {
        String[] split;
        boolean a;
        if (TextUtils.isEmpty(this.j)) {
            kx.b(g, "Content-Signature is empty.");
            return false;
        }
        HashMap hashMap = new HashMap();
        for (String str : this.j.split(";")) {
            int indexOf = str.indexOf(Constants.RequestParameters.EQUAL);
            if (indexOf > 0) {
                hashMap.put(str.substring(0, indexOf), str.substring(indexOf + 1));
            }
        }
        String str2 = (String) hashMap.get("keyid");
        if (TextUtils.isEmpty(str2)) {
            kx.b(g, "Error to get keyid from Signature.");
            return false;
        }
        this.d = y.a.get(str2);
        kx.a(g, "Signature keyid: " + str2 + ", key: " + this.d);
        if (this.d == null) {
            kx.b(g, "Unknown keyid from Signature.");
            return false;
        }
        boolean containsKey = hashMap.containsKey("sha256ecdsa");
        String str3 = (String) hashMap.get(containsKey ? "sha256ecdsa" : "sha256rsa");
        if (TextUtils.isEmpty(str3)) {
            kx.b(g, "Error to get rsa from Signature.");
            return false;
        }
        kx.a(g, "Signature rsa: " + str3);
        String byteArrayOutputStream2 = byteArrayOutputStream.toString();
        if (containsKey) {
            a = b(this.d, byteArrayOutputStream2, str3);
        } else {
            a = a(this.d, byteArrayOutputStream2, str3);
        }
        if (a) {
            return true;
        }
        kx.b(g, "Incorrect signature for response.");
        return false;
    }

    private static boolean a(String str, String str2, String str3) {
        try {
            PublicKey generatePublic = KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(Base64.decode(str, 0)));
            Signature signature = Signature.getInstance("SHA256withRSA");
            signature.initVerify(generatePublic);
            signature.update(str2.getBytes(z.a));
            return signature.verify(Base64.decode(str3, 0));
        } catch (GeneralSecurityException e) {
            String str4 = g;
            kx.b(str4, "GeneralSecurityException for Signature: " + e);
            return false;
        }
    }

    private static boolean b(String str, String str2, String str3) {
        try {
            PublicKey generatePublic = KeyFactory.getInstance("EC").generatePublic(new X509EncodedKeySpec(Base64.decode(str, 0)));
            Signature signature = Signature.getInstance("SHA256withECDSA");
            signature.initVerify(generatePublic);
            signature.update(str2.getBytes(z.a));
            return signature.verify(Base64.decode(str3, 0));
        } catch (GeneralSecurityException e) {
            String str4 = g;
            kx.b(str4, "GeneralSecurityException for Signature: " + e);
            return false;
        }
    }

    public static boolean d() {
        try {
            KeyFactory.getInstance("EC");
            Signature.getInstance("SHA256withECDSA");
            return true;
        } catch (NoSuchAlgorithmException e) {
            String str = g;
            kx.a(str, "ECDSA encryption is not available: " + e);
            return false;
        }
    }
}