OSGI Configuration Parameters for Blueprint Components
About this task
As Jasypt supports blueprint components, it can be easily configured to use it.
Procedure
Results
An example of blueprint configuration (environment variable TESB_ENV_PASSWORD is set to pwd) is shown below:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:enc="http://karaf.apache.org/xmlns/jasypt/v1.0.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">
<cm:property-placeholder persistent-id="my" update-strategy="reload">
<cm:default-properties>
<cm:property name="password" value="ENC(ri+N4zeF/hTl1omjgYky1uQxYwhyxyPmdnyC/UmY1ug=)" />
</cm:default-properties>
</cm:property-placeholder>
<enc:property-placeholder>
<enc:encryptor class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
<property name="config">
<bean class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
<property name="algorithm" value="PBEWITHSHA256AND128BITAES-CBC-BC" />
<property name="passwordEnvName" value="TESB_ENV_PASSWORD" />
</bean>
</property>
</enc:encryptor>
</enc:property-placeholder>
<bean id="serviceBean" class="org.company.example.MyServiceImpl">
<property name="prop" value="${password}"/>
</bean>
<blueprint>
An example of persistent configuration (container/etc/my.cfg) is as follows:
password=ENC(6laeC861kCMSh2Eaj4sjtNzgstdo5BKFh8d+fop2Jt0=)