正在查看: Zepto v25.1.4 应用的 AuthActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Zepto v25.1.4 应用的 AuthActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.amazon.identity.auth.apay.activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.browser.customtabs.CustomTabColorSchemeParams;
import androidx.browser.customtabs.CustomTabsIntent;
import androidx.fragment.app.FragmentActivity;
import com.amazon.android.apay.commonlibrary.commonlib.exception.ApayUncaughtExceptionHandler;
import com.amazon.android.apay.commonlibrary.commonlib.utils.InstrumentUtil;
import com.amazon.android.apay.commonlibrary.interfaces.external.MerchantConstants;
import com.amazon.android.apay.commonlibrary.interfaces.model.AmazonPayError;
import com.amazon.identity.auth.device.AuthError;
import com.amazon.identity.auth.device.Constants;
import com.amazon.identity.auth.device.api.authorization.AuthCancellation;
import com.amazon.identity.auth.device.api.authorization.AuthorizationManager;
import com.amazon.identity.auth.device.api.authorization.AuthorizeListener;
import com.amazon.identity.auth.device.api.authorization.AuthorizeRequest;
import com.amazon.identity.auth.device.api.authorization.AuthorizeResult;
import com.amazon.identity.auth.device.api.authorization.Scope;
import com.amazon.identity.auth.device.api.authorization.ScopeFactory;
import com.amazon.identity.auth.device.api.workflow.RequestContext;
import com.amazon.identity.auth.device.authorization.AuthorizationResponseParser;
import com.amazon.identity.auth.device.authorization.InternalAuthManager;
import com.amazon.identity.auth.device.authorization.R;
import com.amazon.identity.auth.device.authorization.api.AuthzConstants;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import org.json.JSONObject;
public class AuthActivity extends AppCompatActivity {
public static CustomTabsIntent o;
public b.a i;
public b j;
public com.amazon.identity.auth.apay.activity.a k;
public RequestContext l;
public ApayUncaughtExceptionHandler m;
public final Handler n = new Handler();
public final class a extends AuthorizeListener {
public a() {
}
@Override
public final void onCancel(Object obj) {
AuthActivity.this.q((AuthCancellation) obj);
}
@Override
public final void onError(AuthError authError) {
CustomTabsIntent customTabsIntent = AuthActivity.o;
AuthActivity authActivity = AuthActivity.this;
if (authActivity.i == null && authActivity.getIntent().getExtras() != null) {
authActivity.p(authActivity.getIntent().getExtras());
InstrumentUtil.addMetricEvent("ListenerInvokedAfterActivityDestroyed", "LWA_LITE_SDK.AUTH_RESPONSE", authActivity.i.g);
}
b.a aVar = authActivity.i;
String str = aVar.g;
if (aVar.e || aVar.f) {
InstrumentUtil.addMetricEvent("FalseLoginFailed", "LWA_LITE_SDK.AUTH_RESPONSE", str);
} else {
InstrumentUtil.addMetricEvent("AuthError", "LWA_LITE_SDK.AUTH_RESPONSE", str);
authActivity.t("START_BROWSING_ERROR", authError.getMessage(), str);
}
}
@Override
public final void onSuccess(AuthorizeResult authorizeResult) {
CustomTabsIntent customTabsIntent = AuthActivity.o;
AuthActivity.this.r(authorizeResult);
}
@Override
public final void onCancel(AuthCancellation authCancellation) {
AuthActivity.this.q(authCancellation);
}
}
public static Scope[] u(List list) {
ArrayList arrayList = new ArrayList();
arrayList.add(ScopeFactory.scopeNamed("payments::conduct_silentpay"));
arrayList.add(ScopeFactory.scopeNamed("profile:user_id"));
if (list != null && !list.isEmpty()) {
Iterator it = list.iterator();
while (it.hasNext()) {
arrayList.add(ScopeFactory.scopeNamed((String) it.next()));
}
}
return (Scope[]) arrayList.toArray(new Scope[arrayList.size()]);
}
public final void o(int i, String str, Intent intent) {
String.format("AuthActivity:handleOperationComplete invoked with data : %s", intent.toString());
InstrumentUtil.addMetricEvent("AUTHORIZE.OperationCompleted", "AUTHORIZE", str);
setResult(i, intent);
InstrumentUtil.addMetricEvent("AuthComplete", "LWA_LITE_SDK.BUSINESS_METRICS", str);
finish();
}
@Override
public final void onBackPressed() {
b.a aVar = this.i;
boolean z = aVar.e;
String str = aVar.g;
if (z) {
InstrumentUtil.addMetricEvent("BackBtnClickAfterCancel", "LWA_LITE_SDK.AUTH_RESPONSE", str);
return;
}
InstrumentUtil.addMetricEvent("BackBtnClick", "LWA_LITE_SDK.AUTH_RESPONSE", str);
this.i.f = true;
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putSerializable("AUTH_STATUS", "DENIED");
intent.putExtras(bundle);
o(0, this.i.g, intent);
}
public void onCancelBtnClick(View view) {
b.a aVar = this.i;
aVar.e = true;
InstrumentUtil.addMetricEvent("CancelBtnClick", "LWA_LITE_SDK.AUTH_RESPONSE", aVar.g);
findViewById(R.id.cancelBtn).setVisibility(4);
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putSerializable("AUTH_STATUS", "DENIED");
intent.putExtras(bundle);
o(-1, this.i.g, intent);
}
@Override
public final void onCreate(Bundle bundle) {
super.onCreate(bundle);
Bundle extras = getIntent().getExtras();
String string = bundle != null ? bundle.getString("stitchingId") : getIntent().getExtras() != null ? getIntent().getStringExtra("stitchingId") : UUID.randomUUID().toString();
if (extras == null) {
t("INVALID_REQUEST", "Invalid request", string);
}
ApayUncaughtExceptionHandler apayUncaughtExceptionHandler = new ApayUncaughtExceptionHandler(this, string);
this.m = apayUncaughtExceptionHandler;
Thread.setDefaultUncaughtExceptionHandler(apayUncaughtExceptionHandler);
if (bundle == null || bundle.isEmpty()) {
p(getIntent().getExtras());
} else {
p(bundle);
}
setContentView(R.layout.activity_browser_apay);
((TextView) findViewById(R.id.loading_text)).setText(R.string.processing_text);
this.k = new com.amazon.identity.auth.apay.activity.a(this, 0);
this.j = new b(this, string, 0);
InstrumentUtil.addMetricEvent("OnCreateCalled", "LWA_LITE_SDK.AUTH_ACTIVITY_OPERATION", string);
}
@Override
public final void onDestroy() {
this.i = null;
if (findViewById(R.id.cancelBtn) != null) {
findViewById(R.id.cancelBtn).setVisibility(4);
}
Handler handler = this.n;
handler.removeCallbacks(this.k);
handler.removeCallbacks(this.j);
Thread.setDefaultUncaughtExceptionHandler(this.m.getPrevDefaultExceptionHandler());
this.m.tearDown();
this.m = null;
super.onDestroy();
}
@Override
public final void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
b.a aVar = this.i;
aVar.f6539c = true;
InstrumentUtil.addMetricEvent("OnNewIntentCalled", "LWA_LITE_SDK.AUTH_ACTIVITY_OPERATION", aVar.g);
}
@Override
public final void onResume() {
super.onResume();
b.a aVar = this.i;
String str = aVar.g;
if (aVar.i.intValue() > 1) {
InstrumentUtil.addMetricEvent("AppSwitchDone", "LWA_LITE_SDK.BUSINESS_METRICS", str);
}
boolean z = this.i.f6538b;
Handler handler = this.n;
if (!z) {
handler.postDelayed(this.j, 12000L);
InstrumentUtil.addMetricEvent("AuthInitialize", "LWA_LITE_SDK.AUTH_OPERATION", this.i.g);
try {
new CustomTabColorSchemeParams.Builder().f655a = -1;
CustomTabColorSchemeParams customTabColorSchemeParams = new CustomTabColorSchemeParams(-1);
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
builder.f676a.putExtra("android.support.customtabs.extra.TITLE_VISIBILITY", 1);
builder.f678c = customTabColorSchemeParams.a();
CustomTabsIntent a2 = builder.a();
o = a2;
a2.f674a.setPackage("com.android.chrome");
RequestContext create = RequestContext.create((FragmentActivity) this, getIntent(), o);
this.l = create;
create.registerListener(new a());
AuthorizeRequest build = new AuthorizeRequest.Builder(this.l).addScopes(u(this.i.j)).shouldReturnUserData(false).forGrantType(AuthorizeRequest.GrantType.AUTHORIZATION_CODE).withProofKeyParameters(this.i.f6537a, "S256").splitSignInForSubRegion(Constants.AuthConstants.f7502b).build();
AuthorizationManager.setRegion(this, Constants.AuthConstants.f7501a);
AuthorizationManager.authorize(build);
} catch (Exception e) {
if (Objects.equals(e.getMessage(), "Invalid API Key")) {
t("INVALID_API_KEY_ERROR", "Invalid API key provided", this.i.g);
} else {
t("AUTH_FAILURE", "Authorisation failed", this.i.g);
}
}
this.i.f6538b = true;
return;
}
Intent intent = getIntent();
if (intent.getData() != null) {
InstrumentUtil.addMetricEvent("CCTAuthRedirectSuccess", "LWA_LITE_SDK.AUTH_OPERATION", str);
String.format("AuthActivity:onResume with data:%s", intent.getData().toString());
Bundle extras = intent.getExtras();
extras.putSerializable("AUTH_STATUS", "GRANTED");
intent.putExtras(extras);
o(-1, this.i.g, intent);
}
b.a aVar2 = this.i;
boolean z2 = aVar2.f6539c;
if (aVar2.d && Boolean.valueOf(z2) != null && !z2) {
handler.postDelayed(this.k, 6000L);
}
RequestContext requestContext = this.l;
if (requestContext != null) {
requestContext.onResume();
return;
}
String stringExtra = getIntent().getStringExtra("authResponse");
if (stringExtra == null) {
new Handler().postDelayed(new com.amazon.identity.auth.apay.activity.a(this, 1), 200L);
return;
}
try {
s(stringExtra);
} catch (AuthError e2) {
if (this.i == null && getIntent().getExtras() != null) {
p(getIntent().getExtras());
InstrumentUtil.addMetricEvent("ListenerInvokedAfterActivityDestroyed", "LWA_LITE_SDK.AUTH_RESPONSE", this.i.g);
}
b.a aVar3 = this.i;
String str2 = aVar3.g;
if (aVar3.e || aVar3.f) {
InstrumentUtil.addMetricEvent("FalseLoginFailed", "LWA_LITE_SDK.AUTH_RESPONSE", str2);
} else {
InstrumentUtil.addMetricEvent("AuthError", "LWA_LITE_SDK.AUTH_RESPONSE", str2);
t("START_BROWSING_ERROR", e2.getMessage(), str2);
}
} catch (Exception unused) {
t("AUTH_FAILURE", "Authorisation failed", this.i.g);
}
}
@Override
public final void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
InstrumentUtil.addMetricEvent("SaveStateSuccess", "LWA_LITE_SDK.AUTH_ACTIVITY_OPERATION", this.i.g);
bundle.putParcelable("AuthRequest", this.i);
}
@Override
public final void onStop() {
b.a aVar = this.i;
aVar.d = true;
aVar.i = Integer.valueOf(aVar.i.intValue() + 1);
this.n.removeCallbacks(this.j);
super.onStop();
}
public final void p(Bundle bundle) {
String string = bundle != null ? bundle.getString("stitchingId") : getIntent().getExtras() != null ? getIntent().getStringExtra("stitchingId") : UUID.randomUUID().toString();
b.a aVar = (b.a) bundle.getParcelable("AuthRequest");
this.i = aVar;
if (aVar == null) {
InstrumentUtil.addMetricEvent("ExtractStateFailed", "LWA_LITE_SDK.AUTH_ACTIVITY_OPERATION", string);
t("AUTH_FAILURE", "NullAuthRequestExtracted", string);
}
InstrumentUtil.addMetricEvent("ExtractStateSuccess", "LWA_LITE_SDK.AUTH_ACTIVITY_OPERATION", string);
}
public final void q(AuthCancellation authCancellation) {
String.format("LWAAuthorizeListener: onCancel called %s", authCancellation.toString());
if (this.i == null && getIntent().getExtras() != null) {
p(getIntent().getExtras());
InstrumentUtil.addMetricEvent("ListenerInvokedAfterActivityDestroyed", "LWA_LITE_SDK.AUTH_RESPONSE", this.i.g);
}
b.a aVar = this.i;
String str = aVar.g;
if (aVar.e || aVar.f) {
InstrumentUtil.addMetricEvent("FalseLoginCanceled", "LWA_LITE_SDK.AUTH_RESPONSE", str);
return;
}
InstrumentUtil.addMetricEvent("AuthCancelled", "LWA_LITE_SDK.AUTH_RESPONSE", str);
if (authCancellation.getCause() == AuthCancellation.Cause.FAILED_AUTHENTICATION) {
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putSerializable("AUTH_STATUS", "DENIED");
intent.putExtras(bundle);
o(-1, this.i.g, intent);
return;
}
Intent intent2 = new Intent();
Bundle bundle2 = new Bundle();
bundle2.putSerializable("AUTH_STATUS", "FAILURE");
intent2.putExtras(bundle2);
o(-1, this.i.g, intent2);
}
public final void r(AuthorizeResult authorizeResult) {
String.format("LWAAuthorizeListener:onSuccess invoked: %s", authorizeResult);
if (this.i == null && getIntent().getExtras() != null) {
p(getIntent().getExtras());
InstrumentUtil.addMetricEvent("ListenerInvokedAfterActivityDestroyed", "LWA_LITE_SDK.AUTH_RESPONSE", this.i.g);
}
b.a aVar = this.i;
if (aVar.e || aVar.f) {
InstrumentUtil.addMetricEvent("FalseLoginSuccess", "LWA_LITE_SDK.AUTH_RESPONSE", aVar.g);
return;
}
boolean z = aVar.f6539c;
if (Boolean.valueOf(z) == null || !z) {
InstrumentUtil.addMetricEvent("SSOAuthSuccess", "LWA_LITE_SDK.AUTH_RESPONSE", this.i.g);
} else {
InstrumentUtil.addMetricEvent("CCTAuthSuccess", "LWA_LITE_SDK.AUTH_RESPONSE", this.i.g);
}
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putSerializable("authCode", authorizeResult.getAuthorizationCode());
bundle.putSerializable("lwaClientId", authorizeResult.getClientId());
bundle.putSerializable(AuthorizationResponseParser.REDIRECT_URI_STATE, authorizeResult.getRedirectURI());
intent.putExtras(bundle);
Bundle extras = intent.getExtras();
extras.putSerializable("AUTH_STATUS", "GRANTED");
intent.putExtras(extras);
o(-1, this.i.g, intent);
}
public final void s(String str) {
Bundle extractResultsBundle = new AuthorizationResponseParser().extractResultsBundle(str, (String[]) null);
if (extractResultsBundle.containsKey(AuthzConstants.BUNDLE_KEY.CAUSE_ID.val)) {
q(new AuthCancellation(extractResultsBundle));
return;
}
if (!extractResultsBundle.getBoolean(AuthzConstants.BUNDLE_KEY.GET_AUTH_CODE.val, false)) {
InstrumentUtil.addMetricEvent("ReturnAuthCodeFalse", "LWA_LITE_SDK.AUTH_RESPONSE", this.i.g);
t("AUTH_FAILURE", "Authorisation failed", this.i.g);
} else {
if (TextUtils.isEmpty(extractResultsBundle.getString(AuthorizationResponseParser.CODE))) {
InstrumentUtil.addMetricEvent("EmptyCode", "LWA_LITE_SDK.AUTH_RESPONSE", this.i.g);
t("AUTH_FAILURE", "Authorisation failed", this.i.g);
return;
}
Bundle bundle = new Bundle();
bundle.putString(AuthzConstants.BUNDLE_KEY.AUTHORIZATION_CODE.val, extractResultsBundle.getString(AuthorizationResponseParser.CODE));
bundle.putString(AuthzConstants.BUNDLE_KEY.CLIENT_ID.val, InternalAuthManager.getInstance(this).getClientId());
bundle.putString(AuthzConstants.BUNDLE_KEY.REDIRECT_URI.val, InternalAuthManager.getInstance(this).getRedirectURI(this));
r(new AuthorizeResult(bundle));
}
}
public final void t(String str, String str2, String str3) {
Intent putExtra;
InstrumentUtil.addMetricEvent(str, str2, str3);
AmazonPayError amazonPayError = new AmazonPayError(MerchantConstants.AUTH_ERROR, str);
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("ErrorType", amazonPayError.getErrorType());
jSONObject.put("Message", amazonPayError.getErrorMessage());
putExtra = new Intent().putExtra("Error", jSONObject.toString());
} catch (Exception unused) {
putExtra = new Intent().putExtra("Error", "");
}
o(0, str3, putExtra);
}
}