Package org.ametys.core.util
Class CryptoHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.util.CryptoHelper
- All Implemented Interfaces:
LogEnabled
,Component
,Configurable
Helper to encrypt/decrypt some text
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Exception when the decrypt key has not worked -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
configure
(Configuration configuration) Decrypt a string (base64) using the generated keyDecrypt a string (base64) using the selected keyEncrypt (base64) a string using the generated keyEncrypt (base64) a string using the selected keyGet the generated crypto keyMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Constructor Details
-
CryptoHelper
public CryptoHelper()
-
-
Method Details
-
configure
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
decrypt
Decrypt a string (base64) using the selected key- Parameters:
encryptedValue
- the encrypted valuekey
- The key used to decrypt value- Returns:
- the decrypted String
- Throws:
CryptoHelper.WrongKeyException
- If the key is not the right one
-
decrypt
Decrypt a string (base64) using the generated key- Parameters:
encryptedValue
- the encrypted value- Returns:
- the decrypted String
-
encrypt
Encrypt (base64) a string using the selected key- Parameters:
data
- input datakey
- the key used to encrypt- Returns:
- the base64 value of the encrypted data
-
encrypt
Encrypt (base64) a string using the generated key- Parameters:
data
- input data- Returns:
- the base64 value of the encrypted data
-
getCryptoKey
Get the generated crypto key- Returns:
- the generated crypto key
-