Java Code Examples for android.hardware.fingerprint.FingerprintManager#CryptoObject

The following examples show how to use android.hardware.fingerprint.FingerprintManager#CryptoObject . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FingerprintHandler.java    From programming with GNU General Public License v3.0 6 votes vote down vote up
public void startAuth(FingerprintManager manager,
                      FingerprintManager.CryptoObject cryptoObject) {

    cancellationSignal = new CancellationSignal();

    if (ActivityCompat.checkSelfPermission(appContext,
            Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {

        Toast.makeText(appContext,
                appContext.getString(R.string.fingerprint_error_no_permission),
                Toast.LENGTH_LONG).show();

        return;
    }

    manager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}
 
Example 2
Source File: MainActivity.java    From programming with GNU General Public License v3.0 6 votes vote down vote up
private void inicializarSeguranca() {

        if (ActivityCompat.checkSelfPermission(this,
                Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {

            Toast.makeText(this,
                    getString(R.string.fingerprint_error_no_permission),
                    Toast.LENGTH_LONG).show();

            return;
        }

        keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
        fingerprintManager = (FingerprintManager) getSystemService(FINGERPRINT_SERVICE);

        keystoreManager = new AndroidKeystoreManager(KEY_NAME);
        keystoreManager.generateKey();

        if (keystoreManager.cipherInit()) {
            cryptoObject = new FingerprintManager.CryptoObject(keystoreManager.getCipher());
        }
    }
 
Example 3
Source File: RxFingerPrinter.java    From LLApp with Apache License 2.0 6 votes vote down vote up
public PublishSubject<Boolean> begin() {

        if(publishSubject == null){
            publishSubject = PublishSubject.create();
        }
        if (Build.VERSION.SDK_INT < 23){
            publishSubject.onError(new FPerException(SYSTEM_API_ERROR));
        }else {
            initManager();
            confirmFinger();
            try {
                CryptoObjectHelper helper = new CryptoObjectHelper();
                FingerprintManager.CryptoObject cryptoObject = helper.buildCryptoObject();
                startListening(cryptoObject);
            } catch (Exception e) {
                e.printStackTrace();
            }
//            startListening(null);
        }
        return publishSubject;

    }
 
Example 4
Source File: FingerprintUiHelper.java    From keemob with MIT License 5 votes vote down vote up
public void startListening(FingerprintManager.CryptoObject cryptoObject) {
    if (!isFingerprintAuthAvailable()) {
        return;
    }
    mCancellationSignal = new CancellationSignal();
    mSelfCancelled = false;
    mFingerprintManager
            .authenticate(cryptoObject, mCancellationSignal, 0 /* flags */, this, null);

    int ic_fp_40px_id = mContext.getResources()
            .getIdentifier("ic_fp_40px", "drawable", FingerprintAuth.packageName);
    mIcon.setImageResource(ic_fp_40px_id);
}
 
Example 5
Source File: FingerprintHandler.java    From leafpicrevived with GNU General Public License v3.0 5 votes vote down vote up
public void startAuth() {
    if (fingerprintSupported) {
        try {

            generateKey();
        } catch (FingerprintException e) {
            e.printStackTrace();
        }
        if (initCipher()) {
            cryptoObject = new FingerprintManager.CryptoObject(cipher);
            doAuth(fingerprintManager, cryptoObject);
        }
    }
}
 
Example 6
Source File: FingerprintManagerCompatApi23.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private static FingerprintManager.CryptoObject wrapCryptoObject(CryptoObject cryptoObject) {
    if (cryptoObject == null) {
        return null;
    } else if (cryptoObject.getCipher() != null) {
        return new FingerprintManager.CryptoObject(cryptoObject.getCipher());
    } else if (cryptoObject.getSignature() != null) {
        return new FingerprintManager.CryptoObject(cryptoObject.getSignature());
    } else if (cryptoObject.getMac() != null) {
        return new FingerprintManager.CryptoObject(cryptoObject.getMac());
    } else {
        return null;
    }
}
 
Example 7
Source File: FingerprintManagerCompatApi23.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private static CryptoObject unwrapCryptoObject(FingerprintManager.CryptoObject cryptoObject) {
    if (cryptoObject == null) {
        return null;
    } else if (cryptoObject.getCipher() != null) {
        return new CryptoObject(cryptoObject.getCipher());
    } else if (cryptoObject.getSignature() != null) {
        return new CryptoObject(cryptoObject.getSignature());
    } else if (cryptoObject.getMac() != null) {
        return new CryptoObject(cryptoObject.getMac());
    } else {
        return null;
    }
}
 
Example 8
Source File: FingerprintManagerCompatApi23.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static CryptoObject unwrapCryptoObject(FingerprintManager.CryptoObject cryptoObject) {
    if (cryptoObject == null) {
        return null;
    } else if (cryptoObject.getCipher() != null) {
        return new CryptoObject(cryptoObject.getCipher());
    } else if (cryptoObject.getSignature() != null) {
        return new CryptoObject(cryptoObject.getSignature());
    } else if (cryptoObject.getMac() != null) {
        return new CryptoObject(cryptoObject.getMac());
    } else {
        return null;
    }
}
 
Example 9
Source File: MainActivity.java    From android-FingerprintDialog with Apache License 2.0 5 votes vote down vote up
/**
 * Proceed the purchase operation
 *
 * @param withFingerprint {@code true} if the purchase was made by using a fingerprint
 * @param cryptoObject the Crypto object
 */
public void onPurchased(boolean withFingerprint,
        @Nullable FingerprintManager.CryptoObject cryptoObject) {
    if (withFingerprint) {
        // If the user has authenticated with fingerprint, verify that using cryptography and
        // then show the confirmation message.
        assert cryptoObject != null;
        tryEncrypt(cryptoObject.getCipher());
    } else {
        // Authentication happened with backup password. Just show the confirmation message.
        showConfirmation(null);
    }
}
 
Example 10
Source File: FingerprintManagerCompatApi23.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private static FingerprintManager.CryptoObject wrapCryptoObject(CryptoObject cryptoObject) {
    if (cryptoObject == null) {
        return null;
    } else if (cryptoObject.getCipher() != null) {
        return new FingerprintManager.CryptoObject(cryptoObject.getCipher());
    } else if (cryptoObject.getSignature() != null) {
        return new FingerprintManager.CryptoObject(cryptoObject.getSignature());
    } else if (cryptoObject.getMac() != null) {
        return new FingerprintManager.CryptoObject(cryptoObject.getMac());
    } else {
        return null;
    }
}
 
Example 11
Source File: ActivityEnterPassCodeViewModel.java    From iGap-Android with GNU Affero General Public License v3.0 5 votes vote down vote up
public void onResume() {
    if (isFingerPrint) {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
            generateKey();
            if (cipherInit()) {
                FingerprintManager.CryptoObject cryptoObject = null;
                cryptoObject = new FingerprintManager.CryptoObject(cipher);
                helper = new FingerprintHandler(context);
                helper.startAuth(fingerprintManager, cryptoObject);
            }
        }
    }
}
 
Example 12
Source File: FingerprintAuthenticationDialogFragment.java    From UAF with Apache License 2.0 5 votes vote down vote up
@Override
public void onAuthenticated(FingerprintManager.CryptoObject cryptObj) {
    // Callback from FingerprintUiHelper. Let the activity know that authentication was
    // successful.
    ((FingerprintAuthProcessor)mActivity).processAuthentication(cryptObj);
    dismiss();
}
 
Example 13
Source File: FingerprintManagerCompatApi23.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static CryptoObject unwrapCryptoObject(FingerprintManager.CryptoObject cryptoObject) {
    if (cryptoObject == null) {
        return null;
    } else if (cryptoObject.getCipher() != null) {
        return new CryptoObject(cryptoObject.getCipher());
    } else if (cryptoObject.getSignature() != null) {
        return new CryptoObject(cryptoObject.getSignature());
    } else if (cryptoObject.getMac() != null) {
        return new CryptoObject(cryptoObject.getMac());
    } else {
        return null;
    }
}
 
Example 14
Source File: FingerprintManagerCompatApi23.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static FingerprintManager.CryptoObject wrapCryptoObject(CryptoObject cryptoObject) {
    if (cryptoObject == null) {
        return null;
    } else if (cryptoObject.getCipher() != null) {
        return new FingerprintManager.CryptoObject(cryptoObject.getCipher());
    } else if (cryptoObject.getSignature() != null) {
        return new FingerprintManager.CryptoObject(cryptoObject.getSignature());
    } else if (cryptoObject.getMac() != null) {
        return new FingerprintManager.CryptoObject(cryptoObject.getMac());
    } else {
        return null;
    }
}
 
Example 15
Source File: MainActivity.java    From Sparkplug with Eclipse Public License 1.0 5 votes vote down vote up
public void startAuth(FingerprintManager manager, FingerprintManager.CryptoObject cryptoObject) {
    CancellationSignal cancellationSignal = new CancellationSignal();
    if (ActivityCompat.checkSelfPermission(appContext, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
        Log.e(TAG, "No permissions for USE_FINGERPRINT");
        return;
    }
    Log.d(TAG, "Attempting to authenticate...");
    manager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}
 
Example 16
Source File: FingerprintAuthenticationDialogFragment.java    From android-AsymmetricFingerprintDialog with Apache License 2.0 4 votes vote down vote up
/**
 * Sets the crypto object to be passed in when authenticating with fingerprint.
 */
public void setCryptoObject(FingerprintManager.CryptoObject cryptoObject) {
    mCryptoObject = cryptoObject;
}
 
Example 17
Source File: FingerprintDialogCompatV23.java    From FingerprintDialogCompat with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.M)
@Nullable
private FingerprintManager.CryptoObject getCryptoObject() {
    return cipherInit() ? new FingerprintManager.CryptoObject(mCipher) : null;
}
 
Example 18
Source File: BoxFingerprint.java    From PasscodeView with Apache License 2.0 4 votes vote down vote up
@Override
public void onFingerprintAuthSuccess(FingerprintManager.CryptoObject cryptoObject) {
    onAuthenticationSuccess();
}
 
Example 19
Source File: FingerprintAuthenticationDialogFragment.java    From keemob with MIT License 4 votes vote down vote up
/**
 * Sets the crypto object to be passed in when authenticating with fingerprint.
 */
public void setCryptoObject(FingerprintManager.CryptoObject cryptoObject) {
    mCryptoObject = cryptoObject;
}
 
Example 20
Source File: FingerPrintAuthHelper.java    From PasscodeView with Apache License 2.0 2 votes vote down vote up
/**
 * This method will occur whenever  user authentication is successful.
 *
 * @param cryptoObject {@link FingerprintManager.CryptoObject} associated with the scanned finger print.
 */
void onFingerprintAuthSuccess(FingerprintManager.CryptoObject cryptoObject);