Class SharedPrefKeysetReader

  • All Implemented Interfaces:
    KeysetReader

    public final class SharedPrefKeysetReader
    extends java.lang.Object
    implements KeysetReader
    A KeysetReader that can read keysets from private shared preferences on Android.
    Since:
    1.0.0
    • Constructor Summary

      Constructors 
      Constructor Description
      SharedPrefKeysetReader​(android.content.Context context, java.lang.String keysetName, java.lang.String prefFilename)
      Creates a KeysetReader that reads and hex-decodes keysets from the preference name keysetName in the private shared preferences file prefFilename.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.google.crypto.tink.proto.Keyset read()
      Tries to read and return a cleartext Keyset.
      com.google.crypto.tink.proto.EncryptedKeyset readEncrypted()
      Tries to read and return an EncryptedKeyset.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SharedPrefKeysetReader

        public SharedPrefKeysetReader​(android.content.Context context,
                                      java.lang.String keysetName,
                                      java.lang.String prefFilename)
                               throws java.io.IOException
        Creates a KeysetReader that reads and hex-decodes keysets from the preference name keysetName in the private shared preferences file prefFilename.

        If prefFilename is null, uses the default shared preferences file.

        Throws:
        java.io.IOException - if cannot read the keyset
        java.lang.IllegalArgumentException - if keysetName is null
    • Method Detail

      • read

        public com.google.crypto.tink.proto.Keyset read()
                                                 throws java.io.IOException
        Description copied from interface: KeysetReader
        Tries to read and return a cleartext Keyset.
        Specified by:
        read in interface KeysetReader
        Returns:
        the Keyset
        Throws:
        java.io.IOException
      • readEncrypted

        public com.google.crypto.tink.proto.EncryptedKeyset readEncrypted()
                                                                   throws java.io.IOException
        Description copied from interface: KeysetReader
        Tries to read and return an EncryptedKeyset.
        Specified by:
        readEncrypted in interface KeysetReader
        Returns:
        the EncryptedKeyset
        Throws:
        java.io.IOException