Package org.alfresco.encryption
Class AbstractEncryptor
java.lang.Object
org.alfresco.encryption.AbstractEncryptor
- All Implemented Interfaces:
Encryptor
- Direct Known Subclasses:
DefaultEncryptor
Basic support for encryption engines.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected String
protected String
protected KeyProvider
protected static final org.apache.commons.logging.Log
-
Constructor Summary
Constructors -
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 input) 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 objectprotected abstract Cipher
getCipher
(String keyAlias, AlgorithmParameters params, int mode) Factory method to be written by implementations to construct and initialize physical ciphering objects.void
init()
protected void
sealObject
(String keyAlias, AlgorithmParameters params, Serializable input) Convenience method to seal on object up cryptographically.void
setCipherAlgorithm
(String cipherAlgorithm) void
setCipherProvider
(String cipherProvider) void
setKeyProvider
(KeyProvider keyProvider) unsealObject
(String keyAlias, Serializable input) Convenience method to unseal on object sealed up cryptographically.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.alfresco.encryption.Encryptor
keyAvailable
-
Field Details
-
logger
protected static final org.apache.commons.logging.Log logger -
cipherAlgorithm
-
cipherProvider
-
keyProvider
-
-
Constructor Details
-
AbstractEncryptor
protected AbstractEncryptor()Constructs with defaults
-
-
Method Details
-
setKeyProvider
- Parameters:
keyProvider
- provides encryption keys based on aliases
-
getKeyProvider
-
init
public void init() -
getCipher
Factory method to be written by implementations to construct and initialize physical ciphering objects.- Parameters:
keyAlias
- the key aliasparams
- algorithm-specific parametersmode
- the cipher mode- Returns:
- Cipher
-
encrypt
public Pair<byte[],AlgorithmParameters> encrypt(String keyAlias, AlgorithmParameters params, byte[] input) Encrypt some bytes -
resetCipher
protected void resetCipher() -
decrypt
Decrypt some bytes -
decrypt
Decrypt an input stream -
encryptObject
public Pair<byte[],AlgorithmParameters> encryptObject(String keyAlias, AlgorithmParameters params, Object input) Encrypt an object Serializes andencrypts
the input data.- 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 objectDecrypts
and deserializes the input data- Specified by:
decryptObject
in interfaceEncryptor
- Parameters:
keyAlias
- the encryption key aliasinput
- the data to decrypt- Returns:
- the unencrypted data deserialized
-
sealObject
Description copied from interface:Encryptor
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
Description copied from interface:Encryptor
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
-
setCipherAlgorithm
-
getCipherAlgorithm
-
setCipherProvider
-
getCipherProvider
-
decodeAlgorithmParameters
Decodes encoded cipher algorithm parameters- Specified by:
decodeAlgorithmParameters
in interfaceEncryptor
- Parameters:
encoded
- the encoded cipher algorithm parameters- Returns:
- the decoded cipher algorithmParameters
-