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 String
CBC_SYM_ALGORITHM
static String
DEFAULT_ALIAS
static int
DEFAULT_KEY_BITS
static String
DEFAULT_STORE_PASSWORD
static String
DEFAULT_SYM_KEY_ALGORITHM
static String
ECB_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 void
generateAndSaveKey(String file)
static SecretKey
generateKey()
byte[]
getEncodedKey()
static SymmetricCryptor
getSymmectricCryptor(boolean cbc)
Creates a new SymmetricCryptor with a new symmetric keystatic SymmetricCryptor
getSymmectricCryptor(byte[] key, boolean cbc)
Creates a SymmetricCryptor using the supplied byte array as the keystatic SymmetricCryptor
getSymmectricCryptor(byte[] key, String algorithm, String cipherAlgorithm, IvParameterSpec iv)
static SymmetricCryptor
getSymmectricCryptor(URL keyResource)
Creates a SymmetricCryptor using the supplied URL contents as the keystatic void
main(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:
CryptoException
IOException
-
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:
CryptoException
IOException
-
getEncodedKey
public byte[] getEncodedKey()
-
-