Class AndroidKeysetManager.Builder

    • Constructor Detail

      • Builder

        public Builder()
    • 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 using val.
      • 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 new AndroidKeysetManager with 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.