-
public final class MasterKey.BuilderBuilder for generating a MasterKey.
-
-
Constructor Summary
Constructors Constructor Description MasterKey.Builder(Context context)Creates a builder for a MasterKey using the default alias of . MasterKey.Builder(Context context, String keyAlias)Creates a builder for a MasterKey.
-
Method Summary
Modifier and Type Method Description MasterKey.BuildersetKeyScheme(@NonNull() MasterKey.KeyScheme keyScheme)Sets a KeyScheme to be used for the master key. MasterKey.BuildersetUserAuthenticationRequired(boolean authenticationRequired)When used with setKeyScheme, sets that the built master key shouldrequire the user to authenticate before it's unlocked, probably using theandroidx.biometric library. MasterKey.BuildersetUserAuthenticationRequired(boolean authenticationRequired, @IntRange(from = 1) int userAuthenticationValidityDurationSeconds)When used with setKeyScheme, sets that the built master key shouldrequire the user to authenticate before it's unlocked, probably using theandroidx.biometric library, and that the key should remain unlocked for the providedduration. MasterKey.BuildersetRequestStrongBoxBacked(boolean requestStrongBoxBacked)Sets whether or not to request this key is strong box backed. MasterKey.BuildersetKeyGenParameterSpec(@NonNull() KeyGenParameterSpec keyGenParameterSpec)Sets a custom KeyGenParameterSpec to use as the basis of the master key. MasterKeybuild()Builds a MasterKey from this builder. -
-
Method Detail
-
setKeyScheme
@NonNull() MasterKey.Builder setKeyScheme(@NonNull() MasterKey.KeyScheme keyScheme)
Sets a KeyScheme to be used for the master key.
This uses a default KeyGenParameterSpec associated with the provided
{@code * KeyScheme}.NOTE: Either this method OR setKeyGenParameterSpec should be used to set theparameters to use for building the master key. Calling either function after the otherwill throw an IllegalArgumentException.
- Parameters:
keyScheme- The KeyScheme to use.
-
setUserAuthenticationRequired
@NonNull() MasterKey.Builder setUserAuthenticationRequired(boolean authenticationRequired)
When used with setKeyScheme, sets that the built master key shouldrequire the user to authenticate before it's unlocked, probably using theandroidx.biometric library.
- Parameters:
authenticationRequired- Whether user authentication should be required to use thekey.
-
setUserAuthenticationRequired
@NonNull() MasterKey.Builder setUserAuthenticationRequired(boolean authenticationRequired, @IntRange(from = 1) int userAuthenticationValidityDurationSeconds)
When used with setKeyScheme, sets that the built master key shouldrequire the user to authenticate before it's unlocked, probably using theandroidx.biometric library, and that the key should remain unlocked for the providedduration.
- Parameters:
authenticationRequired- Whether user authentication should be required to use thekey.userAuthenticationValidityDurationSeconds- Duration in seconds that the key shouldremain unlocked following user authentication.
-
setRequestStrongBoxBacked
@NonNull() MasterKey.Builder setRequestStrongBoxBacked(boolean requestStrongBoxBacked)
Sets whether or not to request this key is strong box backed. This setting is onlyapplicable on P and above, and only on devices that supportStrongbox.
- Parameters:
requestStrongBoxBacked- Whether to request to use strongbox
-
setKeyGenParameterSpec
@NonNull() MasterKey.Builder setKeyGenParameterSpec(@NonNull() KeyGenParameterSpec keyGenParameterSpec)
Sets a custom KeyGenParameterSpec to use as the basis of the master key. NOTE:Either this method OR setKeyScheme should be used to set theparameters to use for building the master key. Calling either function after the otherwill throw an IllegalArgumentException.
- Parameters:
keyGenParameterSpec- The key spec to use.
-
-
-
-