Class AndroidKeysetManager.Builder
- java.lang.Object
-
- com.google.crypto.tink.integration.android.AndroidKeysetManager.Builder
-
- Enclosing class:
- AndroidKeysetManager
public static final class AndroidKeysetManager.Builder extends java.lang.ObjectA builder forAndroidKeysetManager.This class is thread-safe.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AndroidKeysetManagerbuild()Builds and returns a newAndroidKeysetManagerwith the specified options.AndroidKeysetManager.BuilderdoNotUseKeystore()Deprecated.Please do not use this function.AndroidKeysetManager.BuilderwithKeyTemplate(KeyTemplate val)If the keyset is not found or valid, generates a new one usingval.AndroidKeysetManager.BuilderwithKeyTemplate(com.google.crypto.tink.proto.KeyTemplate val)If the keyset is not found or valid, generates a new one usingval.AndroidKeysetManager.BuilderwithMasterKeyUri(java.lang.String val)Sets the master key URI that references the key in Android Keystore with which the keyset gets encrypted.AndroidKeysetManager.BuilderwithSharedPref(android.content.Context context, java.lang.String keysetName, java.lang.String prefFileName)Reads and writes the keyset from shared preferences.
-
-
-
Method Detail
-
withSharedPref
@CanIgnoreReturnValue public AndroidKeysetManager.Builder withSharedPref(android.content.Context context, java.lang.String keysetName, java.lang.String prefFileName) throws java.io.IOException
Reads and writes the keyset from shared preferences.- Throws:
java.io.IOException
-
withMasterKeyUri
@CanIgnoreReturnValue public AndroidKeysetManager.Builder withMasterKeyUri(java.lang.String val)
Sets the master key URI that references the key in Android Keystore with which the keyset gets encrypted.Only master keys stored in Android Keystore is supported. The URI must start with
android-keystore://.Android Keystore is only supported on Android M (API level 23) and later. On older version, calling this method works but doesn't do anything.
-
withKeyTemplate
@CanIgnoreReturnValue public AndroidKeysetManager.Builder withKeyTemplate(com.google.crypto.tink.proto.KeyTemplate val)
If the keyset is not found or valid, generates a new one usingval.
-
withKeyTemplate
@CanIgnoreReturnValue public AndroidKeysetManager.Builder withKeyTemplate(KeyTemplate val)
If the keyset is not found or valid, generates a new one usingval.
-
doNotUseKeystore
@CanIgnoreReturnValue @Deprecated public AndroidKeysetManager.Builder doNotUseKeystore()
Deprecated.Please do not use this function. Instead, do not call {#code withMasterKeyUri} which has the same effect.Does not use Android Keystore which might not work well in some phones.Warning: When Android Keystore is disabled, keys are stored in cleartext. This should be safe because they are stored in private preferences.
-
build
public AndroidKeysetManager build() throws java.security.GeneralSecurityException, java.io.IOException
Builds and returns a newAndroidKeysetManagerwith the specified options.- Throws:
java.io.IOException- If a keyset is found but unusable.KeystoreException- If a master key is found but unusable.java.security.GeneralSecurityException- If cannot read an existing keyset or generate a new one.
-
-