简体   繁体   English

Camel Property-Placeholder:无法使用嵌套属性配置`camel:sslContextParameters`

[英]Camel Property-Placeholder: Not able to configure `camel:sslContextParameters` with nested properties

I am using Camel-HTTP4 2.10.4 component for calling remote REST services from my application. 我使用Camel-HTTP4 2.10.4组件从我的应用程序调用远程REST服务。 This communication requires SSL configuration. 此通信需要SSL配置。 I successfully tested my configuration with hard coded values for resource and password . 我用resourcepassword硬编码值成功测试了我的配置。

Now I need to configure the same using camel's Property-Placeholder. 现在我需要使用camel的Property-Placeholder来配置相同的内容。 I am using nested properties in spring configuration. 我在spring配置中使用嵌套属性。 ex: 例如:

${${env:${default.fallback.env}}.path.to.keystore} 

I followed Using PropertyPlaceholder and defined 我跟着使用PropertyPlaceholder并定义了

<bean id="bridgePropertyPlaceholder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <ref bean="confgPath1" />
            <ref bean="configPath2" />
        </list>
    </property>
</bean>

and sslContextParameters as follows 和sslContextParameters如下

<camel:sslContextParameters id="sslContextParameters">
    <camel:trustManagers>
        <camel:keyStore resource="{{{{default.fallback.env}}.keystore.file}}"
            password="{{{{default.fallback.env}}.keystore.password}}" />
    </camel:trustManagers>
    <camel:keyManagers keyPassword="{{{{default.fallback.env}}.keystore.password}}">
        <camel:keyStore resource="{{{{default.fallback.env}}.keystore.file}}"
            password="{{{{default.fallback.env}}.keystore.password}}" />
    </camel:keyManagers>
    <camel:clientParameters>
        <camel:cipherSuitesFilter>
            <camel:include>.*</camel:include>
        </camel:cipherSuitesFilter>
    </camel:clientParameters>
</camel:sslContextParameters>

My application loads spring context successfully at start up. 我的应用程序在启动时成功加载了spring上下文。 But after hitting the endpoint I am getting Error: 但是在点击端点后我得到错误:

Failed to resolve endpoint <<My remote service URL>> due to: Error parsing property value: {{{{default.fallback.env}}.keystore.password}}.

I am able to use Camel's property placeholder for simple properties. 我能够使用Camel的属性占位符来获得简单的属性。 For ex 对于前者

{{default.fallback.env}}

But, when I try to use nested properties it is giving me above specified Error. 但是,当我尝试使用嵌套属性时,它给出了我上面指定的错误。 Help me find out the proper way to solve this. 帮我找出解决这个问题的正确方法。

Current camel property component doesn't support the nested properties, so I just fill a JIRA for it. 当前的camel属性组件不支持嵌套属性,所以我只为它填充一个JIRA

As Camel property doesn't support the nested properties in the first place, you can define just define the property file like this, and set the environment from the system property and use {{someproperty}} to reference the properties. 由于Camel属性首先不支持嵌套属性,因此您可以定义这样的属性文件,并从系统属性设置环境并使用{{someproperty}}来引用属性。

someproperty={{{{environment}}.someproperty}}

# LOCAL SERVER
junit.someproperty=junit

# LOCAL SERVER
local.someproperty=local

# TEST
test.someproperty=test

# PROD
prod.someproperty=prod

I just used the Spring way to create Camel SSL configuration: 我只是用Spring方式创建了Camel SSL配置:

  <bean id="sslContextParameters" class="org.apache.camel.util.jsse.SSLContextParameters">
    <property name="keyManagers">
      <bean class="org.apache.camel.util.jsse.KeyManagersParameters">
        <property name="keyPassword" value="${dsi.key.password}" />
        <property name="keyStore">
          <bean class="org.apache.camel.util.jsse.KeyStoreParameters">
            <property name="resource" value="${dsi.keystore.file}" />
            <property name="type" value="JKS" />
            <property name="password" value="${dsi.keystore.password}" />
            <property name="camelContext" ref="camelContext" />
          </bean>
        </property>
        <property name="camelContext" ref="camelContext" />
      </bean>
    </property>
    <property name="camelContext" ref="camelContext" />
  </bean>

I believe with Spring's property resolver you can achieve more and you do not need to use the custom bridge resolver. 我相信使用Spring的属性解析器,您可以获得更多,而且您不需要使用自定义桥接解析器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM