public class AlgorithmCipher extends Object implements Cipher
It's advanced, because it operates on data stored in files, which are separate from the configuration file. Therefore they can be secured.
see docs for encrypt(String) and decrypt(String)} to learn more.
Supported algorithms (in brackets key size which will be used for key generation): AES/CBC/PKCS5Padding (128) DES/CBC/PKCS5Padding (56) DESede/CBC/PKCS5Padding (168)
| Constructor and Description |
|---|
AlgorithmCipher() |
| Modifier and Type | Method and Description |
|---|---|
String |
decrypt(String decryptionParamsInJson)
Decrypts data stored in
SealedObject using SecretKeySpec. |
String |
encrypt(String encryptionParamsInJson)
Creates and then saves in file
SealedObject which stores encrypted data. |
public String encrypt(String encryptionParamsInJson)
SealedObject which stores encrypted data.
Data is encrypted using: SecretKeySpec, AlgorithmParameters and algorithm specified by user.
As parameter expects EncryptionParameters in JSON format
Mandatory fields in JSON:
EncryptionParameters.plainTextPassword - password in plain text
EncryptionParameters.algorithm - one of:
- AES/CBC/PKCS5Padding
- DES/CBC/PKCS5Padding
- DESede/CBC/PKCS5Padding
EncryptionParameters.algorithmKey - should correspond with algorithm field and be one of:
- AES
- DES
- DESede
Optional fields in JSON: (if missing data is searched in environmental variable, if environmental variable is empty then they are generated)
EncryptionParameters.algorithmParametersFilePath - path to file which contains AlgorithmParameters stored in encoded form.
see AlgorithmParametersSerializationFile to check how it will be read / saved.
They should be generated for same algorithm as used for encryption.
In case parameter it's missing, path will be searched in environmental variable under key: EnvironmentVarBasedConfiguration.ENV_VARIABLE_PREFIX + java_security_AlgorithmParameters
In case environmental variable does not exist, they will be generated and then saved in file in encoded form, under unique name using pattern: java.security.AlgorithmParameters_[current system UTC time]
EncryptionParameters.keyFilePath - path to file which contains SecretKeySpec stored as serialized object.
see SerializationFile to check how it will be read /saved.
Should be generated using same algorithm as used for encryption.
In case it's missing, path will be searched in environmental variable under key: EnvironmentVarBasedConfiguration.ENV_VARIABLE_PREFIX + javax_crypto_spec_SecretKeySpec
In case environmental variable does not exist, key will be generated and then saved in file as serialized object, under unique name using pattern: javax.crypto.spec.SecretKeySpec_[current system UTC time] see UniqueFilePathGenerator
encrypt in interface CipherencryptionParamsInJson - EncryptionParameters in JSON formatDecryptionParameters in JSON formatpublic String decrypt(String decryptionParamsInJson)
SealedObject using SecretKeySpec.
As parameter expects DecryptionParameters in JSON format.
Optional fields in JSON: (if missing data is searched in environmental variable)
DecryptionParameters.sealedObjectFilePath - path to file which contains SealedObject stored as serialized object.
see SerializationFile to check how it will be read.
In case it's missing, path will be searched in environmental variable under key: EnvironmentVarBasedConfiguration.ENV_VARIABLE_PREFIX + javax_crypto_SealedObject
DecryptionParameters.keyFilePath - path to file which contains SecretKeySpec stored as serialized object.
see SerializationFile to check how it will be read /saved.
In case it's missing, path will be searched in environmental variable under key: EnvironmentVarBasedConfiguration.ENV_VARIABLE_PREFIX + javax_crypto_spec_SecretKeySpec
decrypt in interface CipherdecryptionParamsInJson - DecryptionParameters in JSON formatCopyright © 2019 Atlassian. All rights reserved.