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
CryptoExceptions.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringcipherAlgorithmprotected KeydecryptKeyThe key to be used for decryption.static StringENCRYPT_PREFIXprotected CipherencryptCipherTheCipherto use for encryption.static StringOLD_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 voidinitDecryptCipher()Initialize the ciphers used for encryption and decryption.protected voidinitEncryptCipher()Initialize the cipher used for encryption.ObjectsealObject(Object object)voidsetClassLoader(ClassLoader classLoader)voidsetUseSealedObject(boolean useSealedObject)ObjectunsealObject(Object object)
-
-
-
Field Detail
-
decryptKey
protected Key decryptKey
The key to be used for decryption.
-
encryptCipher
protected Cipher encryptCipher
TheCipherto 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 CryptoExceptionDecrypt the ciphertext to yield the original cleartext.- Specified by:
decryptin 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 CryptoExceptionInitialize 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:
unsealObjectin interfaceCryptor- Throws:
CryptoException
-
encrypt
public byte[] encrypt(byte[] cleartext) throws CryptoExceptionEncrypt the cleartext in byte array format.- Specified by:
encryptin 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 CryptoExceptionInitialize 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:
sealObjectin interfaceCryptor- Throws:
CryptoException
-
-