54.4. Java DSL の例
Spring Boot および Quarkus ランタイムでは、設定プロパティーを介して Camel Jasypt を設定できます。詳細は、それぞれのドキュメントページを参照してください。
Java DSL では、Jasypt をJasyptPropertiesParser インスタンスとして設定し、Properties コンポーネントでプロパティーを次のように設定する必要があります。
// create the jasypt properties parser
JasyptPropertiesParser jasypt = new JasyptPropertiesParser();
// set the master password (see above for how to do this in a secure way)
jasypt.setPassword("secret");
// create the properties' component
PropertiesComponent pc = new PropertiesComponent();
pc.setLocation("classpath:org/apache/camel/component/jasypt/secret.properties");
// and use the jasypt properties parser, so we can decrypt values
pc.setPropertiesParser(jasypt);
// end enable nested placeholder support
pc.setNestedPlaceholder(true);
// add properties component to camel context
context.setPropertiesComponent(pc);
このように、JasyptPropertiesParser でカスタムアルゴリズムを設定できます。
JasyptPropertiesParser jasyptPropertiesParser = new JasyptPropertiesParser();
jasyptPropertiesParser.setAlgorithm("PBEWithHmacSHA256AndAES_256");
jasyptPropertiesParser.setRandomSaltGeneratorAlgorithm("PKCS11");
jasyptPropertiesParser.setRandomIvGeneratorAlgorithm("PKCS11");
プロパティーファイル secret.properties には、以下に示すように、暗号化された設定値が含まれます。パスワード値が暗号化され、ENC (値はこちら) のように囲まれていることに注意してください。
my.secret.password=ENC(bsW9uV37gQ0QHFu7KO03Ww==)