語言

KeyGenParameterSpec.Builder.SetUserAuthenticationParameters 方法

定義

設定使用者成功認證後,該金鑰被授權使用的時間長度(秒)及授權類型。

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

參數

timeout
Int32

持續時間以秒為單位,若每次使用金鑰都必須進行使用者驗證,則為 0。 值為 0 或以上

type
Int32

一組可授權使用金鑰的認證類型。 請參見 KeyProperties.AUTH 旗標。 值可為 0,或以下組合:KeyProperties.AUTH_BIOMETRIC_STRONG;KeyProperties.AUTH_DEVICE_CREDENTIAL

傳回

屬性

備註

設定使用者成功認證後,該金鑰被授權使用的時間長度(秒)及授權類型。 若金鑰使用時需使用者驗證(參見 setUserAuthenticationRequired(布林)),此規定會生效。

預設情況下,若需使用者驗證,則必須在每次使用金鑰時進行驗證。

若使用者需要驗證才能繼續,這些密碼操作會在初始化時拋出 UserNotAuthenticatedException。 此情況可透過使用者依照金鑰要求的生物識別或憑證進行認證來解決。 請參見 BiometricPrompt.Builder.setAllowedAuthenticators(int) 與 BiometricManager.Authenticators。

解決後,若使用者驗證流程成功完成,使用此金鑰(或任何被授權在使用者認證後固定時間內使用的其他金鑰)初始化新的密碼操作,應能成功。

Android 參考資料。android.security.keystore.KeyGenParameterSpec.Builder.setUserAuthenticationParameters

本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。

適用於