Package org.alfresco.encryption
Class DefaultFallbackEncryptor
java.lang.Object
org.alfresco.encryption.DefaultFallbackEncryptor
- All Implemented Interfaces:
Encryptor
,FallbackEncryptor
The fallback encryptor provides a fallback mechanism for decryption, first using the default
encryption keys and, if they fail (perhaps because they have been changed), falling back
to a backup set of keys.
Note that encryption will be performed only using the default encryption keys.
- Since:
- 4.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
backupKeyAvailable
(String keyAlias) Is the backup key available in order to fall back to?decodeAlgorithmParameters
(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.void
setFallback
(Encryptor fallback) void
unsealObject
(String keyAlias, Serializable input) Convenience method to unseal on object sealed up cryptographically.
-
Constructor Details
-
DefaultFallbackEncryptor
public DefaultFallbackEncryptor() -
DefaultFallbackEncryptor
-
-
Method Details
-
setFallback
-
setMain
-
encrypt
public Pair<byte[],AlgorithmParameters> encrypt(String keyAlias, AlgorithmParameters params, byte[] input) Encrypt some bytes -
decrypt
Decrypt some bytes -
decrypt
Decrypt an input stream -
encryptObject
public Pair<byte[],AlgorithmParameters> encryptObject(String keyAlias, AlgorithmParameters params, Object input) Encrypt an object- Specified by:
encryptObject
in interfaceEncryptor
- 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- Specified by:
decryptObject
in interfaceEncryptor
- 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.- Specified by:
sealObject
in interfaceEncryptor
- 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
.- Specified by:
unsealObject
in interfaceEncryptor
- 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:
InvalidKeyException
-
decodeAlgorithmParameters
Decodes encoded cipher algorithm parameters- Specified by:
decodeAlgorithmParameters
in interfaceEncryptor
- Parameters:
encoded
- the encoded cipher algorithm parameters- Returns:
- the decoded cipher algorithmParameters
-
keyAvailable
- Specified by:
keyAvailable
in interfaceEncryptor
-
backupKeyAvailable
Is the backup key available in order to fall back to?- Specified by:
backupKeyAvailable
in interfaceFallbackEncryptor
- Returns:
- boolean
-