导航菜单

页面标题

页面副标题

Kaspi.kz v5.85.1 - PageEventPlugin.java 源代码

正在查看: Kaspi.kz v5.85.1 应用的 PageEventPlugin.java JAVA 源代码文件

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


package com.iap.android.mppclient.mpm.plugin;

import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import com.iap.android.mppclient.basic.async.AsyncTask;
import com.iap.android.mppclient.basic.log.ACLogEvent;
import com.iap.android.mppclient.container.IContainerPresenter;
import com.iap.android.mppclient.container.event.ContainerEvent;
import com.iap.android.mppclient.container.event.ContainerEventFilter;
import com.iap.android.mppclient.container.plugin.BaseContainerPlugin;
import com.iap.android.mppclient.mpm.model.AcDecodeConfig;
import com.iap.android.mppclient.mpm.model.ActionResumeParams;
import com.iap.android.mppclient.mpm.model.HookUrlConfig;
import com.iap.android.mppclient.mpm.model.HookUrlMappingParams;
import com.iap.android.mppclient.mpm.request.DecodeRequest;
import com.iap.android.mppclient.mpm.request.PrepareAuthRequest;
import com.iap.android.mppclient.mpm.route.RouterManager;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class PageEventPlugin extends BaseContainerPlugin {
    private static final String AUTH_URL = "AUTH_URL";
    private static final String CONTAIN = "CONTAIN";
    private static final String DECODE_URL = "DECODE_URL";
    private static final String DOWNGRADE_URL = "DOWNGRADE_URL";
    private static final String PRE_CREATE_ORDER_DECODE_URL = "PRE_CREATE_ORDER_DECODE_URL";
    private static final String REGEX = "REGEX";
    private static final String TAG = "PageEventPlugin";
    private ContainerEvent event;

    @Override
    public boolean interceptorEvent(ContainerEvent containerEvent) {
        if (!"h5PageShouldLoadUrl".equals(containerEvent.action) || !shouldIntercept(containerEvent)) {
            return false;
        }
        this.event = containerEvent;
        try {
            return handleUrl((String) containerEvent.params.get("url"));
        } catch (Throwable th) {
            Log.e(TAG, "exception occur:" + th.getMessage());
            return false;
        }
    }

    @Override
    public ContainerEventFilter onPrepare(ContainerEventFilter containerEventFilter) {
        containerEventFilter.addAction("h5PageShouldLoadUrl");
        return containerEventFilter;
    }

    protected boolean shouldIntercept(ContainerEvent containerEvent) {
        try {
            return "ACCode".equals(containerEvent.containerPresenter.getActivity().getIntent().getStringExtra("bizScenario"));
        } catch (Throwable unused) {
            return false;
        }
    }

    private boolean handleUrl(String str) {
        AcDecodeConfig parseConfig;
        if (TextUtils.isEmpty(str)) {
            return false;
        }
        Log.d(TAG, "handle original url:" + str);
        if (str.startsWith("http://")) {
            String stringExtra = this.event.containerPresenter.getActivity().getIntent().getStringExtra("acDecodeConfig");
            if (!TextUtils.isEmpty(stringExtra) && (parseConfig = AcDecodeConfig.parseConfig(stringExtra)) != null && parseConfig.forceHttps.booleanValue()) {
                this.event.containerPresenter.loadUrl(str.replaceFirst("http://", "https://"));
                return true;
            }
        }
        List<HookUrlConfig> parseConfig2 = HookUrlConfig.parseConfig("[{\"hookType\":\"DECODE_URL\",\"mappingParams\":\"{\\\"codeParamKey\\\":\\\"ACCodeValue\\\",\\\"loadingUrl\\\":\\\"loadingUrl\\\"}\",\"matchRule\":\"https://render.alipay.com/p/w/ac-fe-adaptor/\",\"matchType\":\"CONTAIN\"},{\"hookType\":\"AUTH_URL\",\"mappingParams\":\"{ \\\"acquireId\\\": \\\"1022088000000000001\\\" }\",\"matchRule\":\"http://openauth.alipay.com/\",\"matchType\":\"CONTAIN\"},{\"hookType\":\"AUTH_URL\",\"mappingParams\":\"{ \\\"acquireId\\\": \\\"1022088000000000001\\\" }\",\"matchRule\":\"https://openauth.alipay.com/\",\"matchType\":\"CONTAIN\"},{\"hookType\":\"DOWNGRADE_URL\",\"mappingParams\":\"{\\\"redirectUrl\\\":\\\"https://render.alipay.com/p/yuyan/180020010001253580/exception_no_support.html?errorType=UNMARKED_MOVING_PINS\\\"}\",\"matchRule\":\"^https://render.alipay.com/p/s/i.*scheme=alipays.*\",\"matchType\":\"REGEX\"},{\"hookType\":\"PRE_CREATE_ORDER_DECODE_URL\",\"mappingParams\":\"{\\\"redirectUrl\\\":\\\"https://render.alipay.com/p/yuyan/180020010001253580/exception_no_support.html?errorType=UNMARKED_MOVING_PINS\\\",\\\"queryParamKey\\\":\\\"scheme\\\",\\\"codeParamKey\\\":\\\"qrcode\\\",\\\"codeParamRule\\\":\\\"^https:\\\\\\\\/\\\\\\\\/qr.alipay.com\\\\\\\\/ba.*\\\"}\",\"matchRule\":\"^https://ds.alipay.com.*scheme=alipays.*\",\"matchType\":\"REGEX\"},{\"hookType\":\"DOWNGRADE_URL\",\"mappingParams\":\"{\\\"redirectUrl\\\": \\\"https://render.alipay.com/p/yuyan/180020010001253580/exception_no_support.html?errorType=UNMARKED_MOVING_PINS\\\" }\",\"matchRule\":\"^https://d.alipay.com.*scheme=alipays.*\",\"matchType\":\"REGEX\"},{\"hookType\":\"DOWNGRADE_URL\",\"mappingParams\":\"{ \\\"redirectUrl\\\": \\\"https://render.alipay.com/p/yuyan/180020010001253580/exception_no_support.html?errorType=UNMARKED_MOVING_PINS\\\" }\",\"matchRule\":\"^https://ulink.alipay.com.*scheme=alipays.*\",\"matchType\":\"REGEX\"},{\"hookType\":\"PRE_CREATE_ORDER_DECODE_URL\",\"mappingParams\":\"{\\\"redirectUrl\\\":\\\"https://render.alipay.com/p/yuyan/180020010001253580/exception_no_support.html?errorType=UNMARKED_MOVING_PINS\\\",\\\"queryParamKey\\\":\\\"scheme\\\",\\\"codeParamKey\\\":\\\"qrcode\\\",\\\"codeParamRule\\\":\\\"^https:\\\\\\\\/\\\\\\\\/qr.alipay.com\\\\\\\\/ba.*\\\"}\",\"matchRule\":\"^https://render.alipay.com/p/s/i.*scheme=.*\",\"matchType\":\"REGEX\"}]");
        if (parseConfig2 != null && !parseConfig2.isEmpty()) {
            for (HookUrlConfig hookUrlConfig : parseConfig2) {
                Matcher matcher = Pattern.compile(hookUrlConfig.matchRule).matcher(str);
                if ((CONTAIN.equals(hookUrlConfig.matchType) && str.contains(hookUrlConfig.matchRule)) || (REGEX.equals(hookUrlConfig.matchType) && matcher.matches())) {
                    ACLogEvent.newLogger("mpp_mpm_launch_hook_url").addParams("url", str).addParams("hookType", hookUrlConfig.hookType).addParams("matchType", hookUrlConfig.matchType).event();
                    try {
                        HookUrlMappingParams parseMappingParams = HookUrlMappingParams.parseMappingParams(hookUrlConfig.mappingParams);
                        if (AUTH_URL.equals(hookUrlConfig.hookType)) {
                            IContainerPresenter iContainerPresenter = this.event.containerPresenter;
                            final PrepareAuthRequest prepareAuthRequest = new PrepareAuthRequest();
                            prepareAuthRequest.authUrl = str;
                            final ActionResumeParams actionResumeParams = new ActionResumeParams();
                            actionResumeParams.containerPresenter = iContainerPresenter;
                            AsyncTask.asyncTask(new Runnable() {
                                @Override
                                public void run() {
                                    RouterManager.getInstance().onResumeCNCollectionFlow(prepareAuthRequest, actionResumeParams);
                                }
                            });
                            return true;
                        }
                        if (DECODE_URL.equals(hookUrlConfig.hookType)) {
                            Uri parse = Uri.parse(str);
                            String queryParameter = parse.getQueryParameter(parseMappingParams.codeParamKey);
                            if (!TextUtils.isEmpty(parseMappingParams.loadingUrl)) {
                                String queryParameter2 = parse.getQueryParameter(parseMappingParams.loadingUrl);
                                if (str.startsWith("https://render.alipay.com/p/w/ac-fe-adaptor") && !TextUtils.isEmpty(queryParameter2)) {
                                    this.event.containerPresenter.loadUrl(queryParameter2);
                                }
                            }
                            if (TextUtils.isEmpty(queryParameter)) {
                                return false;
                            }
                            final DecodeRequest decodeRequest = new DecodeRequest();
                            decodeRequest.codeValue = queryParameter;
                            final ActionResumeParams actionResumeParams2 = new ActionResumeParams();
                            actionResumeParams2.containerPresenter = this.event.containerPresenter;
                            AsyncTask.asyncTask(new Runnable() {
                                @Override
                                public void run() {
                                    RouterManager.getInstance().onResumeCommonCollectionFlow(decodeRequest, actionResumeParams2);
                                }
                            });
                            return true;
                        }
                        if (DOWNGRADE_URL.equals(hookUrlConfig.hookType)) {
                            if (!TextUtils.isEmpty(parseMappingParams.redirectUrl)) {
                                this.event.containerPresenter.loadUrl(parseMappingParams.redirectUrl);
                            }
                            return true;
                        }
                        if (PRE_CREATE_ORDER_DECODE_URL.equals(hookUrlConfig.hookType)) {
                            String str2 = parseMappingParams.redirectUrl;
                            Uri parse2 = Uri.parse(str);
                            if (!TextUtils.isEmpty(parseMappingParams.queryParamKey)) {
                                String queryParameter3 = parse2.getQueryParameter(parseMappingParams.queryParamKey);
                                if (!TextUtils.isEmpty(queryParameter3)) {
                                    Uri parse3 = Uri.parse(queryParameter3);
                                    if (!TextUtils.isEmpty(parseMappingParams.codeParamKey)) {
                                        String queryParameter4 = parse3.getQueryParameter(parseMappingParams.codeParamKey);
                                        String str3 = parseMappingParams.codeParamRule;
                                        if (!TextUtils.isEmpty(queryParameter4) && !TextUtils.isEmpty(str3) && Pattern.compile(str3).matcher(queryParameter4).matches()) {
                                            final DecodeRequest decodeRequest2 = new DecodeRequest();
                                            decodeRequest2.codeValue = queryParameter4;
                                            final ActionResumeParams actionResumeParams3 = new ActionResumeParams();
                                            actionResumeParams3.containerPresenter = this.event.containerPresenter;
                                            AsyncTask.asyncTask(new Runnable() {
                                                @Override
                                                public void run() {
                                                    RouterManager.getInstance().onResumeCommonCollectionFlow(decodeRequest2, actionResumeParams3);
                                                }
                                            });
                                            return true;
                                        }
                                    }
                                }
                            }
                            if (!TextUtils.isEmpty(str2)) {
                                this.event.containerPresenter.loadUrl(str2);
                            }
                            return true;
                        }
                    } catch (Exception unused) {
                    }
                }
            }
        }
        return false;
    }
}