public class CryptoUtil
extends java.lang.Object
| Constructor and Description |
|---|
CryptoUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
decryptFields(java.lang.Object object,
CollectionMetaData cmd,
ICipher cipher)
A utility method to decrypt the value of field marked by the @Secret annotation using its
setter/mutator method.
|
static void |
encryptFields(java.lang.Object object,
CollectionMetaData cmd,
ICipher cipher)
A utility method to encrypt the value of field marked by the @Secret annotation using its
setter/mutator method.
|
static java.lang.String |
generate128BitKey(java.lang.String password,
java.lang.String salt)
Utility method to help generate a strong 128 bit Key to be used for the DefaultAESCBCCipher.
|
public static void encryptFields(java.lang.Object object,
CollectionMetaData cmd,
ICipher cipher)
throws java.lang.IllegalAccessException,
java.lang.IllegalArgumentException,
java.lang.reflect.InvocationTargetException
object - the actual Object representing the POJO we want the Id of.cmd - the CollectionMetaData object from which we can obtain the list
containing names of fields which have the @Secret annotationcipher - the actual cipher implementation to usejava.lang.IllegalAccessException - Error when invoking method for a @Secret annotated field due to permissionsjava.lang.IllegalArgumentException - Error when invoking method for a @Secret annotated field due to wrong argumentsjava.lang.reflect.InvocationTargetException - Error when invoking method for a @Secret annotated field, the method threw a exceptionpublic static void decryptFields(java.lang.Object object,
CollectionMetaData cmd,
ICipher cipher)
throws java.lang.IllegalAccessException,
java.lang.IllegalArgumentException,
java.lang.reflect.InvocationTargetException
object - the actual Object representing the POJO we want the Id of.cmd - the CollectionMetaData object from which we can obtain the list
containing names of fields which have the @Secret annotationcipher - the actual cipher implementation to usejava.lang.IllegalAccessException - Error when invoking method for a @Secret annotated field due to permissionsjava.lang.IllegalArgumentException - Error when invoking method for a @Secret annotated field due to wrong argumentsjava.lang.reflect.InvocationTargetException - Error when invoking method for a @Secret annotated field, the method threw a exceptionpublic static java.lang.String generate128BitKey(java.lang.String password,
java.lang.String salt)
throws java.security.NoSuchAlgorithmException,
java.io.UnsupportedEncodingException,
java.security.spec.InvalidKeySpecException
PBEKeySpec below to 256password - A password which acts as a seed for generation of the keysalt - A salt used in combination with the password for the generation of the keyjava.security.NoSuchAlgorithmException - if the KeyFactory algorithm is not found in available crypto providersjava.io.UnsupportedEncodingException - if the char encoding of the salt is not known.java.security.spec.InvalidKeySpecException - invalid generated key