Interface StorageCipher


@NonNullByDefault public interface StorageCipher
This allows the encryption and decryption to be performed before saving to storage.
Author:
Gary Tse - Initial contribution
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable String
    decrypt(@Nullable String base64CipherText)
    Decrypt the base64 encoded cipher text.
    @Nullable String
    encrypt(@Nullable String plainText)
    Encrypt the plainText, then produce a base64 encoded cipher text
    A unique cipher identifier per each implementation of StorageCipher.
  • Method Details

    • getUniqueCipherId

      String getUniqueCipherId()
      A unique cipher identifier per each implementation of StorageCipher. It allows the OAuthStoreHandler to choose which cipher implementation to use. This is particularly important when old ciphers becomes out-dated and need to be replaced by new implementations.
      Returns:
      unique identifier
    • encrypt

      @Nullable String encrypt(@Nullable String plainText) throws GeneralSecurityException
      Encrypt the plainText, then produce a base64 encoded cipher text
      Parameters:
      plainText -
      Returns:
      base64 encoded( encrypted( text ) )
      Throws:
      GeneralSecurityException - all security-related exception
    • decrypt

      @Nullable String decrypt(@Nullable String base64CipherText) throws GeneralSecurityException
      Decrypt the base64 encoded cipher text.
      Parameters:
      base64CipherText - This should be the result from the encrypt(String)
      Returns:
      plain text
      Throws:
      GeneralSecurityException - all security-related exception