Class BiometricAuthentication
- All Implemented Interfaces:
IBiometricAuthentication
IBiometricAuthentication of an environment, which carries its requests to the client as remote event 15 of the environment and gets the client's answers as remote event 16, the way the passkey bridge of EnvProps does. One instance per environment, created on first use by EnvProps.getBiometricAuthentication(); NONE serves a gyro that is not a server's.The wire. A request carries r (the request ID) and k (the kind): caps asks for the report; auth asks for a check, with the prompt's texts t (title), s (subtitle), d (description), c (cancel text) and f (fallback text) where given, and the booleans b (the device credential is allowed) and e (an emulated answer is allowed) where true. The client answers r with, for a report: i (iiziRun: Cordova is present), p (the plugin is present), t (the type word of the plugin's isAvailable for biometrics only, none without one), c and g (that call's error code and message when it failed), s (a strong biometric is available), d (the device credential: y, n or u), m (the emulation is on), v (a virtual device) and x (an iOS app on a Mac); for a check: ok (the user passed), m (the answer is emulated), and for a failure c (the code) and g (the message). The client's bridge is iz/EnvProps.js.
Threads. The getters read a volatile report. The request registry is guarded by this instance. Callbacks run where the application session's worker runs the client's other answers (EnvProps.deliverToApplication(String, Runnable)); a callback that throws is logged.
- Author:
- Christopher Mindus
Nested Class Summary
Nested classes/interfaces inherited from interface IBiometricAuthentication
IBiometricAuthentication.DeviceCredentialField Summary
FieldsModifier and TypeFieldDescriptionstatic final BiometricAuthenticationThe instance of a gyro that is not a server client session: nothing is reported, nothing is available, a check is answeredBiometricError.NOT_IIZIRUNat once.static final longHow long the client has to report: 30 seconds, as for the passkey capabilities.Method Summary
Modifier and TypeMethodDescriptionintauthenticate(BiometricPrompt prompt, Consumer<BiometricResult> callback) --- The check ---Gets whether the device has a credential a prompt may let stand in.intGets the number of requests that wait for the client.getType()Gets the kind of biometric the device offers.Gets the message the plugin answered with the reason.Gets why no biometric check can be made.booleanChecks if the client reported that it is an iPhone or iPad app running on an Apple-silicon Mac (device.isiOSAppOnMac), where the biometric check is the Mac's Touch ID or the user's password.booleanChecks if a check of this client session waits for the client.booleanChecks if a biometric check can be made: the plugin is present and reported a biometric type, or iiziRun Developer's emulation is on and this is a development server.booleanChecks if iiziRun Developer's biometric emulation is on: the client answers every check with an emulated success.booleanChecks if the client carries the plugin (window.Fingerprint).boolean--- The report ---booleanisStrong()Checks if the biometric is strong: on Android, class 3 (BIOMETRIC_STRONG, which the plugin'sisAvailablewithrequireStrongBiometricsanswers); on iOS every biometric is.booleanChecks if the client reported that it runs on a simulator or an emulator (Cordova'sdevice.isVirtual).intrequestReport(Consumer<IBiometricAuthentication> callback) Asks the client for its report again.voidsetDevelopmentMode(BooleanSupplier development) Sets what decides whether this is a development server, where an emulated answer may count as success: by defaultRunMode.isServerRunDevelopmentMode().voidsetTimerEngine(ITimerEngine engine) Sets the timer engine the deadlines are registered with.toString()Gets a text for a log line: the report as it is.
Field Details
REPORT_DEADLINE_MS
public static final long REPORT_DEADLINE_MSHow long the client has to report: 30 seconds, as for the passkey capabilities.- See Also:
NONE
The instance of a gyro that is not a server client session: nothing is reported, nothing is available, a check is answeredBiometricError.NOT_IIZIRUNat once.
Method Details
setTimerEngine
Sets the timer engine the deadlines are registered with.- Parameters:
engine- The engine, or null for the system's.
setDevelopmentMode
Sets what decides whether this is a development server, where an emulated answer may count as success: by defaultRunMode.isServerRunDevelopmentMode().- Parameters:
development- The supplier.- Throws:
NullPointerException- Ifdevelopmentis null.
getPendingRequests
public int getPendingRequests()Gets the number of requests that wait for the client.- Returns:
- The count.
isReported
public boolean isReported()--- The report ---- Specified by:
isReportedin interfaceIBiometricAuthentication- Returns:
- true when a report arrived; false before it, after the client failed to answer within the deadline, and in a client that is not iiziRun.
isAvailable
public boolean isAvailable()Description copied from interface:IBiometricAuthenticationChecks if a biometric check can be made: the plugin is present and reported a biometric type, or iiziRun Developer's emulation is on and this is a development server.- Specified by:
isAvailablein interfaceIBiometricAuthentication- Returns:
- true when
IBiometricAuthentication.authenticate(BiometricPrompt, Consumer)can be expected to prompt the user.
getType
Description copied from interface:IBiometricAuthenticationGets the kind of biometric the device offers.- Specified by:
getTypein interfaceIBiometricAuthentication- Returns:
- The type:
BiometricType.NONEbefore the report and when none is available,BiometricType.DEVICE_CREDENTIALwhen only the device credential is.
isStrong
public boolean isStrong()Description copied from interface:IBiometricAuthenticationChecks if the biometric is strong: on Android, class 3 (BIOMETRIC_STRONG, which the plugin'sisAvailablewithrequireStrongBiometricsanswers); on iOS every biometric is. A device whose only biometric is weak (class 2, face unlock on many Android phones) reports a type andfalsehere: the plugin's prompt accepts it all the same, so a caller that wants a strong one reads this.- Specified by:
isStrongin interfaceIBiometricAuthentication- Returns:
- true for a strong biometric, false when weak, not available or not reported.
getDeviceCredential
Description copied from interface:IBiometricAuthenticationGets whether the device has a credential a prompt may let stand in.- Specified by:
getDeviceCredentialin interfaceIBiometricAuthentication- Returns:
- The answer,
IBiometricAuthentication.DeviceCredential.UNKNOWNbefore the report.
isVirtual
public boolean isVirtual()Description copied from interface:IBiometricAuthenticationChecks if the client reported that it runs on a simulator or an emulator (Cordova'sdevice.isVirtual). The iOS Simulator and the Android emulator can answer a check (Features > Face ID > Matching Face,adb emu finger touch); the caller decides what that is worth, or refuses it withBiometricPrompt.rejectVirtual(boolean).- Specified by:
isVirtualin interfaceIBiometricAuthentication- Returns:
- true for a virtual device, false otherwise or before the report.
isAppOnMac
public boolean isAppOnMac()Description copied from interface:IBiometricAuthenticationChecks if the client reported that it is an iPhone or iPad app running on an Apple-silicon Mac (device.isiOSAppOnMac), where the biometric check is the Mac's Touch ID or the user's password.- Specified by:
isAppOnMacin interfaceIBiometricAuthentication- Returns:
- true on a Mac, false otherwise or before the report.
isEmulated
public boolean isEmulated()Description copied from interface:IBiometricAuthenticationChecks if iiziRun Developer's biometric emulation is on: the client answers every check with an emulated success.- Specified by:
isEmulatedin interfaceIBiometricAuthentication- Returns:
- true when on, false otherwise or before the report.
isPluginPresent
public boolean isPluginPresent()Description copied from interface:IBiometricAuthenticationChecks if the client carries the plugin (window.Fingerprint).- Specified by:
isPluginPresentin interfaceIBiometricAuthentication- Returns:
- true when present, false otherwise or before the report.
requestReport
Description copied from interface:IBiometricAuthenticationAsks the client for its report again. The callback gets this instance once the report arrived, or once the deadline passed without one (IBiometricAuthentication.isReported()then says which, and a report that arrived earlier is kept); it runs on the worker of the application session. In a client that is not iiziRun, or when the session is disposed of, the callback is called at once with the state as it is.- Specified by:
requestReportin interfaceIBiometricAuthentication- Parameters:
callback- The callback, or null for none.- Returns:
- The request ID, or 0 when nothing was sent.
authenticate
--- The check ---- Specified by:
authenticatein interfaceIBiometricAuthentication- Parameters:
prompt- What the user is shown and what the check accepts.callback- The callback, called exactly once.- Returns:
- The request ID, or 0 when nothing was sent and the callback was called at once.
isAuthenticating
public boolean isAuthenticating()Description copied from interface:IBiometricAuthenticationChecks if a check of this client session waits for the client.- Specified by:
isAuthenticatingin interfaceIBiometricAuthentication- Returns:
- true while one waits.
toString