Question

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?

Était-ce utile?

La solution

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()));
}}

Autres conseils

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))
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top