Skip to content

Instantly share code, notes, and snippets.

@bot2600
Created January 9, 2017 19:06
Show Gist options
  • Save bot2600/2514e3d39b3df06c4b4c484a09f2c9df to your computer and use it in GitHub Desktop.
Save bot2600/2514e3d39b3df06c4b4c484a09f2c9df to your computer and use it in GitHub Desktop.
let KeyStore = java.security.KeyStore
let Cipher = javax.crypto.Cipher
let KeyGenerator = javax.crypto.KeyGenerator
let KeyProperties = android.security.keystore.KeyProperties
let KeyGenParameterSpec = android.security.keystore.KeyGenParameterSpec
let FingerprintManager = android.hardware.fingerprint.FingerprintManager
export class TestClass {
private keyguardManager = utils.ad.getApplicationContext().getSystemService("keyguard")
private fingerprintManager = utils.ad.getApplicationContext().getSystemService("fingerprint")
private REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS = 1001
private KEY_NAME = 'fingerprintauth'
startFingerprintMagic() {
let cancellationSignal = new android.os.CancellationSignal()
let cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" +
KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7)
let cryptoObject = FingerprintManager.CryptoObject(cipher)
let callbackClass = FingerprintManager.AuthenticationCallback.extend({
onAuthenticationError: function (args) {
console.log("error")
},
onAuthenticationHelp: function (args) {
console.log("help?")
},
onAuthenticationSucceeded: function (args) {
console.log("success")
},
onAuthenticationFailed: function () {
console.log("failed")
}
})
let callbackInstance = new callbackClass()
//the following line dies with "Trying to link invalid 'this' to a Java object"
this.fingerprintManager.authenticate(cryptoObject, cancellationSignal, 0, callbackInstance, null)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment