Interface Encryptor

All Known Subinterfaces:
FallbackEncryptor
All Known Implementing Classes:
AbstractEncryptor, DefaultEncryptor, DefaultFallbackEncryptor

public interface Encryptor
Interface providing methods to encrypt and decrypt data.
Since:
4.0
  • Method Details

    • encrypt

      Pair<byte[],AlgorithmParameters> encrypt(String keyAlias, AlgorithmParameters params, byte[] input)
      Encrypt some bytes
      Parameters:
      keyAlias - the encryption key alias
      input - the data to encrypt
      Returns:
      the encrypted data and parameters used
    • decrypt

      byte[] decrypt(String keyAlias, AlgorithmParameters params, byte[] input)
      Decrypt some bytes
      Parameters:
      keyAlias - the encryption key alias
      input - the data to decrypt
      Returns:
      the unencrypted data
    • decrypt

      InputStream decrypt(String keyAlias, AlgorithmParameters params, InputStream in)
      Decrypt an input stream
      Parameters:
      keyAlias - the encryption key alias
      in - the data to decrypt
      Returns:
      the unencrypted data
    • encryptObject

      Pair<byte[],AlgorithmParameters> encryptObject(String keyAlias, AlgorithmParameters params, Object input)
      Encrypt an object
      Parameters:
      keyAlias - the encryption key alias
      input - the object to write to bytes
      Returns:
      the encrypted data and parameters used
    • decryptObject

      Object decryptObject(String keyAlias, AlgorithmParameters params, byte[] input)
      Decrypt data as an object
      Parameters:
      keyAlias - the encryption key alias
      input - the data to decrypt
      Returns:
      the unencrypted data deserialized
    • sealObject

      Serializable sealObject(String keyAlias, AlgorithmParameters params, Serializable input)
      Convenience method to seal on object up cryptographically.

      Note that the original object may be returned directly if there is no key associated with the alias.

      Parameters:
      keyAlias - the encryption key alias
      input - the object to encrypt and seal
      Returns:
      the sealed object that can be decrypted with the original key
    • unsealObject

      Serializable unsealObject(String keyAlias, Serializable input) throws InvalidKeyException
      Convenience method to unseal on object sealed up cryptographically.

      Note that the algorithm parameters not provided on the assumption that a symmetric key algorithm is in use - only the key is required for unsealing.

      Note that the original object may be returned directly if there is no key associated with the alias or if the input object is not a SealedObject.

      Parameters:
      keyAlias - the encryption key alias
      input - the object to decrypt and unseal
      Returns:
      the original unsealed object that was encrypted with the original key
      Throws:
      IllegalStateException - if the key alias is not valid and the input is a SealedObject
      InvalidKeyException
    • decodeAlgorithmParameters

      AlgorithmParameters decodeAlgorithmParameters(byte[] encoded)
      Decodes encoded cipher algorithm parameters
      Parameters:
      encoded - the encoded cipher algorithm parameters
      Returns:
      the decoded cipher algorithmParameters
    • keyAvailable

      boolean keyAvailable(String keyAlias)