导航菜单

页面标题

页面副标题

Tasker v6.6.3 - f.java 源代码

正在查看: Tasker v6.6.3 应用的 f.java JAVA 源代码文件

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


package mg;

import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import com.joaomgcd.taskerm.net.auth.AuthInfo;
import com.joaomgcd.taskerm.util.b7;
import com.joaomgcd.taskerservercommon.ConstantsCommonTaskerServer;
import ik.l;
import java.net.HttpURLConnection;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import jk.p;
import kotlin.Pair;
import kotlin.collections.m0;
import kotlin.collections.n;
import lg.x;
import org.json.JSONObject;
import sk.q;
import ti.r;
import vj.e0;
import vj.o;
import xg.e2;

public final class f implements mg.b {
    private final Context a;
    private final String b;
    private final String c;
    private final String d;
    private final String e;
    private final String[] f;
    private final j g;
    private final boolean h;

    public static final class a {
        public static final int[] a;

        static {
            int[] iArr = new int[j.values().length];
            try {
                iArr[j.q.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                iArr[j.r.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            a = iArr;
        }
    }

    public static final class b extends i {
        final AuthInfo a;

        b(AuthInfo authInfo) {
            this.a = authInfo;
        }

        @Override
        public void a(HashMap<String, String> hashMap) {
            p.i(hashMap, "headers");
            hashMap.put(this.a.getAuthHeaderKey(), this.a.getAuthHeaderValue());
        }
    }

    public static final class c<T> implements yi.g {
        public static final c<T> a = new c<>();

        @Override
        public final boolean test(Object obj) {
            p.i(obj, "it");
            return obj instanceof mg.a;
        }
    }

    public f(Context context, String str, String str2, String str3, String str4, String[] strArr, j jVar, boolean z) {
        p.i(context, "context");
        p.i(str, "clientId");
        p.i(str2, "clientSecret");
        p.i(str3, "endpointCode");
        p.i(str4, "endpointRefresh");
        p.i(strArr, "scopes");
        p.i(jVar, "tokenDataType");
        this.a = context;
        this.b = str;
        this.c = str2;
        this.d = str3;
        this.e = str4;
        this.f = strArr;
        this.g = jVar;
        this.h = z;
    }

    public static final i h(f fVar, long j) {
        AuthInfo p = fVar.h ? null : fVar.p();
        if (p == null) {
            p = fVar.i(j);
        } else if (p.isExpired()) {
            p = fVar.j(p, j);
        }
        fVar.s(p);
        return new b(p);
    }

    private final com.joaomgcd.taskerm.net.auth.AuthInfo i(long r6) {
        throw new UnsupportedOperationException("Method not decompiled: mg.f.i(long):com.joaomgcd.taskerm.net.auth.AuthInfo");
    }

    private final AuthInfo j(AuthInfo authInfo, long j) {
        try {
            String refreshToken = authInfo.getRefreshToken();
            if (refreshToken == null) {
                return authInfo;
            }
            JSONObject jSONObject = new JSONObject(m(l(refreshToken), true));
            String b2 = b(jSONObject);
            if (b2 != null) {
                refreshToken = b2;
            }
            String a2 = a(jSONObject);
            if (a2 != null) {
                return new AuthInfo(refreshToken, a2, c(jSONObject));
            }
            throw new RuntimeException("Could not get access token");
        } catch (lg.p unused) {
            s(null);
            return i(j);
        }
    }

    private final String k(String str, String str2) {
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("grant_type", "authorization_code");
        jSONObject.put("code", str);
        if (str2 == null) {
            str2 = "https://tasker.joaoapps.com/auth.html";
        }
        jSONObject.put("redirect_uri", str2);
        jSONObject.put("client_id", this.b);
        jSONObject.put("client_secret", this.c);
        int i = a.a[this.g.ordinal()];
        if (i != 1) {
            if (i == 2) {
                return b7.b2(jSONObject);
            }
            throw new o();
        }
        String jSONObject2 = jSONObject.toString();
        p.h(jSONObject2, "toString(...)");
        return jSONObject2;
    }

    private final String l(String str) {
        JSONObject jSONObject = new JSONObject();
        jSONObject.put("grant_type", "refresh_token");
        jSONObject.put("refresh_token", str);
        int i = a.a[this.g.ordinal()];
        if (i != 1) {
            if (i == 2) {
                return b7.b2(jSONObject);
            }
            throw new o();
        }
        String jSONObject2 = jSONObject.toString();
        p.h(jSONObject2, "toString(...)");
        return jSONObject2;
    }

    private final String m(String str, final boolean z) {
        lg.g gVar = new lg.g(str, this.e, null, null, 12, null);
        gVar.w(new l() {
            @Override
            public final Object invoke(Object obj) {
                e0 n;
                n = f.n(z, this, (HttpURLConnection) obj);
                return n;
            }
        });
        return (String) x.l(new lg.e0(gVar), null, 1, null);
    }

    public static final e0 n(boolean z, f fVar, HttpURLConnection httpURLConnection) {
        p.i(httpURLConnection, "it");
        if (z) {
            String d2 = fVar.d(fVar.b, fVar.c);
            p.h(d2, "base64EncodeUserPass(...)");
            b7.s5(httpURLConnection, d2);
        }
        b7.v5(httpURLConnection, fVar.g.d());
        return e0.a;
    }

    private final String o() {
        return n.l0(this.f, " ", null, null, 0, null, null, 62, null);
    }

    private final AuthInfo p() {
        String q = q();
        SharedPreferences a2 = mg.c.a(this.a);
        p.h(a2, "<get-preferencesHttpAuth>(...)");
        String string = a2.getString(q, null);
        return (AuthInfo) (string != null ? eg.f.c().h(string, AuthInfo.class) : null);
    }

    private final String q() {
        return this.b + ConstantsCommonTaskerServer.ID_SEPARATOR + this.c + ConstantsCommonTaskerServer.ID_SEPARATOR + this.d + ConstantsCommonTaskerServer.ID_SEPARATOR + this.e + ConstantsCommonTaskerServer.ID_SEPARATOR + o();
    }

    private final String r(boolean z) {
        HashMap b2;
        List<Pair> t;
        Uri.Builder appendQueryParameter = Uri.parse(this.d).buildUpon().appendQueryParameter("client_id", this.b).appendQueryParameter("response_type", "code");
        String uuid = UUID.randomUUID().toString();
        p.h(uuid, "toString(...)");
        Uri.Builder appendQueryParameter2 = appendQueryParameter.appendQueryParameter("state", q.I(uuid, "-", "", false, 4, null));
        if (z) {
            appendQueryParameter2.appendQueryParameter("redirect_uri", "https://tasker.joaoapps.com/auth.html");
        }
        if (!(this.f.length == 0)) {
            appendQueryParameter2.appendQueryParameter("scope", o());
        }
        b2 = g.b();
        HashMap hashMap = (HashMap) b2.get(this.d);
        if (hashMap != null && (t = m0.t(hashMap)) != null) {
            for (Pair pair : t) {
                appendQueryParameter2.appendQueryParameter((String) pair.getFirst(), (String) pair.getSecond());
            }
        }
        if (this.h) {
            appendQueryParameter2.appendQueryParameter("show_dialog", "true");
        }
        String uri = appendQueryParameter2.build().toString();
        p.h(uri, "toString(...)");
        return uri;
    }

    private final void s(AuthInfo authInfo) {
        Context context = this.a;
        String q = q();
        SharedPreferences a2 = mg.c.a(this.a);
        p.h(a2, "<get-preferencesHttpAuth>(...)");
        rg.i.V(context, q, authInfo, a2, null, 8, null);
    }

    @Override
    public String a(JSONObject jSONObject) {
        return super.a(jSONObject);
    }

    @Override
    public String b(JSONObject jSONObject) {
        return super.b(jSONObject);
    }

    @Override
    public Long c(JSONObject jSONObject) {
        return super.c(jSONObject);
    }

    @Override
    public String d(String str, String str2) {
        return super.d(str, str2);
    }

    @Override
    public r<i> e(final long j) {
        return e2.y1(new ik.a() {
            @Override
            public final Object e() {
                i h;
                h = f.h(f.this, j);
                return h;
            }
        });
    }

    public f(Context context, String str, String str2, String str3, String str4, String[] strArr, j jVar, boolean z, int i, jk.h hVar) {
        this(context, str, str2, str3, str4, strArr, (i & 64) != 0 ? j.r : jVar, (i & 128) != 0 ? false : z);
    }

    public static final class d implements l<mg.a, e0> {
        public static final d i = new d();

        @Override
        public e0 invoke(mg.a aVar) {
            a(aVar);
            return e0.a;
        }

        public final void a(mg.a aVar) {
        }
    }
}