You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tristan Cartoux <tr...@gmail.com> on 2019/11/05 09:02:19 UTC

camel-jasypt outside of camelContext in blueprint

Hello,

I tried to follow this exemple
<https://camel.465427.n5.nabble.com/camel-jasypt-with-Blueprint-DSL-td5752562.html>
to use camel-jasypt to instantiate beans in my blueprint xml, but with no
success. I have no error but jasypt just seems to ignore ENC(...) as i get
the raw values in my beans.

Here is what i tried :
(1)

* <cm:property-placeholder id="myProperties" persistent-id="propFile"
update-strategy="reload" />*









* <!-- Encoded param parser --> <bean id="jasypt"
class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
 <property name="password" value="test"/> </bean> <!-- Link parser to
property-placeholder --> <bean id="properties"
class="org.apache.camel.component.properties.PropertiesComponent">
 <property name="location" value="blueprint:myProperties"/>    <property
name="propertiesParser" ref="jasypt"/> </bean>*
*<!-- Bean to init -->*


*<bean id="someBean" class="someClass">   <property name="keystorePassword"
value="${keystore.password}" />*
*</bean>*

I finally managed to do this using jasypt "enc" namespace like below :
(2)

*<cm:property-placeholder id="myProperties" persistent-id="propFile"
update-strategy="reload" />  *
*<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="test"/>             </bean>
</property>     </enc:encryptor> </enc:property-placeholder>*
This solution required me to declare xmlns:enc="
http://karaf.apache.org/xmlns/jasypt/v1.0.0" in my blueprint, activate
"jasypt-encryption" karaf feature and adding
"org.jasypt.encryption.pbe;version=1.9.1_2;" to my bundle Import-Package
declaration.

However i would like to know if method (1) can achieve the same thing ? I
prefer the syntax and i find it easier to use as it does not require adding
namespace schema or odd maven import declaration.
Since i have no error, i'm feeling like i just missed a littlle thing to
make solution (1) work.

Furthermore, maybe camel doc on jasypt component
<https://camel.apache.org/components/latest/jasypt.html> should have a note
for this ?
Initializing beans with properties is a really common need imo and doc only
shows exemples for loading props inside of camelContext. If it is not
possible with camel-jasypt component, maybe it should be specified as well ?


(Camel version used : 2.22.2)

Thank you for your help

Re: camel-jasypt outside of camelContext in blueprint

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi,

I guess you are using Karaf as runtime ? Did you install the jasypt
feature ?

Regards
JB

On 05/11/2019 10:02, Tristan Cartoux wrote:
> Hello,
> 
> I tried to follow this exemple
> <https://camel.465427.n5.nabble.com/camel-jasypt-with-Blueprint-DSL-td5752562.html>
> to use camel-jasypt to instantiate beans in my blueprint xml, but with no
> success. I have no error but jasypt just seems to ignore ENC(...) as i get
> the raw values in my beans.
> 
> Here is what i tried :
> (1)
> 
> * <cm:property-placeholder id="myProperties" persistent-id="propFile"
> update-strategy="reload" />*
> 
> 
> 
> 
> 
> 
> 
> 
> 
> * <!-- Encoded param parser --> <bean id="jasypt"
> class="org.apache.camel.component.jasypt.JasyptPropertiesParser">
>  <property name="password" value="test"/> </bean> <!-- Link parser to
> property-placeholder --> <bean id="properties"
> class="org.apache.camel.component.properties.PropertiesComponent">
>  <property name="location" value="blueprint:myProperties"/>    <property
> name="propertiesParser" ref="jasypt"/> </bean>*
> *<!-- Bean to init -->*
> 
> 
> *<bean id="someBean" class="someClass">   <property name="keystorePassword"
> value="${keystore.password}" />*
> *</bean>*
> 
> I finally managed to do this using jasypt "enc" namespace like below :
> (2)
> 
> *<cm:property-placeholder id="myProperties" persistent-id="propFile"
> update-strategy="reload" />  *
> *<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="test"/>             </bean>
> </property>     </enc:encryptor> </enc:property-placeholder>*
> This solution required me to declare xmlns:enc="
> http://karaf.apache.org/xmlns/jasypt/v1.0.0" in my blueprint, activate
> "jasypt-encryption" karaf feature and adding
> "org.jasypt.encryption.pbe;version=1.9.1_2;" to my bundle Import-Package
> declaration.
> 
> However i would like to know if method (1) can achieve the same thing ? I
> prefer the syntax and i find it easier to use as it does not require adding
> namespace schema or odd maven import declaration.
> Since i have no error, i'm feeling like i just missed a littlle thing to
> make solution (1) work.
> 
> Furthermore, maybe camel doc on jasypt component
> <https://camel.apache.org/components/latest/jasypt.html> should have a note
> for this ?
> Initializing beans with properties is a really common need imo and doc only
> shows exemples for loading props inside of camelContext. If it is not
> possible with camel-jasypt component, maybe it should be specified as well ?
> 
> 
> (Camel version used : 2.22.2)
> 
> Thank you for your help
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com