new SecuredPropertiesConfig() is a valid Configuration with following default behaviors:
The following customizations are available:
private Config config = new SecuredPropertiesConfig() .initDefault() // [1] .init(ConfigInitializers.systemProperties()) // [2] .withSecretFile(new File("./mySecret.key")) // [3] .withSaltLength(0) // [4] .withAllowedAlgorithm(SupportedAlgorithm.AES_256) // [5] .addAllowedAlgorithm(SupportedAlgorithm.DESede_168) // [6] .withAutoCreateSecretKey(false); // [7]
Similar to Spring-Boot, Externalize your configuration so that you can work with the same application code in different environments.
The last one has the highest priority and will overwrite properties before.
The Properties which can be configured can be found in ConfigKey.java.
The default prefix is “SECURED_PROPERTIES” and the keys must be configured formatted as:
The generic variant of initDefault().
Just put in the ConfigInitializers.java you want into it in the order you want.
Or implement yout own ConfigInitializer.java.
The last ConfigInitializer has the highest priority and will overwrite properties before.
If no secret file path is configured in th eproperty file with key secretFilePropertyKey, then the defaultSecretFile will be used.
Without defaultSecretFile the default “%user_home%/.secret/securedProperties.key” will be used as secret file.
The salt length defines the length of the randomly generated salt which will be added to the value before encryption. Default is 11, and a length of 0 will deactivate the salt. The salt makes sure that two properties with the same value doesn’t have the same encrypted value.