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.StringAESThe name of the algorithm.static com.google.common.io.BaseEncodingBASE64URL parameter safe base64 encoder.static java.lang.StringPARAM_SECRETThe 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()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConfigurationParameter(java.lang.String paramName, java.lang.String paramValue)Adds a configuration parameter to this parameter configurable class instance.java.lang.Stringdecrypt(java.lang.String input)Decrypts encrypted data.java.lang.Stringencrypt(java.lang.String input)Encrypts data.static javax.crypto.SecretKeygenerateAESKey(java.lang.String secret)Helper method for generating an AES key from a secret string.CmsParameterConfigurationgetConfiguration()Returns the parameters of this configurable class instance, ornullif the class does not need any parameters.java.lang.StringgetName()Gets the name of the encryption handler.voidinitConfiguration()Initializes a configuration after all parameters have been added.voidinitialize(CmsObject cms)Initializes the encryption handler.voidsetName(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()
-
-
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_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:
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_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:
I_CmsTextEncryption.decrypt(java.lang.String)
-
encrypt
public java.lang.String encrypt(java.lang.String input) throws CmsEncryptionException
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:
I_CmsTextEncryption.encrypt(java.lang.String)
-
getConfiguration
public CmsParameterConfiguration 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:
I_CmsConfigurationParameterHandler.getConfiguration()
-
getName
public java.lang.String getName()
Description copied from interface:I_CmsTextEncryptionGets the name of the encryption handler.- Specified by:
getNamein interfaceI_CmsTextEncryption- Returns:
- the name
- See Also:
I_CmsTextEncryption.getName()
-
initConfiguration
public void initConfiguration()
Description copied from interface:I_CmsConfigurationParameterHandlerInitializes a configuration after all parameters have been added.- Specified by:
initConfigurationin interfaceI_CmsConfigurationParameterHandler- See Also:
I_CmsConfigurationParameterHandler.initConfiguration()
-
initialize
public void initialize(CmsObject cms)
Description copied from interface:I_CmsTextEncryptionInitializes the encryption handler.- Specified by:
initializein 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_CmsTextEncryptionSets the name of the encryption handler.- Specified by:
setNamein interfaceI_CmsTextEncryption- Parameters:
name- the name that should be set- See Also:
I_CmsTextEncryption.setName(java.lang.String)
-
-