Package org.opencms.crypto
Class CmsAESTextEncryption
java.lang.Object
org.opencms.crypto.CmsAESTextEncryption
- All Implemented Interfaces:
I_CmsConfigurationParameterHandler
,I_CmsTextEncryption
Default text encryption class using AES, where the encryption key is generated from a string passed in as a parameter.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
The name of the algorithm.static final com.google.common.io.BaseEncoding
URL parameter safe base64 encoder.static final String
The configuration parameter for configuring the secret.Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
-
Constructor Summary
ConstructorDescriptionDefault constructor (used when instantiated automatically during OpenCms configuration).CmsAESTextEncryption
(String secret) Constructor used to manually, conveniently create a new encryption object with a given secret. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConfigurationParameter
(String paramName, String paramValue) Adds a configuration parameter to this parameter configurable class instance.Decrypts encrypted data.Encrypts data.static SecretKey
generateAESKey
(String secret) Helper method for generating an AES key from a secret string.Returns the parameters of this configurable class instance, ornull
if the class does not need any parameters.getName()
Gets the name of the encryption handler.void
Initializes a configuration after all parameters have been added.void
initialize
(CmsObject cms) Initializes the encryption handler.void
Sets the name of the encryption handler.
-
Field Details
-
AES
The name of the algorithm.- See Also:
-
BASE64
URL parameter safe base64 encoder. -
PARAM_SECRET
The configuration parameter for configuring the secret.- See Also:
-
-
Constructor Details
-
CmsAESTextEncryption
public CmsAESTextEncryption()Default constructor (used when instantiated automatically during OpenCms configuration). -
CmsAESTextEncryption
Constructor used to manually, conveniently create a new encryption object with a given secret.When using this constructor, it is not necessary to call initialize() to make the object usable.
- Parameters:
secret
- the secret used to generate the key
-
-
Method Details
-
generateAESKey
Helper method for generating an AES key from a secret string.- Parameters:
secret
- the secret string- Returns:
- the AES key
-
addConfigurationParameter
Description copied from interface:I_CmsConfigurationParameterHandler
Adds a configuration parameter to this parameter configurable class instance.- Specified by:
addConfigurationParameter
in interfaceI_CmsConfigurationParameterHandler
- Parameters:
paramName
- the name of the parameterparamValue
- the value for the parameter- See Also:
-
decrypt
Description copied from interface:I_CmsTextEncryption
Decrypts encrypted data.- Specified by:
decrypt
in interfaceI_CmsTextEncryption
- Parameters:
input
- the encrypted data- Returns:
- the decrypted data
- Throws:
CmsEncryptionException
- if the data couldn't be decrypted- See Also:
-
encrypt
Description copied from interface:I_CmsTextEncryption
Encrypts data.- Specified by:
encrypt
in interfaceI_CmsTextEncryption
- Parameters:
input
- the data to encrypt- Returns:
- the encrypted data
- Throws:
CmsEncryptionException
- if the data couldn't be encrypted- See Also:
-
getConfiguration
Description copied from interface:I_CmsConfigurationParameterHandler
Returns the parameters of this configurable class instance, ornull
if the class does not need any parameters.- Specified by:
getConfiguration
in interfaceI_CmsConfigurationParameterHandler
- Returns:
- the parameters of this configurable class instance,
or
null
if the class does not need any parameters - See Also:
-
getName
Description copied from interface:I_CmsTextEncryption
Gets the name of the encryption handler.- Specified by:
getName
in interfaceI_CmsTextEncryption
- Returns:
- the name
- See Also:
-
initConfiguration
Description copied from interface:I_CmsConfigurationParameterHandler
Initializes a configuration after all parameters have been added.- Specified by:
initConfiguration
in interfaceI_CmsConfigurationParameterHandler
- See Also:
-
initialize
Description copied from interface:I_CmsTextEncryption
Initializes the encryption handler.- Specified by:
initialize
in interfaceI_CmsTextEncryption
- Parameters:
cms
- an Admin CMS context- See Also:
-
setName
Description copied from interface:I_CmsTextEncryption
Sets the name of the encryption handler.- Specified by:
setName
in interfaceI_CmsTextEncryption
- Parameters:
name
- the name that should be set- See Also:
-