Package org.opencms.crypto
Class CmsAESTextEncryption
- java.lang.Object
-
- org.opencms.crypto.CmsAESTextEncryption
-
- All Implemented Interfaces:
I_CmsConfigurationParameterHandler
,I_CmsTextEncryption
public class CmsAESTextEncryption extends java.lang.Object implements I_CmsTextEncryption
Default text encryption class using AES, where the encryption key is generated from a string passed in as a parameter.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AES
The name of the algorithm.static com.google.common.io.BaseEncoding
BASE64
URL parameter safe base64 encoder.static java.lang.String
PARAM_SECRET
The configuration parameter for configuring the secret.-
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
-
-
Constructor Summary
Constructors Constructor Description CmsAESTextEncryption()
Default constructor (used when instantiated automatically during OpenCms configuration).CmsAESTextEncryption(java.lang.String secret)
Constructor used to manually, conveniently create a new encryption object with a given secret.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConfigurationParameter(java.lang.String paramName, java.lang.String paramValue)
Adds a configuration parameter to this parameter configurable class instance.java.lang.String
decrypt(java.lang.String input)
Decrypts encrypted data.java.lang.String
encrypt(java.lang.String input)
Encrypts data.static javax.crypto.SecretKey
generateAESKey(java.lang.String secret)
Helper method for generating an AES key from a secret string.CmsParameterConfiguration
getConfiguration()
Returns the parameters of this configurable class instance, ornull
if the class does not need any parameters.java.lang.String
getName()
Gets the name of the encryption handler.void
initConfiguration()
Initializes a configuration after all parameters have been added.void
initialize(CmsObject cms)
Initializes the encryption handler.void
setName(java.lang.String name)
Sets the name of the encryption handler.
-
-
-
Field Detail
-
AES
public static final java.lang.String AES
The name of the algorithm.- See Also:
- Constant Field Values
-
BASE64
public static final com.google.common.io.BaseEncoding BASE64
URL parameter safe base64 encoder.
-
PARAM_SECRET
public static final java.lang.String PARAM_SECRET
The configuration parameter for configuring the secret.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsAESTextEncryption
public CmsAESTextEncryption()
Default constructor (used when instantiated automatically during OpenCms configuration).
-
CmsAESTextEncryption
public CmsAESTextEncryption(java.lang.String secret)
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 Detail
-
generateAESKey
public static javax.crypto.SecretKey generateAESKey(java.lang.String secret)
Helper method for generating an AES key from a secret string.- Parameters:
secret
- the secret string- Returns:
- the AES key
-
addConfigurationParameter
public void addConfigurationParameter(java.lang.String paramName, java.lang.String paramValue)
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:
I_CmsConfigurationParameterHandler.addConfigurationParameter(java.lang.String, java.lang.String)
-
decrypt
public java.lang.String decrypt(java.lang.String input) throws CmsEncryptionException
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:
I_CmsTextEncryption.decrypt(java.lang.String)
-
encrypt
public java.lang.String encrypt(java.lang.String input) throws CmsEncryptionException
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:
I_CmsTextEncryption.encrypt(java.lang.String)
-
getConfiguration
public CmsParameterConfiguration 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:
I_CmsConfigurationParameterHandler.getConfiguration()
-
getName
public java.lang.String 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:
I_CmsTextEncryption.getName()
-
initConfiguration
public void initConfiguration()
Description copied from interface:I_CmsConfigurationParameterHandler
Initializes a configuration after all parameters have been added.- Specified by:
initConfiguration
in interfaceI_CmsConfigurationParameterHandler
- See Also:
I_CmsConfigurationParameterHandler.initConfiguration()
-
initialize
public void initialize(CmsObject cms)
Description copied from interface:I_CmsTextEncryption
Initializes the encryption handler.- Specified by:
initialize
in interfaceI_CmsTextEncryption
- Parameters:
cms
- an Admin CMS context- See Also:
I_CmsTextEncryption.initialize(org.opencms.file.CmsObject)
-
setName
public void setName(java.lang.String name)
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:
I_CmsTextEncryption.setName(java.lang.String)
-
-