Package org.teiid.core.crypto
Class SymmetricCryptor
- java.lang.Object
-
- org.teiid.core.crypto.BasicCryptor
-
- org.teiid.core.crypto.SymmetricCryptor
-
- All Implemented Interfaces:
Cryptor
public class SymmetricCryptor extends BasicCryptor
Provides a symmetric cryptor using AES
-
-
Field Summary
Fields Modifier and Type Field Description static StringCBC_SYM_ALGORITHMstatic StringDEFAULT_ALIASstatic intDEFAULT_KEY_BITSstatic StringDEFAULT_STORE_PASSWORDstatic StringDEFAULT_SYM_KEY_ALGORITHMstatic StringECB_SYM_ALGORITHM-
Fields inherited from class org.teiid.core.crypto.BasicCryptor
cipherAlgorithm, decryptKey, ENCRYPT_PREFIX, encryptCipher, OLD_ENCRYPT_PREFIX
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidgenerateAndSaveKey(String file)static SecretKeygenerateKey()byte[]getEncodedKey()static SymmetricCryptorgetSymmectricCryptor(boolean cbc)Creates a new SymmetricCryptor with a new symmetric keystatic SymmetricCryptorgetSymmectricCryptor(byte[] key, boolean cbc)Creates a SymmetricCryptor using the supplied byte array as the keystatic SymmetricCryptorgetSymmectricCryptor(byte[] key, String algorithm, String cipherAlgorithm, IvParameterSpec iv)static SymmetricCryptorgetSymmectricCryptor(URL keyResource)Creates a SymmetricCryptor using the supplied URL contents as the keystatic voidmain(String[] args)-
Methods inherited from class org.teiid.core.crypto.BasicCryptor
decrypt, encrypt, encrypt, initDecryptCipher, initEncryptCipher, sealObject, setClassLoader, setUseSealedObject, unsealObject
-
-
-
-
Field Detail
-
DEFAULT_SYM_KEY_ALGORITHM
public static final String DEFAULT_SYM_KEY_ALGORITHM
- See Also:
- Constant Field Values
-
ECB_SYM_ALGORITHM
public static final String ECB_SYM_ALGORITHM
- See Also:
- Constant Field Values
-
CBC_SYM_ALGORITHM
public static final String CBC_SYM_ALGORITHM
- See Also:
- Constant Field Values
-
DEFAULT_KEY_BITS
public static final int DEFAULT_KEY_BITS
- See Also:
- Constant Field Values
-
DEFAULT_STORE_PASSWORD
public static final String DEFAULT_STORE_PASSWORD
- See Also:
- Constant Field Values
-
DEFAULT_ALIAS
public static final String DEFAULT_ALIAS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSymmectricCryptor
public static SymmetricCryptor getSymmectricCryptor(boolean cbc) throws CryptoException
Creates a new SymmetricCryptor with a new symmetric key- Returns:
- a new SymmetricCryptor
- Throws:
CryptoException
-
generateKey
public static SecretKey generateKey() throws CryptoException
- Throws:
CryptoException
-
getSymmectricCryptor
public static SymmetricCryptor getSymmectricCryptor(URL keyResource) throws CryptoException, IOException
Creates a SymmetricCryptor using the supplied URL contents as the key- Parameters:
keyResource- URL to the key- Returns:
- a new SymmetricCryptor
- Throws:
CryptoExceptionIOException
-
getSymmectricCryptor
public static SymmetricCryptor getSymmectricCryptor(byte[] key, boolean cbc) throws CryptoException
Creates a SymmetricCryptor using the supplied byte array as the key- Parameters:
key-- Returns:
- a new SymmetricCryptor
- Throws:
CryptoException
-
getSymmectricCryptor
public static SymmetricCryptor getSymmectricCryptor(byte[] key, String algorithm, String cipherAlgorithm, IvParameterSpec iv) throws CryptoException
- Throws:
CryptoException
-
generateAndSaveKey
public static void generateAndSaveKey(String file) throws CryptoException, IOException
- Throws:
CryptoExceptionIOException
-
getEncodedKey
public byte[] getEncodedKey()
-
-