MasterKey.Builder
public final class MasterKey.Builder
Builder for generating a MasterKey.
Summary
Public constructors |
|---|
|
Creates a builder for a |
|
Creates a builder for a |
Public methods |
|
|---|---|
@NonNull MasterKey |
Builds a |
@NonNull MasterKey.Builder |
@RequiresApi(value = Build.VERSION_CODES.M)Sets a custom |
@NonNull MasterKey.Builder |
Sets a |
@NonNull MasterKey.Builder |
Sets whether or not to request this key is strong box backed. |
@NonNull MasterKey.Builder |
When used with |
@NonNull MasterKey.Builder |
When used with |
Public constructors
publicBuilder(@NonNull Context context)
Creates a builder for a MasterKey using the default alias of DEFAULT_MASTER_KEY_ALIAS.
Public methods
@RequiresApi(value = Build.VERSION_CODES.M)
public @NonNull MasterKey.BuildersetKeyGenParameterSpec(@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 the parameters to use for building the master key. Calling either function after the other will throw an IllegalArgumentException.
| Parameters | |
|---|---|
@NonNull KeyGenParameterSpec keyGenParameterSpec |
The key spec to use. |
| Returns | |
|---|---|
@NonNull MasterKey.Builder |
This builder. |
public @NonNull MasterKey.BuildersetKeyScheme(@NonNull MasterKey.KeyScheme keyScheme)
Sets a KeyScheme to be used for the master key.
This uses a default KeyGenParameterSpec associated with the provided KeyScheme.
NOTE: Either this method OR setKeyGenParameterSpec should be used to set the parameters to use for building the master key. Calling either function after the other will throw an IllegalArgumentException.
| Parameters | |
|---|---|
@NonNull MasterKey.KeyScheme keyScheme |
The KeyScheme to use. |
| Returns | |
|---|---|
@NonNull MasterKey.Builder |
This builder. |
public @NonNull MasterKey.BuildersetRequestStrongBoxBacked(boolean requestStrongBoxBacked)
Sets whether or not to request this key is strong box backed. This setting is only applicable on P and above, and only on devices that support Strongbox.
| Parameters | |
|---|---|
boolean requestStrongBoxBacked |
Whether to request to use strongbox |
| Returns | |
|---|---|
@NonNull MasterKey.Builder |
This builder. |
public @NonNull MasterKey.BuildersetUserAuthenticationRequired(boolean authenticationRequired)
When used with setKeyScheme, sets that the built master key should require the user to authenticate before it's unlocked, probably using the androidx.biometric library.
This method sets the validity duration of the key to getDefaultAuthenticationValidityDurationSeconds.
| Parameters | |
|---|---|
boolean authenticationRequired |
Whether user authentication should be required to use the key. |
| Returns | |
|---|---|
@NonNull MasterKey.Builder |
This builder. |
public @NonNull MasterKey.BuildersetUserAuthenticationRequired(
boolean authenticationRequired,
@IntRange(from = 1) int userAuthenticationValidityDurationSeconds
)
When used with setKeyScheme, sets that the built master key should require the user to authenticate before it's unlocked, probably using the androidx.biometric library, and that the key should remain unlocked for the provided duration.
| Parameters | |
|---|---|
boolean authenticationRequired |
Whether user authentication should be required to use the key. |
@IntRange(from = 1) int userAuthenticationValidityDurationSeconds |
Duration in seconds that the key should remain unlocked following user authentication. |
| Returns | |
|---|---|
@NonNull MasterKey.Builder |
This builder. |