【问题标题】:apache camel crypto set 'CamelSignaturePublicKeyOrCert' in JMS TextMessage HeaderJMS TextMessage Header中的apache骆驼加密设置'CamelSignaturePublicKeyOrCert'
【发布时间】:2013-12-06 19:51:35
【问题描述】:

我正在尝试使用私钥对 JMS 文本消息的有效负载进行签名。然后将消息发送到队列并进行相应的路由。签名将与公钥一起放置在消息头中。

我正在使用下面的代码来设置带有公钥的标题。

TextMessage textMessage = session.createTextMessage(message);
String publicKey = new String(pubk.getEncoded());
 textMessage.setStringProperty("CamelSignaturePublicKeyOrCert", publicKey);

但是,当消息开始路由时,我收到以下错误

11:13:20,027 WARN [org.apache.camel.component.jms.EndpointMessageListener] JMS 消息侦听器执行失败。原因:[org.apache.camel.RuntimeCamelException - java.lang.IllegalStateException:无法验证签名,因为没有提供公钥或证书。在路由定义中提供一个或通过消息头“CamelSignaturePublicKeyOrCert”]:org.apache.camel.RuntimeCamelException:java.lang.IllegalStateException:无法验证签名,因为没有提供公钥或证书。在路由定义中提供一个或通过消息头 'CamelSignaturePublicKeyOrCert

路由定义如下

<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<!-- Dependencies: ojdbc.jar and aqjms.jar must be in the activemq lib directory -->
<route>
    <from uri="activemq:queue:queue.outbound"/>
    <log message="The expected queue is :: ${headers.queue}" />

     <to uri="crypto:verify://slpy" />
    <choice>
        <when>
            <simple>${headers.queue} == 'ora'</simple>
            <to uri="oracleQueue:queue:SLEEPY_LION_QUEUE"/>
        </when>
        <when>
            <simple>${headers.queue} == 'proc'</simple>
            <to uri="activemq:queue:queue.proc"/>
        </when>
        <otherwise>
            <log message="Invalid queue"/>
        </otherwise>
    </choice>
</route>

【问题讨论】:

    标签: java jms activemq apache-camel


    【解决方案1】:

    为了解决这个问题,我更新了 broker-config.xml 如下

    <route>
        <!-- <package>com.rs2.sleepylion.routes</package> -->
        <from uri="activemq:queue:queue.outbound"/>
    
        <to uri="log:in?showHeaders=true" />
        <log message="The expected queue is :: ${headers.queue}" />
        <to uri="log:out?showHeaders=true" />
    
        <choice>
            <when>
                <simple>${headers.queue} == 'ora'</simple>
                <to uri="oracleQueue:queue:SLEEPY_LION_QUEUE"/>
            </when>
            <when>
                <simple>${headers.queue} == 'proc'</simple>
                <to uri="crypto:verify://headers?publicKey=#myPublicKey&amp;clearHeaders=false" />
                <to uri="activemq:queue:queue.proc"/>
            </when>
            <otherwise>
                <log message="Invalid queue"/>
            </otherwise>
        </choice>
    </route>
    <bean id="myPublicKey" class="com.rs2.sleepylion.routes.Keys" factory-method="publicKey"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-10
      • 1970-01-01
      • 1970-01-01
      • 2012-12-01
      相关资源
      最近更新 更多