0

我正在尝试在属性文件中添加加密,内容未解密

我的 Spring DSL 看起来像:

<bean id="jasypt" class="org.apache.camel.component.jasypt.JasyptPropertiesParser">

    <property name="password" value="test"/>

    <property name="algorithm" value="PBEWithMD5AndDES"/>

</bean>
 <!-- define the camel properties component -->

<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">

    <!-- the properties file is in the classpath -->

    <property name="location" value="classpath:my-properties.properties"/>

    <!-- and let it leverage the jasypt parser -->

    <property name="propertiesParser" ref="jasypt"/>

</bean> 
<bean class="org.apache.activemq.ActiveMQConnectionFactory" id="jmsFactory">

        <property name="brokerURL" value="tcp://localhost:61616"/>

        <property name="userName" value="${jboss.fuse.username}"/>

        <property name="password" value="${jboss.fuse.password}"/>

</bean>

我的属性.properties

jboss.fuse.username=ENC(D0hnlLDZfGPiC6DtU+NKog==)

jboss.fuse.password=ENC(D0hnlLDZfGPiC6DtU+NKog==)

错误消息:java.lang.SecurityException:用户名 [ENC(D0hnlLDZfGPiC6DtU+NKog==)] 或密码无效。

4

1 回答 1

0

PropertiesComponent 不起作用。如果您使用 Spring DSL,它应该是BridgePropertyPlaceholderConfigurer

<bean
        class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer" id="bridgePropertyPlaceholder">
        <property name="location" value="classpath:my-properties.properties"/>
        <property name="parser" ref="jasypt"/>
 </bean>
于 2017-05-10T23:26:57.240 回答