Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
com.codenameone:fingerprint-scanner
Advanced tools
= Fingerprint Scanner
Fingerprint scanning and biometric support for https://www.codenameone.com[Codename One].
image::images/fingerprint-scanner-feature.jpg[]
This cn1lib provides basic support for fingerprint scanning on iOS/Android with one API. Due to the difference between the two implementations we chose a simplified approach that just verifies the fingerprint and doesn't delve into the nuanced complexities for this API.
== Supported Platforms
Currently this library supports only Android (API 23+), and iOS.
== Installation
For instructions on installing cn1libs, see https://www.codenameone.com/blog/automatically-install-update-distribute-cn1libs-extensions.html[this tutorial].
=== Alternate Maven Installation
If your project uses Maven, the above installation instructions will still work, but you can alternately simply add the Maven dependency to your common/pom.xml file:
Android builds must use build tools 29 or higher. E.g. Add the following build hints:
====
== Basic Usage
Note that the values passed to value/fail are null
and don't include any data at this time...
Also check out the following samples:
. https://github.com/codenameone/FingerprintScannerTest[FingerprintScannerTest App] - Basic usage. Just fingerprint scanning. . https://github.com/codenameone/CodenameOne/blob/master/Samples/samples/FingerprintScannerSample/FingerprintScannerSample.java[FingerprintScannerSample] - From Codename One samples. Includes sample of storing, retrieving, and deleting passwords.
== Protecting Passwords with Fingerprints
This library also allows you to store passwords in the system keychain, protected by biometric authentication. The user will be asked to authenticate with their fingerprint (or Face recognition on supported devices) in order to retrieve passwords using this library. On Android, currently the user is also prompted to authenticate when storing passwords as well.
NOTE: While these methods say that they are for storing passwords, you can use them for storing any text. Both Android and iOS should allow you to store strings of sufficiently large size to store anything you might otherwise store in Preferences.
=== Storing Passwords
String account = "steve@example.com"; String password = "....";
=== Retrieving Passwords
String account = "steve@example.com";
=== Deleting Passwords
String account = "steve@example.com";
=== Password Invalidation
Passwords stored in the keychain will be automatically purged if any of the following occurs:
. The user adds additional fingers to fingerprint authentication. . The user adds additional faces to face ID biometric authentication. . The user turns off phone login security. E.g. if they turn off password or fingerprint requirements for login to the phone.
=== Android Implementation
Currently, on Android we are using the https://developer.android.com/reference/android/hardware/fingerprint/FingerprintManager[FingerprintManager] class for authentication on API 28 (Android 9) and lower and https://developer.android.com/reference/android/hardware/biometrics/BiometricPrompt[BiometricPrompt] on devices running API 29 (Android 10) and higher. This means that Android 9, despite supporting Face recognition at an OS level, will use FingerPrintManager and will not support face recognition for authentication. Future versions may attempt to incorporate workarounds to add this support to Android 9, e.g. https://github.com/sergeykomlach/AdvancedBiometricPromptCompat[AdvancedBiometricPromptCompat].
Passwords are not, themselves, stored inside the system Keystore. Rather, a symmetric Key is generated and stored inside the keychain, which is used to encrypt and decrypt the passwords, which are stored private SharedPreferences
.
Currently the key specifications are:
Refer to the https://developer.android.com/reference/android/security/keystore/KeyGenParameterSpec.Builder[KeyGenParameterSpec.Builder docs] for a more detailed description of what these settings mean.
The .setUserAuthenticationRequired(true)
call is what causes the key to become invalid when the user adds fingers or faces to authentication.
=== iOS Implementation
On iOS, the library acts as a thin layer on top of the https://developer.apple.com/documentation/security/1401659-secitemadd?language=objc[SecItemAdd], https://developer.apple.com/documentation/security/1398306-secitemcopymatching?language=objc[SecItemCopyMatching], and https://developer.apple.com/documentation/security/1395547-secitemdelete?language=objc[SecItemDelete] functions which directly add passwords to the keychain.
The security settings on the passwords are:
For more details on what these mean, see the following documentation pages:
. https://developer.apple.com/documentation/security/secaccesscontrolref?language=objc[SecAccessControlRef] . https://developer.apple.com/documentation/security/ksecattraccessiblewhenpasscodesetthisdeviceonly?language=objc[kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly] . https://developer.apple.com/documentation/security/secaccesscontrolcreateflags/ksecaccesscontroltouchidcurrentset?language=objc[kSecAccessControlTouchIDCurrentSet]
== Working with the Sources
. Check out with git clone https://github.com/codenameone/FingerprintScanner
. Build with mvn package
.. You'll find cn1lib in the common/target directory.
See https://shannah.github.io/codenameone-maven-manual/[the Codename One Maven Manual] for more information about working with Codename One Maven projects.
=== Releasing to Maven Central
bash update-version.sh $NEW_VERSION
where $NEW_VERSION
is the new version. E.g. "1.1".git push && git push --tags
to push the new version tag to git.mvn deploy -Psign-artifacts
bash update-version $NEW_SNAPSHOT_VERSION
where $NEW_SNAPSHOT_VERSION
is the next snapshot version E.g. 1.2-SNAPSHOT.FAQs
Codename One fingerprint-scanner library
We found that com.codenameone:fingerprint-scanner demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.