在数据库连接

时间:2016-03-17 05:48:10

标签: spring spring-boot

我们公司有一个加密实用程序,我们希望将其用作通用加密/解密方法。我们的spring-boot应用程序有一个外部属性来指定spring.datasource。*配置。

@Configuration
@ComponentScan
@EnableAutoConfiguration
@PropertySources({ @PropertySource(value = { "classpath:application.properties" }),
                   @PropertySource(value = { "file:${application.properties}" }, ignoreResourceNotFound = true) })

现在,我们想在连接到数据库之前解密它。我看过spring-boot jasypt但是如果你想使用你自己的密钥作为解密方法它将无法工作。有没有办法使用存储在系统中的密钥进行解密?

我已加密并将密码保存在此初始化程序的外部属性中

@Configuration
public class PropertyPasswordContextInitializer implements ApplicationContextInitializer<ConfigurableWebApplicationContext> {

@Override
public void initialize(final ConfigurableWebApplicationContext applicationContext) {
    String configPath = applicationContext.getServletContext().getInitParameter("application.properties"));
    //load properties
    //encrypt if property is spring.datasource.password and starts with ## 
    //save properties file
}

现在加密工作正常。它现在正在寻找实现解密过程的钩子。

0 个答案:

没有答案
相关问题