WeChat.apk(点击下载) / a.java


package nm4;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import jm4.b;
import mm4.c;
import mm4.d;
import mm4.e;
import mm4.g;
import mm4.h;
import mm4.i;
import mm4.j;
import mm4.k;

public class a implements b {

    /* renamed from: c  reason: collision with root package name */
    public static /* synthetic */ int[] f272256c;

    /* renamed from: a  reason: collision with root package name */
    public mm4.a f272257a;

    /* renamed from: b  reason: collision with root package name */
    public b f272258b;

    public a(b bVar, mm4.a aVar) {
        this.f272258b = bVar;
        this.f272257a = aVar;
    }

    public final void a(c cVar, i iVar) {
        this.f272258b.getClass();
        cVar.d("oauth_timestamp", String.valueOf(Long.valueOf(Long.valueOf(System.currentTimeMillis()).longValue() / 1000)));
        this.f272258b.getClass();
        cVar.d("oauth_nonce", String.valueOf(Long.valueOf(Long.valueOf(System.currentTimeMillis()).longValue() / 1000).longValue() + ((long) Integer.valueOf(new Random().nextInt()).intValue())));
        cVar.d("oauth_consumer_key", this.f272257a.f266348a);
        this.f272258b.getClass();
        cVar.d("oauth_signature_method", "HMAC-SHA1");
        cVar.d("oauth_version", "1.0");
        this.f272257a.getClass();
        this.f272257a.a("generating signature...");
        this.f272258b.getClass();
        pm4.c.b(cVar, "Cannot extract base string from null object");
        Map<String, String> map = cVar.f266352g;
        if (map == null || ((HashMap) map).size() <= 0) {
            throw new km4.c(cVar);
        }
        String b15 = pm4.b.b(cVar.f266357b.name());
        String str = "";
        String b16 = pm4.b.b(cVar.f266356a.replaceAll("\\?.*", str).replace("\\:\\d{4}", str));
        ArrayList arrayList = new ArrayList();
        try {
            ArrayList arrayList2 = new ArrayList();
            String query = new URL(cVar.f266356a).getQuery();
            if (query != null && query.length() > 0) {
                for (String str2 : query.split("&")) {
                    String[] split = str2.split("=");
                    arrayList2.add(new d(pm4.b.a(split[0]), split.length > 1 ? pm4.b.a(split[1]) : str));
                }
            }
            arrayList2.addAll(cVar.f266358c.f266355a);
            arrayList.addAll(arrayList2);
            arrayList.addAll(cVar.f266359d.f266355a);
            Map<String, String> map2 = cVar.f266352g;
            ArrayList arrayList3 = new ArrayList();
            for (Map.Entry entry : ((HashMap) map2).entrySet()) {
                arrayList3.add(new d((String) entry.getKey(), (String) entry.getValue()));
            }
            arrayList.addAll(arrayList3);
            e eVar = new e(arrayList);
            Collections.sort(eVar.f266355a);
            String format = String.format("%s&%s&%s", b15, b16, pm4.b.b(eVar.a()));
            this.f272258b.getClass();
            om4.a aVar = new om4.a();
            String str3 = this.f272257a.f266349b;
            String str4 = iVar.f266368e;
            try {
                pm4.c.a(format, "Base string cant be null or empty string");
                pm4.c.a(str3, "Api secret cant be null or empty string");
                String a15 = aVar.a(format, String.valueOf(pm4.b.b(str3)) + '&' + pm4.b.b(str4));
                this.f272257a.a("base string is: " + format);
                this.f272257a.a("signature is: " + a15);
                cVar.d("oauth_signature", a15);
                mm4.a aVar2 = this.f272257a;
                StringBuilder sb5 = new StringBuilder("appended additional OAuth parameters: ");
                Map<String, String> map3 = cVar.f266352g;
                if (map3 != null) {
                    HashMap hashMap = (HashMap) map3;
                    if (hashMap.isEmpty()) {
                        str = "{}";
                    } else {
                        StringBuilder sb6 = new StringBuilder();
                        for (Map.Entry entry2 : hashMap.entrySet()) {
                            sb6.append(String.format(", %s -> %s ", entry2.getKey().toString(), entry2.getValue().toString()));
                        }
                        str = "{" + sb6.substring(1) + "}";
                    }
                }
                sb5.append(str);
                aVar2.a(sb5.toString());
            } catch (Exception e15) {
                throw new km4.d(format, e15);
            }
        } catch (MalformedURLException e16) {
            throw new km4.b("Malformed URL", e16);
        }
    }

    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing exception handler attribute for start block: B:5:0x0011 */
    public final void b(c cVar) {
        int[] iArr = f272256c;
        if (iArr == null) {
            iArr = new int[h.values().length];
            iArr[0] = 1;
            try {
                iArr[1] = 2;
            } catch (NoSuchFieldError unused) {
            }
            f272256c = iArr;
        }
        this.f272257a.getClass();
        int i15 = iArr[0];
        if (i15 == 1) {
            this.f272257a.a("using Http Header signature");
            this.f272258b.getClass();
            pm4.c.b(cVar, "Cannot extract a header from a null object");
            Map<String, String> map = cVar.f266352g;
            if (map == null || ((HashMap) map).size() <= 0) {
                throw new km4.c(cVar);
            }
            HashMap hashMap = (HashMap) cVar.f266352g;
            StringBuffer stringBuffer = new StringBuffer(hashMap.size() * 20);
            stringBuffer.append("OAuth ");
            for (String str : hashMap.keySet()) {
                if (stringBuffer.length() > 6) {
                    stringBuffer.append(", ");
                }
                stringBuffer.append(String.format("%s=\"%s\"", str, pm4.b.b((String) hashMap.get(str))));
            }
            ((HashMap) cVar.f266360e).put("Authorization", stringBuffer.toString());
        } else if (i15 == 2) {
            this.f272257a.a("using Querystring signature");
            for (Map.Entry entry : ((HashMap) cVar.f266352g).entrySet()) {
                ((ArrayList) cVar.f266358c.f266355a).add(new d((String) entry.getKey(), (String) entry.getValue()));
            }
        }
    }

    public i c(i iVar, k kVar) {
        mm4.a aVar = this.f272257a;
        this.f272258b.getClass();
        aVar.getClass();
        this.f272258b.getClass();
        j jVar = j.f266370e;
        this.f272258b.getClass();
        c cVar = new c(jVar, "https://api.twitter.com/oauth/access_token");
        cVar.d("oauth_token", iVar.f266367d);
        cVar.d("oauth_verifier", kVar.f266373a);
        mm4.a aVar2 = this.f272257a;
        iVar.toString();
        aVar2.getClass();
        a(cVar, iVar);
        b(cVar);
        g c15 = cVar.c();
        this.f272258b.getClass();
        lm4.a aVar3 = new lm4.a();
        String a15 = c15.a();
        pm4.c.a(a15, "Response body is incorrect. Can't extract a token from an empty string");
        return new i(aVar3.a(a15, lm4.a.f254207a), aVar3.a(a15, lm4.a.f254208b), a15);
    }

    public String d(i iVar) {
        ((jm4.c) this.f272258b).getClass();
        return String.format("https://api.twitter.com/oauth/authorize?oauth_token=%s", iVar.f266367d);
    }

    public i e() {
        mm4.a aVar = this.f272257a;
        this.f272258b.getClass();
        aVar.getClass();
        this.f272258b.getClass();
        j jVar = j.f266370e;
        this.f272258b.getClass();
        c cVar = new c(jVar, "https://api.twitter.com/oauth/request_token");
        mm4.a aVar2 = this.f272257a;
        String str = this.f272257a.f266350c;
        aVar2.getClass();
        cVar.d("oauth_callback", this.f272257a.f266350c);
        a(cVar, mm4.b.f266351a);
        b(cVar);
        this.f272257a.getClass();
        String a15 = cVar.c().a();
        this.f272257a.getClass();
        this.f272257a.getClass();
        this.f272258b.getClass();
        lm4.a aVar3 = new lm4.a();
        pm4.c.a(a15, "Response body is incorrect. Can't extract a token from an empty string");
        return new i(aVar3.a(a15, lm4.a.f254207a), aVar3.a(a15, lm4.a.f254208b), a15);
    }
}