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
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the algorithm.static final com.google.common.io.BaseEncodingURL parameter safe base64 encoder.static final StringThe configuration parameter for configuring the secret.Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD -
Constructor Summary
ConstructorsConstructorDescriptionDefault 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 TypeMethodDescriptionvoidaddConfigurationParameter(String paramName, String paramValue) Adds a configuration parameter to this parameter configurable class instance.Decrypts encrypted data.Encrypts data.static SecretKeygenerateAESKey(String secret) Helper method for generating an AES key from a secret string.Returns the parameters of this configurable class instance, ornullif the class does not need any parameters.getName()Gets the name of the encryption handler.voidInitializes a configuration after all parameters have been added.voidinitialize(CmsObject cms) Initializes the encryption handler.voidSets 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_CmsConfigurationParameterHandlerAdds a configuration parameter to this parameter configurable class instance.- Specified by:
addConfigurationParameterin interfaceI_CmsConfigurationParameterHandler- Parameters:
paramName- the name of the parameterparamValue- the value for the parameter- See Also:
-
decrypt
Description copied from interface:I_CmsTextEncryptionDecrypts encrypted data.- Specified by:
decryptin 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_CmsTextEncryptionEncrypts data.- Specified by:
encryptin 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_CmsConfigurationParameterHandlerReturns the parameters of this configurable class instance, ornullif the class does not need any parameters.- Specified by:
getConfigurationin interfaceI_CmsConfigurationParameterHandler- Returns:
- the parameters of this configurable class instance,
or
nullif the class does not need any parameters - See Also:
-
getName
Description copied from interface:I_CmsTextEncryptionGets the name of the encryption handler.- Specified by:
getNamein interfaceI_CmsTextEncryption- Returns:
- the name
- See Also:
-
initConfiguration
Description copied from interface:I_CmsConfigurationParameterHandlerInitializes a configuration after all parameters have been added.- Specified by:
initConfigurationin interfaceI_CmsConfigurationParameterHandler- See Also:
-
initialize
Description copied from interface:I_CmsTextEncryptionInitializes the encryption handler.- Specified by:
initializein interfaceI_CmsTextEncryption- Parameters:
cms- an Admin CMS context- See Also:
-
setName
Description copied from interface:I_CmsTextEncryptionSets the name of the encryption handler.- Specified by:
setNamein interfaceI_CmsTextEncryption- Parameters:
name- the name that should be set- See Also:
-