Paolo Antinori created ARIES-1655:
-------------------------------------
Summary: Placeholders in XML - issue with enc: , cm: and
ConfigAdmin updates
Key: ARIES-1655
URL: https://issues.apache.org/jira/browse/ARIES-1655
Project: Aries
Issue Type: Bug
Components: Blueprint
Reporter: Paolo Antinori
It seems there is an issue with token replacement when both {{cm:}} and
{{enc:}} namespaces are involved:
Full reproducer inline since is short enough:
{code:xml}
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:enc="http://karaf.apache.org/xmlns/jasypt/v1.0.0">
<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="PBEWithMD5AndDES"/>
<property name="password" value="ENCRYPTION_PASSWORD"/>
</bean>
</property>
</enc:encryptor>
</enc:property-placeholder>
<cm:property-placeholder persistent-id="mytest" update-strategy="reload">
<cm:default-properties>
<!-- <cm:property name="mykey" value="5f85Rg1mhRZkAwPiRK3H+w=="/> -->
<!-- <cm:property name="token" value="ENC(${mykey})"/> -->
<cm:property name="token" value="ENC(5f85Rg1mhRZkAwPiRK3H+w==)"/>
</cm:default-properties>
</cm:property-placeholder>
<camelContext id="blueprintContext" trace="false"
xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="timer:foo?fixedRate=true&period=1000" />
<setBody><simple>{{token}}</simple>
</setBody>
<log message="Outside of Camel Context ${body}" />
</route>
</camelContext>
</blueprint>
{code}
If the above blueprint file is deployed, it works as expected: camel is able to
log lines containing the decrypted value of the encoded token.
But
if the value is changed at {{ConfigAdmin}} level, in Karaf with this command:
{code}
config:propset --pid mytest token 'ENC(5f85Rg1mhRZkAwPiRK3H+w==)'
{code}
The token is no longer unencrypted:
{code}
2017-01-09 15:07:24,666 | INFO | #2 - timer://foo | route2
| 232 - org.apache.camel.camel-core - 2.17.0.redhat-630187 | Outside of
Camel Context ENC(5f85Rg1mhRZkAwPiRK3H+w==)
{code}
I have tried adding indirection, with the lines you can see commented out but I
have not been able to make it work.
I have worked around the issue writing an implementation of
{{org.osgi.service.cm.ConfigurationPlugin}} that gave me the functionality I
needed but I wonder if this should just work out of the box:
https://github.com/paoloantinori/fabric8/commit/88159db9957cd85e773c807c63bf737be6dc8d81
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)