org.teiid.core.crypto
Class BasicCryptor

java.lang.Object
  extended by org.teiid.core.crypto.BasicCryptor
All Implemented Interfaces:
Cryptor
Direct Known Subclasses:
SymmetricCryptor

public class BasicCryptor
extends java.lang.Object
implements Cryptor

Public methods in this class throw only CryptoExceptions.


Field Summary
protected  java.lang.String cipherAlgorithm
           
protected  java.security.Key decryptKey
          The key to be used for decryption.
static java.lang.String ENCRYPT_PREFIX
           
protected  javax.crypto.Cipher encryptCipher
          The Cipher to use for encryption.
static java.lang.String OLD_ENCRYPT_PREFIX
           
 
Constructor Summary
BasicCryptor(java.security.Key encryptKey, java.security.Key decryptKey, java.lang.String algorithm)
           
 
Method Summary
 byte[] decrypt(byte[] ciphertext)
          Decrypt the ciphertext to yield the original cleartext.
 java.lang.String decrypt(java.lang.String ciphertext)
          Decrypt the ciphertext to yield the original cleartext.
 byte[] encrypt(byte[] cleartext)
          Encrypt the cleartext in byte array format.
 java.lang.String encrypt(java.lang.String cleartext)
          Encrypt the cleartext
protected  void initDecryptCipher()
          Initialize the ciphers used for encryption and decryption.
protected  void initEncryptCipher()
          Initialize the cipher used for encryption.
 java.lang.Object sealObject(java.lang.Object object)
           
static java.lang.String stripEncryptionPrefix(java.lang.String ciphertext)
           
 java.lang.Object unsealObject(java.lang.Object object)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

decryptKey

protected java.security.Key decryptKey
The key to be used for decryption.


encryptCipher

protected javax.crypto.Cipher encryptCipher
The Cipher to use for encryption.


cipherAlgorithm

protected java.lang.String cipherAlgorithm

OLD_ENCRYPT_PREFIX

public static final java.lang.String OLD_ENCRYPT_PREFIX
See Also:
Constant Field Values

ENCRYPT_PREFIX

public static final java.lang.String ENCRYPT_PREFIX
See Also:
Constant Field Values
Constructor Detail

BasicCryptor

public BasicCryptor(java.security.Key encryptKey,
                    java.security.Key decryptKey,
                    java.lang.String algorithm)
             throws CryptoException
Throws:
CryptoException
Method Detail

decrypt

public byte[] decrypt(byte[] ciphertext)
               throws CryptoException
Decrypt the ciphertext to yield the original cleartext.

Specified by:
decrypt in interface Cryptor
Parameters:
ciphertext - The text to be encrypted, in byte form
The - decrypted cleartext, in byte form
Throws:
CryptoException

decrypt

public java.lang.String decrypt(java.lang.String ciphertext)
                         throws CryptoException
Description copied from interface: Cryptor
Decrypt the ciphertext to yield the original cleartext.

Specified by:
decrypt in interface Cryptor
Parameters:
ciphertext - The text to be encrypted
Throws:
CryptoException

stripEncryptionPrefix

public static java.lang.String stripEncryptionPrefix(java.lang.String ciphertext)

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 java.lang.Object unsealObject(java.lang.Object object)
                              throws CryptoException
Specified by:
unsealObject in interface Cryptor
Throws:
CryptoException

encrypt

public byte[] encrypt(byte[] cleartext)
               throws CryptoException
Encrypt the cleartext in byte array format.

Specified by:
encrypt in interface Cryptor
Parameters:
cleartext - The text to be encrypted, in byte form
The - encrypted ciphertext, in byte form
Throws:
CryptoException

encrypt

public java.lang.String encrypt(java.lang.String cleartext)
                         throws CryptoException
Description copied from interface: Cryptor
Encrypt the cleartext

Specified by:
encrypt in interface Cryptor
Parameters:
cleartext - The text to be encrypted
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 java.lang.Object sealObject(java.lang.Object object)
                            throws CryptoException
Specified by:
sealObject in interface Cryptor
Throws:
CryptoException


Copyright © 2011. All Rights Reserved.