用户名中的camel sftp特殊字符

nkoocmlb  于 2022-11-07  发布在  Apache
关注(0)|答案(2)|浏览(349)

我正在使用Apache Camel 2.13.2,并尝试连接到一个sftp,该sftp的用户名中包含特殊字符。用户名类似于“XXX\XX-XXXXXXX”。结尾处的camel URL被转换为如下所示的内容,并且验证失败。有人能告诉我如何处理用户名中的这些特殊字符吗?

Endpoint[sftp://XXX%5CXX-xxxxxxx@99.999.99.99:22//folder_Test/?binary=true&consumer.bridgeErrorHandler=true&delay=15000&idempotent=true&idempotentKey=%24%7Bfile%3Aname%7D-%24%7Bfile%3Asize%7D-%24%7Bfile%3Amodified%7D&include=.*Test.*&maxMessagesPerPoll=30&password=xxxxxx&pollStrategy=%23FTPPollingConsumerPollStrategy&readLock=changed&sendEmptyMessageWhenIdle=true&stepwise=false&throwExceptionOnConnectFailed=true]

下面是我在日志中看到的异常。

org.apache.camel.component.file.GenericFileOperationFailedException: Cannot connect to sftp://XXX\XX-XXXXX@99.999.99.99:22
    at org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:143)
    at org.apache.camel.component.file.remote.RemoteFileConsumer.connectIfNecessary(RemoteFileConsumer.java:154)
    at org.apache.camel.component.file.remote.RemoteFileConsumer.recoverableConnectIfNecessary(RemoteFileConsumer.java:145)
    at org.apache.camel.component.file.remote.RemoteFileConsumer.prePollCheck(RemoteFileConsumer.java:55)
    at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:106)
    at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:187)
    at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:114)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(Unknown Source)
    at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(Unknown Source)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: com.jcraft.jsch.JSchException: Auth fail
    at com.jcraft.jsch.Session.connect(Session.java:512)
    at org.apache.camel.component.file.remote.SftpOperations.connect(SftpOperations.java:115)
    ... 15 more

在使用fileZilla或Apache FTP实用程序时,sftp的相同凭据也可以正常工作。

rekjcdws

rekjcdws1#

请参阅如何配置端点的文档,尤其是有关密码的文档:http://camel.apache.org/how-do-i-configure-endpoints.html,其中您需要使用RAW语法。您可以使用RAW语法将用户名/密码指定为uri参数,而不是在uri的开头。

2w3rbyxf

2w3rbyxf2#

RAW()确实适用于大多数情况,但是,如果ftp密码包含特殊字符,比如Ravi的“\”,您可以简单地将其转义。
例如,此密码不起作用:

password=RAW(a@b$c/d\e)

因此需要将其更改为:

password=RAW(a@b$c/d\\e)

相关问题