문제

I'd like to add Jasypt to the configuration. So I would like to create a plugin that decrypts the application.conf entries that are needed.

I've created a simple plugin, but the db configuration has already been read/executed by the time my onStart() is called.

I've tried GlobalSettings onLoadConfig and beforeStart, both come after the db is configured.

Where can I hook in to achieve my goal?

도움이 되었습니까?

해결책

public class Global extends GlobalSettings {

// inject Jasypt StandardPBEStringEncryptor

@Override
public Configuration onLoadConfig(Configuration configuration, File file, ClassLoader classLoader) {
    final Config config = ConfigFactory.parseString(String.format("db.default.user=%s", callJasyptStringEncryptor()));

    return new Configuration(config.withFallback(configuration.getWrappedConfiguration().underlying()));
}}

다른 팁

If you are using scala,

override def onLoadConfig(config: Configuration, path: File, classloader: ClassLoader, mode: Mode.Mode): Configuration = {
        val parsed = ConfigFactory.parseString("db.default.user=\"JasyptText\"")
        new Configuration(parsed.withFallback(config.underlying))
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top