How to change jasypt algorithm in spring-boot application? why doesn't it work with default values?

121 views Asked by At

In my Spring boot app I have following application.yml file:

jasypt:
  encryptor:
    password: secretKey
    algorithm: "PBEWithMD5AndDES"
    iv-generator-classname: org.jasypt.iv.NoIvGenerator
 my:
   ldap:
     user: CN=Administrator,CN=Users,DC=company,DC=com
     password: ENC(ObIbZYSJF60VnboZMRtlhj9a/+4B/kkP)

Configuration:

@Configuration
@EnableConfigurationProperties(MyProperties::class)
class MyConfig(
    private val myProperties: MyProperties,
) {...}

========================

@ConfigurationProperties(prefix = "my.ldap")
data class MyProperties(
   password: String
)

The setup above is fully working but if I want to change algorithm:

jasypt:
  encryptor:
    password: secretKey
    iv-generator-classname: org.jasypt.iv.NoIvGenerator

Or both (generator and algorithm )

 jasypt:
   encryptor:
     password: secretKey

So will be used default algorithm PBEWITHHMACSHA512ANDAES_256 and org.jasypt.iv.RandomIvGenerator but I receive an error:

Failed to bind properties under 'my.ldap.password' to java.lang.String:

Property: my.ldap.user
Value: "CN=Administrator,CN=Users,DC=company,DC=com"
Origin: class path resource [application-local.yaml] - 5:11
Reason: org.springframework.boot.context.properties.bind.BindException: Failed

to bind properties under 'my.ldap.password' to java.lang.String

enter image description here https://github.com/ulisesbocchio/jasypt-spring-boot

Based on table above I expected that I have to provide a single parameter

jasypt.encryptor.password

but it doesn't work.

Why does it happen ?

0

There are 0 answers