Apache Camel - 如何在动态 sftp 端点中设置私钥 [英] Apache Camel - How to set a private key in a dinamic sftp endpoint

查看:37
本文介绍了Apache Camel - 如何在动态 sftp 端点中设置私钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Java DSL,我有一个路由,在该路由中我使用消息头中设置的文件名轮询 SFTP 服务器中的文件

Using Java DSL, I have a route in which I poll a file in an SFTP server using the file name set in the message headers

from("direct:download")
        .pollEnrich()
        .simple("sftp://my.host:22/folder/?username=foo&fileName=${header.CamelFileName}")
        .to("file://state/downloaded");

sftp 端点需要设置私钥.通常这样的事情就足够了:

The sftp endpoint needs to have set a private key. Usually something like this suffices:

        endpoint("sftp://my.host:22/folder/?username=foo&fileName=my_file_explicitly_written_here", SftpEndpoint.class).getConfiguration().setPrivateKey(getSshPrivateKey());

但是,我认为无法在 pollEnrich().simple() 中的 URI (${header.CamelFileName}) 中混合"动态字段带有端点配置.

However, I see no way to "mix" dynamic fields in the URI (${header.CamelFileName}) in the pollEnrich().simple()) with endpoint configuration.

对此有什么建议吗?

推荐答案

您可以将 privateKey 引用为来自注册表的 bean.

You can reference privateKey as bean from registry.

.pollEnrich()
    .simple("sftp://my.host:22/folder/?username=foo&privateKey=#myKeyInRegistry&fileName=${header.CamelFileName}")

将 bean 绑定到注册表取决于您使用的平台和 Camel 版本.

Binding bean to registry depends on platform and Camel version you are using.

这篇关于Apache Camel - 如何在动态 sftp 端点中设置私钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆