Active IQ v6.7.1版本的 MD5 值为:5082594ca2b69fbfbe64e6d6ee2159a7
以下内容为反编译后的 LoginActivity.java 源代码,内容仅作参考
package com.netapp.myautosupport.presentation.login;
import android.app.AlertDialog;
import android.app.KeyguardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.databinding.DataBindingUtil;
import android.graphics.Typeface;
import android.hardware.fingerprint.FingerprintManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.TextView;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.gson.JsonArray;
import com.netapp.myautosupport.BuildConfig;
import com.netapp.myautosupport.Manifest;
import com.netapp.myautosupport.MyAsupApplication;
import com.netapp.myautosupport.R;
import com.netapp.myautosupport.WebViewActivity;
import com.netapp.myautosupport.common.ApiErrorLog;
import com.netapp.myautosupport.common.AppConstants;
import com.netapp.myautosupport.common.SharedPreferenceHandle;
import com.netapp.myautosupport.common.Utils;
import com.netapp.myautosupport.databinding.ActivityLoginBinding;
import com.netapp.myautosupport.fingerprintAuth.FingerPrintLoginHandler;
import com.netapp.myautosupport.fingerprintAuth.FpAuthInterface;
import com.netapp.myautosupport.models.NotificationPreference;
import com.netapp.myautosupport.models.User;
import com.netapp.myautosupport.presentation.base.BaseActivity;
import com.netapp.myautosupport.presentation.login.LoginContract;
import com.netapp.myautosupport.presentation.login.agreement.LicenseAgreementActivity;
import com.netapp.myautosupport.presentation.login.biometricagreement.BiometricAgreementActivity;
import com.netapp.myautosupport.presentation.main.MainActivity;
import com.netapp.myautosupport.services.ServiceGenerator;
import com.netapp.myautosupport.singleton.NotificationInfo;
import com.netapp.myautosupport.singleton.UserInfo;
import io.fabric.sdk.android.services.common.AbstractSpiCall;
import java.io.BufferedInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import javax.crypto.Cipher;
import net.smartam.leeloo.client.request.OAuthClientRequest;
import okhttp3.Credentials;
import org.json.JSONObject;
import org.jsoup.Jsoup;
import org.kxml2.wap.Wbxml;
import uk.co.chrisjenx.calligraphy.CalligraphyContextWrapper;
public class LoginActivity extends BaseActivity implements LoginContract.View, FpAuthInterface, AppConstants {
ActivityLoginBinding activityLoginBinding;
LoginPresenter loginPresenter;
private String mErrorResponse;
private int mFailureType;
boolean mFingerPrint;
FingerPrintLoginHandler mFpHandler;
private boolean mFpRegistration;
private User mUserInfoObject;
private AlertDialog m_cObjDialog;
boolean misAuth;
String password;
SharedPreferenceHandle sharedPreferenceHandle;
String username;
Utils utils;
private final String TAG = LoginActivity.class.getSimpleName();
private final int EMAIL_INTENT_KEY = 1000;
private final int REQ_FINGERPRINT_PERMISSION = 4;
private final int REQ_FINGERPRINT_ENROLLMENT = 5;
private final int FP_NEW_USER = 11001;
private final int FP_NEW_OTHER_USER = 11002;
private final int FP_EXISTING_USER = 11003;
@Override
public void authTokenFailure(String str) {
}
@Override
public void authTokenSuccess(String str) {
}
@Override
public void sendTokenFailure(String str, String str2, String str3, int i) {
}
@Override
public void sendTokenSuccess(String str) {
}
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
this.mErrorResponse = "";
this.mFailureType = 0;
this.utils = Utils.getInstance();
this.activityLoginBinding = (ActivityLoginBinding) DataBindingUtil.setContentView(this, R.layout.activity_login);
this.sharedPreferenceHandle = SharedPreferenceHandle.getSharedPreferenceHandle(this);
logEvent("Login Page");
this.misAuth = false;
this.mFingerPrint = true;
String string = this.sharedPreferenceHandle.getString(AppConstants.CURRENT_LOGIN_USER, "");
this.activityLoginBinding.activityLoginUsernameEt.setText(string);
this.activityLoginBinding.appVersionTv.setText(String.format("V %s", BuildConfig.VERSION_NAME));
this.activityLoginBinding.activityLoginUsernameEt.setSelection(string.length());
if (Build.VERSION.SDK_INT >= 23) {
this.mFpHandler = new FingerPrintLoginHandler(this, this);
}
this.loginPresenter = new LoginPresenter();
this.loginPresenter.attachView(this);
this.activityLoginBinding.activityLoginSigninTv.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
LoginActivity.this.lambda$onCreate$0$LoginActivity(view);
}
});
this.activityLoginBinding.activityLoginHelpFaqTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginActivity.this.logEvent("Login - FAQ");
Intent intent = new Intent(LoginActivity.this, WebViewActivity.class);
intent.putExtra(AppConstants.ERROR_LOG, LoginActivity.this.mErrorResponse);
intent.putExtra("android.intent.extra.TITLE", LoginActivity.this.getResources().getString(R.string.sign_in_back_button));
LoginActivity.this.startActivity(intent);
}
});
this.activityLoginBinding.passwordVisibleIcon.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
LoginActivity.this.activityLoginBinding.etPassword.setTypeface(Typeface.createFromAsset(LoginActivity.this.getAssets(), "fonts/Montserrat-Light.ttf"));
if (z) {
LoginActivity.this.activityLoginBinding.etPassword.setInputType(1);
return;
}
LoginActivity.this.activityLoginBinding.etPassword.setInputType(Wbxml.EXT_T_1);
LoginActivity.this.activityLoginBinding.etPassword.setSelection(LoginActivity.this.activityLoginBinding.etPassword.getText().length());
}
});
}
public void lambda$onCreate$0$LoginActivity(View view) {
this.mFingerPrint = false;
this.misAuth = false;
this.username = this.activityLoginBinding.activityLoginUsernameEt.getText().toString();
this.password = this.activityLoginBinding.etPassword.getText().toString();
logEvent("Sign in with Manual");
doLogin();
}
@Override
public void onResume() {
super.onResume();
long j = this.sharedPreferenceHandle.getLong(AppConstants.UPGRADE_DATE, 0L);
long time = new Date().getTime();
boolean z = false;
if ((0 == j || time - j >= AppConstants.WEEKLY_TIME) && this.utils.isNetworkAvailable(this)) {
try {
if (!new VersionChecker().execute(new String[0]).get().trim().equalsIgnoreCase(BuildConfig.VERSION_NAME.trim())) {
z = true;
this.sharedPreferenceHandle.putLong(AppConstants.UPGRADE_DATE, new Date().getTime());
displayUpgradePopup();
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e2) {
e2.printStackTrace();
}
}
if (z) {
return;
}
processesOnResume();
}
public void processesOnResume() {
if (!checkFpForDevice()) {
try {
this.username = this.sharedPreferenceHandle.getString(AppConstants.CURRENT_LOGIN_USER, null);
if (this.username != null) {
this.sharedPreferenceHandle.putString(AppConstants.FPUSERNAME, this.username);
}
this.mFpHandler.deleteFpKey(this.sharedPreferenceHandle);
} catch (Exception e) {
e.printStackTrace();
}
}
if (this.sharedPreferenceHandle.getBoolean(AppConstants.FINGER_PRINT_APP_ENROLLMENT, false)) {
AuthenticateUsingFp();
}
}
@Override
public void onPause() {
FingerPrintLoginHandler fingerPrintLoginHandler = this.mFpHandler;
if (fingerPrintLoginHandler != null) {
fingerPrintLoginHandler.stopAuth();
}
hideDialog();
super.onPause();
}
@Override
protected void onStop() {
super.onStop();
findViewById(R.id.activity_login_layout).setVisibility(0);
findViewById(R.id.Login_Error_View).setVisibility(8);
}
public void doLogin() {
String string = this.sharedPreferenceHandle.getString("username", "");
if (this.username.trim().length() > 0 && !string.equals(this.username)) {
String string2 = this.sharedPreferenceHandle.getString(AppConstants.FIRST_TIME_USER_LOGIN_SEARCH_SWIPE_ALERT, "");
String string3 = this.sharedPreferenceHandle.getString(AppConstants.FIRST_TIME_USER_LOGIN_EFFICIENCY_ALERT, "");
String string4 = this.sharedPreferenceHandle.getString(AppConstants.FPUSERNAME, "");
String string5 = this.sharedPreferenceHandle.getString(AppConstants.CURRENT_LOGIN_USER, "");
boolean z = this.sharedPreferenceHandle.getBoolean(AppConstants.FINGER_PRINT_APP_ENROLLMENT, false);
long j = this.sharedPreferenceHandle.getLong(AppConstants.UPGRADE_DATE, 0L);
this.sharedPreferenceHandle.clearSharedPreference();
this.sharedPreferenceHandle.putString(AppConstants.FPUSERNAME, string4);
this.sharedPreferenceHandle.putString(AppConstants.CURRENT_LOGIN_USER, string5);
this.sharedPreferenceHandle.putBoolean(AppConstants.FINGER_PRINT_APP_ENROLLMENT, z);
this.sharedPreferenceHandle.putString(AppConstants.FIRST_TIME_USER_LOGIN_SEARCH_SWIPE_ALERT, string2);
this.sharedPreferenceHandle.putString(AppConstants.FIRST_TIME_USER_LOGIN_EFFICIENCY_ALERT, string3);
this.sharedPreferenceHandle.putLong(AppConstants.UPGRADE_DATE, j);
}
if (!this.loginPresenter.checkInput(this.username) && !this.loginPresenter.checkInput(this.password)) {
this.utils.showDialogWithOneButton(this, getString(R.string.enter_username_password));
} else if (!this.loginPresenter.checkInput(this.username)) {
this.utils.showDialogWithOneButton(this, getString(R.string.enter_user_name));
} else if (!this.loginPresenter.checkInput(this.password)) {
this.utils.showDialogWithOneButton(this, getString(R.string.enter_password));
} else if (this.utils.isNetworkAvailable(this)) {
this.username = netAppEmailValidation(this.username);
this.loginPresenter.login(this.username, this.password, getString(R.string.login_url));
} else {
this.utils.showDialogWithOneButton(this, AppConstants.CHECK_INTERNET_MSG);
}
}
@Override
public void loginSuccess(String str) {
this.sharedPreferenceHandle.putBoolean(AppConstants.IS_LOGOUT, false);
MyAsupApplication.SSO_COOKIE = str;
String str2 = this.TAG;
Log.d(str2, "loginSuccess: cookie:" + MyAsupApplication.SSO_COOKIE);
this.sharedPreferenceHandle.putString(AppConstants.LOGIN_KEY, AppConstants.LOGGED_IN_KEY);
this.sharedPreferenceHandle.putString("username", this.username);
this.sharedPreferenceHandle.putString(AppConstants.CURRENT_LOGIN_USER, this.username);
if (this.utils.isNetworkAvailable(this)) {
new OAuthAuthentication().execute(getString(R.string.authorization_url), getString(R.string.client_id), getString(R.string.redirect_url));
} else {
this.utils.showDialogWithOneButton(this, AppConstants.CHECK_INTERNET_MSG);
}
}
@Override
public void loginFailure(ApiErrorLog apiErrorLog, String str) {
String str2;
String string = this.sharedPreferenceHandle.getString(AppConstants.FPUSERNAME, null);
if (this.username == null) {
this.username = this.sharedPreferenceHandle.getString(AppConstants.CURRENT_LOGIN_USER, null);
}
if (this.sharedPreferenceHandle.getBoolean(AppConstants.FINGER_PRINT_APP_ENROLLMENT, false) && (str2 = this.username) != null && string != null && string.equalsIgnoreCase(str2) && this.mFingerPrint) {
if (apiErrorLog.getErrorCode() == 401) {
super.showError(getString(R.string.fingerprint_login_update));
this.mFpHandler.deleteFpKey(this.sharedPreferenceHandle);
return;
} else if (apiErrorLog.getErrorCode() == 3) {
displayRetryPopup(apiErrorLog.getErrorMsg());
return;
} else {
this.mFailureType = 1;
this.mErrorResponse = getErrorResponse(str, true, apiErrorLog);
displayApiFailedpopup(str, apiErrorLog.getErrorMsg());
return;
}
}
if (apiErrorLog.getErrorCode() == 401 || apiErrorLog.getErrorMsg().equalsIgnoreCase(AppConstants.CHECK_INTERNET_MSG)) {
super.showError(apiErrorLog.getErrorMsg());
} else if (apiErrorLog.getErrorCode() == 3) {
displayRetryPopup(apiErrorLog.getErrorMsg());
} else {
this.mFailureType = 1;
this.mErrorResponse = getErrorResponse(str, false, apiErrorLog);
displayApiFailedpopup(str, apiErrorLog.getErrorMsg());
}
this.sharedPreferenceHandle.putString(AppConstants.CURRENT_LOGIN_USER, string);
}
@Override
public void userInfoSuccess(User user) {
Utils.writeUserInfoForInMemoryAccess(user);
String str = this.TAG;
Log.d(str, "userInfoSuccess: userType:" + user.getCRMCUSTOMERTYPE());
this.mUserInfoObject = user;
if (!user.getCRMCUSTOMERTYPE().equalsIgnoreCase(AppConstants.EXTERNAL) && !user.getCRMCUSTOMERTYPE().equalsIgnoreCase(AppConstants.RESELLER)) {
NotificationInfo.INSTANCE.reset();
} else {
if ((this.sharedPreferenceHandle.getBoolean(AppConstants.SHOULD_REFRESH_FCM_TOKEN, true) || !user.getUSERNAME().equalsIgnoreCase(this.sharedPreferenceHandle.getString(AppConstants.CUSTOMER_NAME, ""))) && FirebaseInstanceId.getInstance().getToken() != null) {
this.loginPresenter.sendGcmToken();
}
if (NotificationInfo.INSTANCE.getNotificationType() != null && !NotificationInfo.INSTANCE.getNotificationType().isEmpty() && !NotificationInfo.INSTANCE.getTargetUserId().equalsIgnoreCase(user.getUSERNAME())) {
NotificationInfo.INSTANCE.reset();
}
}
this.sharedPreferenceHandle.putString(AppConstants.USER_TYPE, user.getCRMCUSTOMERTYPE());
this.sharedPreferenceHandle.putString(AppConstants.CUSTOMER_ID, user.getCRMCOMPANYID());
this.sharedPreferenceHandle.putString(AppConstants.CUSTOMER_NAME, user.getUSERNAME());
if (this.mFingerPrint) {
logEvent("SSO call Success with BioMetric");
} else {
logEvent("SSO call Success with Manual Sign in");
}
if (this.mUserInfoObject.getLicense_agreement() != null && this.mUserInfoObject.getLicense_agreement().equalsIgnoreCase(AppConstants.YES)) {
LicenseAgreed();
} else {
startActivityForResult(new Intent(this, LicenseAgreementActivity.class), 101);
}
}
@Override
public void userInfoFailure(ApiErrorLog apiErrorLog) {
this.mErrorResponse = getErrorResponse(this.username, false, apiErrorLog);
disPlayErrorScreen("UserInfo", apiErrorLog);
}
private void LicenseAgreed() {
if (this.mUserInfoObject.getBiometricEnabled() != null && this.mUserInfoObject.getBiometricEnabled().contains("true")) {
doBioMetricRegd();
return;
}
this.mFpHandler.deleteFpKey(this.sharedPreferenceHandle);
authFinished();
}
private void doBioMetricRegd() {
SharedPreferences sharedPreferences = getSharedPreferences(AppConstants.FINGER_PRINT_AGREEMENT_AGREED, 0);
this.misAuth = false;
if (checkDeviceCompatibility()) {
if (this.sharedPreferenceHandle.getBoolean(AppConstants.FINGER_PRINT_APP_ENROLLMENT, false)) {
authFinished();
return;
} else if (this.mUserInfoObject.getFingerprint_agreement().equalsIgnoreCase("Y")) {
this.misAuth = true;
if (AuthenticateUsingFp()) {
return;
}
authFinished();
return;
} else if (sharedPreferences.getString(this.username.trim(), null) == null) {
Intent intent = new Intent(this, BiometricAgreementActivity.class);
intent.putExtra("USER", this.username);
startActivityForResult(intent, 100);
return;
} else {
authFinished();
return;
}
}
authFinished();
}
@Override
public void faqSuccess(String str) {
Intent intent = new Intent(this, MainActivity.class);
String str2 = this.TAG;
Log.d(str2, "faqSuccess: " + str);
intent.putExtra("url", str);
startActivity(intent);
finish();
}
@Override
public void getSubscriptionPreferenceSuccess(JsonArray jsonArray, ArrayList<NotificationPreference> arrayList) {
if (jsonArray.size() > 0) {
this.sharedPreferenceHandle.putBoolean(AppConstants.SHOW_NEWSLETTER, false);
for (int i = 0; i < jsonArray.size(); i++) {
if (jsonArray.get(i).getAsString().contains(AppConstants.eventMetaId.NEWSLETTER)) {
this.sharedPreferenceHandle.putBoolean(AppConstants.SHOW_NEWSLETTER, true);
} else if (jsonArray.get(i).getAsString().equalsIgnoreCase(AppConstants.eventMetaId.RENEWAL) || jsonArray.get(i).getAsString().equalsIgnoreCase(AppConstants.eventMetaId.CAPACITY) || jsonArray.get(i).getAsString().equalsIgnoreCase(AppConstants.eventMetaId.RISK)) {
if (!UserInfo.INSTANCE.getCustomerType().equalsIgnoreCase(AppConstants.INTERNAL)) {
this.sharedPreferenceHandle.putBoolean(AppConstants.SHOW_SETTINGS, true);
} else {
this.sharedPreferenceHandle.putBoolean(AppConstants.SHOW_SETTINGS, false);
}
}
}
} else {
this.sharedPreferenceHandle.putBoolean(AppConstants.SHOW_SETTINGS, false);
this.sharedPreferenceHandle.putBoolean(AppConstants.SHOW_NEWSLETTER, false);
}
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(AppConstants.SETTINGS_PREFERENCE_DATA, arrayList);
startActivity(intent);
finish();
}
@Override
public void getSubscriptionPreferenceFailure(ApiErrorLog apiErrorLog) {
Log.e(this.TAG, apiErrorLog.getResponse());
this.sharedPreferenceHandle.putBoolean(AppConstants.SHOW_SETTINGS, false);
this.sharedPreferenceHandle.putBoolean(AppConstants.SHOW_NEWSLETTER, false);
this.mErrorResponse = getErrorResponse(this.username, false, apiErrorLog);
disPlayErrorScreen("preference", apiErrorLog);
}
@Override
protected void attachBaseContext(Context context) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(context));
}
@Override
protected void onDestroy() {
super.onDestroy();
this.loginPresenter.detachView();
}
public String netAppEmailValidation(String str) {
return str.contains("@netapp.com") ? str.replace("@netapp.com", "") : str;
}
@Override
public void authSucesses(Cipher cipher) {
hideDialog();
if (!this.sharedPreferenceHandle.getBoolean(AppConstants.FINGER_PRINT_APP_ENROLLMENT, false)) {
logEvent("Biometric Registration Success");
this.sharedPreferenceHandle.putBoolean(AppConstants.FINGER_PRINT_APP_ENROLLMENT, true);
this.sharedPreferenceHandle.putString(AppConstants.FPUSERNAME, this.username);
this.mFpHandler.create(cipher, this.username, this.password);
return;
}
try {
String credential = this.mFpHandler.getCredential(cipher);
this.username = credential.split("/")[0];
this.password = credential.split("/")[1];
doLogin();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void authFaild(int i) {
hideDialog();
switch (i) {
case FingerPrintLoginHandler.ERROR_FP_AUTH_FAILED:
displayYesNoAlert(R.string.fingerprint_error, null, FingerPrintLoginHandler.ERROR_FP_AUTH_FAILED);
return;
case FingerPrintLoginHandler.ERROR_FP_TOO_MANY_ATTEMPTS:
if (this.mFpRegistration) {
showErrorAlert(R.string.fingerprint_error_many_attempts, null, R.string.ok, 11);
return;
} else {
showErrorAlert(R.string.fingerprint_error_many_attempts, null, R.string.ok, -1);
return;
}
case FingerPrintLoginHandler.ERROR_FP_USER_CANCEL:
authFinished();
return;
case FingerPrintLoginHandler.ERROR_FP_CANCELED:
hideDialog();
logEvent("Biometric Signin");
return;
default:
return;
}
}
@Override
public void authFinished() {
this.loginPresenter.getSubscriptionPreference();
}
public boolean checkFpForDevice() {
FingerprintManager fingerprintManager;
if (Build.VERSION.SDK_INT < 23 || (fingerprintManager = (FingerprintManager) getSystemService("fingerprint")) == null || ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != 0 || !fingerprintManager.isHardwareDetected()) {
return false;
}
try {
if (fingerprintManager.isHardwareDetected()) {
return fingerprintManager.hasEnrolledFingerprints();
}
return false;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public boolean checkDeviceCompatibility() {
FingerprintManager fingerprintManager;
return Build.VERSION.SDK_INT >= 23 && (fingerprintManager = (FingerprintManager) getSystemService("fingerprint")) != null && ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) == 0 && fingerprintManager.isHardwareDetected();
}
public boolean AuthenticateUsingFp() {
int i;
if (Build.VERSION.SDK_INT >= 23) {
if (Utils.FINGER_PRINT_AUTH) {
KeyguardManager keyguardManager = (KeyguardManager) getSystemService("keyguard");
FingerprintManager fingerprintManager = (FingerprintManager) getSystemService("fingerprint");
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.USE_FINGERPRINT) != 0) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.USE_FINGERPRINT}, 4);
return false;
}
if (!fingerprintManager.hasEnrolledFingerprints()) {
displayYesNoAlert(R.string.fingerprint_enroll_on_device, null, R.string.fingerprint_setting, R.string.fingerprint_not_now, 5);
} else if (keyguardManager.isKeyguardSecure()) {
try {
if (!this.sharedPreferenceHandle.getBoolean(AppConstants.FINGER_PRINT_APP_ENROLLMENT, false)) {
i = 11001;
this.mFpRegistration = true;
} else {
i = 11003;
this.mFpRegistration = false;
}
this.mFingerPrint = true;
showFpAuthDialog(i);
this.mFpHandler.startAuth();
} catch (Exception e) {
e.printStackTrace();
Log.e(this.TAG, e.toString());
}
} else {
Log.e(this.TAG, "Key guard lock not available.");
}
return true;
}
Log.e(this.TAG, "Device is rooted");
return false;
}
String str = this.TAG;
Log.e(str, "Lower end device :" + Build.VERSION.SDK_INT);
return false;
}
@Override
public void onActivityResult(int i, int i2, Intent intent) {
super.onActivityResult(i, i2, intent);
if (i == 5) {
AuthenticateUsingFp();
} else if (i != 100) {
if (i == 101 && i2 == -1) {
LicenseAgreed();
}
} else {
SharedPreferences sharedPreferences = getSharedPreferences(AppConstants.FINGER_PRINT_AGREEMENT_AGREED, 0);
if (sharedPreferences.getString(this.username.trim(), null) != null && sharedPreferences.getString(this.username.trim(), null).equalsIgnoreCase("YES")) {
this.misAuth = true;
if (AuthenticateUsingFp()) {
return;
}
authFinished();
return;
}
authFinished();
}
}
public void displayYesNoAlert(int i, String str, int i2, int i3) {
displayYesNoAlert(i, str, i2, i3, -1);
}
public void displayYesNoAlert(int i, String str, int i2) {
displayYesNoAlert(i, str, -1, -1, i2);
}
public void displayYesNoAlert(int i, String str, int i2, int i3, final int i4) {
hideDialog();
if (str == null) {
str = getString(i);
}
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
builder.setTitle(getString(R.string.app_name));
builder.setMessage(str);
if (-1 == i2) {
i2 = R.string.yes;
}
builder.setPositiveButton(getString(i2), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i5) {
LoginActivity.this.hideDialog();
int i6 = i4;
if (i6 == 5) {
LoginActivity.this.startActivityForResult(new Intent("android.settings.SETTINGS"), 5);
} else if (i6 != 5000) {
} else {
LoginActivity.this.AuthenticateUsingFp();
}
}
});
builder.setNegativeButton(-1 != i3 ? getString(i3) : getString(R.string.no), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i5) {
int i6 = i4;
if ((i6 == 5 || i6 == 5000) && LoginActivity.this.misAuth) {
LoginActivity.this.mFpHandler.deleteFpKey(LoginActivity.this.sharedPreferenceHandle);
LoginActivity.this.authFinished();
}
LoginActivity.this.hideDialog();
}
});
this.m_cObjDialog = builder.create();
this.m_cObjDialog.show();
}
public void showFpAuthDialog(final int i) {
hideDialog();
String str = "";
if (i == 11001) {
str = getResources().getString(R.string.fingerprint_signup);
} else if (i == 11003) {
str = getResources().getString(R.string.fingerprint_signin, this.sharedPreferenceHandle.getString(AppConstants.FPUSERNAME, ""));
}
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
builder.setTitle(getString(R.string.app_name));
View inflate = LayoutInflater.from(this).inflate(R.layout.dialog_fingerprint_auth, (ViewGroup) null);
builder.setView(inflate);
((TextView) inflate.findViewById(R.id.fp_dialog_message_text)).setText(str);
((TextView) inflate.findViewById(R.id.fp_dialog_cancel_btn)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginActivity.this.mFpHandler.stopAuth();
if (i == 11001) {
LoginActivity.this.authFinished();
}
LoginActivity.this.hideDialog();
}
});
this.m_cObjDialog = builder.create();
this.m_cObjDialog.show();
}
public void showErrorAlert(int i, String str) {
showErrorAlert(i, str, -1, -1);
}
public void showErrorAlert(int i, String str, int i2, final int i3) {
if (str == null) {
str = getResources().getString(i);
}
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
builder.setTitle(getString(R.string.app_name));
builder.setMessage(str);
builder.setPositiveButton(-1 != i2 ? getString(i2) : getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i4) {
LoginActivity.this.hideDialog();
if (i3 == 11) {
LoginActivity.this.authFinished();
}
}
});
this.m_cObjDialog = builder.create();
this.m_cObjDialog.show();
}
public void hideDialog() {
AlertDialog alertDialog = this.m_cObjDialog;
if (alertDialog != null) {
alertDialog.dismiss();
this.m_cObjDialog = null;
}
}
public String getLandingPage(String str) {
char c;
int hashCode = str.hashCode();
if (hashCode != -1038134325) {
if (hashCode == 432053106 && str.equals(AppConstants.RESELLER)) {
c = 1;
}
c = 65535;
} else {
if (str.equals(AppConstants.EXTERNAL)) {
c = 0;
}
c = 65535;
}
return c != 0 ? c != 1 ? AppConstants.INTERNAL : AppConstants.RESELLER : AppConstants.EXTERNAL;
}
@Override
protected void onStart() {
super.onStart();
}
private void disPlayErrorScreen(String str, ApiErrorLog apiErrorLog) {
if (apiErrorLog.getErrorCode() != 0) {
this.loginPresenter.LogError(apiErrorLog.getUrl(), apiErrorLog.getErrorMsg(), apiErrorLog.getResponse(), apiErrorLog.getErrorCode());
}
hideLoading();
findViewById(R.id.activity_login_layout).setVisibility(8);
findViewById(R.id.Login_Error_View).setVisibility(0);
((TextView) findViewById(R.id.dialog_error_error_txt)).setText(apiErrorLog.getErrorMsg());
findViewById(R.id.dialog_error_retry_btn).setTag(str);
findViewById(R.id.dialog_error_retry_btn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (LoginActivity.this.utils.isNetworkAvailable(LoginActivity.this)) {
LoginActivity.this.showLoading();
String str2 = (String) view.getTag();
char c = 65535;
int hashCode = str2.hashCode();
if (hashCode != -1459831589) {
if (hashCode == -202159303 && str2.equals("UserInfo")) {
c = 1;
}
} else if (str2.equals("preference")) {
c = 0;
}
if (c == 0) {
LoginActivity.this.loginPresenter.getSubscriptionPreference();
return;
} else if (c != 1) {
return;
} else {
LoginActivity.this.loginPresenter.userInfo();
return;
}
}
((TextView) LoginActivity.this.findViewById(R.id.dialog_error_error_txt)).setText(AppConstants.CHECK_INTERNET_MSG);
}
});
findViewById(R.id.dialog_error_close_img).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginActivity.this.findViewById(R.id.activity_login_layout).setVisibility(0);
LoginActivity.this.findViewById(R.id.Login_Error_View).setVisibility(8);
}
});
}
public void displayRetryPopup(String str) {
hideLoading();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
View inflate = ((LayoutInflater) getSystemService("layout_inflater")).inflate(R.layout.dialog_api_error_without_email, (ViewGroup) null);
((TextView) inflate.findViewById(R.id.dialog_error_txt)).setText(str);
builder.setView(inflate);
inflate.findViewById(R.id.dialog_close_img).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginActivity.this.m_cObjDialog.dismiss();
}
});
((TextView) inflate.findViewById(R.id.dialog_retry_btn)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginActivity.this.m_cObjDialog.dismiss();
LoginActivity.this.doLogin();
}
});
this.m_cObjDialog = builder.create();
this.m_cObjDialog.show();
}
public void displayApiFailedpopup(final String str, String str2) {
hideLoading();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
View inflate = ((LayoutInflater) getSystemService("layout_inflater")).inflate(R.layout.dialog_api_error, (ViewGroup) null);
((TextView) inflate.findViewById(R.id.dialog_error_error_txt)).setText(str2);
builder.setView(inflate);
inflate.findViewById(R.id.dialog_error_close_img).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginActivity.this.m_cObjDialog.dismiss();
}
});
((TextView) inflate.findViewById(R.id.dialog_error_need_help_btn)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginActivity.this.m_cObjDialog.dismiss();
Intent intent = new Intent(LoginActivity.this, WebViewActivity.class);
intent.putExtra(AppConstants.ERROR_LOG, LoginActivity.this.mErrorResponse);
intent.putExtra("username", str);
intent.putExtra(AppConstants.ERROR_TYPE, LoginActivity.this.mFailureType);
intent.putExtra("android.intent.extra.TITLE", LoginActivity.this.getResources().getString(R.string.sign_in_back_button));
LoginActivity.this.startActivity(intent);
}
});
((TextView) inflate.findViewById(R.id.dialog_error_retry_btn)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginActivity.this.m_cObjDialog.dismiss();
LoginActivity.this.doLogin();
}
});
this.m_cObjDialog = builder.create();
this.m_cObjDialog.show();
}
public class VersionChecker extends AsyncTask<String, String, String> {
String newVersion;
public VersionChecker() {
}
@Override
protected void onPreExecute() {
super.onPreExecute();
LoginActivity.this.showLoading();
}
@Override
public String doInBackground(String... strArr) {
try {
this.newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=com.netapp.myautosupport").timeout(30000).userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6").referrer("http://www.google.com").get().select("div.hAyfc:nth-child(4) > span:nth-child(2) > div:nth-child(1) > span:nth-child(1)").first().ownText();
} catch (IOException e) {
e.printStackTrace();
}
return this.newVersion;
}
@Override
public void onPostExecute(String str) {
super.onPostExecute((VersionChecker) str);
LoginActivity.this.hideLoading();
}
}
public void displayUpgradePopup() {
hideLoading();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(false);
View inflate = ((LayoutInflater) getSystemService("layout_inflater")).inflate(R.layout.dialog_upgrade_app, (ViewGroup) null);
builder.setView(inflate);
((TextView) inflate.findViewById(R.id.dialog_update_cancel_btn)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginActivity.this.m_cObjDialog.dismiss();
LoginActivity.this.processesOnResume();
}
});
((TextView) inflate.findViewById(R.id.dialog_update_btn)).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LoginActivity.this.m_cObjDialog.dismiss();
LoginActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse("market://details?id=com.netapp.myautosupport")));
}
});
this.m_cObjDialog = builder.create();
this.m_cObjDialog.show();
}
private class OAuthAuthentication extends AsyncTask<String, String, String> {
private OAuthAuthentication() {
}
@Override
protected void onPreExecute() {
super.onPreExecute();
try {
Utils.getInstance().showProgressDialog(LoginActivity.this);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public String doInBackground(String... strArr) {
String str = "";
try {
OAuthClientRequest buildQueryMessage = OAuthClientRequest.authorizationLocation(strArr[0]).setClientId(strArr[1]).setScope(LoginActivity.this.getString(R.string.scopes)).setRedirectURI(strArr[2]).buildQueryMessage();
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(Uri.parse(buildQueryMessage.getLocationUri() + "&response_type=code").toString()).openConnection();
httpURLConnection.setConnectTimeout(AbstractSpiCall.DEFAULT_TIMEOUT);
httpURLConnection.setReadTimeout(AbstractSpiCall.DEFAULT_TIMEOUT);
httpURLConnection.setInstanceFollowRedirects(true);
httpURLConnection.setRequestProperty("Cookie", MyAsupApplication.SSO_COOKIE + "; domain=netapp.com; path=/; secure=true; httponly");
if (httpURLConnection.getResponseCode() == 200) {
String fragment = Uri.parse(String.valueOf(httpURLConnection.getURL())).getFragment();
if (fragment != null && !fragment.isEmpty()) {
str = fragment.substring(fragment.indexOf("=") + 1);
String str2 = LoginActivity.this.TAG;
Log.d(str2, "grantCode :: " + str);
}
UserInfo.INSTANCE.setGrantCode(str);
LoginActivity.this.sharedPreferenceHandle.putString(AppConstants.GRANT_CODE, str);
}
httpURLConnection.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
@Override
public void onPostExecute(String str) {
super.onPostExecute((OAuthAuthentication) str);
try {
Utils.getInstance().dismissDialog();
HashMap hashMap = new HashMap();
hashMap.put("grant_type", AppConstants.GrantType.AUTHORIZATION_CODE.toString());
hashMap.put("code", str);
hashMap.put("redirect_uri", LoginActivity.this.getResources().getString(R.string.redirect_url));
new AuthTokenAsyncTask(hashMap).execute(LoginActivity.this.getResources().getString(R.string.auth_token_url));
} catch (Exception e) {
e.printStackTrace();
}
}
}
public class AuthTokenAsyncTask extends AsyncTask<String, Void, Void> {
JSONObject postData;
public AuthTokenAsyncTask(Map<String, String> map) {
if (map != null) {
this.postData = new JSONObject(map);
}
}
@Override
protected void onPreExecute() {
super.onPreExecute();
Utils.getInstance().showProgressDialog(LoginActivity.this);
}
@Override
public Void doInBackground(String... strArr) {
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(strArr[0]).openConnection();
httpURLConnection.setDoInput(true);
httpURLConnection.setDoOutput(true);
httpURLConnection.setInstanceFollowRedirects(false);
httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
httpURLConnection.setUseCaches(false);
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setRequestProperty("Authorization", Credentials.basic(LoginActivity.this.getResources().getString(R.string.client_id), LoginActivity.this.getResources().getString(R.string.client_secret)));
if (this.postData != null) {
String format = String.format("redirect_uri=%s&grant_type=%s&code=%s", this.postData.getString("redirect_uri"), this.postData.getString("grant_type"), this.postData.getString("code"));
DataOutputStream dataOutputStream = new DataOutputStream(httpURLConnection.getOutputStream());
dataOutputStream.write(format.getBytes());
dataOutputStream.flush();
}
if (httpURLConnection.getResponseCode() == 200) {
JSONObject jSONObject = new JSONObject(Utils.convertInputStreamToString(new BufferedInputStream(httpURLConnection.getInputStream())));
if (jSONObject.has("access_token")) {
String string = jSONObject.getString("access_token");
String str = LoginActivity.this.TAG;
Log.d(str, "AccessToken :: " + string);
if (string != null && !string.isEmpty()) {
MyAsupApplication.ACCESS_TOKEN = string;
UserInfo.INSTANCE.setAccessToken(string);
LoginActivity.this.sharedPreferenceHandle.putString("access_token", string);
}
}
if (jSONObject.has("refresh_token")) {
String string2 = jSONObject.getString("refresh_token");
String str2 = LoginActivity.this.TAG;
Log.d(str2, "RefreshToken :: " + string2);
if (string2 == null || string2.isEmpty()) {
return null;
}
UserInfo.INSTANCE.setRefreshToken(string2);
LoginActivity.this.sharedPreferenceHandle.putString("refresh_token", string2);
return null;
}
return null;
}
return null;
} catch (Exception e) {
Log.e(LoginActivity.this.TAG, e.getLocalizedMessage());
PrintStream printStream = System.out;
printStream.print(LoginActivity.this.TAG + "::::::::" + e.getLocalizedMessage());
return null;
}
}
@Override
public void onPostExecute(Void r5) {
super.onPostExecute((AuthTokenAsyncTask) r5);
Utils.getInstance().dismissDialog();
ServiceGenerator.setRequiredValues(MyAsupApplication.SSO_COOKIE, MyAsupApplication.ACCESS_TOKEN, LoginActivity.this.getString(R.string.url), LoginActivity.this.getString(R.string.aiq_public_api_base_url));
if (LoginActivity.this.utils.isNetworkAvailable(LoginActivity.this)) {
UserInfo.INSTANCE.reset();
LoginActivity.this.loginPresenter.userInfo();
return;
}
LoginActivity.this.utils.showDialogWithOneButton(LoginActivity.this, AppConstants.CHECK_INTERNET_MSG);
}
}
}