Package com.tailf.maapi
Enum Class MaapiCryptoType
- All Implemented Interfaces:
Serializable
,Comparable<MaapiCryptoType>
,Constable
Data encryption and decryption helper class for each supported
encryption algorithm. Should be used through
MaapiCrypto
.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionSame as callingdecrypt(byte[], String, byte[])
with the iv parameter set to null.Decrypt an encrypted string using the given key and IV.Encrypt a plaintext string using a supplied key.static final MaapiCryptoType
Find the crypto type corresponding for an encrypted string.boolean
Check if an encrypted string was encrypted using a random or a fixed IV.static final boolean
isEncrypted
(String value) Check if a string is encrypted or not based on the prefix of the string.static MaapiCryptoType
Returns the enum constant of this class with the specified name.static MaapiCryptoType[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
DES3
-
AES128
-
AES256
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
fixedIV
Check if an encrypted string was encrypted using a random or a fixed IV.- Parameters:
value
- The encrypted string.- Returns:
- true if a fixed IV was used, false otherwise.
-
encrypt
Encrypt a plaintext string using a supplied key.- Parameters:
key
- The key to use when encrypting the plaintext.plaintext
- The plaintext value to encrypt.- Returns:
- The encrypted and base64 encoded value as a string with a prefix detailing the encryption algoritm used.
- Throws:
MaapiException
-
decrypt
Same as callingdecrypt(byte[], String, byte[])
with the iv parameter set to null.- Throws:
MaapiException
-
decrypt
Decrypt an encrypted string using the given key and IV. The encrypted string is assumed to include the prefix of the encryption algorithm used. If the IV is included in the encrypted string the iv parameter should be set to null, otherwise ir should be the fixed IV user during encryption.- Parameters:
key
- The key to use for decryption.encrypted
- The string to decrypt.iv
- The fixed IV to use for decryption or null if the IV is included in the encrypted string.- Returns:
- The decrypted value as a string.
- Throws:
MaapiException
-
find
Find the crypto type corresponding for an encrypted string. Will check the prefix of the string to find the algorith used to encrypt it and return the MaapiCryptoType enum corresponding to that algorithm.- Parameters:
encrypted
- The encrypted string to find the crypto type for.- Returns:
- A
MaapiCryptoType
object or null if the type could not be found from the encrypted string.
-
isEncrypted
Check if a string is encrypted or not based on the prefix of the string.- Parameters:
value
- The string to check if it is encrypted.- Returns:
- true of the value is encrypted, false otherwise.
-