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()));
}}
Extend Playframework 2 so encrypted strings can be used in properties
-
31-05-2022 - |
質問
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?
解決
他のヒント
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))
}
所属していません StackOverflow