SquirrelVPN.apk(点击下载) / cl.java


package com.flurry.sdk;

import android.net.TrafficStats;
import android.os.Build;
import android.text.TextUtils;
import com.flurry.sdk.cb;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import java.util.UUID;
import javax.net.ssl.HttpsURLConnection;

public final class cl extends co {
    private static String i;
    private HttpsURLConnection j;
    private String k;
    private boolean l;

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

    /* access modifiers changed from: protected */
    /* JADX WARNING: Removed duplicated region for block: B:28:0x0117  */
    /* JADX WARNING: Removed duplicated region for block: B:30:0x011c  */
    @Override // com.flurry.sdk.co
    public final InputStream a() throws IOException {
        BufferedWriter bufferedWriter;
        OutputStream outputStream;
        Throwable th;
        HttpsURLConnection httpsURLConnection = (HttpsURLConnection) new URL(this.a).openConnection();
        this.j = httpsURLConnection;
        httpsURLConnection.setReadTimeout(10000);
        this.j.setConnectTimeout(15000);
        this.j.setRequestMethod("POST");
        this.j.setRequestProperty("User-Agent", i);
        this.j.setRequestProperty("Content-Type", "application/json");
        this.j.setDoInput(true);
        this.j.setDoOutput(true);
        TrafficStats.setThreadStatsTag(1234);
        this.j.connect();
        df.a(this.j);
        this.c = UUID.randomUUID().toString().toUpperCase(Locale.ENGLISH);
        try {
            outputStream = this.j.getOutputStream();
            try {
                bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
            } catch (Throwable th2) {
                bufferedWriter = null;
                th = th2;
                if (bufferedWriter != null) {
                }
                if (outputStream != null) {
                }
                throw th;
            }
            try {
                bufferedWriter.write(cn.a(this.c));
                bufferedWriter.close();
                if (outputStream != null) {
                    outputStream.close();
                }
                int responseCode = this.j.getResponseCode();
                if (responseCode < 400) {
                    this.k = this.j.getHeaderField("Content-Signature");
                    this.g = this.j.getHeaderField("ETag");
                    cx.a("HttpTransport", "Content-Signature: " + this.k + ", ETag: " + this.g);
                    if (responseCode == 304) {
                        if (a(this.c)) {
                            this.b = cb.b;
                            cx.a("HttpTransport", "Empty 304 payload; No Change.");
                        } else {
                            this.b = new cb(cb.a.AUTHENTICATE, "GUID Signature Error.");
                            cx.b("HttpTransport", "Authentication error: " + this.b);
                        }
                    }
                    return this.j.getInputStream();
                }
                throw new IOException("Server response code is ".concat(String.valueOf(responseCode)));
            } catch (Throwable th3) {
                th = th3;
                if (bufferedWriter != null) {
                }
                if (outputStream != null) {
                }
                throw th;
            }
        } catch (Throwable th4) {
            bufferedWriter = null;
            th = th4;
            outputStream = null;
            if (bufferedWriter != null) {
                bufferedWriter.close();
            }
            if (outputStream != null) {
                outputStream.close();
            }
            throw th;
        }
    }

    /* access modifiers changed from: protected */
    @Override // com.flurry.sdk.co
    public final void b() {
        HttpsURLConnection httpsURLConnection = this.j;
        if (httpsURLConnection != null) {
            httpsURLConnection.disconnect();
        }
    }

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

    /* access modifiers changed from: protected */
    @Override // com.flurry.sdk.co
    public final boolean a(String str) {
        boolean z;
        if (!b(this.k)) {
            return false;
        }
        if (this.l) {
            z = cq.c(this.e, str, this.f);
        } else {
            z = cq.b(this.e, str, this.f);
        }
        if (z) {
            return true;
        }
        cx.b("HttpTransport", "Incorrect signature for response.");
        return false;
    }

    private boolean b(String str) {
        if (TextUtils.isEmpty(str)) {
            cx.b("HttpTransport", "Content-Signature is empty.");
            return false;
        }
        HashMap hashMap = new HashMap();
        String[] split = str.split(";");
        for (String str2 : split) {
            int indexOf = str2.indexOf("=");
            if (indexOf > 0) {
                hashMap.put(str2.substring(0, indexOf), str2.substring(indexOf + 1));
            }
        }
        this.d = (String) hashMap.get("keyid");
        if (TextUtils.isEmpty(this.d)) {
            cx.b("HttpTransport", "Error to get keyid from Signature.");
            return false;
        }
        this.e = cr.a.get(this.d);
        cx.a("HttpTransport", "Signature keyid: " + this.d + ", key: " + this.e);
        if (this.e == null) {
            cx.b("HttpTransport", "Unknown keyid from Signature.");
            return false;
        }
        String str3 = "sha256ecdsa";
        boolean containsKey = hashMap.containsKey(str3);
        this.l = containsKey;
        if (!containsKey) {
            str3 = "sha256rsa";
        }
        this.f = (String) hashMap.get(str3);
        if (TextUtils.isEmpty(this.f)) {
            cx.b("HttpTransport", "Error to get rsa from Signature.");
            return false;
        }
        cx.a("HttpTransport", "Signature rsa: " + this.f);
        return true;
    }
}