Package org.alfresco.encryption
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 Summary
Modifier and TypeMethodDescriptiondecodeAlgorithmParameters
(byte[] encoded) Decodes encoded cipher algorithm parametersbyte[]
decrypt
(String keyAlias, AlgorithmParameters params, byte[] input) Decrypt some bytesdecrypt
(String keyAlias, AlgorithmParameters params, InputStream in) Decrypt an input streamdecryptObject
(String keyAlias, AlgorithmParameters params, byte[] input) Decrypt data as an objectPair<byte[],
AlgorithmParameters> encrypt
(String keyAlias, AlgorithmParameters params, byte[] input) Encrypt some bytesPair<byte[],
AlgorithmParameters> encryptObject
(String keyAlias, AlgorithmParameters params, Object input) Encrypt an objectboolean
keyAvailable
(String keyAlias) sealObject
(String keyAlias, AlgorithmParameters params, Serializable input) Convenience method to seal on object up cryptographically.unsealObject
(String keyAlias, Serializable input) Convenience method to unseal on object sealed up cryptographically.
-
Method Details
-
encrypt
Encrypt some bytes- Parameters:
keyAlias
- the encryption key aliasinput
- the data to encrypt- Returns:
- the encrypted data and parameters used
-
decrypt
Decrypt some bytes- Parameters:
keyAlias
- the encryption key aliasinput
- the data to decrypt- Returns:
- the unencrypted data
-
decrypt
Decrypt an input stream- Parameters:
keyAlias
- the encryption key aliasin
- 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 aliasinput
- the object to write to bytes- Returns:
- the encrypted data and parameters used
-
decryptObject
Decrypt data as an object- Parameters:
keyAlias
- the encryption key aliasinput
- the data to decrypt- Returns:
- the unencrypted data deserialized
-
sealObject
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 aliasinput
- the object to encrypt and seal- Returns:
- the sealed object that can be decrypted with the original key
-
unsealObject
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 aSealedObject
.- Parameters:
keyAlias
- the encryption key aliasinput
- 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 SealedObjectInvalidKeyException
-
decodeAlgorithmParameters
Decodes encoded cipher algorithm parameters- Parameters:
encoded
- the encoded cipher algorithm parameters- Returns:
- the decoded cipher algorithmParameters
-
keyAvailable
-