正在查看: MedEd v5.3.6 应用的 Godel.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: MedEd v5.3.6 应用的 Godel.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package in.juspay.hypersdk.safe;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewManager;
import android.view.ViewParent;
import android.webkit.CookieManager;
import android.webkit.URLUtil;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.widget.FrameLayout;
import androidx.compose.material.LE.GWJYkMcDhLPQtL;
import com.google.android.material.slider.hwjb.PPBOHKTwZMfdl;
import com.google.firebase.perf.network.FirebasePerfUrlConnection;
import in.juspay.hyper.core.ExecutorManager;
import in.juspay.hyper.core.JuspayLogger;
import in.juspay.hypersdk.R;
import in.juspay.hypersdk.core.AcsInterface;
import in.juspay.hypersdk.core.DuiInterface;
import in.juspay.hypersdk.core.GodelJsInterface;
import in.juspay.hypersdk.core.JuspayServices;
import in.juspay.hypersdk.core.JuspayWebViewConfigurationCallback;
import in.juspay.hypersdk.core.PaymentUtils;
import in.juspay.hypersdk.core.SdkTracker;
import in.juspay.hypersdk.data.KeyValueStore;
import in.juspay.hypersdk.data.PaymentSessionInfo;
import in.juspay.hypersdk.services.FileProviderService;
import in.juspay.hypersdk.utils.Utils;
import in.juspay.hypersdk.utils.network.NetUtils;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.SequenceInputStream;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class Godel {
private static final String GODEL = "Godel";
private static final String LOG_TAG = "PaymentUtils";
private static final long ON_EXCEPTION_GODEL_OFF_STICKINESS = 86400000;
private final AcsInterface acsInterface;
private final JSONObject bundleParameters;
private JSONObject config;
private final Context context;
private final DuiInterface duiInterface;
private final JuspayServices juspayServices;
private final JuspayWebChromeClient juspayWebChromeClient;
private final JuspayWebView juspayWebView;
private final JuspayWebViewClient juspayWebViewClient;
private final JuspayWebViewConfigurationCallback juspayWebViewConfigurationCallback;
private final PaymentSessionInfo paymentSessionInfo;
private final JSONObject processPayload;
private final SdkTracker sdkTracker;
private final List<String> allowedDeeplinkPackages = new ArrayList();
public boolean isRupaySupportedAdded = false;
public Godel(JuspayServices juspayServices) {
Context context = juspayServices.getContext();
this.context = context;
this.juspayServices = juspayServices;
Activity activity = juspayServices.getActivity();
JuspayWebView juspayWebView = new JuspayWebView(activity != null ? activity : context);
this.juspayWebView = juspayWebView;
this.juspayWebViewClient = new JuspayWebViewClient(this, juspayWebView);
this.juspayWebChromeClient = new JuspayWebChromeClient(this);
this.acsInterface = new AcsInterface(juspayServices);
this.juspayWebViewConfigurationCallback = juspayServices.getWebViewConfigurationCallback();
this.sdkTracker = juspayServices.getSdkTracker();
this.duiInterface = juspayServices.getJBridge();
this.paymentSessionInfo = juspayServices.getPaymentSessionInfo();
this.bundleParameters = juspayServices.getSessionInfo().getBundleParams();
this.processPayload = juspayServices.getLastProcessPayload();
this.config = new JSONObject();
}
private android.webkit.WebResourceResponse addAcsToJSFile(android.webkit.WebResourceRequest r9, java.lang.String r10, java.lang.String r11, org.json.JSONObject r12, org.json.JSONObject r13) {
throw new UnsupportedOperationException("Method not decompiled: in.juspay.hypersdk.safe.Godel.addAcsToJSFile(android.webkit.WebResourceRequest, java.lang.String, java.lang.String, org.json.JSONObject, org.json.JSONObject):android.webkit.WebResourceResponse");
}
private String getAcsScript() {
FileProviderService fileProviderService = this.juspayServices.getFileProviderService();
StringBuilder b = I8.b("window.juspayContext = {}; juspayContext['web_lab_rules'] = " + getWebLabRules(), ", ");
b.append(fileProviderService.readFromFile(this.juspayServices.getContext(), "payments/in.juspay.godel/v1-acs.jsa"));
return b.toString();
}
private String getConnectionData(Reader reader, int i) {
try {
StringBuilder sb = new StringBuilder();
char[] cArr = new char[i];
while (true) {
int read = reader.read(cArr);
if (read == -1) {
return sb.toString();
}
sb.append(cArr, 0, read);
}
} catch (Exception unused) {
return null;
}
}
private InputStream getDataAcsFromPostRequest(HttpsURLConnection httpsURLConnection, String str) {
try {
if (".html".matches(str)) {
return handleHtmlFile(httpsURLConnection);
}
if (!".js".matches(str) && !".jsp".matches(str)) {
return null;
}
return handleJsFile(httpsURLConnection);
} catch (Exception unused) {
return null;
}
}
private InputStream getDataFromGetRequest(HttpsURLConnection httpsURLConnection, WebResourceRequest webResourceRequest) {
try {
for (String str : webResourceRequest.getRequestHeaders().keySet()) {
httpsURLConnection.setRequestProperty(str, webResourceRequest.getRequestHeaders().get(str));
}
httpsURLConnection.setDoOutput(false);
return new SequenceInputStream(new ByteArrayInputStream(("window.addEventListener('load', function() { if(!window.GK) { " + getAcsScript() + " } });").getBytes(StandardCharsets.UTF_8)), httpsURLConnection.getInputStream());
} catch (Exception unused) {
return null;
}
}
private List<Pattern> getExcludeUrlsPatternList() {
Exception exc;
SdkTracker sdkTracker;
String str;
String str2;
String str3;
LinkedList linkedList = null;
try {
LinkedList linkedList2 = new LinkedList();
try {
JSONArray jSONArray = this.config.getJSONArray("exclude_url_patterns");
if (!isNotNull(jSONArray)) {
return linkedList2;
}
for (int i = 0; i < jSONArray.length(); i++) {
linkedList2.add(Pattern.compile(jSONArray.get(i).toString()));
}
return linkedList2;
} catch (JSONException e) {
exc = e;
linkedList = linkedList2;
sdkTracker = this.sdkTracker;
str = LOG_TAG;
str2 = "util";
str3 = "Json Exception while fetching excludeUrlPatterns from config";
sdkTracker.trackAndLogException(str, "action", "system", str2, str3, exc);
return linkedList;
} catch (Exception e2) {
exc = e2;
linkedList = linkedList2;
sdkTracker = this.sdkTracker;
str = LOG_TAG;
str2 = "util";
str3 = "Exception while compiling patterns in excludeUrlPatterns from config";
sdkTracker.trackAndLogException(str, "action", "system", str2, str3, exc);
return linkedList;
}
} catch (JSONException e3) {
exc = e3;
} catch (Exception e4) {
exc = e4;
}
}
private HttpsURLConnection getPostRequestConnection(JSONObject jSONObject, JSONObject jSONObject2, WebResourceRequest webResourceRequest) {
try {
String sessionAttribute = this.juspayServices.getJBridge().getSessionAttribute("iframe_form_data", "wait_for_me");
JSONObject jSONObject3 = this.config.getJSONObject("waiting_time_postparams");
int optInt = jSONObject3.optInt("interval", 50);
for (int optInt2 = jSONObject3.optInt("total_time", 1000); sessionAttribute.equals("wait_for_me") && optInt2 > 0; optInt2 -= optInt) {
TimeUnit.MILLISECONDS.sleep(optInt);
sessionAttribute = this.juspayServices.getJBridge().getSessionAttribute("iframe_form_data", "wait_for_me");
}
if (sessionAttribute.equals("wait_for_me")) {
return null;
}
this.juspayServices.getJBridge().setSessionAttribute("iframe_form_data", "wait_for_me");
HashMap<String, String> map = toMap(sessionAttribute);
NetUtils netUtils = new NetUtils(jSONObject.optInt("connection_timeout", 10000), jSONObject.optInt("read_timeout", 10000));
HashMap hashMap = new HashMap();
Iterator<String> keys = jSONObject2.keys();
while (keys.hasNext()) {
String next = keys.next();
hashMap.put(next, jSONObject2.getString(next));
}
return netUtils.postUrl(new URL(webResourceRequest.getUrl().toString()), hashMap, map, new JSONObject());
} catch (Exception unused) {
return null;
}
}
private List<String> getRupaySpecificDomains() {
Exception exc;
SdkTracker sdkTracker;
String str;
String str2;
String str3;
ArrayList arrayList = null;
try {
JSONArray jSONArray = this.config.getJSONArray("rupay_specific_domains");
this.juspayServices.sdkDebug(LOG_TAG, "printing urlArray" + jSONArray);
if (!isNotNull(jSONArray)) {
return null;
}
int length = jSONArray.length();
ArrayList arrayList2 = new ArrayList(length);
for (int i = 0; i < length; i++) {
try {
arrayList2.add(jSONArray.get(i).toString());
} catch (JSONException e) {
exc = e;
arrayList = arrayList2;
sdkTracker = this.sdkTracker;
str = LOG_TAG;
str2 = "util";
str3 = "Json Exception while fetching Rupay Urls from config";
sdkTracker.trackAndLogException(str, "action", "system", str2, str3, exc);
return arrayList;
} catch (Exception e2) {
exc = e2;
arrayList = arrayList2;
sdkTracker = this.sdkTracker;
str = LOG_TAG;
str2 = "util";
str3 = "Exception while getting rupay urls from config";
sdkTracker.trackAndLogException(str, "action", "system", str2, str3, exc);
return arrayList;
}
}
return arrayList2;
} catch (JSONException e3) {
exc = e3;
} catch (Exception e4) {
exc = e4;
}
}
private InputStream handleHtmlFile(HttpsURLConnection httpsURLConnection) {
String connectionData;
BufferedReader bufferedReader;
String str;
if (httpsURLConnection == null) {
return null;
}
try {
?? r0 = "<script>{ " + getAcsScript() + " } </script></body>";
String contentEncoding = httpsURLConnection.getContentEncoding();
try {
if (contentEncoding == null || !contentEncoding.equalsIgnoreCase("gzip")) {
if (contentEncoding != null && !contentEncoding.equals("")) {
str = 0;
}
BufferedReader bufferedReader2 = new BufferedReader(new InputStreamReader(httpsURLConnection.getInputStream()), 8000);
try {
connectionData = getConnectionData(bufferedReader2, 8000);
bufferedReader = bufferedReader2;
bufferedReader.close();
str = connectionData;
} catch (Throwable th) {
bufferedReader2.close();
throw th;
}
} else {
bufferedReader = new BufferedReader(new InputStreamReader(new GZIPInputStream(httpsURLConnection.getInputStream()), StandardCharsets.UTF_8), 8000);
try {
connectionData = getConnectionData(bufferedReader, 8000);
bufferedReader.close();
str = connectionData;
} catch (Throwable th2) {
bufferedReader.close();
throw th2;
}
}
if (str != 0) {
return new ByteArrayInputStream(str.replace("</body>", (CharSequence) r0).getBytes(StandardCharsets.UTF_8));
}
return null;
} catch (Throwable th3) {
r0.addSuppressed(th3);
throw r0;
}
} catch (Exception unused) {
return null;
}
}
private InputStream handleJsFile(HttpsURLConnection httpsURLConnection) {
if (httpsURLConnection == null) {
return null;
}
try {
return new SequenceInputStream(new ByteArrayInputStream(("window.addEventListener('load', function() { if(!window.GK) { " + getAcsScript() + " } });").getBytes(StandardCharsets.UTF_8)), httpsURLConnection.getInputStream());
} catch (Exception unused) {
return null;
}
}
private void initializeJuspayWebView(Context context) {
this.sdkTracker.trackAction("system", "info", "initialise_juspay_webview", "started", context);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
this.juspayWebView.setId(R.id.juspay_browser_view);
this.juspayWebView.setLayoutParams(layoutParams);
this.juspayWebView.setHorizontalScrollBarEnabled(false);
this.juspayWebView.setVerticalScrollBarEnabled(false);
this.juspayWebView.addJavascriptInterface(this.acsInterface, "ACSGatekeeper");
FileProviderService fileProviderService = this.juspayServices.getFileProviderService();
this.paymentSessionInfo.setPaymentDetails(this.bundleParameters);
fileProviderService.addToFileCacheWhiteList("acs.jsa");
prepareWebView();
}
private boolean isAcsToBeAddedToResource(URL url) {
List<String> rupaySpecificDomains = getRupaySpecificDomains();
if (rupaySpecificDomains == null) {
return false;
}
Iterator<String> it = rupaySpecificDomains.iterator();
while (it.hasNext()) {
if (url.toString().toLowerCase().contains(it.next()) && url.getPath().toLowerCase().endsWith(".js") && !url.getPath().toLowerCase().endsWith(".jsp")) {
return true;
}
}
return false;
}
private boolean isClientWhitelistedForWebViewAccess(String str) {
JSONArray optJSONArray = Utils.optJSONArray(Utils.optJSONObject(Utils.optJSONObject(this.juspayServices.getSdkConfigService().getSdkConfig(), "godelConfig"), "webViewAccess"), "whitelistedClientIds");
for (int i = 0; i < optJSONArray.length(); i++) {
try {
if (str.contains(optJSONArray.getString(i))) {
return true;
}
} catch (JSONException e) {
this.sdkTracker.trackAndLogException(GODEL, "action", "system", "godel_webview_whitelist", "Failed to read whitelisted config", e);
}
}
return false;
}
private static boolean isNotNull(JSONArray jSONArray) {
return (jSONArray == null || jSONArray == JSONObject.NULL) ? false : true;
}
public void lambda$onBrowserReady$0(Activity activity, String str, String str2, String str3) {
addWebView(activity, str);
loadPage(str2, str3);
}
public void lambda$onBrowserReady$1(Activity activity, String str, String str2, String str3, String str4, String str5, String str6) {
addWebView(activity, str);
this.juspayWebView.loadDataWithBaseURL(str2, str3, str4, str5, str6);
}
private boolean shouldDisableGodel(Context context) {
long j;
if (context == null || !KeyValueStore.contains(this.juspayServices, "GODEL_EXCEPTION_OFF")) {
return false;
}
long optLong = getConfig().optLong("ON_EXCEPTION_GODEL_OFF_STICKINESS", ON_EXCEPTION_GODEL_OFF_STICKINESS);
try {
j = System.currentTimeMillis() - Long.parseLong(KeyValueStore.read(this.juspayServices, "GODEL_EXCEPTION_OFF", String.valueOf(System.currentTimeMillis())));
} catch (NumberFormatException e) {
long currentTimeMillis = System.currentTimeMillis();
this.sdkTracker.trackAndLogException(GODEL, "action", "user", "should_disable_godel", "Failed while parsing number", e);
j = currentTimeMillis;
}
this.sdkTracker.trackAction("user", "info", "should_disable_godel", "exception_info", KeyValueStore.read(this.juspayServices, "EXCEPTION_INFO", (String) null));
if (j <= optLong) {
return true;
}
KeyValueStore.remove(this.juspayServices, "GODEL_EXCEPTION_OFF");
KeyValueStore.remove(this.juspayServices, "EXCEPTION_OFF");
return false;
}
private WebResourceResponse shouldExcludeResource(String str) {
String str2;
Pattern compile = Pattern.compile(".*\\.(gif|jpg|jpeg|png)([;?].*)?$");
Bitmap createBitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_4444);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
createBitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
List<Pattern> excludeUrlsPatternList = getExcludeUrlsPatternList();
if (excludeUrlsPatternList == null) {
excludeUrlsPatternList = new ArrayList<>();
}
Iterator<Pattern> it = excludeUrlsPatternList.iterator();
while (it.hasNext()) {
if (it.next().matcher(str).matches()) {
if (compile.matcher(str).matches()) {
str2 = "text/html";
} else {
byteArray = "[blocked]".getBytes();
str2 = "text/plain";
}
return new WebResourceResponse(str2, "utf-8", new ByteArrayInputStream(byteArray));
}
}
return null;
}
private HashMap<String, String> toMap(String str) {
HashMap<String, String> hashMap = new HashMap<>();
try {
JSONObject jSONObject = new JSONObject(str);
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
hashMap.put(next, jSONObject.getString(next));
}
return hashMap;
} catch (JSONException unused) {
JuspayLogger.d(LOG_TAG, "Not a json string. Passing as such");
return null;
}
}
private void turnOffGodelIfNeeded() {
if (shouldDisableGodel(this.context)) {
this.paymentSessionInfo.setGodelDisabled("ON_GODEL_EXCEPTION");
}
if (!PaymentUtils.hasTelephonyService(this.juspayServices)) {
this.juspayServices.sdkDebug(GODEL, "No telephony service found.. disabling JB");
this.paymentSessionInfo.setGodelDisabled("TELEPHONY_NOT_FOUND");
}
PaymentUtils.switchOffGodelIfLowOnMemory(this, this.juspayServices, this.paymentSessionInfo);
}
public void addWebView(Activity activity, String str) {
initializeJuspayWebView(this.context);
FrameLayout frameLayout = this.juspayServices.getContainer() != null ? (FrameLayout) this.juspayServices.getContainer().findViewById(Integer.parseInt(str)) : null;
if (frameLayout != null || activity == null) {
this.sdkTracker.trackAction("system", "error", "add_web_view", "missing", "activity");
} else {
frameLayout = (FrameLayout) activity.findViewById(Integer.parseInt(str));
}
if (frameLayout == null) {
this.sdkTracker.trackAction("system", "error", "add_web_view", "missing", "view");
return;
}
if (this.juspayWebView.getParent() == frameLayout) {
this.sdkTracker.trackAction("system", "warning", "add_web_view", "parent", "parent view is same as before");
return;
}
turnOffGodelIfNeeded();
ViewParent parent = this.juspayWebView.getParent();
if (parent != null) {
this.sdkTracker.trackAction("system", "warning", "add_web_view", "parent", "already present");
if (!(parent instanceof ViewGroup)) {
this.sdkTracker.trackAction("system", "error", "add_web_view", "parent", "not a ViewGroup");
return;
}
((ViewGroup) parent).removeView(this.juspayWebView);
}
frameLayout.addView((View) this.juspayWebView, 0);
}
public void exit() {
ExecutorManager.runOnMainThread(new on2(this, 8));
}
public AcsInterface getAcsInterface() {
return this.acsInterface;
}
public List<String> getAllowedDeeplinkPackages() {
return this.allowedDeeplinkPackages;
}
public JSONObject getConfig() {
return this.config;
}
public Context getContext() {
return this.context;
}
public DuiInterface getDuiInterface() {
return this.duiInterface;
}
public JuspayServices getJuspayServices() {
return this.juspayServices;
}
public JuspayWebView getJuspayWebView() {
return this.juspayWebView;
}
public PaymentSessionInfo getPaymentSessionInfo() {
return this.paymentSessionInfo;
}
public JSONObject getWebLabRules() {
try {
return this.config.getJSONObject("weblab");
} catch (Exception e) {
this.sdkTracker.trackAndLogException(LOG_TAG, "action", "system", "util", "Unable to find weblab key in config", e);
return null;
}
}
public boolean isDuiLoaded() {
return true;
}
public void loadPage() {
String str;
String str2;
if (this.bundleParameters.has("url")) {
str = "file:///android_assets/juspay/acs_blank.html";
str2 = null;
} else {
str = this.bundleParameters.optString("url");
str2 = this.bundleParameters.optString("postData");
}
loadPage(str, str2);
}
public void onBrowserReady(Activity activity, String str, String str2, String str3) {
ExecutorManager.runOnMainThread(new FX0(this, activity, str3, str, str2, 1));
}
public void onDuiReady() {
this.paymentSessionInfo.setGodelManager(this);
this.juspayServices.getJBridge().attach("NETWORK_STATUS", "{}", "");
setupAllowedDeeplinkPackages();
this.sdkTracker.trackLifecycle("hypersdk", "info", "on_dui_ready", "class", "HyperFragment");
}
public void onDuiReleased() {
this.sdkTracker.trackAction("system", "info", "on_dui_released", "exit_sdk", JSONObject.NULL);
exit();
this.paymentSessionInfo.setGodelManager(null);
}
public void prepareWebView() {
this.juspayWebView.getSettings().setJavaScriptEnabled(true);
this.juspayWebView.getSettings().setDomStorageEnabled(true);
JSONObject jSONObject = null;
try {
jSONObject = this.bundleParameters.getJSONObject("payload");
if (jSONObject.optBoolean("godel_receive_merchant_messages")) {
this.juspayWebView.addJavascriptInterface(new GodelJsInterface(this.juspayServices), "GodelInterface");
}
} catch (JSONException e) {
this.sdkTracker.trackAndLogException(GODEL, "action", "system", "initialise_juspay_webview", "Initiate payload is missing", e);
}
this.juspayWebView.setDefaultWebViewClient(this.juspayWebViewClient);
this.juspayWebView.setDefaultWebChromeClient(this.juspayWebChromeClient);
this.juspayWebView.getSettings().setAllowFileAccess(true);
this.juspayWebView.getSettings().setCacheMode(-1);
this.sdkTracker.trackAction("system", "info", "initialise_juspay_webview", "enabling_third_party_cookies", Boolean.TRUE);
CookieManager.getInstance().setAcceptThirdPartyCookies(this.juspayWebView, true);
if (!this.juspayServices.getJBridge().execute("NETWORK_STATUS", "", "{}", "").equals(String.valueOf(true))) {
this.sdkTracker.trackAction("system", "info", "initialise_juspay_webview", "no_network", "Setting web view to load from cache if there is no network");
this.juspayWebView.getSettings().setCacheMode(1);
}
if (this.bundleParameters.has("clearCookies") && this.bundleParameters.optBoolean("clearCookies")) {
this.sdkTracker.trackAction("system", "info", "initialise_juspay_webview", "clearing", "cookies");
PaymentUtils.clearCookies(this.juspayServices);
}
if (jSONObject == null) {
this.sdkTracker.trackAction("system", "error", "initialise_juspay_webview", "missing", PPBOHKTwZMfdl.tGCAz);
return;
}
String optString = jSONObject.optString("clientId", "");
if (this.juspayWebViewConfigurationCallback == null || !isClientWhitelistedForWebViewAccess(optString)) {
return;
}
this.juspayWebViewConfigurationCallback.configureJuspayWebView(this.juspayWebView);
this.sdkTracker.trackAction("system", "info", "godel_webview_whitelist", "configured", "JuspayWebView");
}
public void resetWebView() {
JuspayWebView juspayWebView = this.juspayWebView;
juspayWebView.setDefaultWebChromeClient(juspayWebView.getWebChromeClient());
JuspayWebView juspayWebView2 = this.juspayWebView;
juspayWebView2.setDefaultWebViewClient(juspayWebView2.getWebViewClient());
this.juspayWebView.stopLoading();
this.juspayWebView.removeJavascriptInterface("ACSGatekeeper");
this.juspayWebView.clearHistory();
this.juspayWebView.destroy();
if (this.juspayWebView.getParent() != null) {
((ViewManager) this.juspayWebView.getParent()).removeView(this.juspayWebView);
}
}
public void setConfig(JSONObject jSONObject) {
this.config = jSONObject;
}
public void setIsRupaySupportedAdded(boolean z) {
this.isRupaySupportedAdded = z;
}
public void setupAllowedDeeplinkPackages() {
JSONObject jSONObject = this.processPayload;
JSONObject optJSONObject = jSONObject != null ? jSONObject.optJSONObject("payload") : null;
if (optJSONObject == null) {
return;
}
JSONArray optJSONArray = optJSONObject.optJSONArray("allowedDeepLinkPackages");
this.allowedDeeplinkPackages.clear();
if (optJSONArray != null) {
for (int i = 0; i < optJSONArray.length(); i++) {
String optString = optJSONArray.optString(i);
if (optString != null) {
this.allowedDeeplinkPackages.add(optString);
}
}
}
}
public WebResourceResponse shouldInterceptRequest(WebResourceRequest webResourceRequest) {
JSONArray optJSONArray;
try {
int i = 0;
if (!this.juspayServices.getSessionInfo().get("inject_acs_into_iframes", "false").equals("true") || !webResourceRequest.getMethod().equals("GET")) {
if (!webResourceRequest.getMethod().equals("POST") || (optJSONArray = this.config.optJSONArray("post_urls")) == null) {
return null;
}
while (i < optJSONArray.length()) {
JSONObject jSONObject = optJSONArray.getJSONObject(i);
if (Pattern.compile(jSONObject.getString("url")).matcher(webResourceRequest.getUrl().toString()).find()) {
return addAcsToJSFile(webResourceRequest, "POST", jSONObject.getString("file_type"), jSONObject.getJSONObject("headers"), jSONObject.getJSONObject("timeout"));
}
i++;
}
return null;
}
JSONArray optJSONArray2 = this.config.optJSONArray("bank_js_urls_v2");
if (optJSONArray2 == null) {
JSONArray optJSONArray3 = this.config.optJSONArray("bank_js_urls");
if (optJSONArray3 != null) {
while (i < optJSONArray3.length()) {
if (Pattern.compile(optJSONArray3.getString(i)).matcher(webResourceRequest.getUrl().toString()).find()) {
return addAcsToJSFile(webResourceRequest, "GET", ".*\\.jsp?$", new JSONObject(), new JSONObject());
}
i++;
}
}
} else {
for (int i2 = 0; i2 < optJSONArray2.length(); i2++) {
JSONArray jSONArray = optJSONArray2.getJSONArray(i2);
if (Pattern.compile(jSONArray.getString(0)).matcher(webResourceRequest.getUrl().toString()).find()) {
return addAcsToJSFile(webResourceRequest, "GET", jSONArray.getString(1), new JSONObject(), new JSONObject());
}
}
}
return null;
} catch (Exception e) {
this.sdkTracker.trackAndLogException(LOG_TAG, "action", "system", "util", "Exception while adding ACS to js file", e);
return null;
}
}
public void loadPage(String str, String str2) {
try {
this.bundleParameters.put("url", str);
this.bundleParameters.put("postData", str2);
} catch (JSONException e) {
this.sdkTracker.trackAndLogException(GODEL, "lifecycle", "hypersdk", "load_page", "Failed to write to JSON bundle parameters", e);
}
if (str2 != null) {
this.juspayWebView.postUrl(str, str2.getBytes());
} else {
this.juspayWebView.loadUrl(str);
}
}
public void onBrowserReady(Activity activity, String str, String str2, String str3, String str4, String str5, String str6) {
ExecutorManager.runOnMainThread(new hJ0(this, activity, str6, str, str2, str3, str4, str5));
}
public WebResourceResponse shouldInterceptRequest(String str) {
String str2 = GWJYkMcDhLPQtL.LtcjrCZ;
try {
JuspayServices juspayServices = this.juspayServices;
String str3 = LOG_TAG;
juspayServices.sdkDebug(str3, "Intercepted URL: " + str);
if (!URLUtil.isValidUrl(str) || !isAcsToBeAddedToResource(new URL(str)) || this.isRupaySupportedAdded) {
WebResourceResponse shouldExcludeResource = shouldExcludeResource(str);
if (shouldExcludeResource == null) {
return null;
}
this.sdkTracker.trackAction("system", "info", "util", "url_excluded", str);
return shouldExcludeResource;
}
URL url = new URL(str);
this.juspayServices.sdkDebug(str3, str2 + str);
setIsRupaySupportedAdded(true);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(getAcsScript().getBytes(StandardCharsets.UTF_8));
try {
SequenceInputStream sequenceInputStream = new SequenceInputStream(byteArrayInputStream, FirebasePerfUrlConnection.openStream(url));
try {
WebResourceResponse webResourceResponse = new WebResourceResponse("text/javascript", "utf-8", sequenceInputStream);
sequenceInputStream.close();
byteArrayInputStream.close();
return webResourceResponse;
} finally {
}
} finally {
}
} catch (Exception e) {
this.sdkTracker.trackAndLogException(LOG_TAG, "action", "system", "util", "Error while Caching Files", e);
return null;
}
}
}