Browse Source

Biometric migration fixes

master
Preyea Regmi 4 years ago
parent
commit
f9976e07ec
  1. BIN
      .idea/caches/build_file_checksums.ser
  2. 2
      app/build.gradle
  3. 2
      app/src/main/java/com/gmeremit/online/gmeremittance_native/loginV2/presenter/LoginV2Presenter.java
  4. 4
      app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/view/profilechange/UserEmailChangeActivity.java
  5. 4
      app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/view/profilechange/UserMobileChangeActivity.java
  6. 106
      app/src/main/java/com/gmeremit/online/gmeremittance_native/security/GMEAuthManager.java
  7. 21
      app/src/main/java/com/gmeremit/online/gmeremittance_native/security/GMEAuthManagerGateway.java
  8. 31
      app/src/main/java/com/gmeremit/online/gmeremittance_native/settings/view/SettingsView.java

BIN
.idea/caches/build_file_checksums.ser

2
app/build.gradle

@ -149,8 +149,6 @@ dependencies {
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
implementation 'com.scottyab:rootbeer-lib:0.0.7'
// implementation 'com.mtramin:rxfingerprint:2.2.1'
implementation 'com.github.pwittchen:rxbiometric:0.1.0'
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation project(':securitykeypad')

2
app/src/main/java/com/gmeremit/online/gmeremittance_native/loginV2/presenter/LoginV2Presenter.java

@ -80,7 +80,7 @@ public class LoginV2Presenter extends BasePresenter implements LoginV2PresenterI
@Override
public void promptForBiometricAuth() {
GMEAuthManager.getGmeAuthManager((AppCompatActivity) view.getContext()).requestExplicitly(GMEAuthManager.GMEAuthType.BIOMETRIC)
GMEAuthManager.getGmeAuthManager((AppCompatActivity) view.getContext()).requestBiometricAuth()
.setListener(new GMEAuthManager.GMEAuthListener() {
@Override
public void onGMEAuthSuccess(String secret) {

4
app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/view/profilechange/UserEmailChangeActivity.java

@ -69,7 +69,7 @@ public class UserEmailChangeActivity extends BaseActivity implements ProfileChan
public void updateEmail() {
GMEAuthManager.getGmeAuthManager(this).requestExplicitly(GMEAuthManager.GMEAuthType.USER_PASSWORD).setListener(new GMEAuthManager.GMEAuthListener() {
GMEAuthManager.getGmeAuthManager(this).requestAuthPerScreenExplicitly(GMEAuthManager.GMEScreenBasedAuthType.PASSWORD_USER_PROFILE).setListener(new GMEAuthManager.GMEAuthListener() {
@Override
public void onGMEAuthSuccess(String secret) {
viewModel.proceeedToChangeCredential(edTxtEmail.getText().toString(), secret);
@ -90,7 +90,7 @@ public class UserEmailChangeActivity extends BaseActivity implements ProfileChan
@Override
public void onPasswordVerificationSuccess(String targetValue) {
GMEAuthManager.getGmeAuthManager(this).requestExplicitly(GMEAuthManager.GMEAuthType.OTP_PROFILE_SUBMIT)
GMEAuthManager.getGmeAuthManager(this).requestAuthPerScreenExplicitly(GMEAuthManager.GMEScreenBasedAuthType.OTP_SUBMIT_PROFILE)
.setParam(GMEUserProfileChangeOTPRequestBottomSheetDialog.constructParam(targetValue))
.setListener(new GMEAuthManager.GMEAuthListener() {
@Override

4
app/src/main/java/com/gmeremit/online/gmeremittance_native/profile/view/profilechange/UserMobileChangeActivity.java

@ -68,7 +68,7 @@ public class UserMobileChangeActivity extends BaseActivity implements ProfileCha
public void updateMobile() {
GMEAuthManager.getGmeAuthManager(this).requestExplicitly(GMEAuthManager.GMEAuthType.USER_PASSWORD).setListener(new GMEAuthManager.GMEAuthListener() {
GMEAuthManager.getGmeAuthManager(this).requestAuthPerScreenExplicitly(GMEAuthManager.GMEScreenBasedAuthType.PASSWORD_USER_PROFILE).setListener(new GMEAuthManager.GMEAuthListener() {
@Override
public void onGMEAuthSuccess(String secret) {
viewModel.proceeedToChangeCredential(edTxtMobile.getText().toString(), secret);
@ -89,7 +89,7 @@ public class UserMobileChangeActivity extends BaseActivity implements ProfileCha
@Override
public void onPasswordVerificationSuccess(String targetValue) {
GMEAuthManager.getGmeAuthManager(UserMobileChangeActivity.this).requestExplicitly(GMEAuthManager.GMEAuthType.OTP_PROFILE_SUBMIT)
GMEAuthManager.getGmeAuthManager(UserMobileChangeActivity.this).requestAuthPerScreenExplicitly(GMEAuthManager.GMEScreenBasedAuthType.OTP_SUBMIT_PROFILE)
.setParam(GMEUserProfileChangeOTPRequestBottomSheetDialog.constructParam(targetValue))
.setListener(new GMEAuthManager.GMEAuthListener() {
@Override

106
app/src/main/java/com/gmeremit/online/gmeremittance_native/security/GMEAuthManager.java

@ -1,26 +1,18 @@
package com.gmeremit.online.gmeremittance_native.security;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.security.keystore.KeyPermanentlyInvalidatedException;
import android.util.Log;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import com.github.pwittchen.rxbiometric.library.RxBiometric;
import com.github.pwittchen.rxbiometric.library.validation.RxPreconditions;
import com.gmeremit.online.gmeremittance_native.GmeApplication;
import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.base.PrefKeys;
import com.gmeremit.online.gmeremittance_native.base.PrivilegedGateway;
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog;
import com.gmeremit.online.gmeremittance_native.security.auth.GMEUserPasswordPromptBottomSheetDialog;
import com.gmeremit.online.gmeremittance_native.security.auth.GMEUserProfileChangeOTPRequestBottomSheetDialog;
import com.gmeremit.online.gmeremittance_native.security.utils.SecurityUtils;
import com.gmeremit.online.gmeremittance_native.transactionpasspromt.view.TransactionBiometricPromptDialog;
import com.mtramin.rxfingerprint.RxFingerprint;
import com.mtramin.rxfingerprint.data.BiometricExceptions;
import com.mtramin.rxfingerprint.data.FingerprintDecryptionResult;
@ -28,7 +20,6 @@ import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.internal.operators.completable.CompletableError;
import io.reactivex.schedulers.Schedulers;
import static com.gmeremit.online.gmeremittance_native.utils.https.HTTPConstants.INVALID_REQUEST;
@ -45,8 +36,8 @@ public class GMEAuthManager {
private AppCompatActivity context;
private GMEAuthListener listener;
private String paymentSourceType;
private GMEAuthType explicitlyRequestedAuthType;
private GMEAuthType gmeAuthType;
private GMEScreenBasedAuthType explicitlyRequestedAuthType;
private Bundle param;
private GMEAuthManagerGateway gmeAuthManagerGateway;
@ -58,7 +49,7 @@ public class GMEAuthManager {
private void resetParamToDefault() {
listener = null;
paymentSourceType = null;
gmeAuthType = null;
explicitlyRequestedAuthType = null;
}
@ -74,15 +65,36 @@ public class GMEAuthManager {
public GMEAuthManager fromPaymentSource(String paymentSourceType) {
this.paymentSourceType = paymentSourceType;
if ("wallet".equalsIgnoreCase(paymentSourceType))
if (checkIfUserHasEnabledBiometric())
this.gmeAuthType = GMEAuthType.BIOMETRIC;
else
this.gmeAuthType = GMEAuthType.PASSWORD;
else if ("autodebit".equalsIgnoreCase(paymentSourceType))
this.gmeAuthType = GMEAuthType.OTP;
this.explicitlyRequestedAuthType = null;
return this;
}
public GMEAuthManager requestExplicitly(GMEAuthType gmeAuthType) {
public GMEAuthManager requestAuthPerScreenExplicitly(GMEScreenBasedAuthType gmeAuthType) {
this.explicitlyRequestedAuthType = gmeAuthType;
this.paymentSourceType = null;
this.gmeAuthType = null;
return this;
}
public GMEAuthManager requestBiometricAuth() {
this.gmeAuthType = GMEAuthType.BIOMETRIC;
this.explicitlyRequestedAuthType = null;
return this;
}
public GMEAuthManager requestPasswordAuth() {
this.gmeAuthType = GMEAuthType.PASSWORD;
this.explicitlyRequestedAuthType = null;
return this;
}
@ -94,27 +106,45 @@ public class GMEAuthManager {
public void prompt() {
if (explicitlyRequestedAuthType != null) {
startAuthFromRequestedAuthType();
} else {
} else if (gmeAuthType != null) {
startAuthFromPaymentSourceType();
}
} else
returnInvalidRequest();
}
private void startAuthFromPaymentSourceType() {
if ("wallet".equalsIgnoreCase(paymentSourceType))
if (checkIfUserHasEnabledBiometric())
showBiometricAuthPrompt();
else
showUserPasswordPrompt();
else if ("autodebit".equalsIgnoreCase(paymentSourceType))
switch (gmeAuthType) {
case OTP:
showOTPTxnPrompt();
else
returnInvalidRequest();
break;
case PASSWORD:
showUserPasswordPrompt();
break;
case BIOMETRIC:
showBiometricAuthPrompt();
break;
}
}
public boolean isBiometricDataAvailable() {
return gmeAuthManagerGateway.isBiometricDataAvailable();
}
public boolean isBiometricEnabledOnTheApp() {
return gmeAuthManagerGateway.isBiometricEnabledOnTheApp();
}
public boolean isBiometricSupportedByDevice() {
return RxFingerprint.isAvailable(context);
}
private void returnInvalidRequest() {
if (listener != null)
listener.onGMEAuthFailed("Payment source not recognized.\n" + INVALID_REQUEST);
listener.onGMEAuthFailed("Unknown auth requested.\n" + INVALID_REQUEST);
}
private void returnSecret(String secret) {
@ -127,9 +157,6 @@ public class GMEAuthManager {
}
private void showBiometricAuthPrompt() {
// TransactionBiometricPromptDialog promptDialog = new TransactionBiometricPromptDialog();
// promptDialog.show(context.getSupportFragmentManager(), promptDialog.getClass().getSimpleName());
biometricAuthenticateAndReturnUserCredentialOnSuccess()
.subscribeOn(Schedulers.io())
@ -237,19 +264,16 @@ public class GMEAuthManager {
showOTPTxnPrompt();
break;
case OTP_PROFILE_REQUEST:
case OTP_REQUEST_PROFILE:
showOTPProfilePrompt(true);
break;
case OTP_PROFILE_SUBMIT:
case OTP_SUBMIT_PROFILE:
showOTPProfilePrompt(false);
break;
case BIOMETRIC:
showBiometricAuthPrompt();
break;
case USER_PASSWORD:
case PASSWORD_USER_PROFILE:
showUserPasswordPrompt();
break;
@ -260,10 +284,6 @@ public class GMEAuthManager {
}
private static class GMEAuthManagerGateway extends PrivilegedGateway {
}
public static class UserCredentialDecryptionResultDTO {
String userId;
String userPwd;
@ -299,7 +319,11 @@ public class GMEAuthManager {
void onGMEAuthCancelled();
}
public enum GMEScreenBasedAuthType {
PASSWORD_USER_PROFILE, OTP_REQUEST_PROFILE, OTP_SUBMIT_PROFILE, OTP_TXN
}
public enum GMEAuthType {
USER_PASSWORD, BIOMETRIC, OTP_PROFILE_REQUEST, OTP_PROFILE_SUBMIT, OTP_TXN
BIOMETRIC, PASSWORD, OTP
}
}

21
app/src/main/java/com/gmeremit/online/gmeremittance_native/security/GMEAuthManagerGateway.java

@ -0,0 +1,21 @@
package com.gmeremit.online.gmeremittance_native.security;
import android.content.SharedPreferences;
import com.gmeremit.online.gmeremittance_native.GmeApplication;
import com.gmeremit.online.gmeremittance_native.base.PrefKeys;
import com.gmeremit.online.gmeremittance_native.base.PrivilegedGateway;
class GMEAuthManagerGateway extends PrivilegedGateway {
public boolean isBiometricDataAvailable() {
SharedPreferences sp = GmeApplication.getStorage();
return sp.getString(PrefKeys.APP_USER_ID_SECRET_KEY, null) != null && sp.getString(PrefKeys.APP_USER_SECRET_KEY, null) != null && sp.getString(PrefKeys.APP_SECRET_KEY, null) != null;
}
public boolean isBiometricEnabledOnTheApp() {
return GmeApplication.getStorage().getBoolean(PrefKeys.APP_FINGER_PRINT_ENABLED, false);
}
}

31
app/src/main/java/com/gmeremit/online/gmeremittance_native/settings/view/SettingsView.java

@ -46,6 +46,7 @@ public class SettingsView extends BaseActivity implements CompoundButton.OnCheck
Disposable fingerPrintAuthEnableSubs;
LanguageSelectionGatewayInterface languageSelectionGatewayInterface;
private GMEAuthManager gmeAuthManager;
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -55,23 +56,17 @@ public class SettingsView extends BaseActivity implements CompoundButton.OnCheck
private void init() {
ButterKnife.bind(this);
gmeAuthManager= GMEAuthManager.getGmeAuthManager(this);
languageSelectionGatewayInterface=new LanguageSelectionGateway();
if (!SecurityUtils.checkFingerPrintUsablity(this)) {
if (!gmeAuthManager.isBiometricSupportedByDevice()) {
view_fingerprint.setVisibility(View.GONE);
view_fingerprint_divider.setVisibility(View.GONE);
} else {
checkIfFingerPrintIsEnabled();
view_fingerprint.setChecked(gmeAuthManager.isBiometricEnabledOnTheApp());
}
}
private void checkIfFingerPrintIsEnabled() {
view_fingerprint.setChecked(GmeApplication.getStorage().getBoolean(PrefKeys.APP_FINGER_PRINT_ENABLED, false));
}
private boolean isBiometricDataAvailable() {
SharedPreferences sp = GmeApplication.getStorage();
return sp.getString(PrefKeys.APP_USER_ID_SECRET_KEY, null) != null && sp.getString(PrefKeys.APP_USER_SECRET_KEY, null) != null&&sp.getString(PrefKeys.APP_SECRET_KEY,null)!=null;
}
@OnClick({R.id.view_change_password, R.id.iv_back, R.id.view_language, R.id.view_fingerprint})
public void onClick(View view) {
@ -147,9 +142,9 @@ public class SettingsView extends BaseActivity implements CompoundButton.OnCheck
view_fingerprint.setOnCheckedChangeListener(this);
//TODO check if biometric data are available
if (isBiometricDataAvailable()) {
if (gmeAuthManager.isBiometricDataAvailable()) {
GMEAuthManager.getGmeAuthManager(this).requestExplicitly(GMEAuthManager.GMEAuthType.BIOMETRIC).setListener(new GMEAuthManager.GMEAuthListener() {
gmeAuthManager.requestBiometricAuth().setListener(new GMEAuthManager.GMEAuthListener() {
@Override
public void onGMEAuthSuccess(String secret) {
GmeApplication.getStorage().edit().putBoolean(PrefKeys.APP_FINGER_PRINT_ENABLED, isChecked).apply();
@ -164,13 +159,13 @@ public class SettingsView extends BaseActivity implements CompoundButton.OnCheck
view_fingerprint.setChecked(false);
view_fingerprint.setOnCheckedChangeListener(SettingsView.this);
new Handler().postDelayed(() -> {
GmeApplication.getStorage().edit().clear().apply();
showPopUpMessage(getString(R.string.fingerprint_changed_externally), CustomAlertDialog.AlertType.ALERT,
alert -> {
logout();
});
}, 200);
// new Handler().postDelayed(() -> {
// GmeApplication.getStorage().edit().clear().apply();
// showPopUpMessage(getString(R.string.fingerprint_changed_externally), CustomAlertDialog.AlertType.ALERT,
// alert -> {
// logout();
// });
// }, 200);
}
@Override

Loading…
Cancel
Save