Q:

jasypt property placeholder not working

I have this properties file:
secret.key = ENC(foobar)
region = ABC

Then in the config.xml:
<spring:beans>

    <encryption:encryptor-config id="eConf" password-sys-property-name="MULE_ENCRYPTION_PASSWORD" algorithm="PBEWithMD5AndDES" password="" />
    <encryption:string-encryptor id="stringEnc" config-bean="eConf" />
    <encryption:encryptable-property-placeholder encryptor="stringEnc" location="${env}.properties" />

</spring:beans>

But the property placeholders don't work, for example:
<sqs:config secretKey="${secret.key}" region="${region}"></sqs-config>

Does anyone know why?

A:

Encrypted password needs to be write within ENC() function and should be encrypted.    
Let's consider in properties file where password value is Login@123... Now the encrypted value in properties file will be :-
password=ENC(B0u7D8wLwq/ugin31KNpP78gBcLP7VIN) 

Step1 :- We can generate Key using following commands in Command prompt of \jasypt-1.9.2\bin directory :- encrypt input="Login@123" password=sqlpassword algorithm=PBEWithMD5AndDES
Step2 :- In runtime Environment we need to give (Right click->Run As->Run Configuration->Environment) :- Variable :- MULE_ENCRYPTION_PASSWORD and Value:-sqlpassword
In your Mule config, you need configure it as following :-
 <spring:beans>
        <spring:bean id="environmentVariablesConfiguration" class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
            <spring:property name="algorithm" value="PBEWithMD5AndDES"/>
            <spring:property name="passwordEnvName" value="MULE_ENCRYPTION_PASSWORD"/>
        </spring:bean>

        <!-- The will be the encryptor used for decrypting configuration values. -->
        <spring:bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
            <spring:property name="config" ref="environmentVariablesConfiguration"/>
        </spring:bean>

        <!-- The EncryptablePropertyPlaceholderConfigurer will read the -->
        <!-- .properties files and make their values accessible as ${var} -->
        <!-- Our "configurationEncryptor" bean (which implements -->
        <!-- org.jasypt.encryption.StringEncryptor) is set as a constructor arg. -->

        <spring:bean id="propertyConfigurer" class="org.jasypt.spring.properties.EncryptablePropertyPlaceholderConfigurer">
            <spring:constructor-arg ref="configurationEncryptor"/>
            <spring:property name="locations">
                <spring:list>
                    <spring:value>conf/yourPropertyFile.properties</spring:value>
                </spring:list>
            </spring:property>
        </spring:bean>

Then you can use encrypted values like :- ${password}
Reference :- http://blogs.mulesoft.org/encrypting-passwords-in-mule/
and http://pragmaticintegrator.wordpress.com/2014/03/09/using-encrypted-passwords-with-mule-esb/
and https://code.google.com/p/soi-toolkit/issues/detail?id=183
and http://soi-toolkit.googlecode.com/svn-history/r2022/wiki/UG_PropertyFile.wiki 

