Mule jasypt属性占位符不工作

Mule jasypt属性占位符不工作,mule,mule-studio,Mule,Mule Studio,我有这个属性文件: secret.key = ENC(foobar) region = ABC 然后在config.xml中: <spring:beans> <encryption:encryptor-config id="eConf" password-sys-property-name="MULE_ENCRYPTION_PASSWORD" algorithm="PBEWithMD5AndDES" password="" /> <encrypt

我有这个属性文件:

secret.key = ENC(foobar)
region = ABC
然后在
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>

但是属性占位符不起作用,例如:

<sqs:config secretKey="${secret.key}" region="${region}"></sqs-config>


有人知道原因吗?

加密密码需要写入ENC()函数中,并且应该加密

让我们在属性文件中考虑密码值是什么Login@123... 现在,属性文件中的加密值将为:-

password=ENC(B0u7D8wLwq/ugin31KNpP78gBcLP7VIN) 
步骤1:-我们可以在\jasypt-1.9.2\bin目录的命令提示符中使用以下命令生成密钥:-
加密输入=”Login@123“password=sqlpassword algorithm=PBEWithMD5AndDES

步骤2:-在运行时环境中,我们需要给出(右键单击->运行方式->运行配置->环境):-变量:-MULE\u ENCRYPTION\u密码和值:-sqlpassword

在您的Mule config中,您需要按照以下方式对其进行配置:-

 <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>

conf/yourPropertyFile.properties
然后可以使用加密值,如:-
${password}

参考资料:-



加密密码需要写入ENC()函数中,并且应该加密

让我们在属性文件中考虑密码值是什么Login@123... 现在,属性文件中的加密值将为:-

password=ENC(B0u7D8wLwq/ugin31KNpP78gBcLP7VIN) 
步骤1:-我们可以在\jasypt-1.9.2\bin目录的命令提示符中使用以下命令生成密钥:-
加密输入=”Login@123“password=sqlpassword algorithm=PBEWithMD5AndDES

步骤2:-在运行时环境中,我们需要给出(右键单击->运行方式->运行配置->环境):-变量:-MULE\u ENCRYPTION\u密码和值:-sqlpassword

在您的Mule config中,您需要按照以下方式对其进行配置:-

 <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>

conf/yourPropertyFile.properties
然后可以使用加密值,如:-
${password}

参考资料:-



而且

我遇到了类似的问题,我确实按照中的说明配置了所有内容。在我的例子中,问题是加载了bean,以便在加载bean之前加载其他属性。因此,删除bean(如果有的话)只需添加bean,即使对于其他未加密的属性,如中所述,它也可以正常工作。

我也有类似的问题,我确实按照中所述配置了所有内容。在我的例子中,问题是加载了bean,以便在加载bean之前加载其他属性。因此,删除bean(如果有的话)只需添加bean,即使对于其他非加密属性,如中所述,它也可以正常工作。

感谢您的详细回答:)我确实输入了加密字符串。事实证明,如果我使用Jasypt,Anypoint Studio不支持读取占位符(不知道为什么)。是的,我支持。根据我的理解,这与我使用
所做的基本相同。无论如何,我尝试了你的方法,但没有成功。顺便说一句,如果我构建项目并运行它,而不是尝试
测试连接..
很好,如果它成功。。我已经给了你详细的步骤。。你也可以参考这里给出的链接。我有类似的问题,我把所有的东西都配置为。在我的例子中,问题是在EncryptablePropertyPlaceholderConfigurer bean之前加载了bean。所以删除PropertyPlaceholderConfigurer bean(如果有的话)只要添加EncryptablePropertyPlaceholderConfigurer bean就可以了。谢谢你的详细回答:)我确实输入了一个加密字符串。事实证明,如果我使用Jasypt,Anypoint Studio不支持读取占位符(不知道为什么)。是的,我支持。根据我的理解,这与我使用
所做的基本相同。无论如何,我尝试了你的方法,但没有成功。顺便说一句,如果我构建项目并运行它,而不是尝试
测试连接..
很好,如果它成功。。我已经给了你详细的步骤。。你也可以参考这里给出的链接。我有类似的问题,我把所有的东西都配置为。在我的例子中,问题是在EncryptablePropertyPlaceholderConfigurer bean之前加载了bean。因此,删除PropertyPlaceholderConfigurer bean(如果有),只要添加EncryptablePropertyPlaceholderConfigurer bean,它就可以正常工作。