public abstract class AbstractEncryptor extends Object implements Encryptor
Modifier and Type | Field and Description |
---|---|
protected String |
cipherAlgorithm |
protected String |
cipherProvider |
protected KeyProvider |
keyProvider |
protected static org.apache.commons.logging.Log |
logger |
Modifier | Constructor and Description |
---|---|
protected |
AbstractEncryptor()
Constructs with defaults
|
Modifier and Type | Method and Description |
---|---|
AlgorithmParameters |
decodeAlgorithmParameters(byte[] encoded)
Decodes encoded cipher algorithm parameters
|
byte[] |
decrypt(String keyAlias,
AlgorithmParameters params,
byte[] input)
Decrypt some bytes
|
InputStream |
decrypt(String keyAlias,
AlgorithmParameters params,
InputStream input)
Decrypt an input stream
|
Object |
decryptObject(String keyAlias,
AlgorithmParameters params,
byte[] input)
Decrypt data as an object
|
Pair<byte[],AlgorithmParameters> |
encrypt(String keyAlias,
AlgorithmParameters params,
byte[] input)
Encrypt some bytes
|
Pair<byte[],AlgorithmParameters> |
encryptObject(String keyAlias,
AlgorithmParameters params,
Object input)
Encrypt an object
|
protected abstract Cipher |
getCipher(String keyAlias,
AlgorithmParameters params,
int mode)
Factory method to be written by implementations to construct and initialize
physical ciphering objects.
|
String |
getCipherAlgorithm() |
String |
getCipherProvider() |
KeyProvider |
getKeyProvider() |
void |
init() |
protected void |
resetCipher() |
Serializable |
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) |
Serializable |
unsealObject(String keyAlias,
Serializable input)
Convenience method to unseal on object sealed up cryptographically.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
keyAvailable
protected static final org.apache.commons.logging.Log logger
protected String cipherAlgorithm
protected String cipherProvider
protected KeyProvider keyProvider
public void setKeyProvider(KeyProvider keyProvider)
keyProvider
- provides encryption keys based on aliasespublic KeyProvider getKeyProvider()
public void init()
protected abstract Cipher getCipher(String keyAlias, AlgorithmParameters params, int mode)
keyAlias
- the key aliasparams
- algorithm-specific parametersmode
- the cipher modepublic Pair<byte[],AlgorithmParameters> encrypt(String keyAlias, AlgorithmParameters params, byte[] input)
protected void resetCipher()
public byte[] decrypt(String keyAlias, AlgorithmParameters params, byte[] input)
public InputStream decrypt(String keyAlias, AlgorithmParameters params, InputStream input)
public Pair<byte[],AlgorithmParameters> encryptObject(String keyAlias, AlgorithmParameters params, Object input)
encrypts
the input data.encryptObject
in interface Encryptor
keyAlias
- the encryption key aliasinput
- the object to write to bytespublic Object decryptObject(String keyAlias, AlgorithmParameters params, byte[] input)
Decrypts
and deserializes the input datadecryptObject
in interface Encryptor
keyAlias
- the encryption key aliasinput
- the data to decryptpublic Serializable sealObject(String keyAlias, AlgorithmParameters params, Serializable input)
Encryptor
sealObject
in interface Encryptor
keyAlias
- the encryption key aliasinput
- the object to encrypt and sealpublic Serializable unsealObject(String keyAlias, Serializable input) throws InvalidKeyException
Encryptor
SealedObject
.unsealObject
in interface Encryptor
keyAlias
- the encryption key aliasinput
- the object to decrypt and unsealInvalidKeyException
public void setCipherAlgorithm(String cipherAlgorithm)
public String getCipherAlgorithm()
public void setCipherProvider(String cipherProvider)
public String getCipherProvider()
public AlgorithmParameters decodeAlgorithmParameters(byte[] encoded)
decodeAlgorithmParameters
in interface Encryptor
encoded
- the encoded cipher algorithm parametersCopyright © 2005–2016 Alfresco Software. All rights reserved.