Skip to content

Commit 30da70e

Browse files
committed
Provide access to internal SFTP server configuration
1 parent 9f594be commit 30da70e

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Fake SFTP Server Rule is available from
2727
<dependency>
2828
<groupId>com.github.stefanbirkner</groupId>
2929
<artifactId>fake-sftp-server-rule</artifactId>
30-
<version>2.0.1</version>
30+
<version>2.1.1</version>
3131
</dependency>
3232

3333
If you upgrade from a version < 2.x to the newest version please read the last

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</parent>
1010

1111
<artifactId>fake-sftp-server-rule</artifactId>
12-
<version>2.1.0-SNAPSHOT</version>
12+
<version>2.1.1</version>
1313
<packaging>jar</packaging>
1414

1515
<name>Fake SFTP Server Rule</name>

src/main/java/com/github/stefanbirkner/fakesftpserver/rule/FakeSftpServerRule.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.stefanbirkner.fakesftpserver.rule;
22

3+
import java.util.function.Consumer;
34
import org.apache.sshd.server.SshServer;
45
import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
56
import org.apache.sshd.server.session.ServerSession;
@@ -182,6 +183,23 @@ public FileVisitResult postVisitDirectory(
182183

183184
private FileSystem fileSystem;
184185
private SshServer server;
186+
private Consumer<SshServer> sshServerConsumer = (sshServer) -> {};
187+
188+
/**
189+
* Configures the internal SFTP server of the Apache SSHD project.
190+
* If you need personal changes in internal SFTP server that
191+
* are not supported by the rule, you can use this method to get the inner
192+
* internal SFTP server of the rule before construction and change it to
193+
* suit your needs.
194+
* (Correct use of this feature is the responsibility of the user)
195+
*
196+
* @param sshServerConsumer internal SFTP server consumer
197+
* @return the rule itself.
198+
*/
199+
public FakeSftpServerRule configureInternalSshServer(Consumer<SshServer> sshServerConsumer) {
200+
this.sshServerConsumer = sshServerConsumer;
201+
return this;
202+
}
185203

186204
/**
187205
* Returns the port of the SFTP server. If the SFTP server listens on an
@@ -435,6 +453,7 @@ private SshServer startServer(
435453
* have to use a file system wrapper whose close() does nothing.
436454
*/
437455
server.setFileSystemFactory(session -> new DoNotClose(fileSystem));
456+
sshServerConsumer.accept(server);
438457
server.start();
439458
this.server = server;
440459
return server;

0 commit comments

Comments
 (0)