GH-3211: Add DefSftpSF.setKnownHosts(Resource)#3212
GH-3211: Add DefSftpSF.setKnownHosts(Resource)#3212garyrussell merged 2 commits intospring-projects:masterfrom
Conversation
Fixes spring-projects#3211 * Add `DefaultSftpSessionFactory.setKnownHosts(Resource)` to allow to configure externally any resource for file with known_hosts content * Deprecate an existing method in favor of new one * The new method makes it aligned with the `setPrivateKey(Resource)` * Fix tests do not use a deprecated method any more **Cherry-pick to 5.2.x**
| * @see JSch#setKnownHosts(InputStream) | ||
| * @since 5.2.5 | ||
| */ | ||
| public void setKnownHosts(Resource knownHosts) { |
There was a problem hiding this comment.
Won't this cause a problem with <bean/> config? (ambiguous setter) setKnownHostsResource() ?
There was a problem hiding this comment.
Looks like Juergen has fixed something in SF. See Travis 😄
There was a problem hiding this comment.
If I recall correctly, failures were random; also it looks like you changed all the tests to return a Resource using SpEL.
Perhaps the problem only occurs when a PropertyEditor is needed (although I remember most of the problems were with String Vs. Expression .
I will defer to you, though, if you think it's safe.
There was a problem hiding this comment.
Well, I can rename it to setKnownHostsResource to have it really very safe...
* Change `sftp.adoc` to reflect a new property
| * @see JSch#setKnownHosts(String) | ||
| * @deprecated since 5.2.5 in favor of {@link #setKnownHostsResource(Resource)} | ||
| */ | ||
| @Deprecated |
There was a problem hiding this comment.
Should we really deprecate? This is easier if you are using Java Config and want to point to a simple file name.
Not related to this PR but perhaps we should consider adding a SftpSessionFactorySpec ?
There was a problem hiding this comment.
Then we need also to add a string-based for privateKey.
More over it is better to resolve any resources via @Value Resource then inject.
Fixes #3211
DefaultSftpSessionFactory.setKnownHosts(Resource)toallow to configure externally any resource for file with known_hosts content
setPrivateKey(Resource)Cherry-pick to 5.2.x