Language

KeyProtection.Builder.SetUserAuthenticationParameters(Int32, Int32) Method

Definition

Sets the duration of time (seconds) and authorization type for which this key is authorized to be used after the user is successfully authenticated.

[Android.Runtime.Register("setUserAuthenticationParameters", "(II)Landroid/security/keystore/KeyProtection$Builder;", "", ApiSince=30)]
public Android.Security.Keystore.KeyProtection.Builder SetUserAuthenticationParameters(int timeout, int type);
[<Android.Runtime.Register("setUserAuthenticationParameters", "(II)Landroid/security/keystore/KeyProtection$Builder;", "", ApiSince=30)>]
member this.SetUserAuthenticationParameters : int * int -> Android.Security.Keystore.KeyProtection.Builder

Parameters

timeout
Int32

duration in seconds or 0 if user authentication must take place for every use of the key. Value is 0 or greater

type
Int32

set of authentication types which can authorize use of the key. See KeyProperties.AUTH flags. Value is either 0 or a combination of the following: KeyProperties.AUTH_BIOMETRIC_STRONG; KeyProperties.AUTH_DEVICE_CREDENTIAL

Returns

Attributes

Remarks

Sets the duration of time (seconds) and authorization type for which this key is authorized to be used after the user is successfully authenticated. This has effect if the key requires user authentication for its use (see setUserAuthenticationRequired(boolean)).

By default, if user authentication is required, it must take place for every use of the key.

These cryptographic operations will throw UserNotAuthenticatedException during initialization if the user needs to be authenticated to proceed. This situation can be resolved by the user authenticating with the appropriate biometric or credential as required by the key. See BiometricPrompt.Builder.setAllowedAuthenticators(int) and BiometricManager.Authenticators.

Once resolved, initializing a new cryptographic operation using this key (or any other key which is authorized to be used for a fixed duration of time after user authentication) should succeed provided the user authentication flow completed successfully.

Android reference for android.security.keystore.KeyProtection.Builder.setUserAuthenticationParameters.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to