diff --git a/build.gradle b/build.gradle index ebe896db64..364dc4d55d 100644 --- a/build.gradle +++ b/build.gradle @@ -83,7 +83,7 @@ subprojects { subproject -> ext { activeMqVersion = '5.12.3' aspectjVersion = '1.8.7' - apacheSshdVersion = '0.14.0' + apacheSshdVersion = '1.4.0' boonVersion = '0.33' chronicleVersion = '3.4.3' commonsDbcpVersion = '1.4' @@ -953,9 +953,3 @@ task dist(dependsOn: assemble) { group = 'Distribution' description = 'Builds -dist, -docs and -schema distribution archives.' } - -task wrapper(type: Wrapper) { - description = 'Generates gradlew[.bat] scripts' - gradleVersion = '2.5' - distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip" -} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 30d399d8d2..3baa851b28 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2580126796..5958e1e76d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Jul 23 15:28:51 EDT 2015 +#Mon Mar 13 12:28:08 EDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-2.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip diff --git a/gradlew b/gradlew index 91a7e269e1..27309d9231 100755 --- a/gradlew +++ b/gradlew @@ -6,12 +6,30 @@ ## ############################################################################## -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -30,6 +48,7 @@ die ( ) { cygwin=false msys=false darwin=false +nonstop=false case "`uname`" in CYGWIN* ) cygwin=true @@ -40,31 +59,11 @@ case "`uname`" in MINGW* ) msys=true ;; + NONSTOP* ) + nonstop=true + ;; esac -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. @@ -90,7 +89,7 @@ location of your Java installation." fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then @@ -114,6 +113,7 @@ fi if $cygwin ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` diff --git a/gradlew.bat b/gradlew.bat index aec99730b4..f6d5974e72 100755 --- a/gradlew.bat +++ b/gradlew.bat @@ -8,14 +8,14 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome @@ -46,7 +46,7 @@ echo location of your Java installation. goto fail :init -@rem Get command-line arguments, handling Windowz variants +@rem Get command-line arguments, handling Windows variants if not "%OS%" == "Windows_NT" goto win9xME_args if "%@eval[2+2]" == "4" goto 4NT_args diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpTestSupport.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpTestSupport.java index 32f7b1a650..faf3fd1219 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpTestSupport.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/SftpTestSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 the original author or authors. + * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +19,10 @@ package org.springframework.integration.sftp; import java.io.File; import java.util.Collections; -import org.apache.sshd.SshServer; -import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory; -import org.apache.sshd.server.Command; -import org.apache.sshd.server.PasswordAuthenticator; +import org.apache.sshd.server.SshServer; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; -import org.apache.sshd.server.sftp.SftpSubsystem; +import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -59,18 +56,11 @@ public class SftpTestSupport extends RemoteFileTestSupport { @BeforeClass public static void createServer() throws Exception { server = SshServer.setUpDefaultServer(); - server.setPasswordAuthenticator(new PasswordAuthenticator() { - - @Override - public boolean authenticate(String username, String password, - org.apache.sshd.server.session.ServerSession session) { - return true; - } - }); + server.setPasswordAuthenticator((username, password, session) -> true); server.setPort(0); - server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); - server.setSubsystemFactories(Collections.>singletonList(new SftpSubsystem.Factory())); - server.setFileSystemFactory(new VirtualFileSystemFactory(remoteTemporaryFolder.getRoot().getAbsolutePath())); + server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser"))); + server.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory())); + server.setFileSystemFactory(new VirtualFileSystemFactory(remoteTemporaryFolder.getRoot().toPath())); server.start(); port = server.getPort(); } diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/TestSftpServer.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/TestSftpServer.java index 8befdcdd8b..a4a80541b6 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/TestSftpServer.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/TestSftpServer.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2015 the original author or authors. + * Copyright 2014-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,10 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.Collections; -import org.apache.sshd.SshServer; -import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory; -import org.apache.sshd.server.Command; -import org.apache.sshd.server.PasswordAuthenticator; +import org.apache.sshd.server.SshServer; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; -import org.apache.sshd.server.session.ServerSession; -import org.apache.sshd.server.sftp.SftpSubsystem; +import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory; import org.junit.rules.TemporaryFolder; import org.springframework.beans.factory.DisposableBean; @@ -120,18 +116,11 @@ public class TestSftpServer implements InitializingBean, DisposableBean { public void afterPropertiesSet() throws Exception { this.sftpFolder.create(); this.localFolder.create(); - server.setPasswordAuthenticator(new PasswordAuthenticator() { - - @Override - public boolean authenticate(String arg0, String arg1, ServerSession arg2) { - return true; - } - - }); + server.setPasswordAuthenticator((arg0, arg1, arg2) -> true); server.setPort(0); - server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); - this.server.setSubsystemFactories(Collections.>singletonList(new SftpSubsystem.Factory())); - this.server.setFileSystemFactory(new VirtualFileSystemFactory(sftpRootFolder.getAbsolutePath())); + server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser"))); + this.server.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory())); + this.server.setFileSystemFactory(new VirtualFileSystemFactory(sftpRootFolder.toPath())); server.start(); } diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpStreamingMessageSourceTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpStreamingMessageSourceTests.java index f4ced9d76f..c3c229953d 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpStreamingMessageSourceTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpStreamingMessageSourceTests.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import java.io.InputStream; +import java.util.Comparator; import org.junit.Test; import org.junit.runner.RunWith; @@ -35,10 +36,12 @@ import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.core.MessageSource; -import org.springframework.integration.file.filters.AcceptOnceFileListFilter; +import org.springframework.integration.file.remote.FileInfo; import org.springframework.integration.file.remote.session.SessionFactory; +import org.springframework.integration.metadata.SimpleMetadataStore; import org.springframework.integration.scheduling.PollerMetadata; import org.springframework.integration.sftp.SftpTestSupport; +import org.springframework.integration.sftp.filters.SftpPersistentAcceptOnceFileListFilter; import org.springframework.integration.sftp.session.SftpRemoteFileTemplate; import org.springframework.integration.transformer.StreamTransformer; import org.springframework.messaging.Message; @@ -73,7 +76,7 @@ public class SftpStreamingMessageSourceTests extends SftpTestSupport { received = (Message) this.data.receive(10000); assertNotNull(received); assertThat(new String(received.getPayload()), equalTo("source2")); - assertNull(this.data.receive(0)); + assertNull(this.data.receive(10)); } @Configuration @@ -96,9 +99,10 @@ public class SftpStreamingMessageSourceTests extends SftpTestSupport { @Bean @InboundChannelAdapter("stream") public MessageSource ftpMessageSource() { - SftpStreamingMessageSource messageSource = new SftpStreamingMessageSource(template(), null); + SftpStreamingMessageSource messageSource = new SftpStreamingMessageSource(template(), + Comparator.comparing(FileInfo::getFilename)); messageSource.setRemoteDirectory("sftpSource/"); - messageSource.setFilter(new AcceptOnceFileListFilter()); + messageSource.setFilter(new SftpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "streaming")); return messageSource; } diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpRemoteFileTemplateTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpRemoteFileTemplateTests.java index 84d6776845..e47ae85d08 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpRemoteFileTemplateTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpRemoteFileTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,13 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.sftp.session; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; import org.junit.Test; import org.junit.runner.RunWith; @@ -30,7 +36,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.expression.common.LiteralExpression; import org.springframework.integration.file.DefaultFileNameGenerator; import org.springframework.integration.file.remote.ClientCallbackWithoutResult; -import org.springframework.integration.file.remote.SessionCallback; import org.springframework.integration.file.remote.SessionCallbackWithoutResult; import org.springframework.integration.file.remote.session.Session; import org.springframework.integration.file.remote.session.SessionFactory; @@ -51,7 +56,7 @@ import com.jcraft.jsch.SftpException; * @since 4.1 * */ -@ContextConfiguration(classes=TestSftpServerConfig.class) +@ContextConfiguration(classes = TestSftpServerConfig.class) @RunWith(SpringJUnit4ClassRunner.class) @DirtiesContext public class SftpRemoteFileTemplateTests extends SftpTestSupport { @@ -67,14 +72,9 @@ public class SftpRemoteFileTemplateTests extends SftpTestSupport { template.setFileNameGenerator(fileNameGenerator); template.setRemoteDirectoryExpression(new LiteralExpression("foo/")); template.setUseTemporaryFileName(false); - template.execute(new SessionCallback() { - - @Override - public Boolean doInSession(Session session) throws IOException { - session.mkdir("foo/"); - return session.mkdir("foo/bar/"); - } - + template.execute(session -> { + session.mkdir("foo/"); + return session.mkdir("foo/bar/"); }); template.append(new GenericMessage("foo")); template.append(new GenericMessage("bar")); @@ -99,7 +99,9 @@ public class SftpRemoteFileTemplateTests extends SftpTestSupport { assertTrue(session.remove("foo/foobar.txt")); assertTrue(session.rmdir("foo/bar/")); LsEntry[] files = session.list("foo/"); - assertEquals(0, files.length); + List list = Arrays.asList(files); + assertThat(list.stream().map(LsEntry::getFilename).collect(Collectors.toList()), + containsInAnyOrder(".", "..")); assertTrue(session.rmdir("foo/")); } }); diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpServerTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpServerTests.java index 8f6c169c7a..1c020ec9c1 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpServerTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpServerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,18 +29,13 @@ import java.security.KeyFactory; import java.security.PublicKey; import java.security.spec.RSAPublicKeySpec; import java.util.Arrays; +import java.util.Base64; import java.util.Collections; -import org.apache.sshd.SshServer; -import org.apache.sshd.common.NamedFactory; import org.apache.sshd.common.file.virtualfs.VirtualFileSystemFactory; -import org.apache.sshd.common.util.Base64; -import org.apache.sshd.server.Command; -import org.apache.sshd.server.PasswordAuthenticator; -import org.apache.sshd.server.PublickeyAuthenticator; +import org.apache.sshd.server.SshServer; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; -import org.apache.sshd.server.session.ServerSession; -import org.apache.sshd.server.sftp.SftpSubsystem; +import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory; import org.junit.Test; import org.springframework.core.io.ByteArrayResource; @@ -64,19 +59,14 @@ public class SftpServerTests { public void testUcPw() throws Exception { SshServer server = SshServer.setUpDefaultServer(); try { - server.setPasswordAuthenticator(new PasswordAuthenticator() { - - @Override - public boolean authenticate(String arg0, String arg1, ServerSession arg2) { - return true; - } - }); + server.setPasswordAuthenticator((arg0, arg1, arg2) -> true); server.setPort(0); - server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); - server.setSubsystemFactories(Collections.>singletonList(new SftpSubsystem.Factory())); + server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser"))); + server.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory())); final String pathname = System.getProperty("java.io.tmpdir") + File.separator + "sftptest" + File.separator; - new File(pathname).mkdirs(); - server.setFileSystemFactory(new VirtualFileSystemFactory(pathname)); + File rootPath = new File(pathname); + rootPath.mkdirs(); + server.setFileSystemFactory(new VirtualFileSystemFactory(rootPath.toPath())); server.start(); DefaultSftpSessionFactory f = new DefaultSftpSessionFactory(); @@ -108,20 +98,14 @@ public class SftpServerTests { SshServer server = SshServer.setUpDefaultServer(); final PublicKey allowedKey = decodePublicKey(pubKey); try { - server.setPublickeyAuthenticator(new PublickeyAuthenticator() { - - @Override - public boolean authenticate(String username, PublicKey key, ServerSession session) { - return key.equals(allowedKey); - } - - }); + server.setPublickeyAuthenticator((username, key, session) -> key.equals(allowedKey)); server.setPort(0); - server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); - server.setSubsystemFactories(Collections.>singletonList(new SftpSubsystem.Factory())); + server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser"))); + server.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory())); final String pathname = System.getProperty("java.io.tmpdir") + File.separator + "sftptest" + File.separator; - new File(pathname).mkdirs(); - server.setFileSystemFactory(new VirtualFileSystemFactory(pathname)); + File rootPath = new File(pathname); + rootPath.mkdirs(); + server.setFileSystemFactory(new VirtualFileSystemFactory(rootPath.toPath())); server.start(); DefaultSftpSessionFactory f = new DefaultSftpSessionFactory(); @@ -145,9 +129,9 @@ public class SftpServerTests { byte[] keyBytes = StreamUtils.copyToByteArray(stream); // strip any newline chars while (keyBytes[keyBytes.length - 1] == 0x0a || keyBytes[keyBytes.length - 1] == 0x0d) { - keyBytes = Arrays.copyOf(keyBytes, keyBytes.length - 1); + keyBytes = Arrays.copyOf(keyBytes, keyBytes.length - 1); } - byte[] decodeBuffer = Base64.decodeBase64(keyBytes); + byte[] decodeBuffer = Base64.getDecoder().decode(keyBytes); ByteBuffer bb = ByteBuffer.wrap(decodeBuffer); int len = bb.getInt(); byte[] type = new byte[len]; @@ -179,7 +163,7 @@ public class SftpServerTests { } session.write(new ByteArrayInputStream("foo".getBytes()), "bar"); list = session.list("."); - assertEquals("bar", list[0].getFilename()); + assertEquals("bar", list[1].getFilename()); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); session.read("bar", outputStream); assertEquals("foo", new String(outputStream.toByteArray())); diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpSessionFactoryTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpSessionFactoryTests.java index 1f376f179c..53b2825f0b 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpSessionFactoryTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/session/SftpSessionFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,19 +28,14 @@ import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import java.io.File; import java.io.IOException; import java.net.ConnectException; -import java.security.PublicKey; import java.util.Collections; -import org.apache.sshd.SshServer; -import org.apache.sshd.common.NamedFactory; -import org.apache.sshd.server.Command; -import org.apache.sshd.server.PasswordAuthenticator; -import org.apache.sshd.server.PublickeyAuthenticator; +import org.apache.sshd.server.SshServer; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; -import org.apache.sshd.server.session.ServerSession; -import org.apache.sshd.server.sftp.SftpSubsystem; +import org.apache.sshd.server.subsystem.sftp.SftpSubsystemFactory; import org.junit.Test; import org.springframework.core.io.ClassPathResource; @@ -65,15 +60,9 @@ public class SftpSessionFactoryTests { public void testConnectFailSocketOpen() throws Exception { SshServer server = SshServer.setUpDefaultServer(); try { - server.setPasswordAuthenticator(new PasswordAuthenticator() { - - @Override - public boolean authenticate(String arg0, String arg1, ServerSession arg2) { - return true; - } - }); + server.setPasswordAuthenticator((arg0, arg1, arg2) -> true); server.setPort(0); - server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); + server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser"))); server.start(); DefaultSftpSessionFactory f = new DefaultSftpSessionFactory(); @@ -221,16 +210,10 @@ public class SftpSessionFactoryTests { @SuppressWarnings("unchecked") private DefaultSftpSessionFactory createServerAndClient(SshServer server) throws IOException { - server.setPublickeyAuthenticator(new PublickeyAuthenticator() { - - @Override - public boolean authenticate(String username, PublicKey key, ServerSession session) { - return true; - } - }); + server.setPublickeyAuthenticator((username, key, session) -> true); server.setPort(0); - server.setSubsystemFactories(Collections.>singletonList(new SftpSubsystem.Factory())); - server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser")); + server.setSubsystemFactories(Collections.singletonList(new SftpSubsystemFactory())); + server.setKeyPairProvider(new SimpleGeneratorHostKeyProvider(new File("hostkey.ser"))); server.start(); DefaultSftpSessionFactory f = new DefaultSftpSessionFactory();