Package org.teiid.core.crypto
Class BasicCryptor
- java.lang.Object
-
- org.teiid.core.crypto.BasicCryptor
-
- All Implemented Interfaces:
Cryptor
- Direct Known Subclasses:
SymmetricCryptor
public class BasicCryptor extends Object implements Cryptor
Public methods in this class throw only
CryptoException
s.
-
-
Field Summary
Fields Modifier and Type Field Description protected String
cipherAlgorithm
protected Key
decryptKey
The key to be used for decryption.static String
ENCRYPT_PREFIX
protected Cipher
encryptCipher
TheCipher
to use for encryption.static String
OLD_ENCRYPT_PREFIX
-
Constructor Summary
Constructors Constructor Description BasicCryptor(Key encryptKey, Key decryptKey, String algorithm, IvParameterSpec iv)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
decrypt(byte[] ciphertext)
Decrypt the ciphertext to yield the original cleartext.byte[]
encrypt(byte[] cleartext)
Encrypt the cleartext in byte array format.byte[]
encrypt(byte[] buffer, int offset, int length)
protected void
initDecryptCipher()
Initialize the ciphers used for encryption and decryption.protected void
initEncryptCipher()
Initialize the cipher used for encryption.Object
sealObject(Object object)
void
setClassLoader(ClassLoader classLoader)
void
setUseSealedObject(boolean useSealedObject)
Object
unsealObject(Object object)
-
-
-
Field Detail
-
decryptKey
protected Key decryptKey
The key to be used for decryption.
-
encryptCipher
protected Cipher encryptCipher
TheCipher
to use for encryption.
-
cipherAlgorithm
protected String cipherAlgorithm
-
OLD_ENCRYPT_PREFIX
public static final String OLD_ENCRYPT_PREFIX
- See Also:
- Constant Field Values
-
ENCRYPT_PREFIX
public static final String ENCRYPT_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BasicCryptor
public BasicCryptor(Key encryptKey, Key decryptKey, String algorithm, IvParameterSpec iv) throws CryptoException
- Throws:
CryptoException
-
-
Method Detail
-
setUseSealedObject
public void setUseSealedObject(boolean useSealedObject)
-
setClassLoader
public void setClassLoader(ClassLoader classLoader)
-
decrypt
public byte[] decrypt(byte[] ciphertext) throws CryptoException
Decrypt the ciphertext to yield the original cleartext.- Specified by:
decrypt
in interfaceCryptor
- Parameters:
ciphertext
- The text to be encrypted, in byte form- Returns:
- The decrypted cleartext, in byte form
- Throws:
CryptoException
-
initDecryptCipher
protected void initDecryptCipher() throws CryptoException
Initialize the ciphers used for encryption and decryption. The ciphers define the algorithms to be used. They are initialized with the appropriate key to be used in the encryption or decryption operation.- Throws:
CryptoException
-
unsealObject
public Object unsealObject(Object object) throws CryptoException
- Specified by:
unsealObject
in interfaceCryptor
- Throws:
CryptoException
-
encrypt
public byte[] encrypt(byte[] cleartext) throws CryptoException
Encrypt the cleartext in byte array format.- Specified by:
encrypt
in interfaceCryptor
- Parameters:
cleartext
- The text to be encrypted, in byte form- Returns:
- The encrypted ciphertext, in byte form
- Throws:
CryptoException
-
encrypt
public byte[] encrypt(byte[] buffer, int offset, int length) throws CryptoException
- Throws:
CryptoException
-
initEncryptCipher
protected void initEncryptCipher() throws CryptoException
Initialize the cipher used for encryption. The cipher defines the algorithm to be used. It is initialized with the appropriate key to be used in the encryption operation.- Throws:
CryptoException
-
sealObject
public Object sealObject(Object object) throws CryptoException
- Specified by:
sealObject
in interfaceCryptor
- Throws:
CryptoException
-
-