Language

KeyProtection.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/KeyProtection$Builder;", "", ApiSince=23)]
public Android.Security.Keystore.KeyProtection.Builder SetUserAuthenticationRequired(bool required);
[<Android.Runtime.Register("setUserAuthenticationRequired", "(Z)Landroid/security/keystore/KeyProtection$Builder;", "", ApiSince=23)>]
member this.SetUserAuthenticationRequired : bool -> Android.Security.Keystore.KeyProtection.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 import if secure lock screen is set up (see KeyguardManager.isDeviceSecure()). Additionally, if the key requires that user authentication takes place for every use of the key (see setUserAuthenticationValidityDurationSeconds(int)), at least one biometric must be enrolled (see BiometricManager.canAuthenticate()); The use of the key must be authorized by the user by authenticating to this Android device using a subset of their secure lock screen credentials such as password/PIN/pattern or biometric. More information; The key will become irreversibly invalidated once the secure lock screen is disabled (reconfigured to None, Swipe or other mode which does not authenticate the user) or when the secure lock screen is forcibly reset (e.g., by a Device Administrator). Additionally, if the key requires that user authentication takes place for every use of the key, it is also irreversibly invalidated once a new biometric is enrolled or once no more biometrics are enrolled, unless setInvalidatedByBiometricEnrollment(boolean) is used to allow validity after enrollment. Attempts to initialize cryptographic operations using such keys will throw KeyPermanentlyInvalidatedException.

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

Android reference for android.security.keystore.KeyProtection.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