Class AlgorithmSecretStore
- All Implemented Interfaces:
SecretStore
- Direct Known Subclasses:
AesOnlyAlgorithmSecretStore
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 store(String) and get(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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected DecryptionParametersencrypt(EncryptionParameters parameters) Decrypts data stored inSealedObjectusingSecretKeySpec.protected SealedObjectgetEncryptedPassword(DecryptionParameters dataToDecrypt) Creates and then saves in fileSealedObjectwhich stores encrypted data.
-
Constructor Details
-
AlgorithmSecretStore
public AlgorithmSecretStore()
-
-
Method Details
-
store
Creates and then saves in fileSealedObjectwhich stores encrypted data. Data is encrypted using:SecretKeySpec,AlgorithmParametersand algorithm specified by user.As parameter expects
EncryptionParametersin JSON format Mandatory fields in JSON:EncryptionParameters.plainTextPassword- password in plain textEncryptionParameters.algorithm- one of: - AES/CBC/PKCS5Padding - DES/CBC/PKCS5Padding - DESede/CBC/PKCS5PaddingEncryptionParameters.algorithmKey- should correspond with algorithm field and be one of: - AES - DES - DESedeOptional 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 containsAlgorithmParametersstored in encoded form. seeAlgorithmParametersSerializationFileto 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 containsSecretKeySpecstored as serialized object. seeSerializationFileto 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] seeUniqueFilePathGeneratorEncryptionParameters.outputFilesBasePath- store path where createdSealedObject,SecretKeySpecandAlgorithmParameterswill be saved. If not provided files will be saved in the default directory. If provided, it must be ended with file separator ('/' or '\')- Specified by:
storein interfaceSecretStore- Parameters:
encryptionParamsInJson-EncryptionParametersin JSON format- Returns:
DecryptionParametersin JSON format
-
get
Decrypts data stored inSealedObjectusingSecretKeySpec.As parameter expects
DecryptionParametersin JSON format.Optional fields in JSON: (if missing data is searched in environmental variable)
DecryptionParameters.serializedSealedObject- string which containsSealedObjectstored as serialized object. In case it's missing, the data aboutSealedObjectin stored byDecryptionParameters.sealedObjectFilePath.DecryptionParameters.sealedObjectFilePath- path to file which containsSealedObjectstored as serialized object. seeSerializationFileto check how it will be read. IfDecryptionParameters.serializedSealedObjectis not null, this param will not be taken into account. But in case whenDecryptionParameters.sealedObjectFilePathandDecryptionParameters.serializedSealedObjectare missing, path will be searched in environmental variable under key:EnvironmentVarBasedConfiguration.ENV_VARIABLE_PREFIX+ javax_crypto_SealedObjectDecryptionParameters.keyFilePath- path to file which containsSecretKeySpecstored as serialized object. seeSerializationFileto 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- Specified by:
getin interfaceSecretStore- Parameters:
decryptionParamsInJson-DecryptionParametersin JSON format- Returns:
- plain text password
-
getEncryptedPassword
-
encrypt
-