Langue

KeyGenParameterSpec.Builder.SetUserAuthenticationRequired(Boolean) Method

Definition

Sets whether this key is authorized to be used only if the user has been authenticated.

[Android.Runtime.Register("setUserAuthenticationRequired", "(Z)Landroid/security/keystore/KeyGenParameterSpec$Builder;", "", ApiSince=23)]
public Android.Security.Keystore.KeyGenParameterSpec.Builder SetUserAuthenticationRequired(bool required);
[<Android.Runtime.Register("setUserAuthenticationRequired", "(Z)Landroid/security/keystore/KeyGenParameterSpec$Builder;", "", ApiSince=23)>]
member this.SetUserAuthenticationRequired : bool -> Android.Security.Keystore.KeyGenParameterSpec.Builder

Parameters

required
Boolean

Returns

Attributes

Remarks

Sets whether this key is authorized to be used only if the user has been authenticated.

By default, the key is authorized to be used regardless of whether the user has been authenticated.

When user authentication is required, the key can only be generated if a secure lock screen is set up (see KeyguardManager.isDeviceSecure()). The user authorizes key use by authenticating to the device using a secure lock-screen credential, such as a password, PIN, or pattern, or biometric authentication.

For a biometric-only configuration that requires authentication for every use, at least one biometric must be enrolled (see BiometricManager.canAuthenticate()). The key is irreversibly invalidated if the secure lock screen is disabled or forcibly reset. For biometric-only configurations that require authentication for every use, it is also invalidated when a new biometric is enrolled or when no biometrics remain enrolled, unless setInvalidatedByBiometricEnrollment(boolean) allows validity after enrollment. A configuration that includes KeyProperties.AUTH_DEVICE_CREDENTIAL in setUserAuthenticationParameters(int, int) is not subject to this biometric-enrollment prerequisite.

This authorization applies only to secret key and private key operations. Public key operations are not restricted.

Android reference for android.security.keystore.KeyGenParameterSpec.Builder.setUserAuthenticationRequired.

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