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?

Was it helpful?

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

OTHER TIPS

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))
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top