CryptoHelper
Class FQN: it.greenvulcano.util.crypto.CryptoHelper
The keystore/key management is handled by GVCryptoHelper configuration section.
Following the CryptoHelper public constants
/**
* default keyId for configuration cypher key
*/
public static final String DEFAULT_KEY_ID = "XMLConfig";
/**
* default keyStoreId for configuration cypher key
*/
public static final String DEFAULT_KEYSTORE_ID = "GVEsb";
/**
* default file name for configuration keystore
*/
public static final String DEFAULT_KEY_STORE_NAME = "GVEsb.jks";
Following the CryptoHelper public static methods
/**
* Check if the given data is already encrypted with the keyID key.
*
* @param keyID
* @param data
* @return
* @throws CryptoHelperException
* @throws CryptoUtilsException
*/
public static boolean isEncrypted(String keyID, String data) throws CryptoHelperException, CryptoUtilsException
/**
* Encrypt the given data with the algorithm of the keyID key. The result is encoded in Base64 and with the type prefix.
*
* @param keyID
* the key identification name
* @param data
* the data to encrypt, with encoding 'ISO-8859-1'
* @param encode
* if true the the output is encoded with the type prefix
*
* @return the encrypted data
* @throws CryptoHelperException
* if error occurs
* @throws CryptoUtilsException
* if error occurs
*/
public static String encrypt(String keyID, String data, boolean encode) throws CryptoHelperException, CryptoUtilsException
/**
* Encrypt the given data with the algorithm of the keyID key. The result is encoded in Base64 and with the type prefix.
*
* @param keyID
* the key identification name
* @param data
* the data to encrypt
* @param inputEnc
* the input encoding
* @param encode
* if true the the output is encoded with the type prefix
*
* @return the encrypted data
* @throws CryptoHelperException
* if error occurs
* @throws CryptoUtilsException
* if error occurs
*/
public static String encrypt(String keyID, String data, String inputEnc, boolean encode) throws CryptoHelperException, CryptoUtilsException
/**
* Decrypt the given data with the algorithm of the keyID key. The input must be encoded in Base64 and with the type prefix.
*
* @param keyID
* the key identification name
* @param data
* the data to decrypt, with encoding 'ISO-8859-1'
* @param canBeClear
* if true the data can be in clear form
* @return the decrypted data
* @throws CryptoHelperException
* if error occurs
* @throws CryptoUtilsException
* if error occurs
*/
public static String decrypt(String keyID, String data, boolean canBeClear) throws CryptoHelperException, CryptoUtilsException
/**
* Decrypt the given data with the algorithm of the keyID key. The input must be encoded in Base64 and with the type prefix.
*
* @param keyID
* the key identification name
* @param data
* the data to decrypt
* @param inputEnc
* the input encoding
* @param canBeClear
* if true the data can be in clear form
* @return the decrypted data
* @throws CryptoHelperException
* if error occurs
* @throws CryptoUtilsException
* if error occurs
*/
public static String decrypt(String keyID, String data, String inputEnc, boolean canBeClear) throws CryptoHelperException, CryptoUtilsException
/**
* Encrypt the given data with the algorithm of the keyID key.
*
* @param keyID
* the key identification name
* @param data
* the data to encrypt
* @param encode
* if true the the output is encoded with the type prefix
*
* @return the encrypted data
* @throws CryptoHelperException
* if error occurs
* @throws CryptoUtilsException
* if error occurs
*/
public static byte[] encrypt(String keyID, byte[] data, boolean encode) throws CryptoHelperException, CryptoUtilsException
/**
* Decrypt the given data with the algorithm of the keyID key. The input must be encoded in Base64.
*
* @param keyID
* the key identification name
* @param data
* the data to decrypt
* @param canBeClear
* if true the data can be in clear form
* @return the decrypted data
* @throws CryptoHelperException
* if error occurs
* @throws CryptoUtilsException
* if error occurs
*/
public static byte[] decrypt(String keyID, byte[] data, boolean canBeClear) throws CryptoHelperException, CryptoUtilsException
/**
* Retrieve the requested KeyStoreID
*
* @param kStoreID
* the keyStore identification name
* @return the requested KeyStore
* @throws CryptoHelperException
* if error occurs
*/
public static KeyStore getKeyStore(String keyStoreID) throws CryptoHelperException, KeyStoreUtilsException
/**
* Retrieve the requested KeyStoreID
*
* @param kStoreID
* the keyStore identification name
* @return the requested KeyStoreID
* @throws CryptoHelperException
* if error occurs
*/
public static synchronized KeyStoreID getKeyStoreID(String kStoreID) throws CryptoHelperException