Discussion:
[1/9] mina-sshd git commit: Upgraded JGit version to 5.1.3.201810200350-r
l***@apache.org
2018-10-25 09:10:57 UTC
Permalink
Repository: mina-sshd
Updated Branches:
refs/heads/master cbd87aa4c -> 9d33888da


Upgraded JGit version to 5.1.3.201810200350-r


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/9d33888d
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/9d33888d
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/9d33888d

Branch: refs/heads/master
Commit: 9d33888da044b5e1e48200eaf1ec6028a18f7b63
Parents: 6d20f6f
Author: Lyor Goldstein <***@apache.org>
Authored: Thu Oct 25 11:19:32 2018 +0300
Committer: Lyor Goldstein <***@apache.org>
Committed: Thu Oct 25 12:10:49 2018 +0300

----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d33888d/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2a09c12..d993f0e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -112,7 +112,7 @@
<bouncycastle.version>1.60</bouncycastle.version>
<slf4j.version>1.7.25</slf4j.version>
<spring.version>5.1.1.RELEASE</spring.version>
- <jgit.version>5.1.2.201810061102-r</jgit.version>
+ <jgit.version>5.1.3.201810200350-r</jgit.version>
<junit.version>4.12</junit.version>
<bytebuddy.version>1.9.2</bytebuddy.version>
l***@apache.org
2018-10-25 09:11:01 UTC
Permalink
Upgraded Checkstyle version to 8.14


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/6d20f6f1
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/6d20f6f1
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/6d20f6f1

Branch: refs/heads/master
Commit: 6d20f6f19c8b7ae4732b917d77766dedd65d7b45
Parents: 98ac7c2
Author: Lyor Goldstein <***@apache.org>
Authored: Thu Oct 25 11:18:16 2018 +0300
Committer: Lyor Goldstein <***@apache.org>
Committed: Thu Oct 25 12:10:49 2018 +0300

----------------------------------------------------------------------
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/6d20f6f1/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ddcdc21..2a09c12 100644
--- a/pom.xml
+++ b/pom.xml
@@ -734,7 +734,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
- <version>8.13</version>
+ <version>8.14</version>
<exclusions>
<!-- MCHECKSTYLE-156 -->
<exclusion>
l***@apache.org
2018-10-25 09:10:58 UTC
Permalink
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java b/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java
deleted file mode 100644
index db2f1be..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.common.file.root;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channel;
-import java.nio.channels.FileChannel;
-import java.nio.file.DirectoryStream;
-import java.nio.file.FileSystem;
-import java.nio.file.Files;
-import java.nio.file.InvalidPathException;
-import java.nio.file.OpenOption;
-import java.nio.file.Path;
-import java.nio.file.StandardCopyOption;
-import java.nio.file.StandardOpenOption;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Objects;
-import java.util.Random;
-import java.util.TreeSet;
-
-import org.apache.sshd.util.test.CommonTestSupportUtils;
-import org.apache.sshd.util.test.NoIoTestCase;
-import org.junit.BeforeClass;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runners.MethodSorters;
-
-/**
- * Tests the RootedFileSystemProvider implementation of
- * {@link java.nio.file.spi.FileSystemProvider} checking that permissions for
- * generic FS commands are not permitted outside of the root directory.
- *
- * Individual tests are form pairs (e.g. testX, testXInvalid) where testXInvalid
- * is expected to test a parent path of {@link RootedFileSystem#getRoot()}
- * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
- */
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-@Category({ NoIoTestCase.class })
-public class RootedFileSystemProviderTest extends AssertableFile {
- private static RootedFileSystem fileSystem;
- private static Path rootSandbox;
-
- public RootedFileSystemProviderTest() {
- super();
- }
-
- @BeforeClass
- public static void initializeFileSystem() throws IOException {
- Path targetFolder = Objects.requireNonNull(
- CommonTestSupportUtils.detectTargetFolder(RootedFileSystemProviderTest.class), "Failed to detect target folder");
- rootSandbox = FileHelper.createTestSandbox(targetFolder.resolve(TEMP_SUBFOLDER_NAME));
- fileSystem = (RootedFileSystem) new RootedFileSystemProvider().newFileSystem(rootSandbox, Collections.emptyMap());
- }
-
- @Test
- public void testRoot() {
- Path root = fileSystem.getRoot();
- assertTrue("Exists? " + root, exists(root));
- assertTrue("Dir? " + root, isDir(root));
- assertTrue("Readable? " + root, isReadable(root));
- assertTrue(root + " rooted at " + rootSandbox + " ?", isRootedAt(rootSandbox, root));
- }
-
- /* mkdir */
- @Test
- public void testMkdir() throws IOException {
- Path created = FileHelper.createDirectory(fileSystem.getPath(getCurrentTestName()));
- assertTrue(exists(created) && isDir(created) && isReadable(created));
- }
-
- @Test(expected = InvalidPathException.class)
- public void testMkdirInvalid() throws IOException {
- Path parent = FileHelper.createDirectory(fileSystem.getPath("../" + getCurrentTestName()));
- fail(String.format("Unexpected success in creating directory %s", parent.toString()));
- }
-
- /* rmdir */
- @Test
- public void testRmdir() throws IOException {
- Path created = FileHelper.createDirectory(fileSystem.getPath(getCurrentTestName()));
- Path deleted = FileHelper.deleteDirectory(created);
- notExists(deleted);
- }
-
- @Test(expected = InvalidPathException.class)
- public void testRmdirInvalid() throws IOException {
- Path deleted = FileHelper.deleteDirectory(fileSystem.getPath("../" + getCurrentTestName()));
- fail(String.format("Unexpected success in removing directory %s", deleted.toString()));
- }
-
- /* chdir */
- @Test
- public void testChdir() throws IOException {
- Path created = FileHelper.createDirectory(fileSystem.getPath(getCurrentTestName()));
- Path createdFile = FileHelper.createFile(created.resolve(getCurrentTestName()));
- boolean hasFile = false;
- try (DirectoryStream<Path> ds = FileHelper.readDirectory(created)) {
- for (Path p : ds) {
- hasFile |= FileHelper.isSameFile(createdFile,
- fileSystem.getPath(created.getFileName() + "/" + p.getFileName()));
- }
- }
- assertTrue(createdFile + " found in ch directory", hasFile);
- }
-
- @Test(expected = InvalidPathException.class)
- public void testChdirInvalid() throws IOException {
- Path chdir = FileHelper.createDirectory(fileSystem.getPath("../" + getCurrentTestName()));
- fail(String.format("Unexpected success in changing directory %s", chdir.toString()));
- }
-
- /* write */
- @Test
- public void testWriteFile() throws IOException {
- Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
- assertTrue(exists(created) && isReadable(created));
- }
-
- @Test(expected = InvalidPathException.class)
- public void testWriteFileInvalid() throws IOException {
- Path written = FileHelper.createFile(fileSystem.getPath("../" + getCurrentTestName()));
- fail(String.format("Unexpected success in writing file %s", written.toString()));
- }
-
- /* read */
- @Test
- public void testReadFile() throws IOException {
- Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
- isNonEmpty(FileHelper.readFile(created));
- }
-
- @Test(expected = InvalidPathException.class)
- public void testReadFileInvalid() throws IOException {
- Path read = fileSystem.getPath("../" + getCurrentTestName());
- FileHelper.readFile(read);
- fail(String.format("Unexpected success in reading file %s", read.toString()));
- }
-
- /* rm */
- @Test
- public void testDeleteFile() throws IOException {
- Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
- Path deleted = FileHelper.deleteFile(created);
- notExists(deleted);
- }
-
- @Test(expected = InvalidPathException.class)
- public void testDeleteFileInvalid() throws IOException {
- Path deleted = FileHelper.deleteFile(fileSystem.getPath("../" + getCurrentTestName()));
- fail(String.format("Unexpected success in deleting file %s", deleted.toString()));
- }
-
- /* cp */
- @Test
- public void testCopyFile() throws IOException {
- Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
- Path destination = fileSystem.getPath(getCurrentTestName() + "dest");
- FileHelper.copyFile(created, destination);
- assertTrue(exists(destination) && isReadable(destination));
- }
-
- @Test(expected = InvalidPathException.class)
- public void testCopyFileInvalid() throws IOException {
- Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
- Path copy = FileHelper.copyFile(created, fileSystem.getPath("../" + getCurrentTestName()));
- fail(String.format("Unexpected success in copying file to %s", copy.toString()));
- }
-
- /* mv */
- @Test
- public void testMoveFile() throws IOException {
- Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
- Path destination = fileSystem.getPath(getCurrentTestName() + "dest");
- FileHelper.moveFile(created, destination);
- assertTrue(notExists(created) && exists(destination) && isReadable(destination));
- }
-
- @Test(expected = InvalidPathException.class)
- public void testMoveFileInvalid() throws IOException {
- Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
- Path moved = FileHelper.moveFile(created, fileSystem.getPath("../" + getCurrentTestName()));
- fail(String.format("Unexpected success in moving file to %s", moved.toString()));
- }
-
- /* link */
- @Test
- public void testCreateLink() throws IOException {
- Path existing = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
- Path link = fileSystem.getPath(getCurrentTestName() + "link");
- FileHelper.createLink(link, existing);
- assertTrue(exists(link) && isReadable(link));
- }
-
- @Test(expected = InvalidPathException.class)
- public void testCreateLinkInvalid() throws IOException {
- Path existing = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
- Path link = FileHelper.createLink(fileSystem.getPath("../" + getCurrentTestName() + "link"), existing);
- fail(String.format("Unexpected success in linking file %s", link.toString()));
- }
-
- @Test
- public void testNewByteChannelProviderMismatchException() throws IOException {
- RootedFileSystemProvider provider = new RootedFileSystemProvider();
- Path tempFolder = assertHierarchyTargetFolderExists(getTempTargetFolder());
- Path file = Files.createTempFile(tempFolder, getCurrentTestName(), ".txt");
- try (FileSystem fs = provider.newFileSystem(tempFolder, Collections.emptyMap());
- Channel channel = provider.newByteChannel(fs.getPath(file.getFileName().toString()), Collections.emptySet())) {
- assertTrue("Channel not open", channel.isOpen());
- }
- }
-
- @Test
- public void testResolveRoot() throws IOException {
- Path root = fileSystem.getRootDirectories().iterator().next();
- Path dir = root.resolve("tsd");
- FileHelper.createDirectory(dir);
- Path f1 = FileHelper.createFile(dir.resolve("test.txt"));
- Path f2 = Files.newDirectoryStream(dir).iterator().next();
- assertTrue("Unrooted path found", f2 instanceof RootedPath);
- assertEquals(f1, f2);
- FileHelper.deleteFile(f1);
- FileHelper.deleteDirectory(dir);
- }
-
- /* Private helper */
-
- /**
- * Wrapper around the FileSystemProvider to test generic FS related
- * commands. All created temp directories and files used for testing are
- * deleted upon JVM exit.
- */
- @SuppressWarnings("synthetic-access")
- private static final class FileHelper {
- private FileHelper() {
- super();
- }
-
- /**
- * Create a randomized test sandbox on each test execution
- *
- * @param tempDir location to create the sandbox
- * @return the created sandbox Path
- * @throws IOException
- * on failure to create
- */
- public static Path createTestSandbox(Path tempDir) throws IOException {
- Path created = Files.createDirectories(tempDir.resolve(RootedFileSystemProviderTest.class.getSimpleName()));
- created.toFile().deleteOnExit();
- return created;
- }
-
- public static Path createFile(Path source) throws InvalidPathException, IOException {
- try (FileChannel fc = fileSystem.provider().newFileChannel(source,
- new TreeSet<OpenOption>(Arrays.asList(StandardOpenOption.CREATE, StandardOpenOption.WRITE)))) {
- byte[] randomBytes = new byte[1000];
- new Random().nextBytes(randomBytes);
- fc.write(ByteBuffer.wrap(randomBytes));
- source.toFile().deleteOnExit();
- return source;
- }
- }
-
- public static Path createLink(Path link, Path existing) throws IOException {
- fileSystem.provider().createLink(link, existing);
- link.toFile().deleteOnExit();
- return link;
- }
-
- public static Path createDirectory(Path dir) throws InvalidPathException, IOException {
- fileSystem.provider().createDirectory(dir);
- dir.toFile().deleteOnExit();
- return dir;
- }
-
- public static Path deleteDirectory(Path dir) throws InvalidPathException, IOException {
- return deleteFile(dir);
- }
-
- public static Path deleteFile(Path source) throws InvalidPathException, IOException {
- fileSystem.provider().delete(source);
- return source;
- }
-
- public static byte[] readFile(Path source) throws IOException {
- try (FileChannel fc = fileSystem.provider().newFileChannel(source,
- new TreeSet<OpenOption>(Arrays.asList(StandardOpenOption.READ)))) {
- byte[] readBytes = new byte[(int) source.toFile().length()];
- fc.read(ByteBuffer.wrap(readBytes));
- return readBytes;
- }
- }
-
- public static Path copyFile(Path source, Path destination) throws InvalidPathException, IOException {
- fileSystem.provider().copy(source, destination, StandardCopyOption.COPY_ATTRIBUTES);
- destination.toFile().deleteOnExit();
- return destination;
- }
-
- public static Path moveFile(Path source, Path destination) throws InvalidPathException, IOException {
- fileSystem.provider().move(source, destination, StandardCopyOption.ATOMIC_MOVE);
- destination.toFile().deleteOnExit();
- return destination;
- }
-
- public static DirectoryStream<Path> readDirectory(Path dir) throws InvalidPathException, IOException {
- DirectoryStream<Path> dirStream = fileSystem.provider().newDirectoryStream(dir, entry -> true);
- return dirStream;
- }
-
- public static boolean isSameFile(Path source, Path destination) throws IOException {
- return fileSystem.provider().isSameFile(source, destination);
- }
- }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java b/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
deleted file mode 100644
index cd95c4e..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.common.file.util;
-
-import java.io.IOException;
-import java.net.URI;
-import java.nio.file.FileSystem;
-import java.nio.file.LinkOption;
-import java.nio.file.Path;
-import java.nio.file.attribute.UserPrincipalLookupService;
-import java.nio.file.spi.FileSystemProvider;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.util.test.BaseTestSupport;
-import org.apache.sshd.util.test.NoIoTestCase;
-import org.junit.Before;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runners.MethodSorters;
-import org.mockito.Mockito;
-
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-@Category({ NoIoTestCase.class })
-@SuppressWarnings("checkstyle:MethodCount")
-public class BasePathTest extends BaseTestSupport {
- private TestFileSystem fileSystem;
-
- public BasePathTest() {
- super();
- }
-
- @Before
- public void setUp() {
- fileSystem = new TestFileSystem(Mockito.mock(FileSystemProvider.class));
- }
-
- @Test
- public void testBasicPathParsing() {
- assertPathEquals("/", "/");
- assertPathEquals("/foo", "/foo");
- assertPathEquals("/foo", "/", "foo");
- assertPathEquals("/foo/bar", "/foo/bar");
- assertPathEquals("/foo/bar", "/", "foo", "bar");
- assertPathEquals("/foo/bar", "/foo", "bar");
- assertPathEquals("/foo/bar", "/", "foo/bar");
- assertPathEquals("foo/bar/baz", "foo/bar/baz");
- assertPathEquals("foo/bar/baz", "foo", "bar", "baz");
- assertPathEquals("foo/bar/baz", "foo/bar", "baz");
- assertPathEquals("foo/bar/baz", "foo", "bar/baz");
- }
-
- @Test
- public void testPathParsingWithExtraSeparators() {
- assertPathEquals("/foo/bar", "///foo/bar");
- assertPathEquals("/foo/bar", "/foo///bar//");
- assertPathEquals("/foo/bar/baz", "/foo", "/bar", "baz/");
- //assertPathEquals("/foo/bar/baz", "/foo\\/bar//\\\\/baz\\/");
- }
-
- @Test
- public void testRootPath() {
- new PathTester(fileSystem, "/")
- .root("/")
- .test("/");
- }
-
- @Test
- public void testRelativePathSingleName() {
- new PathTester(fileSystem, "test")
- .names("test")
- .test("test");
-
- Path path = parsePath("test");
- assertEquals(path, path.getFileName());
- }
-
- @Test
- public void testRelativePathTwoNames() {
- PathTester tester = new PathTester(fileSystem, "foo/bar")
- .names("foo", "bar");
-
- tester.test("foo/bar");
- }
-
- @Test
- public void testRelativePathFourNames() {
- new PathTester(fileSystem, "foo/bar/baz/test")
- .names("foo", "bar", "baz", "test")
- .test("foo/bar/baz/test");
- }
-
- @Test
- public void testAbsolutePathSingleName() {
- new PathTester(fileSystem, "/foo")
- .root("/")
- .names("foo")
- .test("/foo");
- }
-
- @Test
- public void testAbsolutePathTwoNames() {
- new PathTester(fileSystem, "/foo/bar")
- .root("/")
- .names("foo", "bar")
- .test("/foo/bar");
- }
-
- @Test
- public void testAbsoluteMultiNamePathFourNames() {
- new PathTester(fileSystem, "/foo/bar/baz/test")
- .root("/")
- .names("foo", "bar", "baz", "test")
- .test("/foo/bar/baz/test");
- }
-
- @Test
- public void testResolveFromRoot() {
- Path root = parsePath("/");
-
- assertResolvedPathEquals("/foo", root, "foo");
- assertResolvedPathEquals("/foo/bar", root, "foo/bar");
- assertResolvedPathEquals("/foo/bar", root, "foo", "bar");
- assertResolvedPathEquals("/foo/bar/baz/test", root, "foo/bar/baz/test");
- assertResolvedPathEquals("/foo/bar/baz/test", root, "foo", "bar/baz", "test");
- }
-
- @Test
- public void testResolveFromAbsolute() {
- Path path = parsePath("/foo");
-
- assertResolvedPathEquals("/foo/bar", path, "bar");
- assertResolvedPathEquals("/foo/bar/baz/test", path, "bar/baz/test");
- assertResolvedPathEquals("/foo/bar/baz/test", path, "bar/baz", "test");
- assertResolvedPathEquals("/foo/bar/baz/test", path, "bar", "baz", "test");
- }
-
- @Test
- public void testResolveFromRelative() {
- Path path = parsePath("foo");
-
- assertResolvedPathEquals("foo/bar", path, "bar");
- assertResolvedPathEquals("foo/bar/baz/test", path, "bar/baz/test");
- assertResolvedPathEquals("foo/bar/baz/test", path, "bar", "baz", "test");
- assertResolvedPathEquals("foo/bar/baz/test", path, "bar/baz", "test");
- }
-
- @Test
- public void testResolveWithThisAndParentDirNames() {
- Path path = parsePath("/foo");
-
- assertResolvedPathEquals("/foo/bar/../baz", path, "bar/../baz");
- assertResolvedPathEquals("/foo/bar/../baz", path, "bar", "..", "baz");
- assertResolvedPathEquals("/foo/./bar/baz", path, "./bar/baz");
- assertResolvedPathEquals("/foo/./bar/baz", path, ".", "bar/baz");
- }
-
- @Test
- public void testResolveGivenAbsolutePath() {
- assertResolvedPathEquals("/test", parsePath("/foo"), "/test");
- assertResolvedPathEquals("/test", parsePath("foo"), "/test");
- }
-
- @Test
- public void testResolveGivenEmptyPath() {
- assertResolvedPathEquals("/foo", parsePath("/foo"), "");
- assertResolvedPathEquals("foo", parsePath("foo"), "");
- }
-
- @Test
- public void testResolveAgainstEmptyPath() {
- assertResolvedPathEquals("foo/bar", parsePath(""), "foo/bar");
- }
-
- @Test
- public void testResolveSiblingGivenEmptyPath() {
- Path path = parsePath("foo/bar");
- Path resolved = path.resolveSibling("");
- assertPathEquals("foo", resolved);
-
- path = parsePath("foo");
- resolved = path.resolveSibling("");
- assertPathEquals("", resolved);
- }
-
- @Test
- public void testResolveSiblingAgainstEmptyPath() {
- Path path = parsePath("");
- Path resolved = path.resolveSibling("foo");
- assertPathEquals("foo", resolved);
-
- path = parsePath("");
- resolved = path.resolveSibling("");
- assertPathEquals("", resolved);
- }
-
- @Test
- public void testRelativizeBothAbsolute() {
- assertRelativizedPathEquals("b/c", parsePath("/a"), "/a/b/c");
- assertRelativizedPathEquals("c/d", parsePath("/a/b"), "/a/b/c/d");
- }
-
- @Test
- public void testRelativizeBothRelative() {
- assertRelativizedPathEquals("b/c", parsePath("a"), "a/b/c");
- assertRelativizedPathEquals("d", parsePath("a/b/c"), "a/b/c/d");
- }
-
- @Test
- public void testRelativizeAgainstEmptyPath() {
- assertRelativizedPathEquals("foo/bar", parsePath(""), "foo/bar");
- }
-
- @Test
- public void testRelativizeOneAbsoluteOneRelative() {
- try {
- parsePath("/foo/bar").relativize(parsePath("foo"));
- fail();
- } catch (IllegalArgumentException expected) {
- // ignored
- }
-
- try {
- parsePath("foo").relativize(parsePath("/foo/bar"));
- fail();
- } catch (IllegalArgumentException expected) {
- // ignored
- }
- }
-
- @Test
- public void testNormalizeWithParentDirName() {
- assertNormalizedPathEquals("/foo/baz", "/foo/bar/../baz");
- assertNormalizedPathEquals("/foo/baz", "/foo", "bar", "..", "baz");
- }
-
- @Test
- public void testNormalizeWithThisDirName() {
- assertNormalizedPathEquals("/foo/bar/baz", "/foo/bar/./baz");
- assertNormalizedPathEquals("/foo/bar/baz", "/foo", "bar", ".", "baz");
- }
-
- @Test
- public void testNormalizeWithThisAndParentDirNames() {
- assertNormalizedPathEquals("foo/test", "foo/./bar/../././baz/../test");
- }
-
- @Test
- public void testNormalizeWithLeadingParentDirNames() {
- assertNormalizedPathEquals("../../foo/baz", "../../foo/bar/../baz");
- }
-
- @Test
- public void testNormalizeWithLeadingThisAndParentDirNames() {
- assertNormalizedPathEquals("../../foo/baz", "./.././.././foo/bar/../baz");
- }
-
- @Test
- public void testNormalizeWithExtraParentDirNamesAtRoot() {
- assertNormalizedPathEquals("/", "/..");
- assertNormalizedPathEquals("/", "/../../..");
- assertNormalizedPathEquals("/", "/foo/../../..");
- assertNormalizedPathEquals("/", "/../foo/../../bar/baz/../../../..");
- }
-
- @Test
- public void testPathWithExtraSlashes() {
- assertPathEquals("/foo/bar/baz", parsePath("/foo/bar/baz/"));
- assertPathEquals("/foo/bar/baz", parsePath("/foo//bar///baz"));
- assertPathEquals("/foo/bar/baz", parsePath("///foo/bar/baz"));
- }
-
- private void assertResolvedPathEquals(
- String expected, Path path, String firstResolvePath, String... moreResolvePaths) {
- Path resolved = path.resolve(firstResolvePath);
- for (String additionalPath : moreResolvePaths) {
- resolved = resolved.resolve(additionalPath);
- }
- assertPathEquals(expected, resolved);
-
- Path relative = parsePath(firstResolvePath, moreResolvePaths);
- resolved = path.resolve(relative);
- assertPathEquals(expected, resolved);
-
- // assert the invariant that p.relativize(p.resolve(q)).equals(q) when q does not have a root
- // p = path, q = relative, p.resolve(q) = resolved
- if (relative.getRoot() == null) {
- assertEquals(relative, path.relativize(resolved));
- }
- }
-
- private void assertRelativizedPathEquals(String expected, Path path, String relativizePath) {
- Path relativized = path.relativize(parsePath(relativizePath));
- assertPathEquals(expected, relativized);
- }
-
- private void assertNormalizedPathEquals(String expected, String first, String... more) {
- assertPathEquals(expected, parsePath(first, more).normalize());
- }
-
- private void assertPathEquals(String expected, String first, String... more) {
- assertPathEquals(expected, parsePath(first, more));
- }
-
- private void assertPathEquals(String expected, Path path) {
- assertEquals(parsePath(expected), path);
- }
-
- private Path parsePath(String first, String... more) {
- return fileSystem.getPath(first, more);
- }
-
- private static class TestFileSystem extends BaseFileSystem<TestPath> {
- TestFileSystem(FileSystemProvider fileSystemProvider) {
- super(fileSystemProvider);
- }
-
- @Override
- protected TestPath create(String root, List<String> names) {
- return new TestPath(this, root, names);
- }
-
- @Override
- public void close() throws IOException {
- // ignored
- }
-
- @Override
- public boolean isOpen() {
- return false;
- }
-
- @Override
- public Set<String> supportedFileAttributeViews() {
- return null;
- }
-
- @Override
- public UserPrincipalLookupService getUserPrincipalLookupService() {
- return null;
- }
- }
-
- private static class TestPath extends BasePath<TestPath, TestFileSystem> {
- TestPath(TestFileSystem fileSystem, String root, List<String> names) {
- super(fileSystem, root, names);
- }
-
- @Override
- protected TestPath create(String root, List<String> names) {
- return new TestPath(getFileSystem(), root, names);
- }
-
- @Override
- public URI toUri() {
- return null;
- }
-
- @Override
- public Path toRealPath(LinkOption... options) throws IOException {
- return null;
- }
- }
-
- public static class PathTester {
- private final FileSystem fileSystem;
- private final String string;
- private String root;
- private List<String> names = Collections.emptyList();
-
- public PathTester(FileSystem fileSystem, String string) {
- this.fileSystem = fileSystem;
- this.string = string;
- }
-
- public PathTester root(String root) {
- this.root = root;
- return this;
- }
-
- public PathTester names(Collection<String> names) {
- this.names = GenericUtils.unmodifiableList(names);
- return this;
- }
-
- public PathTester names(String... names) {
- return names(Arrays.asList(names));
- }
-
- public void test(String first, String... more) {
- Path path = fileSystem.getPath(first, more);
- test(path);
- }
-
- public void test(Path path) {
- assertEquals(string, path.toString());
-
- testRoot(path);
- testNames(path);
- testParents(path);
- testStartsWith(path);
- testEndsWith(path);
- testSubpaths(path);
- }
-
- protected void testRoot(Path path) {
- if (root != null) {
- assertTrue(path + ".isAbsolute() should be true", path.isAbsolute());
- assertNotNull(path + ".getRoot() should not be null", path.getRoot());
- assertEquals(root, path.getRoot().toString());
- } else {
- assertFalse(path + ".isAbsolute() should be false", path.isAbsolute());
- assertNull(path + ".getRoot() should be null", path.getRoot());
- }
- }
-
- protected void testNames(Path path) {
- assertEquals(names.size(), path.getNameCount());
- assertEquals(names, names(path));
- for (int i = 0; i < names.size(); i++) {
- assertEquals(names.get(i), path.getName(i).toString());
- // don't test individual names if this is an individual name
- if (names.size() > 1) {
- new PathTester(fileSystem, names.get(i))
- .names(names.get(i))
- .test(path.getName(i));
- }
- }
- if (names.size() > 0) {
- String fileName = names.get(names.size() - 1);
- assertEquals(fileName, path.getFileName().toString());
- // don't test individual names if this is an individual name
- if (names.size() > 1) {
- new PathTester(fileSystem, fileName)
- .names(fileName)
- .test(path.getFileName());
- }
- }
- }
-
- protected void testParents(Path path) {
- Path parent = path.getParent();
- if (((root != null) && (names.size() >= 1)) || (names.size() > 1)) {
- assertNotNull(parent);
- }
-
- if (parent != null) {
- String parentName = names.size() == 1 ? root : string.substring(0, string.lastIndexOf('/'));
- new PathTester(fileSystem, parentName)
- .root(root)
- .names(names.subList(0, names.size() - 1))
- .test(parent);
- }
- }
-
- protected void testSubpaths(Path path) {
- int nameCount = path.getNameCount();
- if (path.getRoot() == null) {
- assertEquals(path, path.subpath(0, nameCount));
- }
-
- if (nameCount > 1) {
- String stringWithoutRoot = root == null ? string : string.substring(root.length());
-
- // test start + 1 to end and start to end - 1 subpaths... this recursively tests all subpaths
- // actually tests most possible subpaths multiple times but... eh
- Path startSubpath = path.subpath(1, nameCount);
- List<String> startNames = split(stringWithoutRoot, '/')
- .subList(1, nameCount);
-
- new PathTester(fileSystem, GenericUtils.join(startNames, '/'))
- .names(startNames)
- .test(startSubpath);
-
- Path endSubpath = path.subpath(0, nameCount - 1);
- List<String> endNames = split(stringWithoutRoot, '/')
- .subList(0, nameCount - 1);
-
- new PathTester(fileSystem, GenericUtils.join(endNames, '/'))
- .names(endNames)
- .test(endSubpath);
- }
- }
-
- protected void testStartsWith(Path path) {
- // empty path doesn't start with any path
- if (root != null || !names.isEmpty()) {
- Path other = path;
- while (other != null) {
- assertTrue(path + ".startsWith(" + other + ") should be true",
- path.startsWith(other));
- assertTrue(path + ".startsWith(" + other + ") should be true",
- path.startsWith(other.toString()));
- other = other.getParent();
- }
- }
- }
-
- protected void testEndsWith(Path path) {
- // empty path doesn't start with any path
- if (root != null || !names.isEmpty()) {
- Path other = path;
- while (other != null) {
- assertTrue(path + ".endsWith(" + other + ") should be true",
- path.endsWith(other));
- assertTrue(path + ".endsWith(" + other + ") should be true",
- path.endsWith(other.toString()));
- if (other.getRoot() != null && other.getNameCount() > 0) {
- other = other.subpath(0, other.getNameCount());
- } else if (other.getNameCount() > 1) {
- other = other.subpath(1, other.getNameCount());
- } else {
- other = null;
- }
- }
- }
- }
-
- private static List<String> names(Path path) {
- List<String> list = new ArrayList<>();
- for (Path p : path) {
- list.add(p.toString());
- }
- return list;
- }
-
- private static List<String> split(String string, char sep) {
- return Arrays.asList(GenericUtils.split(string, sep));
- }
- }
-}
l***@apache.org
2018-10-25 09:11:02 UTC
Permalink
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpSubsystemHelper.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpSubsystemHelper.java b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpSubsystemHelper.java
index f731904..d75ce82 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpSubsystemHelper.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/AbstractSftpSubsystemHelper.java
@@ -135,18 +135,18 @@ public abstract class AbstractSftpSubsystemHelper
* The default reported supported client extensions
*/
public static final Map<String, OptionalFeature> DEFAULT_SUPPORTED_CLIENT_EXTENSIONS =
- // TODO text-seek - see http://tools.ietf.org/wg/secsh/draft-ietf-secsh-filexfer/draft-ietf-secsh-filexfer-13.txt
- // TODO home-directory - see http://tools.ietf.org/wg/secsh/draft-ietf-secsh-filexfer/draft-ietf-secsh-filexfer-09.txt
- GenericUtils.<String, OptionalFeature>mapBuilder()
- .put(SftpConstants.EXT_VERSION_SELECT, OptionalFeature.TRUE)
- .put(SftpConstants.EXT_COPY_FILE, OptionalFeature.TRUE)
- .put(SftpConstants.EXT_MD5_HASH, BuiltinDigests.md5)
- .put(SftpConstants.EXT_MD5_HASH_HANDLE, BuiltinDigests.md5)
- .put(SftpConstants.EXT_CHECK_FILE_HANDLE, OptionalFeature.any(BuiltinDigests.VALUES))
- .put(SftpConstants.EXT_CHECK_FILE_NAME, OptionalFeature.any(BuiltinDigests.VALUES))
- .put(SftpConstants.EXT_COPY_DATA, OptionalFeature.TRUE)
- .put(SftpConstants.EXT_SPACE_AVAILABLE, OptionalFeature.TRUE)
- .immutable();
+ // TODO text-seek - see http://tools.ietf.org/wg/secsh/draft-ietf-secsh-filexfer/draft-ietf-secsh-filexfer-13.txt
+ // TODO home-directory - see http://tools.ietf.org/wg/secsh/draft-ietf-secsh-filexfer/draft-ietf-secsh-filexfer-09.txt
+ GenericUtils.<String, OptionalFeature>mapBuilder()
+ .put(SftpConstants.EXT_VERSION_SELECT, OptionalFeature.TRUE)
+ .put(SftpConstants.EXT_COPY_FILE, OptionalFeature.TRUE)
+ .put(SftpConstants.EXT_MD5_HASH, BuiltinDigests.md5)
+ .put(SftpConstants.EXT_MD5_HASH_HANDLE, BuiltinDigests.md5)
+ .put(SftpConstants.EXT_CHECK_FILE_HANDLE, OptionalFeature.any(BuiltinDigests.VALUES))
+ .put(SftpConstants.EXT_CHECK_FILE_NAME, OptionalFeature.any(BuiltinDigests.VALUES))
+ .put(SftpConstants.EXT_COPY_DATA, OptionalFeature.TRUE)
+ .put(SftpConstants.EXT_SPACE_AVAILABLE, OptionalFeature.TRUE)
+ .immutable();

/**
* Comma-separated list of which {@code OpenSSH} extensions are reported and
@@ -156,14 +156,15 @@ public abstract class AbstractSftpSubsystemHelper
*/
public static final String OPENSSH_EXTENSIONS_PROP = "sftp-openssh-extensions";
public static final List<OpenSSHExtension> DEFAULT_OPEN_SSH_EXTENSIONS =
- Collections.unmodifiableList(
- Arrays.asList(
- new OpenSSHExtension(FsyncExtensionParser.NAME, "1"),
- new OpenSSHExtension(HardLinkExtensionParser.NAME, "1")
- ));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ new OpenSSHExtension(FsyncExtensionParser.NAME, "1"),
+ new OpenSSHExtension(HardLinkExtensionParser.NAME, "1")
+ ));

public static final List<String> DEFAULT_OPEN_SSH_EXTENSIONS_NAMES =
- Collections.unmodifiableList(NamedResource.getNameList(DEFAULT_OPEN_SSH_EXTENSIONS));
+ Collections.unmodifiableList(
+ NamedResource.getNameList(DEFAULT_OPEN_SSH_EXTENSIONS));

/**
* Comma separate list of {@code SSH_ACL_CAP_xxx} names - where name can be without
@@ -171,12 +172,12 @@ public abstract class AbstractSftpSubsystemHelper
*/
public static final String ACL_SUPPORTED_MASK_PROP = "sftp-acl-supported-mask";
public static final Set<Integer> DEFAULT_ACL_SUPPORTED_MASK =
- Collections.unmodifiableSet(
- new HashSet<>(Arrays.asList(
- SftpConstants.SSH_ACL_CAP_ALLOW,
- SftpConstants.SSH_ACL_CAP_DENY,
- SftpConstants.SSH_ACL_CAP_AUDIT,
- SftpConstants.SSH_ACL_CAP_ALARM)));
+ Collections.unmodifiableSet(
+ new HashSet<>(Arrays.asList(
+ SftpConstants.SSH_ACL_CAP_ALLOW,
+ SftpConstants.SSH_ACL_CAP_DENY,
+ SftpConstants.SSH_ACL_CAP_AUDIT,
+ SftpConstants.SSH_ACL_CAP_ALARM)));

/**
* Property that can be used to set the reported NL value.
@@ -252,7 +253,7 @@ public abstract class AbstractSftpSubsystemHelper
protected Boolean validateProposedVersion(Buffer buffer, int id, String proposed) throws IOException {
if (log.isDebugEnabled()) {
log.debug("validateProposedVersion({})[id={}] SSH_FXP_EXTENDED(version-select) (version={})",
- getServerSession(), id, proposed);
+ getServerSession(), id, proposed);
}

if (GenericUtils.length(proposed) != 1) {
@@ -307,11 +308,12 @@ public abstract class AbstractSftpSubsystemHelper

if (log.isTraceEnabled()) {
log.trace("checkVersionCompatibility({})[id={}] - proposed={}, available={}",
- session, id, proposed, available);
+ session, id, proposed, available);
}

if ((proposed < low) || (proposed > hig)) {
- sendStatus(prepareReply(buffer), id, failureOpcode, "Proposed version (" + proposed + ") not in supported range: " + available);
+ sendStatus(prepareReply(buffer), id, failureOpcode,
+ "Proposed version (" + proposed + ") not in supported range: " + available);
return null;
}

@@ -331,7 +333,7 @@ public abstract class AbstractSftpSubsystemHelper
int id = buffer.getInt();
if (log.isDebugEnabled()) {
log.debug("process({})[length={}, type={}, id={}] processing",
- getServerSession(), length, SftpConstants.getCommandMessageName(type), id);
+ getServerSession(), length, SftpConstants.getCommandMessageName(type), id);
}
doProcess(buffer, length, type, id);
}
@@ -416,8 +418,9 @@ public abstract class AbstractSftpSubsystemHelper
protected void doUnsupported(Buffer buffer, int length, int type, int id) throws IOException {
String name = SftpConstants.getCommandMessageName(type);
log.warn("process({})[length={}, type={}, id={}] unknown command",
- getServerSession(), length, name, id);
- sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OP_UNSUPPORTED, "Command " + name + " is unsupported or not implemented");
+ getServerSession(), length, name, id);
+ sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OP_UNSUPPORTED,
+ "Command " + name + " is unsupported or not implemented");
}

protected abstract void doInit(Buffer buffer, int id) throws IOException;
@@ -507,12 +510,14 @@ public abstract class AbstractSftpSubsystemHelper
*/
protected abstract String doOpen(int id, String path, int pflags, int access, Map<String, Object> attrs) throws IOException;

- protected <E extends IOException> E signalOpenFailure(int id, String pathValue, Path path, boolean isDir, E thrown) throws IOException {
+ protected <E extends IOException> E signalOpenFailure(
+ int id, String pathValue, Path path, boolean isDir, E thrown)
+ throws IOException {
SftpEventListener listener = getSftpEventListenerProxy();
ServerSession session = getServerSession();
if (log.isDebugEnabled()) {
log.debug("signalOpenFailure(id={})[{}] signal {} for {}: {}",
- id, pathValue, thrown.getClass().getSimpleName(), path, thrown.getMessage());
+ id, pathValue, thrown.getClass().getSimpleName(), path, thrown.getMessage());
}

listener.openFailed(session, pathValue, path, isDir, thrown);
@@ -542,7 +547,7 @@ public abstract class AbstractSftpSubsystemHelper
int readLen = Math.min(requestedLength, maxAllowed);
if (log.isTraceEnabled()) {
log.trace("doRead({})[id={}]({})[offset={}] - req={}, max={}, effective={}",
- session, id, handle, offset, requestedLength, maxAllowed, readLen);
+ session, id, handle, offset, requestedLength, maxAllowed, readLen);
}

try {
@@ -587,7 +592,9 @@ public abstract class AbstractSftpSubsystemHelper
sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "");
}

- protected abstract void doWrite(int id, String handle, long offset, int length, byte[] data, int doff, int remaining) throws IOException;
+ protected abstract void doWrite(
+ int id, String handle, long offset, int length, byte[] data, int doff, int remaining)
+ throws IOException;

protected void doLStat(Buffer buffer, int id) throws IOException {
String path = buffer.getString();
@@ -612,7 +619,7 @@ public abstract class AbstractSftpSubsystemHelper
Path p = resolveFile(path);
if (log.isDebugEnabled()) {
log.debug("doLStat({})[id={}] SSH_FXP_LSTAT (path={}[{}], flags=0x{})",
- getServerSession(), id, path, p, Integer.toHexString(flags));
+ getServerSession(), id, path, p, Integer.toHexString(flags));
}

/*
@@ -638,7 +645,7 @@ public abstract class AbstractSftpSubsystemHelper
protected void doSetStat(int id, String path, Map<String, ?> attrs) throws IOException {
if (log.isDebugEnabled()) {
log.debug("doSetStat({})[id={}] SSH_FXP_SETSTAT (path={}, attrs={})",
- getServerSession(), id, path, attrs);
+ getServerSession(), id, path, attrs);
}
Path p = resolveFile(path);
doSetAttributes(p, attrs);
@@ -688,7 +695,7 @@ public abstract class AbstractSftpSubsystemHelper
Path p = resolveNormalizedLocation(path);
if (log.isDebugEnabled()) {
log.debug("doOpenDir({})[id={}] SSH_FXP_OPENDIR (path={})[{}]",
- getServerSession(), id, path, p);
+ getServerSession(), id, path, p);
}

LinkOption[] options =
@@ -714,7 +721,7 @@ public abstract class AbstractSftpSubsystemHelper
try {
if (log.isDebugEnabled()) {
log.debug("doLink({})[id={}] SSH_FXP_LINK linkpath={}, targetpath={}, symlink={}",
- getServerSession(), id, linkPath, targetPath, symLink);
+ getServerSession(), id, linkPath, targetPath, symLink);
}

doLink(id, targetPath, linkPath, symLink);
@@ -736,7 +743,7 @@ public abstract class AbstractSftpSubsystemHelper
try {
if (log.isDebugEnabled()) {
log.debug("doSymLink({})[id={}] SSH_FXP_SYMLINK linkpath={}, targetpath={}",
- getServerSession(), id, targetPath, linkPath);
+ getServerSession(), id, targetPath, linkPath);
}
doSymLink(id, targetPath, linkPath);
} catch (IOException | RuntimeException e) {
@@ -761,7 +768,8 @@ public abstract class AbstractSftpSubsystemHelper
try {
doOpenSSHHardLink(id, srcFile, dstFile);
} catch (IOException | RuntimeException e) {
- sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_EXTENDED, HardLinkExtensionParser.NAME, srcFile, dstFile);
+ sendStatus(prepareReply(buffer), id, e, SftpConstants.SSH_FXP_EXTENDED,
+ HardLinkExtensionParser.NAME, srcFile, dstFile);
return;
}

@@ -771,7 +779,7 @@ public abstract class AbstractSftpSubsystemHelper
protected void doOpenSSHHardLink(int id, String srcFile, String dstFile) throws IOException {
if (log.isDebugEnabled()) {
log.debug("doOpenSSHHardLink({})[id={}] SSH_FXP_EXTENDED[{}] (src={}, dst={})",
- getServerSession(), id, HardLinkExtensionParser.NAME, srcFile, dstFile);
+ getServerSession(), id, HardLinkExtensionParser.NAME, srcFile, dstFile);
}

createLink(id, srcFile, dstFile, false);
@@ -804,7 +812,7 @@ public abstract class AbstractSftpSubsystemHelper
FileStore store = Files.getFileStore(nrm);
if (log.isTraceEnabled()) {
log.trace("doSpaceAvailable({})[id={}] path={}[{}] - {}[{}]",
- session, id, path, nrm, store.name(), store.type());
+ session, id, path, nrm, store.name(), store.type());
}

return new SpaceAvailableExtensionInfo(store);
@@ -863,9 +871,10 @@ public abstract class AbstractSftpSubsystemHelper
send(buffer);
}

- protected void doCheckFileHash(int id, Path file, NamedFactory<? extends Digest> factory,
+ protected void doCheckFileHash(
+ int id, Path file, NamedFactory<? extends Digest> factory,
long startOffset, long length, int blockSize, Buffer buffer)
- throws Exception {
+ throws Exception {
ValidateUtils.checkTrue(startOffset >= 0L, "Invalid start offset: %d", startOffset);
ValidateUtils.checkTrue(length >= 0L, "Invalid length: %d", length);
ValidateUtils.checkTrue((blockSize == 0) || (blockSize >= SftpConstants.MIN_CHKFILE_BLOCKSIZE), "Invalid block size: %d", blockSize);
@@ -885,8 +894,8 @@ public abstract class AbstractSftpSubsystemHelper
ValidateUtils.checkTrue(effectiveLength > 0L, "Non-positive effective hash data length: %d", effectiveLength);

byte[] digestBuf = (blockSize == 0)
- ? new byte[Math.min((int) effectiveLength, IoUtils.DEFAULT_COPY_SIZE)]
- : new byte[Math.min((int) effectiveLength, blockSize)];
+ ? new byte[Math.min((int) effectiveLength, IoUtils.DEFAULT_COPY_SIZE)]
+ : new byte[Math.min((int) effectiveLength, blockSize)];
ByteBuffer wb = ByteBuffer.wrap(digestBuf);
SftpFileSystemAccessor accessor = getFileSystemAccessor();
ServerSession session = getServerSession();
@@ -918,8 +927,8 @@ public abstract class AbstractSftpSubsystemHelper
byte[] hashValue = digest.digest();
if (traceEnabled) {
log.trace("doCheckFileHash({})[{}] offset={}, length={} - algo={}, hash={}",
- session, file, startOffset, length,
- digest.getAlgorithm(), BufferUtils.toHex(':', hashValue));
+ session, file, startOffset, length,
+ digest.getAlgorithm(), BufferUtils.toHex(':', hashValue));
}
buffer.putBytes(hashValue);
} else {
@@ -942,8 +951,8 @@ public abstract class AbstractSftpSubsystemHelper
byte[] hashValue = digest.digest(); // NOTE: this also resets the hash for the next read
if (traceEnabled) {
log.trace("doCheckFileHash({})({})[{}] offset={}, length={} - algo={}, hash={}",
- session, file, count, startOffset, length,
- digest.getAlgorithm(), BufferUtils.toHex(':', hashValue));
+ session, file, count, startOffset, length,
+ digest.getAlgorithm(), BufferUtils.toHex(':', hashValue));
}
buffer.putBytes(hashValue);
}
@@ -962,9 +971,9 @@ public abstract class AbstractSftpSubsystemHelper
hashValue = doMD5Hash(id, targetType, target, startOffset, length, quickCheckHash);
if (log.isTraceEnabled()) {
log.trace("doMD5Hash({})({})[{}] offset={}, length={}, quick-hash={} - hash={}",
- getServerSession(), targetType, target, startOffset, length,
- BufferUtils.toHex(':', quickCheckHash),
- BufferUtils.toHex(':', hashValue));
+ getServerSession(), targetType, target, startOffset, length,
+ BufferUtils.toHex(':', quickCheckHash),
+ BufferUtils.toHex(':', hashValue));
}

} catch (Exception e) {
@@ -983,7 +992,7 @@ public abstract class AbstractSftpSubsystemHelper

protected abstract byte[] doMD5Hash(
int id, String targetType, String target, long startOffset, long length, byte[] quickCheckHash)
- throws Exception;
+ throws Exception;

protected byte[] doMD5Hash(int id, Path path, long startOffset, long length, byte[] quickCheckHash) throws Exception {
ValidateUtils.checkTrue(startOffset >= 0L, "Invalid start offset: %d", startOffset);
@@ -1044,9 +1053,9 @@ public abstract class AbstractSftpSubsystemHelper
} else {
if (traceEnabled) {
log.trace("doMD5Hash({})({}) offset={}, length={} - quick-hash mismatched expected={}, actual={}",
- session, path, startOffset, length,
- BufferUtils.toHex(':', quickCheckHash),
- BufferUtils.toHex(':', hashValue));
+ session, path, startOffset, length,
+ BufferUtils.toHex(':', quickCheckHash),
+ BufferUtils.toHex(':', hashValue));
}
}
}
@@ -1078,9 +1087,9 @@ public abstract class AbstractSftpSubsystemHelper

if (traceEnabled) {
log.trace("doMD5Hash({})({}) offset={}, length={} - matches={}, quick={} hash={}",
- session, path, startOffset, length, hashMatches,
- BufferUtils.toHex(':', quickCheckHash),
- BufferUtils.toHex(':', hashValue));
+ session, path, startOffset, length, hashMatches,
+ BufferUtils.toHex(':', quickCheckHash),
+ BufferUtils.toHex(':', hashValue));
}

return hashValue;
@@ -1097,7 +1106,7 @@ public abstract class AbstractSftpSubsystemHelper
try {
if (log.isDebugEnabled()) {
log.debug("doReadLink({})[id={}] SSH_FXP_READLINK path={}",
- getServerSession(), id, path);
+ getServerSession(), id, path);
}
l = doReadLink(id, path);
} catch (IOException | RuntimeException e) {
@@ -1113,7 +1122,7 @@ public abstract class AbstractSftpSubsystemHelper
Path t = Files.readSymbolicLink(f);
if (log.isDebugEnabled()) {
log.debug("doReadLink({})[id={}] path={}[{}]: {}",
- getServerSession(), id, path, f, t);
+ getServerSession(), id, path, f, t);
}
return t.toString();
}
@@ -1139,7 +1148,7 @@ public abstract class AbstractSftpSubsystemHelper
protected void doRename(int id, String oldPath, String newPath, int flags) throws IOException {
if (log.isDebugEnabled()) {
log.debug("doRename({})[id={}] SSH_FXP_RENAME (oldPath={}, newPath={}, flags=0x{})",
- getServerSession(), id, oldPath, newPath, Integer.toHexString(flags));
+ getServerSession(), id, oldPath, newPath, Integer.toHexString(flags));
}

Collection<CopyOption> opts = Collections.emptyList();
@@ -1191,7 +1200,9 @@ public abstract class AbstractSftpSubsystemHelper
sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_OK, "");
}

- protected abstract void doCopyData(int id, String readHandle, long readOffset, long readLength, String writeHandle, long writeOffset) throws IOException;
+ protected abstract void doCopyData(
+ int id, String readHandle, long readOffset, long readLength, String writeHandle, long writeOffset)
+ throws IOException;

// see https://tools.ietf.org/html/draft-ietf-secsh-filexfer-extensions-00#section-6
protected void doCopyFile(Buffer buffer, int id) throws IOException {
@@ -1213,14 +1224,14 @@ public abstract class AbstractSftpSubsystemHelper
protected void doCopyFile(int id, String srcFile, String dstFile, boolean overwriteDestination) throws IOException {
if (log.isDebugEnabled()) {
log.debug("doCopyFile({})[id={}] SSH_FXP_EXTENDED[{}] (src={}, dst={}, overwrite=0x{})",
- getServerSession(), id, SftpConstants.EXT_COPY_FILE,
- srcFile, dstFile, overwriteDestination);
+ getServerSession(), id, SftpConstants.EXT_COPY_FILE,
+ srcFile, dstFile, overwriteDestination);
}

doCopyFile(id, srcFile, dstFile,
- overwriteDestination
- ? Collections.singletonList(StandardCopyOption.REPLACE_EXISTING)
- : Collections.emptyList());
+ overwriteDestination
+ ? Collections.singletonList(StandardCopyOption.REPLACE_EXISTING)
+ : Collections.emptyList());
}

protected void doCopyFile(int id, String srcFile, String dstFile, Collection<CopyOption> opts) throws IOException {
@@ -1285,7 +1296,7 @@ public abstract class AbstractSftpSubsystemHelper
protected Map<String, Object> doStat(int id, String path, int flags) throws IOException {
if (log.isDebugEnabled()) {
log.debug("doStat({})[id={}] SSH_FXP_STAT (path={}, flags=0x{})",
- getServerSession(), id, path, Integer.toHexString(flags));
+ getServerSession(), id, path, Integer.toHexString(flags));
}

/*
@@ -1337,7 +1348,7 @@ public abstract class AbstractSftpSubsystemHelper
control = buffer.getUByte();
if (debugEnabled) {
log.debug("doRealPath({}) - control=0x{} for path={}",
- session, Integer.toHexString(control), path);
+ session, Integer.toHexString(control), path);
}
}

@@ -1364,7 +1375,7 @@ public abstract class AbstractSftpSubsystemHelper
} catch (IOException e) {
if (debugEnabled) {
log.debug("doRealPath({}) - failed ({}) to retrieve attributes of {}: {}",
- session, e.getClass().getSimpleName(), p, e.getMessage());
+ session, e.getClass().getSimpleName(), p, e.getMessage());
}
if (log.isTraceEnabled()) {
log.trace("doRealPath(" + session + ")[" + p + "] attributes retrieval failure details", e);
@@ -1406,7 +1417,7 @@ public abstract class AbstractSftpSubsystemHelper
if (numExtra > 0) {
if (log.isDebugEnabled()) {
log.debug("doRealPathV6({})[id={}] path={}, extra={}",
- getServerSession(), id, path, extraPaths);
+ getServerSession(), id, path, extraPaths);
}
StringBuilder sb = new StringBuilder(GenericUtils.length(path) + numExtra * 8);
sb.append(path);
@@ -1423,7 +1434,9 @@ public abstract class AbstractSftpSubsystemHelper
return validateRealPath(id, path, p, options);
}

- protected SimpleImmutableEntry<Path, Boolean> doRealPathV345(int id, String path, Path p, LinkOption... options) throws IOException {
+ protected SimpleImmutableEntry<Path, Boolean> doRealPathV345(
+ int id, String path, Path p, LinkOption... options)
+ throws IOException {
return validateRealPath(id, path, p, options);
}

@@ -1437,7 +1450,9 @@ public abstract class AbstractSftpSubsystemHelper
* @throws IOException If failed to validate the file
* @see IoUtils#checkFileExists(Path, LinkOption...)
*/
- protected SimpleImmutableEntry<Path, Boolean> validateRealPath(int id, String path, Path f, LinkOption... options) throws IOException {
+ protected SimpleImmutableEntry<Path, Boolean> validateRealPath(
+ int id, String path, Path f, LinkOption... options)
+ throws IOException {
Path p = normalize(f);
Boolean status = IoUtils.checkFileExists(p, options);
return new SimpleImmutableEntry<>(p, status);
@@ -1459,7 +1474,7 @@ public abstract class AbstractSftpSubsystemHelper
Path p = resolveFile(path);
if (log.isDebugEnabled()) {
log.debug("doRemoveDirectory({})[id={}] SSH_FXP_RMDIR (path={})[{}]",
- getServerSession(), id, path, p);
+ getServerSession(), id, path, p);
}
if (Files.isDirectory(p, options)) {
doRemove(id, p);
@@ -1506,7 +1521,7 @@ public abstract class AbstractSftpSubsystemHelper
ServerSession session = getServerSession();
if (log.isDebugEnabled()) {
log.debug("doMakeDirectory({})[id={}] SSH_FXP_MKDIR (path={}[{}], attrs={})",
- session, id, path, p, attrs);
+ session, id, path, p, attrs);
}

Boolean status = IoUtils.checkFileExists(p, options);
@@ -1554,7 +1569,7 @@ public abstract class AbstractSftpSubsystemHelper
Path p = resolveFile(path);
if (log.isDebugEnabled()) {
log.debug("doRemove({})[id={}] SSH_FXP_REMOVE (path={}[{}])",
- getServerSession(), id, path, p);
+ getServerSession(), id, path, p);
}

Boolean status = IoUtils.checkFileExists(p, options);
@@ -1577,7 +1592,7 @@ public abstract class AbstractSftpSubsystemHelper
ServerSession session = getServerSession();
if (log.isDebugEnabled()) {
log.debug("signalRemovalPreConditionFailure(id={})[{}] signal {} for {}: {}",
- id, pathValue, thrown.getClass().getSimpleName(), path, thrown.getMessage());
+ id, pathValue, thrown.getClass().getSimpleName(), path, thrown.getMessage());
}
listener.removing(session, path);
listener.removed(session, path, thrown);
@@ -1635,7 +1650,8 @@ public abstract class AbstractSftpSubsystemHelper
if (log.isDebugEnabled()) {
log.debug("executeExtendedCommand({}) received unsupported SSH_FXP_EXTENDED({})", getServerSession(), extension);
}
- sendStatus(buffer, id, SftpConstants.SSH_FX_OP_UNSUPPORTED, "Command SSH_FXP_EXTENDED(" + extension + ") is unsupported or not implemented");
+ sendStatus(buffer, id, SftpConstants.SSH_FX_OP_UNSUPPORTED,
+ "Command SSH_FXP_EXTENDED(" + extension + ") is unsupported or not implemented");
}

protected void appendExtensions(Buffer buffer, String supportedVersions) {
@@ -1673,7 +1689,7 @@ public abstract class AbstractSftpSubsystemHelper
if (mask != 0) {
if (log.isTraceEnabled()) {
log.trace("appendAclSupportedExtension({}) capabilities={}",
- session, AclSupportedParser.AclCapabilities.decodeAclCapabilities(mask));
+ session, AclSupportedParser.AclCapabilities.decodeAclCapabilities(mask));
}

buffer.putString(SftpConstants.EXT_ACL_SUPPORTED);
@@ -1755,7 +1771,8 @@ public abstract class AbstractSftpSubsystemHelper
ValidateUtils.checkTrue((pos > 0) && (pos < (nvp.length() - 1)), "Malformed OpenSSH extension spec: %s", nvp);
String name = GenericUtils.trimToEmpty(nvp.substring(0, pos));
String version = GenericUtils.trimToEmpty(nvp.substring(pos + 1));
- extList.add(new OpenSSHExtension(name, ValidateUtils.checkNotNullAndNotEmpty(version, "No version specified for OpenSSH extension %s", name)));
+ extList.add(new OpenSSHExtension(name,
+ ValidateUtils.checkNotNullAndNotEmpty(version, "No version specified for OpenSSH extension %s", name)));
}

return extList;
@@ -1827,7 +1844,7 @@ public abstract class AbstractSftpSubsystemHelper

if (log.isDebugEnabled()) {
log.debug("appendNewlineExtension({}) value={}",
- getServerSession(), BufferUtils.toHex(':', value.getBytes(StandardCharsets.UTF_8)));
+ getServerSession(), BufferUtils.toHex(':', value.getBytes(StandardCharsets.UTF_8)));
}

buffer.putString(SftpConstants.EXT_NEWLINE);
@@ -2027,7 +2044,8 @@ public abstract class AbstractSftpSubsystemHelper
* @throws IOException If failed to generate an entry
*/
protected int doReadDir(
- int id, String handle, DirectoryHandle dir, Buffer buffer, int maxSize, LinkOption... options) throws IOException {
+ int id, String handle, DirectoryHandle dir, Buffer buffer, int maxSize, LinkOption... options)
+ throws IOException {
int nb = 0;
Map<String, Path> entries = new TreeMap<>(Comparator.naturalOrder());
while ((dir.isSendDot() || dir.isSendDotDot() || dir.hasNext()) && (buffer.wpos() < maxSize)) {
@@ -2065,7 +2083,7 @@ public abstract class AbstractSftpSubsystemHelper
*/
protected void writeDirEntry(
int id, DirectoryHandle dir, Map<String, Path> entries, Buffer buffer, int index, Path f, String shortName, LinkOption... options)
- throws IOException {
+ throws IOException {
Map<String, ?> attrs = resolveFileAttributes(f, SftpConstants.SSH_FILEXFER_ATTR_ALL, options);
entries.put(shortName, f);

@@ -2261,12 +2279,12 @@ public abstract class AbstractSftpSubsystemHelper

if (debugEnabled) {
log.debug("resolveMissingFileAttributes({})[{}[{}]] replace {} with {}",
- getServerSession(), file, name, value, resolved);
+ getServerSession(), file, name, value, resolved);
}
} catch (IOException e) {
if (debugEnabled) {
log.debug("resolveMissingFileAttributes({})[{}[{}]] failed ({}) to resolve missing value: {}",
- getServerSession(), file, name, e.getClass().getSimpleName(), e.getMessage());
+ getServerSession(), file, name, e.getClass().getSimpleName(), e.getMessage());
}
if (log.isTraceEnabled()) {
log.trace("resolveMissingFileAttributes(" + getServerSession() + ")"
@@ -2379,7 +2397,8 @@ public abstract class AbstractSftpSubsystemHelper
case "size": {
long newSize = ((Number) value).longValue();
SftpFileSystemAccessor accessor = getFileSystemAccessor();
- try (SeekableByteChannel channel = accessor.openFile(getServerSession(), this, file, null, EnumSet.of(StandardOpenOption.WRITE))) {
+ try (SeekableByteChannel channel =
+ accessor.openFile(getServerSession(), this, file, null, EnumSet.of(StandardOpenOption.WRITE))) {
channel.truncate(newSize);
}
continue;
@@ -2430,17 +2449,19 @@ public abstract class AbstractSftpSubsystemHelper
handleUnsupportedAttributes(unsupported);
}

- protected void handleSetFileAttributeFailure(Path file, String view, String attribute, Object value, Collection<String> unsupported, Exception e) throws IOException {
+ protected void handleSetFileAttributeFailure(
+ Path file, String view, String attribute, Object value, Collection<String> unsupported, Exception e)
+ throws IOException {
boolean debugEnabled = log.isDebugEnabled();
if (e instanceof UnsupportedOperationException) {
if (debugEnabled) {
log.debug("handleSetFileAttributeFailure({})[{}] {}:{}={} unsupported: {}",
- getServerSession(), file, view, attribute, value, e.getMessage());
+ getServerSession(), file, view, attribute, value, e.getMessage());
}
unsupported.add(attribute);
} else {
log.warn("handleSetFileAttributeFailure({})[{}] {}:{}={} - failed ({}) to set: {}",
- getServerSession(), file, view, attribute, value, e.getClass().getSimpleName(), e.getMessage());
+ getServerSession(), file, view, attribute, value, e.getClass().getSimpleName(), e.getMessage());
if (debugEnabled) {
log.debug("handleSetFileAttributeFailure(" + getServerSession() + ")"
+ "[" + file + "] " + view + ":" + attribute + "=" + value
@@ -2469,7 +2490,9 @@ public abstract class AbstractSftpSubsystemHelper
setFilePermissions(file, perms, options);
} else if ("owner".equalsIgnoreCase(attribute) || "group".equalsIgnoreCase(attribute)) {
setFileOwnership(file, attribute, (Principal) value, options);
- } else if ("creationTime".equalsIgnoreCase(attribute) || "lastModifiedTime".equalsIgnoreCase(attribute) || "lastAccessTime".equalsIgnoreCase(attribute)) {
+ } else if ("creationTime".equalsIgnoreCase(attribute)
+ || "lastModifiedTime".equalsIgnoreCase(attribute)
+ || "lastAccessTime".equalsIgnoreCase(attribute)) {
setFileTime(file, view, attribute, (FileTime) value, options);
} else if ("extended".equalsIgnoreCase(view) && "extended".equalsIgnoreCase(attribute)) {
@SuppressWarnings("unchecked")
@@ -2717,7 +2740,7 @@ public abstract class AbstractSftpSubsystemHelper
protected void sendStatus(Buffer buffer, int id, int substatus, String msg, String lang) throws IOException {
if (log.isDebugEnabled()) {
log.debug("doSendStatus({})[id={}] SSH_FXP_STATUS (substatus={}, lang={}, msg={})",
- getServerSession(), id, SftpConstants.getStatusName(substatus), lang, msg);
+ getServerSession(), id, SftpConstants.getStatusName(substatus), lang, msg);
}

buffer.putByte((byte) SftpConstants.SSH_FXP_STATUS);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java
index 73955b8..b17405a 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/SftpSubsystem.java
@@ -163,7 +163,7 @@ public class SftpSubsystem
* @see ThreadUtils#newSingleThreadExecutor(String)
*/
public SftpSubsystem(CloseableExecutorService executorService, UnsupportedAttributePolicy policy,
- SftpFileSystemAccessor accessor, SftpErrorStatusDataHandler errorStatusDataHandler) {
+ SftpFileSystemAccessor accessor, SftpErrorStatusDataHandler errorStatusDataHandler) {
super(policy, accessor, errorStatusDataHandler);

if (executorService == null) {
@@ -313,7 +313,7 @@ public class SftpSubsystem
if (!closed.get()) { // Ignore
Session session = getServerSession();
log.error("run({}) {} caught in SFTP subsystem: {}",
- session, t.getClass().getSimpleName(), t.getMessage());
+ session, t.getClass().getSimpleName(), t.getMessage());
if (log.isDebugEnabled()) {
log.debug("run(" + session + ") caught exception details", t);
}
@@ -345,7 +345,7 @@ public class SftpSubsystem
ServerSession session = getServerSession();
if (log.isDebugEnabled()) {
log.debug("createLink({})[id={}], existing={}[{}], link={}[{}], symlink={})",
- session, id, linkPath, link, existingPath, existing, symLink);
+ session, id, linkPath, link, existingPath, existing, symLink);
}

SftpEventListener listener = getSftpEventListenerProxy();
@@ -368,7 +368,7 @@ public class SftpSubsystem
Handle h = handles.get(handle);
if (log.isDebugEnabled()) {
log.debug("doTextSeek({})[id={}] SSH_FXP_EXTENDED(text-seek) (handle={}[{}], line={})",
- getServerSession(), id, handle, h, line);
+ getServerSession(), id, handle, h, line);
}

FileHandle fileHandle = validateHandle(handle, h, FileHandle.class);
@@ -392,7 +392,7 @@ public class SftpSubsystem
protected void doCheckFileHash(
int id, String targetType, String target, Collection<String> algos,
long startOffset, long length, int blockSize, Buffer buffer)
- throws Exception {
+ throws Exception {
Path path;
if (SftpConstants.EXT_CHECK_FILE_HANDLE.equalsIgnoreCase(targetType)) {
Handle h = handles.get(target);
@@ -448,11 +448,11 @@ public class SftpSubsystem
@Override
protected byte[] doMD5Hash(
int id, String targetType, String target, long startOffset, long length, byte[] quickCheckHash)
- throws Exception {
+ throws Exception {
if (log.isDebugEnabled()) {
log.debug("doMD5Hash({})({})[{}] offset={}, length={}, quick-hash={}",
- getServerSession(), targetType, target, startOffset, length,
- BufferUtils.toHex(':', quickCheckHash));
+ getServerSession(), targetType, target, startOffset, length,
+ BufferUtils.toHex(':', quickCheckHash));
}

Path path;
@@ -507,9 +507,8 @@ public class SftpSubsystem
* channel.
*/
if (requestsCount.get() > 0L) {
- sendStatus(prepareReply(buffer), id,
- SftpConstants.SSH_FX_FAILURE,
- "Version selection not the 1st request for proposal = " + proposed);
+ sendStatus(prepareReply(buffer), id, SftpConstants.SSH_FX_FAILURE,
+ "Version selection not the 1st request for proposal = " + proposed);
session.close(true);
return;
}
@@ -537,7 +536,7 @@ public class SftpSubsystem
ServerSession session = getServerSession();
if (log.isDebugEnabled()) {
log.debug("doBlock({})[id={}] SSH_FXP_BLOCK (handle={}[{}], offset={}, length={}, mask=0x{})",
- session, id, handle, p, offset, length, Integer.toHexString(mask));
+ session, id, handle, p, offset, length, Integer.toHexString(mask));
}

FileHandle fileHandle = validateHandle(handle, p, FileHandle.class);
@@ -558,7 +557,7 @@ public class SftpSubsystem
ServerSession session = getServerSession();
if (log.isDebugEnabled()) {
log.debug("doUnblock({})[id={}] SSH_FXP_UNBLOCK (handle={}[{}], offset={}, length={})",
- session, id, handle, p, offset, length);
+ session, id, handle, p, offset, length);
}

FileHandle fileHandle = validateHandle(handle, p, FileHandle.class);
@@ -581,9 +580,9 @@ public class SftpSubsystem
Handle wh = inPlaceCopy ? rh : handles.get(writeHandle);
if (log.isDebugEnabled()) {
log.debug("doCopyData({})[id={}] SSH_FXP_EXTENDED[{}] read={}[{}], read-offset={}, read-length={}, write={}[{}], write-offset={})",
- getServerSession(), id, SftpConstants.EXT_COPY_DATA,
- readHandle, rh, readOffset, readLength,
- writeHandle, wh, writeOffset);
+ getServerSession(), id, SftpConstants.EXT_COPY_DATA,
+ readHandle, rh, readOffset, readLength,
+ writeHandle, wh, writeOffset);
}

FileHandle srcHandle = validateHandle(readHandle, rh, FileHandle.class);
@@ -654,8 +653,7 @@ public class SftpSubsystem
ServerSession session = getServerSession();
boolean debugEnabled = log.isDebugEnabled();
if (debugEnabled) {
- log.debug("doReadDir({})[id={}] SSH_FXP_READDIR (handle={}[{}])",
- session, id, handle, h);
+ log.debug("doReadDir({})[id={}] SSH_FXP_READDIR (handle={}[{}])", session, id, handle, h);
}

Buffer reply = null;
@@ -759,7 +757,7 @@ public class SftpSubsystem
Handle h = handles.get(handle);
if (log.isDebugEnabled()) {
log.debug("doFsetStat({})[id={}] SSH_FXP_FSETSTAT (handle={}[{}], attrs={})",
- getServerSession(), id, handle, h, attrs);
+ getServerSession(), id, handle, h, attrs);
}

Handle fileHandle = validateHandle(handle, h, Handle.class);
@@ -771,7 +769,7 @@ public class SftpSubsystem
Handle h = handles.get(handle);
if (log.isDebugEnabled()) {
log.debug("doFStat({})[id={}] SSH_FXP_FSTAT (handle={}[{}], flags=0x{})",
- getServerSession(), id, handle, h, Integer.toHexString(flags));
+ getServerSession(), id, handle, h, Integer.toHexString(flags));
}

Handle fileHandle = validateHandle(handle, h, Handle.class);
@@ -784,7 +782,7 @@ public class SftpSubsystem
ServerSession session = getServerSession();
if (log.isTraceEnabled()) {
log.trace("doWrite({})[id={}] SSH_FXP_WRITE (handle={}[{}], offset={}, data=byte[{}])",
- session, id, handle, h, offset, length);
+ session, id, handle, h, offset, length);
}

FileHandle fh = validateHandle(handle, h, FileHandle.class);
@@ -817,7 +815,7 @@ public class SftpSubsystem
ServerSession session = getServerSession();
if (log.isTraceEnabled()) {
log.trace("doRead({})[id={}] SSH_FXP_READ (handle={}[{}], offset={}, length={})",
- session, id, handle, h, offset, length);
+ session, id, handle, h, offset, length);
}

ValidateUtils.checkTrue(length > 0L, "Invalid read length: %d", length);
@@ -840,8 +838,7 @@ public class SftpSubsystem
Handle h = handles.remove(handle);
ServerSession session = getServerSession();
if (log.isDebugEnabled()) {
- log.debug("doClose({})[id={}] SSH_FXP_CLOSE (handle={}[{}])",
- session, id, handle, h);
+ log.debug("doClose({})[id={}] SSH_FXP_CLOSE (handle={}[{}])", session, id, handle, h);
}

Handle nodeHandle = validateHandle(handle, h, Handle.class);
@@ -860,7 +857,7 @@ public class SftpSubsystem
ServerSession session = getServerSession();
if (log.isDebugEnabled()) {
log.debug("doOpen({})[id={}] SSH_FXP_OPEN (path={}, access=0x{}, pflags=0x{}, attrs={})",
- session, id, path, Integer.toHexString(access), Integer.toHexString(pflags), attrs);
+ session, id, path, Integer.toHexString(access), Integer.toHexString(pflags), attrs);
}

Path file = resolveFile(path);
@@ -869,7 +866,7 @@ public class SftpSubsystem
if (curHandleCount > maxHandleCount) {
throw signalOpenFailure(id, path, file, false,
new SftpException(SftpConstants.SSH_FX_NO_SPACE_ON_FILESYSTEM,
- "Too many open handles: current=" + curHandleCount + ", max.=" + maxHandleCount));
+ "Too many open handles: current=" + curHandleCount + ", max.=" + maxHandleCount));
}

String handle;
@@ -898,8 +895,7 @@ public class SftpSubsystem

if (handles.containsKey(handle)) {
if (traceEnabled) {
- log.trace("generateFileHandle({})[{}] handle={} in use at round {}",
- session, file, handle, index);
+ log.trace("generateFileHandle({})[{}] handle={} in use at round {}", session, file, handle, index);
}
continue;
}
@@ -1026,7 +1022,7 @@ public class SftpSubsystem
}
} catch (IOException e) {
log.error("closeAllHandles({}) failed ({}) to close handle={}[{}]: {}",
- session, e.getClass().getSimpleName(), id, handle, e.getMessage());
+ session, e.getClass().getSimpleName(), id, handle, e.getMessage());
}
});
handles.clear();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/UnixDateFormat.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/UnixDateFormat.java b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/UnixDateFormat.java
index 3ce474a..fa190ba 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/UnixDateFormat.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/UnixDateFormat.java
@@ -34,9 +34,10 @@ public final class UnixDateFormat {
* A {@link List} of <U>short</U> months names where Jan=0, Feb=1, etc.
*/
public static final List<String> MONTHS =
- Collections.unmodifiableList(Arrays.asList(
- "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
- ));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+ ));

/**
* Six months duration in msec.

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/UnsupportedAttributePolicy.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/UnsupportedAttributePolicy.java b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/UnsupportedAttributePolicy.java
index ca763e3..140fc07 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/UnsupportedAttributePolicy.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/server/subsystem/sftp/UnsupportedAttributePolicy.java
@@ -32,5 +32,5 @@ public enum UnsupportedAttributePolicy {
ThrowException;

public static final Set<UnsupportedAttributePolicy> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(UnsupportedAttributePolicy.class));
+ Collections.unmodifiableSet(EnumSet.allOf(UnsupportedAttributePolicy.class));
}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtensionTest.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtensionTest.java b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtensionTest.java
index 1ddd789..6ede1e3 100644
--- a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtensionTest.java
+++ b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtensionTest.java
@@ -68,21 +68,21 @@ import org.junit.runners.Parameterized.UseParametersRunnerFactory;
@UseParametersRunnerFactory(JUnit4ClassRunnerWithParametersFactory.class)
public class AbstractCheckFileExtensionTest extends AbstractSftpClientTestSupport {
private static final Collection<Integer> DATA_SIZES =
- Collections.unmodifiableList(
- Arrays.asList(
- (int) Byte.MAX_VALUE,
- SftpConstants.MIN_CHKFILE_BLOCKSIZE,
- IoUtils.DEFAULT_COPY_SIZE,
- Byte.SIZE * IoUtils.DEFAULT_COPY_SIZE
- ));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ (int) Byte.MAX_VALUE,
+ SftpConstants.MIN_CHKFILE_BLOCKSIZE,
+ IoUtils.DEFAULT_COPY_SIZE,
+ Byte.SIZE * IoUtils.DEFAULT_COPY_SIZE
+ ));
private static final Collection<Integer> BLOCK_SIZES =
- Collections.unmodifiableList(
- Arrays.asList(
- 0,
- SftpConstants.MIN_CHKFILE_BLOCKSIZE,
- 1024,
- IoUtils.DEFAULT_COPY_SIZE
- ));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ 0,
+ SftpConstants.MIN_CHKFILE_BLOCKSIZE,
+ 1024,
+ IoUtils.DEFAULT_COPY_SIZE
+ ));
private static final Collection<Object[]> PARAMETERS;

static {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtensionTest.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtensionTest.java b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtensionTest.java
index c195f15..2393026 100644
--- a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtensionTest.java
+++ b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtensionTest.java
@@ -64,13 +64,13 @@ import org.junit.runners.Parameterized.UseParametersRunnerFactory;
@UseParametersRunnerFactory(JUnit4ClassRunnerWithParametersFactory.class)
public class AbstractMD5HashExtensionTest extends AbstractSftpClientTestSupport {
private static final List<Integer> DATA_SIZES =
- Collections.unmodifiableList(
- Arrays.asList(
- (int) Byte.MAX_VALUE,
- SftpConstants.MD5_QUICK_HASH_SIZE,
- IoUtils.DEFAULT_COPY_SIZE,
- Byte.SIZE * IoUtils.DEFAULT_COPY_SIZE
- ));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ (int) Byte.MAX_VALUE,
+ SftpConstants.MD5_QUICK_HASH_SIZE,
+ IoUtils.DEFAULT_COPY_SIZE,
+ Byte.SIZE * IoUtils.DEFAULT_COPY_SIZE
+ ));

private final int size;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImplTest.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImplTest.java b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImplTest.java
index 6b78607..2b928d4 100644
--- a/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImplTest.java
+++ b/sshd-sftp/src/test/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImplTest.java
@@ -62,33 +62,33 @@ import org.junit.runners.Parameterized.UseParametersRunnerFactory;
@UseParametersRunnerFactory(JUnit4ClassRunnerWithParametersFactory.class)
public class CopyDataExtensionImplTest extends AbstractSftpClientTestSupport {
private static final List<Object[]> PARAMETERS =
- Collections.unmodifiableList(
- Arrays.asList(
- new Object[]{
- Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE),
- Integer.valueOf(0),
- Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE),
- Long.valueOf(0L)
- },
- new Object[]{
- Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE),
- Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE / 2),
- Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE / 4),
- Long.valueOf(0L)
- },
- new Object[]{
- Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE),
- Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE / 2),
- Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE / 4),
- Long.valueOf(IoUtils.DEFAULT_COPY_SIZE / 2)
- },
- new Object[]{
- Integer.valueOf(Byte.MAX_VALUE),
- Integer.valueOf(Byte.MAX_VALUE / 2),
- Integer.valueOf(Byte.MAX_VALUE), // attempt to read more than available
- Long.valueOf(0L)
- }
- ));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ new Object[]{
+ Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE),
+ Integer.valueOf(0),
+ Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE),
+ Long.valueOf(0L)
+ },
+ new Object[]{
+ Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE),
+ Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE / 2),
+ Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE / 4),
+ Long.valueOf(0L)
+ },
+ new Object[]{
+ Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE),
+ Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE / 2),
+ Integer.valueOf(IoUtils.DEFAULT_COPY_SIZE / 4),
+ Long.valueOf(IoUtils.DEFAULT_COPY_SIZE / 2)
+ },
+ new Object[]{
+ Integer.valueOf(Byte.MAX_VALUE),
+ Integer.valueOf(Byte.MAX_VALUE / 2),
+ Integer.valueOf(Byte.MAX_VALUE), // attempt to read more than available
+ Long.valueOf(0L)
+ }
+ ));

private int size;
private int srcOffset;
l***@apache.org
2018-10-25 09:11:00 UTC
Permalink
[SSHD-842] Moved a few more common classes to sshd-common artifact


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/98ac7c2c
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/98ac7c2c
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/98ac7c2c

Branch: refs/heads/master
Commit: 98ac7c2c23535658a17f20d95cfcbddb348b1ef6
Parents: 612ee38
Author: Lyor Goldstein <***@apache.org>
Authored: Thu Oct 25 09:45:25 2018 +0300
Committer: Lyor Goldstein <***@apache.org>
Committed: Thu Oct 25 12:10:49 2018 +0300

----------------------------------------------------------------------
.../sshd/common/file/FileSystemAware.java | 35 ++
.../sshd/common/file/root/RootedFileSystem.java | 101 ++++
.../file/root/RootedFileSystemProvider.java | 504 +++++++++++++++++
.../sshd/common/file/root/RootedPath.java | 58 ++
.../sshd/common/file/util/BaseFileSystem.java | 256 +++++++++
.../apache/sshd/common/file/util/BasePath.java | 423 ++++++++++++++
.../sshd/common/file/util/MockFileSystem.java | 114 ++++
.../apache/sshd/common/file/util/MockPath.java | 186 +++++++
.../sshd/common/file/root/AssertableFile.java | 72 +++
.../file/root/RootedFileSystemProviderTest.java | 334 +++++++++++
.../sshd/common/file/util/BasePathTest.java | 548 ++++++++++++++++++
.../sshd/common/file/FileSystemAware.java | 35 --
.../sshd/common/file/root/RootedFileSystem.java | 101 ----
.../file/root/RootedFileSystemProvider.java | 504 -----------------
.../sshd/common/file/root/RootedPath.java | 58 --
.../sshd/common/file/util/BaseFileSystem.java | 256 ---------
.../apache/sshd/common/file/util/BasePath.java | 423 --------------
.../sshd/common/file/util/MockFileSystem.java | 114 ----
.../apache/sshd/common/file/util/MockPath.java | 186 -------
.../sshd/common/file/root/AssertableFile.java | 72 ---
.../file/root/RootedFileSystemProviderTest.java | 334 -----------
.../sshd/common/file/util/BasePathTest.java | 553 -------------------
22 files changed, 2631 insertions(+), 2636 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-common/src/main/java/org/apache/sshd/common/file/FileSystemAware.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/file/FileSystemAware.java b/sshd-common/src/main/java/org/apache/sshd/common/file/FileSystemAware.java
new file mode 100644
index 0000000..e73c37d
--- /dev/null
+++ b/sshd-common/src/main/java/org/apache/sshd/common/file/FileSystemAware.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.file;
+
+import java.nio.file.FileSystem;
+
+/**
+ * Interface that can be implemented by a command to be able to access the
+ * file system in which this command will be used.
+ */
+@FunctionalInterface
+public interface FileSystemAware {
+ /**
+ * Set the file system in which this shell will be executed.
+ *
+ * @param fileSystem the file system
+ */
+ void setFileSystem(FileSystem fileSystem);
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedFileSystem.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedFileSystem.java b/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedFileSystem.java
new file mode 100644
index 0000000..1b9a71c
--- /dev/null
+++ b/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedFileSystem.java
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.file.root;
+
+import java.io.IOException;
+import java.nio.file.FileStore;
+import java.nio.file.FileSystem;
+import java.nio.file.Path;
+import java.nio.file.attribute.UserPrincipalLookupService;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+import org.apache.sshd.common.file.util.BaseFileSystem;
+
+/**
+ * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class RootedFileSystem extends BaseFileSystem<RootedPath> {
+
+ private final Path rootPath;
+ private final FileSystem rootFs;
+
+ public RootedFileSystem(RootedFileSystemProvider fileSystemProvider, Path root, Map<String, ?> env) {
+ super(fileSystemProvider);
+ this.rootPath = Objects.requireNonNull(root, "No root path");
+ this.rootFs = root.getFileSystem();
+ }
+
+ public FileSystem getRootFileSystem() {
+ return rootFs;
+ }
+
+ public Path getRoot() {
+ return rootPath;
+ }
+
+ @Override
+ public RootedFileSystemProvider provider() {
+ return (RootedFileSystemProvider) super.provider();
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (log.isDebugEnabled()) {
+ log.debug("close({})", this);
+ }
+ }
+
+ @Override
+ public boolean isOpen() {
+ return rootFs.isOpen();
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return rootFs.isReadOnly();
+ }
+
+ @Override
+ public Set<String> supportedFileAttributeViews() {
+ return rootFs.supportedFileAttributeViews();
+ }
+
+ @Override
+ public UserPrincipalLookupService getUserPrincipalLookupService() {
+ return rootFs.getUserPrincipalLookupService();
+ }
+
+ @Override
+ protected RootedPath create(String root, List<String> names) {
+ return new RootedPath(this, root, names);
+ }
+
+ @Override
+ public Iterable<FileStore> getFileStores() {
+ return rootFs.getFileStores();
+ }
+
+ @Override
+ public String toString() {
+ return rootPath.toString();
+ }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java b/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
new file mode 100644
index 0000000..8765f47
--- /dev/null
+++ b/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
@@ -0,0 +1,504 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.file.root;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.channels.AsynchronousFileChannel;
+import java.nio.channels.FileChannel;
+import java.nio.channels.SeekableByteChannel;
+import java.nio.file.AccessMode;
+import java.nio.file.CopyOption;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileStore;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystemAlreadyExistsException;
+import java.nio.file.FileSystemNotFoundException;
+import java.nio.file.Files;
+import java.nio.file.InvalidPathException;
+import java.nio.file.LinkOption;
+import java.nio.file.OpenOption;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.ProviderMismatchException;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.FileAttributeView;
+import java.nio.file.spi.FileSystemProvider;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+
+import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.common.util.io.IoUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * File system provider which provides a rooted file system.
+ * The file system only gives access to files under the root directory.
+ *
+ * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class RootedFileSystemProvider extends FileSystemProvider {
+ protected final Logger log;
+ private final Map<Path, RootedFileSystem> fileSystems = new HashMap<>();
+
+ public RootedFileSystemProvider() {
+ log = LoggerFactory.getLogger(getClass());
+ }
+
+ @Override
+ public String getScheme() {
+ return "root";
+ }
+
+ @Override
+ public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException {
+ return newFileSystem(uri, uriToPath(uri), env);
+ }
+
+ @Override
+ public FileSystem getFileSystem(URI uri) {
+ return getFileSystem(uriToPath(uri));
+ }
+
+ @Override
+ public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException {
+ return newFileSystem(path, path, env);
+ }
+
+ protected FileSystem newFileSystem(Object src, Path path, Map<String, ?> env) throws IOException {
+ Path root = ensureDirectory(path).toRealPath();
+ RootedFileSystem rootedFs = null;
+ synchronized (fileSystems) {
+ if (!this.fileSystems.containsKey(root)) {
+ rootedFs = new RootedFileSystem(this, path, env);
+ this.fileSystems.put(root, rootedFs);
+ }
+ }
+
+ // do all the throwing outside the synchronized block to minimize its lock time
+ if (rootedFs == null) {
+ throw new FileSystemAlreadyExistsException("newFileSystem(" + src + ") already mapped " + root);
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace("newFileSystem({}): {}", src, rootedFs);
+ }
+
+ return rootedFs;
+ }
+
+ protected Path uriToPath(URI uri) {
+ String scheme = uri.getScheme();
+ String expected = getScheme();
+ if ((scheme == null) || (!scheme.equalsIgnoreCase(expected))) {
+ throw new IllegalArgumentException("URI scheme (" + scheme + ") is not '" + expected + "'");
+ }
+
+ String root = uri.getRawSchemeSpecificPart();
+ int i = root.indexOf("!/");
+ if (i != -1) {
+ root = root.substring(0, i);
+ }
+
+ try {
+ return Paths.get(new URI(root)).toAbsolutePath();
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(root + ": " + e.getMessage(), e);
+ }
+ }
+
+ private static Path ensureDirectory(Path path) {
+ return IoUtils.ensureDirectory(path, IoUtils.getLinkOptions(true));
+ }
+
+ @Override
+ public Path getPath(URI uri) {
+ String str = uri.getSchemeSpecificPart();
+ int i = str.indexOf("!/");
+ if (i == -1) {
+ throw new IllegalArgumentException("URI: " + uri + " does not contain path info - e.g., root:file://foo/bar!/");
+ }
+
+ FileSystem fs = getFileSystem(uri);
+ String subPath = str.substring(i + 1);
+ Path p = fs.getPath(subPath);
+ if (log.isTraceEnabled()) {
+ log.trace("getPath({}): {}", uri, p);
+ }
+ return p;
+ }
+
+ @Override
+ public InputStream newInputStream(Path path, OpenOption... options) throws IOException {
+ Path r = unroot(path);
+ FileSystemProvider p = provider(r);
+ return p.newInputStream(r, options);
+ }
+
+ @Override
+ public OutputStream newOutputStream(Path path, OpenOption... options) throws IOException {
+ Path r = unroot(path);
+ FileSystemProvider p = provider(r);
+ return p.newOutputStream(r, options);
+ }
+
+ @Override
+ public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
+ Path r = unroot(path);
+ FileSystemProvider p = provider(r);
+ return p.newFileChannel(r, options, attrs);
+ }
+
+ @Override
+ public AsynchronousFileChannel newAsynchronousFileChannel(
+ Path path, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs)
+ throws IOException {
+ Path r = unroot(path);
+ FileSystemProvider p = provider(r);
+ return p.newAsynchronousFileChannel(r, options, executor, attrs);
+ }
+
+ @Override
+ public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
+ Path r = unroot(path);
+ FileSystemProvider p = provider(r);
+ return p.newByteChannel(r, options, attrs);
+ }
+
+ @Override
+ public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException {
+ Path r = unroot(dir);
+ FileSystemProvider p = provider(r);
+ return root(((RootedPath) dir).getFileSystem(), p.newDirectoryStream(r, filter));
+ }
+
+ protected DirectoryStream<Path> root(RootedFileSystem rfs, DirectoryStream<Path> ds) {
+ return new DirectoryStream<Path>() {
+ @Override
+ public Iterator<Path> iterator() {
+ return root(rfs, ds.iterator());
+ }
+
+ @Override
+ public void close() throws IOException {
+ ds.close();
+ }
+ };
+ }
+
+ protected Iterator<Path> root(RootedFileSystem rfs, Iterator<Path> iter) {
+ return new Iterator<Path>() {
+ @Override
+ public boolean hasNext() {
+ return iter.hasNext();
+ }
+
+ @Override
+ public Path next() {
+ return root(rfs, iter.next());
+ }
+ };
+ }
+
+ @Override
+ public void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOException {
+ Path r = unroot(dir);
+ FileSystemProvider p = provider(r);
+ p.createDirectory(r, attrs);
+ }
+
+ @Override
+ public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException {
+ createLink(link, target, true, attrs);
+ }
+
+ @Override
+ public void createLink(Path link, Path existing) throws IOException {
+ createLink(link, existing, false);
+ }
+
+ protected void createLink(Path link, Path target, boolean symLink, FileAttribute<?>... attrs) throws IOException {
+ Path l = unroot(link);
+ Path t = unroot(target);
+ /*
+ * For a symbolic link preserve the relative path
+ */
+ if (symLink && (!target.isAbsolute())) {
+ RootedFileSystem rfs = ((RootedPath) target).getFileSystem();
+ Path root = rfs.getRoot();
+ t = root.relativize(t);
+ }
+
+ FileSystemProvider p = provider(l);
+ if (symLink) {
+ p.createSymbolicLink(l, t, attrs);
+ } else {
+ p.createLink(l, t);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("createLink(symbolic={}) {} => {}", symLink, l, t);
+ }
+ }
+
+ @Override
+ public void delete(Path path) throws IOException {
+ Path r = unroot(path);
+ if (log.isTraceEnabled()) {
+ log.trace("delete({}): {}", path, r);
+ }
+ FileSystemProvider p = provider(r);
+ p.delete(r);
+ }
+
+ @Override
+ public boolean deleteIfExists(Path path) throws IOException {
+ Path r = unroot(path);
+ if (log.isTraceEnabled()) {
+ log.trace("deleteIfExists({}): {}", path, r);
+ }
+ FileSystemProvider p = provider(r);
+ return p.deleteIfExists(r);
+ }
+
+ @Override
+ public Path readSymbolicLink(Path link) throws IOException {
+ Path r = unroot(link);
+ FileSystemProvider p = provider(r);
+ Path t = p.readSymbolicLink(r);
+ Path target = root((RootedFileSystem) link.getFileSystem(), t);
+ if (log.isTraceEnabled()) {
+ log.trace("readSymbolicLink({})[{}]: {}[{}]", link, r, target, t);
+ }
+ return target;
+ }
+
+ @Override
+ public void copy(Path source, Path target, CopyOption... options) throws IOException {
+ Path s = unroot(source);
+ Path t = unroot(target);
+ if (log.isTraceEnabled()) {
+ log.trace("copy({})[{}]: {}[{}]", source, s, target, t);
+ }
+ FileSystemProvider p = provider(s);
+ p.copy(s, t, options);
+ }
+
+ @Override
+ public void move(Path source, Path target, CopyOption... options) throws IOException {
+ Path s = unroot(source);
+ Path t = unroot(target);
+ if (log.isTraceEnabled()) {
+ log.trace("move({})[{}]: {}[{}]", source, s, target, t);
+ }
+ FileSystemProvider p = provider(s);
+ p.move(s, t, options);
+ }
+
+ @Override
+ public boolean isSameFile(Path path, Path path2) throws IOException {
+ Path r = unroot(path);
+ Path r2 = unroot(path2);
+ FileSystemProvider p = provider(r);
+ return p.isSameFile(r, r2);
+ }
+
+ @Override
+ public boolean isHidden(Path path) throws IOException {
+ Path r = unroot(path);
+ FileSystemProvider p = provider(r);
+ return p.isHidden(r);
+ }
+
+ @Override
+ public FileStore getFileStore(Path path) throws IOException {
+ RootedFileSystem fileSystem = getFileSystem(path);
+ Path root = fileSystem.getRoot();
+ return Files.getFileStore(root);
+ }
+
+ protected RootedFileSystem getFileSystem(Path path) throws FileSystemNotFoundException {
+ Path real = unroot(path);
+ Path rootInstance = null;
+ RootedFileSystem fsInstance = null;
+ synchronized (fileSystems) {
+ // Cannot use forEach because the referenced variable are not effectively final
+ for (Map.Entry<Path, RootedFileSystem> fse : fileSystems.entrySet()) {
+ Path root = fse.getKey();
+ RootedFileSystem fs = fse.getValue();
+ if (real.equals(root)) {
+ return fs; // we were lucky to have the root
+ }
+
+ if (!real.startsWith(root)) {
+ continue;
+ }
+
+ // if already have a candidate prefer the longer match since both are prefixes of the real path
+ if ((rootInstance == null) || (rootInstance.getNameCount() < root.getNameCount())) {
+ rootInstance = root;
+ fsInstance = fs;
+ }
+ }
+ }
+
+ if (fsInstance == null) {
+ throw new FileSystemNotFoundException(path.toString());
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace("getFileSystem({}): {}", path, fsInstance);
+ }
+
+ return fsInstance;
+ }
+
+ @Override
+ public void checkAccess(Path path, AccessMode... modes) throws IOException {
+ Path r = unroot(path);
+ FileSystemProvider p = provider(r);
+ p.checkAccess(r, modes);
+ }
+
+ @Override
+ public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
+ Path r = unroot(path);
+ FileSystemProvider p = provider(r);
+ return p.getFileAttributeView(r, type, options);
+ }
+
+ @Override
+ public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException {
+ Path r = unroot(path);
+ if (log.isTraceEnabled()) {
+ log.trace("readAttributes({})[{}] type={}", path, r, type.getSimpleName());
+ }
+
+ FileSystemProvider p = provider(r);
+ return p.readAttributes(r, type, options);
+ }
+
+ @Override
+ public Map<String, Object> readAttributes(Path path, String attributes, LinkOption... options) throws IOException {
+ Path r = unroot(path);
+ FileSystemProvider p = provider(r);
+ Map<String, Object> attrs = p.readAttributes(r, attributes, options);
+ if (log.isTraceEnabled()) {
+ log.trace("readAttributes({})[{}] {}: {}", path, r, attributes, attrs);
+ }
+ return attrs;
+ }
+
+ @Override
+ public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException {
+ Path r = unroot(path);
+ if (log.isTraceEnabled()) {
+ log.trace("setAttribute({})[{}] {}={}", path, r, attribute, value);
+ }
+ FileSystemProvider p = provider(r);
+ p.setAttribute(r, attribute, value, options);
+ }
+
+ protected FileSystemProvider provider(Path path) {
+ FileSystem fs = path.getFileSystem();
+ return fs.provider();
+ }
+
+ protected Path root(RootedFileSystem rfs, Path nat) {
+ if (nat.isAbsolute()) {
+ Path root = rfs.getRoot();
+ Path rel = root.relativize(nat);
+ return rfs.getPath("/" + rel.toString());
+ } else {
+ return rfs.getPath(nat.toString());
+ }
+ }
+
+ /**
+ * @param path The original (rooted) {@link Path}
+ * @return The actual <U>absolute <B>local</B></U> {@link Path} represented
+ * by the rooted one
+ * @see #resolveLocalPath(RootedPath)
+ * @throws IllegalArgumentException if {@code null} path argument
+ * @throws ProviderMismatchException if not a {@link RootedPath}
+ */
+ protected Path unroot(Path path) {
+ Objects.requireNonNull(path, "No path to unroot");
+ if (!(path instanceof RootedPath)) {
+ throw new ProviderMismatchException("unroot(" + path + ") is not a " + RootedPath.class.getSimpleName()
+ + " but rather a " + path.getClass().getSimpleName());
+ }
+
+ return resolveLocalPath((RootedPath) path);
+ }
+
+ /**
+ * @param path The original {@link RootedPath} - never {@code null}
+ * @return The actual <U>absolute <B>local</B></U> {@link Path} represented
+ * by the rooted one
+ * @throws InvalidPathException If the resolved path is not a proper sub-path
+ * of the rooted file system
+ */
+ protected Path resolveLocalPath(RootedPath path) {
+ RootedPath absPath = Objects.requireNonNull(path, "No rooted path to resolve").toAbsolutePath();
+ RootedFileSystem rfs = absPath.getFileSystem();
+ Path root = rfs.getRoot();
+ FileSystem lfs = root.getFileSystem();
+
+ String rSep = ValidateUtils.checkNotNullAndNotEmpty(rfs.getSeparator(), "No rooted file system separator");
+ ValidateUtils.checkTrue(rSep.length() == 1, "Bad rooted file system separator: %s", rSep);
+ char rootedSeparator = rSep.charAt(0);
+
+ String lSep = ValidateUtils.checkNotNullAndNotEmpty(lfs.getSeparator(), "No local file system separator");
+ ValidateUtils.checkTrue(lSep.length() == 1, "Bad local file system separator: %s", lSep);
+ char localSeparator = lSep.charAt(0);
+
+ String r = absPath.toString();
+ String subPath = r.substring(1);
+ if (rootedSeparator != localSeparator) {
+ subPath = subPath.replace(rootedSeparator, localSeparator);
+ }
+
+ Path resolved = root.resolve(subPath);
+ resolved = resolved.normalize();
+ resolved = resolved.toAbsolutePath();
+ if (log.isTraceEnabled()) {
+ log.trace("resolveLocalPath({}): {}", absPath, resolved);
+ }
+
+ /*
+ * This can happen for Windows since we represent its paths as /C:/some/path,
+ * so substring(1) yields C:/some/path - which is resolved as an absolute path
+ * (which we don't want).
+ */
+ if (!resolved.startsWith(root)) {
+ throw new InvalidPathException(r, "Not under root");
+ }
+ return resolved;
+ }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedPath.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedPath.java b/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedPath.java
new file mode 100644
index 0000000..e708aed
--- /dev/null
+++ b/sshd-common/src/main/java/org/apache/sshd/common/file/root/RootedPath.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.file.root;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.FileSystem;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.nio.file.spi.FileSystemProvider;
+import java.util.List;
+
+import org.apache.sshd.common.file.util.BasePath;
+
+/**
+ * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class RootedPath extends BasePath<RootedPath, RootedFileSystem> {
+ public RootedPath(RootedFileSystem fileSystem, String root, List<String> names) {
+ super(fileSystem, root, names);
+ }
+
+ @Override
+ public File toFile() {
+ RootedPath absolute = toAbsolutePath();
+ RootedFileSystem fs = getFileSystem();
+ Path path = fs.getRoot();
+ for (String n : absolute.names) {
+ path = path.resolve(n);
+ }
+ return path.toFile();
+ }
+
+ @Override
+ public RootedPath toRealPath(LinkOption... options) throws IOException {
+ RootedPath absolute = toAbsolutePath();
+ FileSystem fs = getFileSystem();
+ FileSystemProvider provider = fs.provider();
+ provider.checkAccess(absolute);
+ return absolute;
+ }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-common/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java b/sshd-common/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
new file mode 100644
index 0000000..6287ce1
--- /dev/null
+++ b/sshd-common/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.file.util;
+
+import java.io.IOException;
+import java.nio.file.FileStore;
+import java.nio.file.FileSystem;
+import java.nio.file.Path;
+import java.nio.file.PathMatcher;
+import java.nio.file.WatchService;
+import java.nio.file.spi.FileSystemProvider;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.sshd.common.util.GenericUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class BaseFileSystem<T extends Path> extends FileSystem {
+ protected final Logger log;
+ private final FileSystemProvider fileSystemProvider;
+
+ public BaseFileSystem(FileSystemProvider fileSystemProvider) {
+ this.log = LoggerFactory.getLogger(getClass());
+ this.fileSystemProvider = Objects.requireNonNull(fileSystemProvider, "No file system provider");
+ }
+
+ public T getDefaultDir() {
+ return getPath("/");
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return false;
+ }
+
+ @Override
+ public FileSystemProvider provider() {
+ return fileSystemProvider;
+ }
+
+ @Override
+ public String getSeparator() {
+ return "/";
+ }
+
+ @Override
+ public Iterable<Path> getRootDirectories() {
+ return Collections.singleton(create("/"));
+ }
+
+ @Override
+ public Iterable<FileStore> getFileStores() {
+ throw new UnsupportedOperationException("No file stores available");
+ }
+
+ @Override
+ public T getPath(String first, String... more) {
+ StringBuilder sb = new StringBuilder();
+ if (!GenericUtils.isEmpty(first)) {
+ appendDedupSep(sb, first.replace('\\', '/')); // in case we are running on Windows
+ }
+
+ if (GenericUtils.length(more) > 0) {
+ for (String segment : more) {
+ if ((sb.length() > 0) && (sb.charAt(sb.length() - 1) != '/')) {
+ sb.append('/');
+ }
+ // in case we are running on Windows
+ appendDedupSep(sb, segment.replace('\\', '/'));
+ }
+ }
+
+ if ((sb.length() > 1) && (sb.charAt(sb.length() - 1) == '/')) {
+ sb.setLength(sb.length() - 1);
+ }
+
+ String path = sb.toString();
+ String root = null;
+ if (path.startsWith("/")) {
+ root = "/";
+ path = path.substring(1);
+ }
+
+ String[] names = GenericUtils.split(path, '/');
+ T p = create(root, names);
+ if (log.isTraceEnabled()) {
+ log.trace("getPath({}, {}): {}", first, Arrays.toString(more), p);
+ }
+
+ return p;
+ }
+
+ protected void appendDedupSep(StringBuilder sb, CharSequence s) {
+ for (int i = 0; i < s.length(); i++) {
+ char ch = s.charAt(i);
+ if ((ch != '/') || (sb.length() == 0) || (sb.charAt(sb.length() - 1) != '/')) {
+ sb.append(ch);
+ }
+ }
+ }
+
+ @Override
+ public PathMatcher getPathMatcher(String syntaxAndPattern) {
+ int colonIndex = Objects.requireNonNull(syntaxAndPattern, "No argument").indexOf(':');
+ if ((colonIndex <= 0) || (colonIndex == syntaxAndPattern.length() - 1)) {
+ throw new IllegalArgumentException("syntaxAndPattern must have form \"syntax:pattern\" but was \"" + syntaxAndPattern + "\"");
+ }
+
+ String syntax = syntaxAndPattern.substring(0, colonIndex);
+ String pattern = syntaxAndPattern.substring(colonIndex + 1);
+ String expr;
+ switch (syntax) {
+ case "glob":
+ expr = globToRegex(pattern);
+ break;
+ case "regex":
+ expr = pattern;
+ break;
+ default:
+ throw new UnsupportedOperationException("Unsupported path matcher syntax: \'" + syntax + "\'");
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("getPathMatcher({}): {}", syntaxAndPattern, expr);
+ }
+
+ Pattern regex = Pattern.compile(expr);
+ return path -> {
+ Matcher m = regex.matcher(path.toString());
+ return m.matches();
+ };
+ }
+
+ protected String globToRegex(String pattern) {
+ StringBuilder sb = new StringBuilder(Objects.requireNonNull(pattern, "No pattern").length());
+ int inGroup = 0;
+ int inClass = 0;
+ int firstIndexInClass = -1;
+ char[] arr = pattern.toCharArray();
+ for (int i = 0; i < arr.length; i++) {
+ char ch = arr[i];
+ switch (ch) {
+ case '\\':
+ i++;
+ if (i >= arr.length) {
+ sb.append('\\');
+ } else {
+ char next = arr[i];
+ switch (next) {
+ case ',':
+ // escape not needed
+ break;
+ case 'Q':
+ case 'E':
+ // extra escape needed
+ sb.append("\\\\");
+ break;
+ default:
+ sb.append('\\');
+ break;
+ }
+ sb.append(next);
+ }
+ break;
+ case '*':
+ sb.append((inClass == 0) ? ".*" : "*");
+ break;
+ case '?':
+ sb.append((inClass == 0) ? '.' : '?');
+ break;
+ case '[':
+ inClass++;
+ firstIndexInClass = i + 1;
+ sb.append('[');
+ break;
+ case ']':
+ inClass--;
+ sb.append(']');
+ break;
+ case '.':
+ case '(':
+ case ')':
+ case '+':
+ case '|':
+ case '^':
+ case '$':
+ case '@':
+ case '%':
+ if ((inClass == 0) || ((firstIndexInClass == i) && (ch == '^'))) {
+ sb.append('\\');
+ }
+ sb.append(ch);
+ break;
+ case '!':
+ sb.append((firstIndexInClass == i) ? '^' : '!');
+ break;
+ case '{':
+ inGroup++;
+ sb.append('(');
+ break;
+ case '}':
+ inGroup--;
+ sb.append(')');
+ break;
+ case ',':
+ sb.append((inGroup > 0) ? '|' : ',');
+ break;
+ default:
+ sb.append(ch);
+ }
+ }
+
+ String regex = sb.toString();
+ if (log.isTraceEnabled()) {
+ log.trace("globToRegex({}): {}", pattern, regex);
+ }
+
+ return regex;
+ }
+
+ @Override
+ public WatchService newWatchService() throws IOException {
+ throw new UnsupportedOperationException("Watch service N/A");
+ }
+
+ protected T create(String root, String... names) {
+ return create(root, GenericUtils.unmodifiableList(names));
+ }
+
+ protected T create(String root, Collection<String> names) {
+ return create(root, GenericUtils.unmodifiableList(names));
+ }
+
+ protected abstract T create(String root, List<String> names);
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-common/src/main/java/org/apache/sshd/common/file/util/BasePath.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/file/util/BasePath.java b/sshd-common/src/main/java/org/apache/sshd/common/file/util/BasePath.java
new file mode 100644
index 0000000..d073548
--- /dev/null
+++ b/sshd-common/src/main/java/org/apache/sshd/common/file/util/BasePath.java
@@ -0,0 +1,423 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.file.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.FileSystem;
+import java.nio.file.Path;
+import java.nio.file.ProviderMismatchException;
+import java.nio.file.WatchEvent;
+import java.nio.file.WatchKey;
+import java.nio.file.WatchService;
+import java.util.AbstractList;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+
+import org.apache.sshd.common.util.GenericUtils;
+
+public abstract class BasePath<T extends BasePath<T, FS>, FS extends BaseFileSystem<T>> implements Path {
+
+ protected final String root;
+ protected final List<String> names;
+ private final FS fileSystem;
+ private String strValue;
+ private int hashValue;
+
+ public BasePath(FS fileSystem, String root, List<String> names) {
+ this.fileSystem = Objects.requireNonNull(fileSystem, "No file system provided");
+ this.root = root;
+ this.names = names;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected T asT() {
+ return (T) this;
+ }
+
+ protected T create(String root, String... names) {
+ return create(root, GenericUtils.unmodifiableList(names));
+ }
+
+ protected T create(String root, Collection<String> names) {
+ return create(root, GenericUtils.unmodifiableList(names));
+ }
+
+ protected T create(String root, List<String> names) {
+ return fileSystem.create(root, names);
+ }
+
+ @Override
+ public FS getFileSystem() {
+ return fileSystem;
+ }
+
+ @Override
+ public boolean isAbsolute() {
+ return root != null;
+ }
+
+ @Override
+ public T getRoot() {
+ if (isAbsolute()) {
+ return create(root);
+ }
+ return null;
+ }
+
+ @Override
+ public T getFileName() {
+ if (!names.isEmpty()) {
+ return create(null, names.get(names.size() - 1));
+ }
+ return null;
+ }
+
+ @Override
+ public T getParent() {
+ if (names.isEmpty() || ((names.size() == 1) && (root == null))) {
+ return null;
+ }
+ return create(root, names.subList(0, names.size() - 1));
+ }
+
+ @Override
+ public int getNameCount() {
+ return names.size();
+ }
+
+ @Override
+ public T getName(int index) {
+ int maxIndex = getNameCount();
+ if ((index < 0) || (index >= maxIndex)) {
+ throw new IllegalArgumentException("Invalid name index " + index + " - not in range [0-" + maxIndex + "]");
+ }
+ return create(null, names.subList(index, index + 1));
+ }
+
+ @Override
+ public T subpath(int beginIndex, int endIndex) {
+ int maxIndex = getNameCount();
+ if ((beginIndex < 0) || (beginIndex >= maxIndex) || (endIndex > maxIndex) || (beginIndex >= endIndex)) {
+ throw new IllegalArgumentException("subpath(" + beginIndex + "," + endIndex + ") bad index range - allowed [0-" + maxIndex + "]");
+ }
+ return create(null, names.subList(beginIndex, endIndex));
+ }
+
+ protected boolean startsWith(List<?> list, List<?> other) {
+ return list.size() >= other.size() && list.subList(0, other.size()).equals(other);
+ }
+
+ @Override
+ public boolean startsWith(Path other) {
+ T p1 = asT();
+ T p2 = checkPath(other);
+ return Objects.equals(p1.getFileSystem(), p2.getFileSystem())
+ && Objects.equals(p1.root, p2.root)
+ && startsWith(p1.names, p2.names);
+ }
+
+ @Override
+ public boolean startsWith(String other) {
+ return startsWith(getFileSystem().getPath(other));
+ }
+
+ protected boolean endsWith(List<?> list, List<?> other) {
+ return other.size() <= list.size() && list.subList(list.size() - other.size(), list.size()).equals(other);
+ }
+
+ @Override
+ public boolean endsWith(Path other) {
+ T p1 = asT();
+ T p2 = checkPath(other);
+ if (p2.isAbsolute()) {
+ return p1.compareTo(p2) == 0;
+ }
+ return endsWith(p1.names, p2.names);
+ }
+
+ @Override
+ public boolean endsWith(String other) {
+ return endsWith(getFileSystem().getPath(other));
+ }
+
+ protected boolean isNormal() {
+ int count = getNameCount();
+ if ((count == 0) || ((count == 1) && !isAbsolute())) {
+ return true;
+ }
+ boolean foundNonParentName = isAbsolute(); // if there's a root, the path doesn't start with ..
+ boolean normal = true;
+ for (String name : names) {
+ if (name.equals("..")) {
+ if (foundNonParentName) {
+ normal = false;
+ break;
+ }
+ } else {
+ if (name.equals(".")) {
+ normal = false;
+ break;
+ }
+ foundNonParentName = true;
+ }
+ }
+ return normal;
+ }
+
+ @Override
+ public T normalize() {
+ if (isNormal()) {
+ return asT();
+ }
+
+ Deque<String> newNames = new ArrayDeque<>();
+ for (String name : names) {
+ if (name.equals("..")) {
+ String lastName = newNames.peekLast();
+ if (lastName != null && !lastName.equals("..")) {
+ newNames.removeLast();
+ } else if (!isAbsolute()) {
+ // if there's a root and we have an extra ".." that would go up above the root, ignore it
+ newNames.add(name);
+ }
+ } else if (!name.equals(".")) {
+ newNames.add(name);
+ }
+ }
+
+ return newNames.equals(names) ? asT() : create(root, newNames);
+ }
+
+ @Override
+ public T resolve(Path other) {
+ T p1 = asT();
+ T p2 = checkPath(other);
+ if (p2.isAbsolute()) {
+ return p2;
+ }
+ if (p2.names.isEmpty()) {
+ return p1;
+ }
+ String[] names = new String[p1.names.size() + p2.names.size()];
+ int index = 0;
+ for (String p : p1.names) {
+ names[index++] = p;
+ }
+ for (String p : p2.names) {
+ names[index++] = p;
+ }
+ return create(p1.root, names);
+ }
+
+ @Override
+ public T resolve(String other) {
+ return resolve(getFileSystem().getPath(other, GenericUtils.EMPTY_STRING_ARRAY));
+ }
+
+ @Override
+ public Path resolveSibling(Path other) {
+ Objects.requireNonNull(other, "Missing sibling path argument");
+ T parent = getParent();
+ return parent == null ? other : parent.resolve(other);
+ }
+
+ @Override
+ public Path resolveSibling(String other) {
+ return resolveSibling(getFileSystem().getPath(other, GenericUtils.EMPTY_STRING_ARRAY));
+ }
+
+ @Override
+ public T relativize(Path other) {
+ T p1 = asT();
+ T p2 = checkPath(other);
+ if (!Objects.equals(p1.getRoot(), p2.getRoot())) {
+ throw new IllegalArgumentException("Paths have different roots: " + this + ", " + other);
+ }
+ if (p2.equals(p1)) {
+ return create(null);
+ }
+ if (p1.root == null && p1.names.isEmpty()) {
+ return p2;
+ }
+ // Common subsequence
+ int sharedSubsequenceLength = 0;
+ for (int i = 0; i < Math.min(p1.names.size(), p2.names.size()); i++) {
+ if (p1.names.get(i).equals(p2.names.get(i))) {
+ sharedSubsequenceLength++;
+ } else {
+ break;
+ }
+ }
+ int extraNamesInThis = Math.max(0, p1.names.size() - sharedSubsequenceLength);
+ List<String> extraNamesInOther = (p2.names.size() <= sharedSubsequenceLength)
+ ? Collections.emptyList()
+ : p2.names.subList(sharedSubsequenceLength, p2.names.size());
+ List<String> parts = new ArrayList<>(extraNamesInThis + extraNamesInOther.size());
+ // add .. for each extra name in this path
+ parts.addAll(Collections.nCopies(extraNamesInThis, ".."));
+ // add each extra name in the other path
+ parts.addAll(extraNamesInOther);
+ return create(null, parts);
+ }
+
+ @Override
+ public T toAbsolutePath() {
+ if (isAbsolute()) {
+ return asT();
+ }
+ return fileSystem.getDefaultDir().resolve(this);
+ }
+
+ @Override
+ public URI toUri() {
+ File file = toFile();
+ return file.toURI();
+ }
+
+ @Override
+ public File toFile() {
+ throw new UnsupportedOperationException("To file " + toAbsolutePath() + " N/A");
+ }
+
+ @Override
+ public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) throws IOException {
+ return register(watcher, events, (WatchEvent.Modifier[]) null);
+ }
+
+ @Override
+ public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException {
+ throw new UnsupportedOperationException("Register to watch " + toAbsolutePath() + " N/A");
+ }
+
+ @Override
+ public Iterator<Path> iterator() {
+ return new AbstractList<Path>() {
+ @Override
+ public Path get(int index) {
+ return getName(index);
+ }
+
+ @Override
+ public int size() {
+ return getNameCount();
+ }
+ }.iterator();
+ }
+
+ @Override
+ public int compareTo(Path paramPath) {
+ T p1 = asT();
+ T p2 = checkPath(paramPath);
+ int c = compare(p1.root, p2.root);
+ if (c != 0) {
+ return c;
+ }
+ for (int i = 0; i < Math.min(p1.names.size(), p2.names.size()); i++) {
+ String n1 = p1.names.get(i);
+ String n2 = p2.names.get(i);
+ c = compare(n1, n2);
+ if (c != 0) {
+ return c;
+ }
+ }
+ return p1.names.size() - p2.names.size();
+ }
+
+ protected int compare(String s1, String s2) {
+ if (s1 == null) {
+ return s2 == null ? 0 : -1;
+ } else {
+ return s2 == null ? +1 : s1.compareTo(s2);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected T checkPath(Path paramPath) {
+ Objects.requireNonNull(paramPath, "Missing path argument");
+ if (paramPath.getClass() != getClass()) {
+ throw new ProviderMismatchException("Path is not of this class: " + paramPath + "[" + paramPath.getClass().getSimpleName() + "]");
+ }
+ T t = (T) paramPath;
+
+ FileSystem fs = t.getFileSystem();
+ if (fs.provider() != this.fileSystem.provider()) {
+ throw new ProviderMismatchException("Mismatched providers for " + t);
+ }
+ return t;
+ }
+
+ @Override
+ public int hashCode() {
+ synchronized (this) {
+ if (hashValue == 0) {
+ hashValue = calculatedHashCode();
+ if (hashValue == 0) {
+ hashValue = 1;
+ }
+ }
+ }
+
+ return hashValue;
+ }
+
+ protected int calculatedHashCode() {
+ return Objects.hash(getFileSystem(), root, names);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return (obj instanceof Path) && (compareTo((Path) obj) == 0);
+ }
+
+ @Override
+ public String toString() {
+ synchronized (this) {
+ if (strValue == null) {
+ strValue = asString();
+ }
+ }
+
+ return strValue;
+ }
+
+ protected String asString() {
+ StringBuilder sb = new StringBuilder();
+ if (root != null) {
+ sb.append(root);
+ }
+
+ String separator = getFileSystem().getSeparator();
+ for (String name : names) {
+ if ((sb.length() > 0) && (sb.charAt(sb.length() - 1) != '/')) {
+ sb.append(separator);
+ }
+ sb.append(name);
+ }
+
+ return sb.toString();
+ }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-common/src/main/java/org/apache/sshd/common/file/util/MockFileSystem.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/file/util/MockFileSystem.java b/sshd-common/src/main/java/org/apache/sshd/common/file/util/MockFileSystem.java
new file mode 100644
index 0000000..9181c2d
--- /dev/null
+++ b/sshd-common/src/main/java/org/apache/sshd/common/file/util/MockFileSystem.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.file.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.FileStore;
+import java.nio.file.FileSystem;
+import java.nio.file.Path;
+import java.nio.file.PathMatcher;
+import java.nio.file.WatchService;
+import java.nio.file.attribute.UserPrincipalLookupService;
+import java.nio.file.spi.FileSystemProvider;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class MockFileSystem extends FileSystem {
+ private final AtomicBoolean open = new AtomicBoolean(true);
+ private final String name;
+
+ public MockFileSystem(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public FileSystemProvider provider() {
+ throw new UnsupportedOperationException("provider() N/A");
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (open.getAndSet(false)) {
+ //noinspection UnnecessaryReturnStatement
+ return; // debug breakpoint
+ }
+ }
+
+ @Override
+ public boolean isOpen() {
+ return open.get();
+ }
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
+
+ @Override
+ public String getSeparator() {
+ return File.separator;
+ }
+
+ @Override
+ public Iterable<Path> getRootDirectories() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public Iterable<FileStore> getFileStores() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public Set<String> supportedFileAttributeViews() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Path getPath(String first, String... more) {
+ throw new UnsupportedOperationException("getPath(" + first + ") " + Arrays.toString(more));
+ }
+
+ @Override
+ public PathMatcher getPathMatcher(String syntaxAndPattern) {
+ throw new UnsupportedOperationException("getPathMatcher(" + syntaxAndPattern + ")");
+ }
+
+ @Override
+ public UserPrincipalLookupService getUserPrincipalLookupService() {
+ throw new UnsupportedOperationException("getUserPrincipalLookupService() N/A");
+ }
+
+ @Override
+ public WatchService newWatchService() throws IOException {
+ throw new IOException("newWatchService() N/A");
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-common/src/main/java/org/apache/sshd/common/file/util/MockPath.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/file/util/MockPath.java b/sshd-common/src/main/java/org/apache/sshd/common/file/util/MockPath.java
new file mode 100644
index 0000000..2f781b8
--- /dev/null
+++ b/sshd-common/src/main/java/org/apache/sshd/common/file/util/MockPath.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.file.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.FileSystem;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.nio.file.WatchEvent.Kind;
+import java.nio.file.WatchEvent.Modifier;
+import java.nio.file.WatchKey;
+import java.nio.file.WatchService;
+import java.util.Collections;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class MockPath implements Path {
+ private final String path;
+ private final FileSystem fs;
+
+ public MockPath(String path) {
+ this.path = path;
+ this.fs = new MockFileSystem(path);
+ }
+
+ @Override
+ public FileSystem getFileSystem() {
+ return fs;
+ }
+
+ @Override
+ public boolean isAbsolute() {
+ return true;
+ }
+
+ @Override
+ public Path getRoot() {
+ return this;
+ }
+
+ @Override
+ public Path getFileName() {
+ return this;
+ }
+
+ @Override
+ public Path getParent() {
+ return null;
+ }
+
+ @Override
+ public int getNameCount() {
+ return 0;
+ }
+
+ @Override
+ public Path getName(int index) {
+ if (index == 0) {
+ return this;
+ } else {
+ throw new IllegalArgumentException("getName - bad index: " + index);
+ }
+ }
+
+ @Override
+ public Path subpath(int beginIndex, int endIndex) {
+ throw new UnsupportedOperationException("subPath(" + beginIndex + "," + endIndex + ") N/A");
+ }
+
+ @Override
+ public boolean startsWith(Path other) {
+ return startsWith(other.toString());
+ }
+
+ @Override
+ public boolean startsWith(String other) {
+ return path.startsWith(other);
+ }
+
+ @Override
+ public boolean endsWith(Path other) {
+ return endsWith(other.toString());
+ }
+
+ @Override
+ public boolean endsWith(String other) {
+ return path.endsWith(other);
+ }
+
+ @Override
+ public Path normalize() {
+ return this;
+ }
+
+ @Override
+ public Path resolve(Path other) {
+ return resolve(other.toString());
+ }
+
+ @Override
+ public Path resolve(String other) {
+ throw new UnsupportedOperationException("resolve(" + other + ") N/A");
+ }
+
+ @Override
+ public Path resolveSibling(Path other) {
+ return resolveSibling(other.toString());
+ }
+
+ @Override
+ public Path resolveSibling(String other) {
+ throw new UnsupportedOperationException("resolveSibling(" + other + ") N/A");
+ }
+
+ @Override
+ public Path relativize(Path other) {
+ throw new UnsupportedOperationException("relativize(" + other + ") N/A");
+ }
+
+ @Override
+ public URI toUri() {
+ throw new UnsupportedOperationException("toUri() N/A");
+ }
+
+ @Override
+ public Path toAbsolutePath() {
+ return this;
+ }
+
+ @Override
+ public Path toRealPath(LinkOption... options) throws IOException {
+ return this;
+ }
+
+ @Override
+ public File toFile() {
+ throw new UnsupportedOperationException("toFile() N/A");
+ }
+
+ @Override
+ public WatchKey register(WatchService watcher, Kind<?>... events) throws IOException {
+ return register(watcher, events, (Modifier[]) null);
+ }
+
+ @Override
+ public WatchKey register(WatchService watcher, Kind<?>[] events, Modifier... modifiers) throws IOException {
+ throw new IOException("register(" + path + ") N/A");
+ }
+
+ @Override
+ public Iterator<Path> iterator() {
+ return Collections.<Path>singleton(this).iterator();
+ }
+
+ @Override
+ public int compareTo(Path other) {
+ return path.compareTo(other.toString());
+ }
+
+ @Override
+ public String toString() {
+ return path;
+ }
+
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-common/src/test/java/org/apache/sshd/common/file/root/AssertableFile.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/test/java/org/apache/sshd/common/file/root/AssertableFile.java b/sshd-common/src/test/java/org/apache/sshd/common/file/root/AssertableFile.java
new file mode 100644
index 0000000..8ac531c
--- /dev/null
+++ b/sshd-common/src/test/java/org/apache/sshd/common/file/root/AssertableFile.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.file.root;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import org.apache.sshd.common.util.NumberUtils;
+import org.apache.sshd.util.test.JUnitTestSupport;
+
+/**
+ * TODO upgrade to default methods in JDK 8
+ * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public abstract class AssertableFile extends JUnitTestSupport {
+ protected AssertableFile() {
+ super();
+ }
+
+ public static boolean notExists(Path p) {
+ boolean cond = !Files.exists(p);
+ assertTrue(p + " does not exist", cond);
+ return cond;
+ }
+
+ public static boolean exists(Path p) {
+ boolean cond = Files.exists(p);
+ assertTrue(p + " exists", cond);
+ return cond;
+ }
+
+ public static boolean isDir(Path p) {
+ boolean cond = Files.isDirectory(p);
+ assertTrue(p + " is directory", cond);
+ return cond;
+ }
+
+ public static boolean isReadable(Path p) {
+ boolean cond = Files.isReadable(p);
+ assertTrue(p + " is readable by user", cond);
+ return cond;
+ }
+
+ public static boolean isNonEmpty(byte[] bytes) {
+ boolean cond = !NumberUtils.isEmpty(bytes);
+ assertTrue("bytes are non empty", cond);
+ return cond;
+ }
+
+ public static boolean isRootedAt(Path root, Path check) {
+ boolean cond = check.toAbsolutePath().normalize().startsWith(root.toAbsolutePath().normalize());
+ assertTrue(check + " is subpath of parent " + root, cond);
+ return cond;
+ }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-common/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java b/sshd-common/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java
new file mode 100644
index 0000000..db2f1be
--- /dev/null
+++ b/sshd-common/src/test/java/org/apache/sshd/common/file/root/RootedFileSystemProviderTest.java
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.file.root;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.Channel;
+import java.nio.channels.FileChannel;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileSystem;
+import java.nio.file.Files;
+import java.nio.file.InvalidPathException;
+import java.nio.file.OpenOption;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.StandardOpenOption;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Objects;
+import java.util.Random;
+import java.util.TreeSet;
+
+import org.apache.sshd.util.test.CommonTestSupportUtils;
+import org.apache.sshd.util.test.NoIoTestCase;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+
+/**
+ * Tests the RootedFileSystemProvider implementation of
+ * {@link java.nio.file.spi.FileSystemProvider} checking that permissions for
+ * generic FS commands are not permitted outside of the root directory.
+ *
+ * Individual tests are form pairs (e.g. testX, testXInvalid) where testXInvalid
+ * is expected to test a parent path of {@link RootedFileSystem#getRoot()}
+ * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@Category({ NoIoTestCase.class })
+public class RootedFileSystemProviderTest extends AssertableFile {
+ private static RootedFileSystem fileSystem;
+ private static Path rootSandbox;
+
+ public RootedFileSystemProviderTest() {
+ super();
+ }
+
+ @BeforeClass
+ public static void initializeFileSystem() throws IOException {
+ Path targetFolder = Objects.requireNonNull(
+ CommonTestSupportUtils.detectTargetFolder(RootedFileSystemProviderTest.class), "Failed to detect target folder");
+ rootSandbox = FileHelper.createTestSandbox(targetFolder.resolve(TEMP_SUBFOLDER_NAME));
+ fileSystem = (RootedFileSystem) new RootedFileSystemProvider().newFileSystem(rootSandbox, Collections.emptyMap());
+ }
+
+ @Test
+ public void testRoot() {
+ Path root = fileSystem.getRoot();
+ assertTrue("Exists? " + root, exists(root));
+ assertTrue("Dir? " + root, isDir(root));
+ assertTrue("Readable? " + root, isReadable(root));
+ assertTrue(root + " rooted at " + rootSandbox + " ?", isRootedAt(rootSandbox, root));
+ }
+
+ /* mkdir */
+ @Test
+ public void testMkdir() throws IOException {
+ Path created = FileHelper.createDirectory(fileSystem.getPath(getCurrentTestName()));
+ assertTrue(exists(created) && isDir(created) && isReadable(created));
+ }
+
+ @Test(expected = InvalidPathException.class)
+ public void testMkdirInvalid() throws IOException {
+ Path parent = FileHelper.createDirectory(fileSystem.getPath("../" + getCurrentTestName()));
+ fail(String.format("Unexpected success in creating directory %s", parent.toString()));
+ }
+
+ /* rmdir */
+ @Test
+ public void testRmdir() throws IOException {
+ Path created = FileHelper.createDirectory(fileSystem.getPath(getCurrentTestName()));
+ Path deleted = FileHelper.deleteDirectory(created);
+ notExists(deleted);
+ }
+
+ @Test(expected = InvalidPathException.class)
+ public void testRmdirInvalid() throws IOException {
+ Path deleted = FileHelper.deleteDirectory(fileSystem.getPath("../" + getCurrentTestName()));
+ fail(String.format("Unexpected success in removing directory %s", deleted.toString()));
+ }
+
+ /* chdir */
+ @Test
+ public void testChdir() throws IOException {
+ Path created = FileHelper.createDirectory(fileSystem.getPath(getCurrentTestName()));
+ Path createdFile = FileHelper.createFile(created.resolve(getCurrentTestName()));
+ boolean hasFile = false;
+ try (DirectoryStream<Path> ds = FileHelper.readDirectory(created)) {
+ for (Path p : ds) {
+ hasFile |= FileHelper.isSameFile(createdFile,
+ fileSystem.getPath(created.getFileName() + "/" + p.getFileName()));
+ }
+ }
+ assertTrue(createdFile + " found in ch directory", hasFile);
+ }
+
+ @Test(expected = InvalidPathException.class)
+ public void testChdirInvalid() throws IOException {
+ Path chdir = FileHelper.createDirectory(fileSystem.getPath("../" + getCurrentTestName()));
+ fail(String.format("Unexpected success in changing directory %s", chdir.toString()));
+ }
+
+ /* write */
+ @Test
+ public void testWriteFile() throws IOException {
+ Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
+ assertTrue(exists(created) && isReadable(created));
+ }
+
+ @Test(expected = InvalidPathException.class)
+ public void testWriteFileInvalid() throws IOException {
+ Path written = FileHelper.createFile(fileSystem.getPath("../" + getCurrentTestName()));
+ fail(String.format("Unexpected success in writing file %s", written.toString()));
+ }
+
+ /* read */
+ @Test
+ public void testReadFile() throws IOException {
+ Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
+ isNonEmpty(FileHelper.readFile(created));
+ }
+
+ @Test(expected = InvalidPathException.class)
+ public void testReadFileInvalid() throws IOException {
+ Path read = fileSystem.getPath("../" + getCurrentTestName());
+ FileHelper.readFile(read);
+ fail(String.format("Unexpected success in reading file %s", read.toString()));
+ }
+
+ /* rm */
+ @Test
+ public void testDeleteFile() throws IOException {
+ Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
+ Path deleted = FileHelper.deleteFile(created);
+ notExists(deleted);
+ }
+
+ @Test(expected = InvalidPathException.class)
+ public void testDeleteFileInvalid() throws IOException {
+ Path deleted = FileHelper.deleteFile(fileSystem.getPath("../" + getCurrentTestName()));
+ fail(String.format("Unexpected success in deleting file %s", deleted.toString()));
+ }
+
+ /* cp */
+ @Test
+ public void testCopyFile() throws IOException {
+ Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
+ Path destination = fileSystem.getPath(getCurrentTestName() + "dest");
+ FileHelper.copyFile(created, destination);
+ assertTrue(exists(destination) && isReadable(destination));
+ }
+
+ @Test(expected = InvalidPathException.class)
+ public void testCopyFileInvalid() throws IOException {
+ Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
+ Path copy = FileHelper.copyFile(created, fileSystem.getPath("../" + getCurrentTestName()));
+ fail(String.format("Unexpected success in copying file to %s", copy.toString()));
+ }
+
+ /* mv */
+ @Test
+ public void testMoveFile() throws IOException {
+ Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
+ Path destination = fileSystem.getPath(getCurrentTestName() + "dest");
+ FileHelper.moveFile(created, destination);
+ assertTrue(notExists(created) && exists(destination) && isReadable(destination));
+ }
+
+ @Test(expected = InvalidPathException.class)
+ public void testMoveFileInvalid() throws IOException {
+ Path created = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
+ Path moved = FileHelper.moveFile(created, fileSystem.getPath("../" + getCurrentTestName()));
+ fail(String.format("Unexpected success in moving file to %s", moved.toString()));
+ }
+
+ /* link */
+ @Test
+ public void testCreateLink() throws IOException {
+ Path existing = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
+ Path link = fileSystem.getPath(getCurrentTestName() + "link");
+ FileHelper.createLink(link, existing);
+ assertTrue(exists(link) && isReadable(link));
+ }
+
+ @Test(expected = InvalidPathException.class)
+ public void testCreateLinkInvalid() throws IOException {
+ Path existing = FileHelper.createFile(fileSystem.getPath(getCurrentTestName()));
+ Path link = FileHelper.createLink(fileSystem.getPath("../" + getCurrentTestName() + "link"), existing);
+ fail(String.format("Unexpected success in linking file %s", link.toString()));
+ }
+
+ @Test
+ public void testNewByteChannelProviderMismatchException() throws IOException {
+ RootedFileSystemProvider provider = new RootedFileSystemProvider();
+ Path tempFolder = assertHierarchyTargetFolderExists(getTempTargetFolder());
+ Path file = Files.createTempFile(tempFolder, getCurrentTestName(), ".txt");
+ try (FileSystem fs = provider.newFileSystem(tempFolder, Collections.emptyMap());
+ Channel channel = provider.newByteChannel(fs.getPath(file.getFileName().toString()), Collections.emptySet())) {
+ assertTrue("Channel not open", channel.isOpen());
+ }
+ }
+
+ @Test
+ public void testResolveRoot() throws IOException {
+ Path root = fileSystem.getRootDirectories().iterator().next();
+ Path dir = root.resolve("tsd");
+ FileHelper.createDirectory(dir);
+ Path f1 = FileHelper.createFile(dir.resolve("test.txt"));
+ Path f2 = Files.newDirectoryStream(dir).iterator().next();
+ assertTrue("Unrooted path found", f2 instanceof RootedPath);
+ assertEquals(f1, f2);
+ FileHelper.deleteFile(f1);
+ FileHelper.deleteDirectory(dir);
+ }
+
+ /* Private helper */
+
+ /**
+ * Wrapper around the FileSystemProvider to test generic FS related
+ * commands. All created temp directories and files used for testing are
+ * deleted upon JVM exit.
+ */
+ @SuppressWarnings("synthetic-access")
+ private static final class FileHelper {
+ private FileHelper() {
+ super();
+ }
+
+ /**
+ * Create a randomized test sandbox on each test execution
+ *
+ * @param tempDir location to create the sandbox
+ * @return the created sandbox Path
+ * @throws IOException
+ * on failure to create
+ */
+ public static Path createTestSandbox(Path tempDir) throws IOException {
+ Path created = Files.createDirectories(tempDir.resolve(RootedFileSystemProviderTest.class.getSimpleName()));
+ created.toFile().deleteOnExit();
+ return created;
+ }
+
+ public static Path createFile(Path source) throws InvalidPathException, IOException {
+ try (FileChannel fc = fileSystem.provider().newFileChannel(source,
+ new TreeSet<OpenOption>(Arrays.asList(StandardOpenOption.CREATE, StandardOpenOption.WRITE)))) {
+ byte[] randomBytes = new byte[1000];
+ new Random().nextBytes(randomBytes);
+ fc.write(ByteBuffer.wrap(randomBytes));
+ source.toFile().deleteOnExit();
+ return source;
+ }
+ }
+
+ public static Path createLink(Path link, Path existing) throws IOException {
+ fileSystem.provider().createLink(link, existing);
+ link.toFile().deleteOnExit();
+ return link;
+ }
+
+ public static Path createDirectory(Path dir) throws InvalidPathException, IOException {
+ fileSystem.provider().createDirectory(dir);
+ dir.toFile().deleteOnExit();
+ return dir;
+ }
+
+ public static Path deleteDirectory(Path dir) throws InvalidPathException, IOException {
+ return deleteFile(dir);
+ }
+
+ public static Path deleteFile(Path source) throws InvalidPathException, IOException {
+ fileSystem.provider().delete(source);
+ return source;
+ }
+
+ public static byte[] readFile(Path source) throws IOException {
+ try (FileChannel fc = fileSystem.provider().newFileChannel(source,
+ new TreeSet<OpenOption>(Arrays.asList(StandardOpenOption.READ)))) {
+ byte[] readBytes = new byte[(int) source.toFile().length()];
+ fc.read(ByteBuffer.wrap(readBytes));
+ return readBytes;
+ }
+ }
+
+ public static Path copyFile(Path source, Path destination) throws InvalidPathException, IOException {
+ fileSystem.provider().copy(source, destination, StandardCopyOption.COPY_ATTRIBUTES);
+ destination.toFile().deleteOnExit();
+ return destination;
+ }
+
+ public static Path moveFile(Path source, Path destination) throws InvalidPathException, IOException {
+ fileSystem.provider().move(source, destination, StandardCopyOption.ATOMIC_MOVE);
+ destination.toFile().deleteOnExit();
+ return destination;
+ }
+
+ public static DirectoryStream<Path> readDirectory(Path dir) throws InvalidPathException, IOException {
+ DirectoryStream<Path> dirStream = fileSystem.provider().newDirectoryStream(dir, entry -> true);
+ return dirStream;
+ }
+
+ public static boolean isSameFile(Path source, Path destination) throws IOException {
+ return fileSystem.provider().isSameFile(source, destination);
+ }
+ }
+}
l***@apache.org
2018-10-25 09:11:05 UTC
Permalink
A few minor code style indentations fixes to try and break long lines


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/612ee385
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/612ee385
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/612ee385

Branch: refs/heads/master
Commit: 612ee3857e402c29a2f7b055e13cba83a054ede0
Parents: cbd87aa
Author: Lyor Goldstein <***@apache.org>
Authored: Thu Oct 25 09:07:17 2018 +0300
Committer: Lyor Goldstein <***@apache.org>
Committed: Thu Oct 25 12:10:49 2018 +0300

----------------------------------------------------------------------
.../apache/sshd/cli/client/SshKeyScanMain.java | 5 +-
.../client/config/hosts/HostConfigEntry.java | 8 +-
.../client/config/hosts/KnownHostDigest.java | 2 +-
.../sshd/common/cipher/BuiltinCiphers.java | 4 +-
.../org/apache/sshd/common/cipher/ECCurves.java | 22 +-
.../common/compression/BuiltinCompressions.java | 4 +-
.../common/config/CompressionConfigValue.java | 2 +-
.../sshd/common/config/LogLevelValue.java | 12 +-
.../sshd/common/config/SyslogFacilityValue.java | 14 +-
.../sshd/common/config/TimeValueConfig.java | 2 +-
.../sshd/common/config/VersionProperties.java | 3 +-
.../common/config/keys/BuiltinIdentities.java | 8 +-
.../sshd/common/config/keys/KeyUtils.java | 3 +-
.../keys/loader/AESPrivateKeyObfuscator.java | 3 +-
.../keys/loader/DESPrivateKeyObfuscator.java | 4 +-
.../openssh/OpenSSHKeyPairResourceParser.java | 8 +-
.../loader/pem/DSSPEMResourceKeyPairParser.java | 4 +-
.../pem/ECDSAPEMResourceKeyPairParser.java | 4 +-
.../pem/PKCS8PEMResourceKeyPairParser.java | 4 +-
.../loader/pem/RSAPEMResourceKeyPairParser.java | 4 +-
.../sshd/common/digest/BuiltinDigests.java | 2 +-
.../org/apache/sshd/common/mac/BuiltinMacs.java | 4 +-
.../common/signature/BuiltinSignatures.java | 4 +-
.../org/apache/sshd/common/util/OsUtils.java | 4 +-
.../org/apache/sshd/common/util/io/IoUtils.java | 3 +-
.../common/util/io/ModifiableFileWatcher.java | 4 +-
.../sshd/common/util/io/der/ASN1Class.java | 2 +-
.../sshd/common/util/io/der/ASN1Type.java | 2 +-
.../sshd/common/util/net/SshdSocketAddress.java | 12 +-
.../security/SecurityProviderRegistrar.java | 10 +-
.../BouncyCastleKeyPairResourceParser.java | 20 +-
.../security/eddsa/Ed25519PublicKeyDecoder.java | 4 +-
.../OpenSSHEd25519PrivateKeyEntryDecoder.java | 4 +-
.../sshd/common/util/GenericUtilsTest.java | 5 +-
.../sshd/util/test/CommonTestSupportUtils.java | 4 +-
.../apache/sshd/util/test/JUnitTestSupport.java | 6 +-
.../agent/local/ChannelAgentForwarding.java | 8 +-
.../sshd/agent/local/LocalAgentFactory.java | 6 +-
.../sshd/agent/unix/AgentForwardedChannel.java | 6 +-
.../sshd/agent/unix/ChannelAgentForwarding.java | 12 +-
.../sshd/agent/unix/UnixAgentFactory.java | 6 +-
.../org/apache/sshd/client/ClientBuilder.java | 6 +-
.../java/org/apache/sshd/client/SshClient.java | 6 +-
.../client/auth/BuiltinUserAuthFactories.java | 2 +-
.../client/channel/AbstractClientChannel.java | 48 ++---
.../sshd/client/channel/ChannelSession.java | 11 +-
.../sshd/client/channel/ClientChannel.java | 3 +-
.../sshd/client/channel/ClientChannelEvent.java | 2 +-
.../org/apache/sshd/client/kex/DHGClient.java | 10 +-
.../org/apache/sshd/client/kex/DHGEXClient.java | 11 +-
.../client/session/AbstractClientSession.java | 25 ++-
.../sshd/client/session/ClientSession.java | 2 +-
.../sshd/client/session/ClientSessionImpl.java | 2 +-
.../client/session/ClientUserAuthService.java | 27 +--
.../org/apache/sshd/common/BaseBuilder.java | 96 +++++----
.../sshd/common/channel/AbstractChannel.java | 61 +++---
.../org/apache/sshd/common/channel/PtyMode.java | 10 +-
.../sshd/common/channel/RequestHandler.java | 2 +-
.../common/forward/DefaultForwardingFilter.java | 2 +-
.../sshd/common/forward/TcpipClientChannel.java | 2 +-
.../global/AbstractOpenSshHostKeysHandler.java | 2 +-
.../io/BuiltinIoServiceFactoryFactories.java | 2 +-
.../sshd/common/kex/BuiltinDHFactories.java | 4 +-
.../sshd/common/kex/KexProposalOption.java | 9 +-
.../org/apache/sshd/common/kex/KexState.java | 3 +-
.../org/apache/sshd/common/kex/KeyExchange.java | 12 +-
.../helpers/AbstractConnectionService.java | 36 ++--
.../common/session/helpers/AbstractSession.java | 87 ++++----
.../org/apache/sshd/server/ServerBuilder.java | 31 +--
.../java/org/apache/sshd/server/Signal.java | 21 +-
.../java/org/apache/sshd/server/SshServer.java | 6 +-
.../server/auth/BuiltinUserAuthFactories.java | 2 +-
.../sshd/server/auth/WelcomeBannerPhase.java | 2 +-
.../server/channel/AbstractServerChannel.java | 10 +-
.../sshd/server/channel/ChannelSession.java | 60 +++---
.../server/channel/PuttyRequestHandler.java | 2 +-
.../command/AbstractFileSystemCommand.java | 2 +-
.../server/config/AllowTcpForwardingValue.java | 2 +-
.../server/forward/TcpForwardingFilter.java | 2 +-
.../sshd/server/forward/TcpipServerChannel.java | 73 +++----
.../org/apache/sshd/server/kex/DHGEXServer.java | 9 +-
.../org/apache/sshd/server/kex/DHGServer.java | 11 +-
.../server/session/AbstractServerSession.java | 36 ++--
.../server/session/ServerUserAuthService.java | 44 ++--
.../sshd/server/shell/TtyFilterInputStream.java | 2 +-
.../server/shell/TtyFilterOutputStream.java | 2 +-
.../apache/sshd/common/cipher/CipherTest.java | 24 ++-
.../common/compression/CompressionTest.java | 2 +-
.../org/apache/sshd/common/mac/MacTest.java | 4 +-
.../signature/SignatureFactoriesTest.java | 6 +-
.../server/shell/TtyFilterInputStreamTest.java | 7 +-
.../sshd/git/transport/GitSshdSession.java | 3 +-
.../git/transport/GitSshdSessionProcess.java | 3 +-
.../putty/PuttyKeyPairResourceParser.java | 10 +-
.../sshd/client/scp/AbstractScpClient.java | 35 ++--
.../sshd/client/scp/DefaultScpClient.java | 12 +-
.../org/apache/sshd/server/scp/ScpCommand.java | 6 +-
.../sshd/client/subsystem/sftp/SftpClient.java | 14 +-
.../client/subsystem/sftp/SftpFileSystem.java | 14 +-
.../subsystem/sftp/SftpFileSystemProvider.java | 13 +-
.../subsystem/sftp/SftpRemotePathChannel.java | 10 +-
.../extensions/BuiltinSftpClientExtensions.java | 2 +-
.../subsystem/sftp/impl/AbstractSftpClient.java | 69 +++---
.../subsystem/sftp/impl/DefaultSftpClient.java | 8 +-
.../common/subsystem/sftp/SftpConstants.java | 3 +-
.../sftp/SftpUniversalOwnerAndGroup.java | 2 +-
.../sftp/extensions/AclSupportedParser.java | 9 +-
.../subsystem/sftp/extensions/ParserUtils.java | 30 +--
.../sftp/AbstractSftpSubsystemHelper.java | 209 ++++++++++---------
.../server/subsystem/sftp/SftpSubsystem.java | 54 +++--
.../server/subsystem/sftp/UnixDateFormat.java | 7 +-
.../sftp/UnsupportedAttributePolicy.java | 2 +-
.../helpers/AbstractCheckFileExtensionTest.java | 28 +--
.../helpers/AbstractMD5HashExtensionTest.java | 14 +-
.../helpers/CopyDataExtensionImplTest.java | 54 ++---
115 files changed, 913 insertions(+), 789 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java
----------------------------------------------------------------------
diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java
index adc120f..558245b 100644
--- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java
+++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/SshKeyScanMain.java
@@ -93,7 +93,10 @@ public class SshKeyScanMain implements Channel, Callable<Void>, ServerKeyVerifie
* Default key types if not overridden from the command line
*/
public static final List<String> DEFAULT_KEY_TYPES =
- Collections.unmodifiableList(Arrays.asList(BuiltinIdentities.Constants.RSA, BuiltinIdentities.Constants.ECDSA));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ BuiltinIdentities.Constants.RSA,
+ BuiltinIdentities.Constants.ECDSA));
public static final long DEFAULT_TIMEOUT = TimeUnit.SECONDS.toMillis(5L);
public static final Level DEFAULT_LEVEL = Level.INFO;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java
index cb85cea..90b6549 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/HostConfigEntry.java
@@ -43,8 +43,8 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.NavigableSet;
import java.util.Objects;
-import java.util.Set;
import java.util.TreeMap;

import org.apache.sshd.common.auth.MutableUserHolder;
@@ -83,10 +83,10 @@ public class HostConfigEntry extends HostPatternsHolder implements MutableUserHo
public static final boolean DEFAULT_EXCLUSIVE_IDENTITIES = false;

/**
- * A case <U>insensitive</U> {@link Set} of the properties that receive special handling
+ * A case <U>insensitive</U> {@link NavigableSet} of the properties that receive special handling
*/
- public static final Set<String> EXPLICIT_PROPERTIES =
- Collections.unmodifiableSet(
+ public static final NavigableSet<String> EXPLICIT_PROPERTIES =
+ Collections.unmodifiableNavigableSet(
GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER,
HOST_CONFIG_PROP, HOST_NAME_CONFIG_PROP, PORT_CONFIG_PROP,
USER_CONFIG_PROP, IDENTITY_FILE_CONFIG_PROP, EXCLUSIVE_IDENTITIES_CONFIG_PROP

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java
index 2d9a322..c9777df 100644
--- a/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java
+++ b/sshd-common/src/main/java/org/apache/sshd/client/config/hosts/KnownHostDigest.java
@@ -40,7 +40,7 @@ public enum KnownHostDigest implements NamedFactory<Mac> {
SHA1("1", BuiltinMacs.hmacsha1);

public static final Set<KnownHostDigest> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(KnownHostDigest.class));
+ Collections.unmodifiableSet(EnumSet.allOf(KnownHostDigest.class));

private final String name;
private final Factory<Mac> factory;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java b/sshd-common/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java
index 8609d50..8884e15 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/BuiltinCiphers.java
@@ -74,10 +74,10 @@ public enum BuiltinCiphers implements CipherFactory {
tripledescbc(Constants.TRIPLE_DES_CBC, 8, 24, "DESede", "DESede/CBC/NoPadding");

public static final Set<BuiltinCiphers> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinCiphers.class));
+ Collections.unmodifiableSet(EnumSet.allOf(BuiltinCiphers.class));

private static final Map<String, CipherFactory> EXTENSIONS =
- new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

private final String factoryName;
private final int ivsize;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java b/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
index ae39dd3..cb8cd0d 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/cipher/ECCurves.java
@@ -106,25 +106,21 @@ public enum ECCurves implements NamedResource, OptionalFeature {
* A {@link Set} of all the known curves
*/
public static final Set<ECCurves> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(ECCurves.class));
+ Collections.unmodifiableSet(EnumSet.allOf(ECCurves.class));

/**
* A {@link Set} of all the known curves names
*/
public static final NavigableSet<String> NAMES =
- Collections.unmodifiableNavigableSet(GenericUtils.mapSort(
- VALUES,
- ECCurves::getName,
- String.CASE_INSENSITIVE_ORDER));
+ Collections.unmodifiableNavigableSet(
+ GenericUtils.mapSort(VALUES, ECCurves::getName, String.CASE_INSENSITIVE_ORDER));

/**
* A {@link Set} of all the known curves key types
*/
public static final NavigableSet<String> KEY_TYPES =
- Collections.unmodifiableNavigableSet(GenericUtils.mapSort(
- VALUES,
- ECCurves::getKeyType,
- String.CASE_INSENSITIVE_ORDER));
+ Collections.unmodifiableNavigableSet(
+ GenericUtils.mapSort(VALUES, ECCurves::getKeyType, String.CASE_INSENSITIVE_ORDER));

public static final Comparator<ECCurves> BY_KEY_SIZE = (o1, o2) -> {
int k1 = (o1 == null) ? Integer.MAX_VALUE : o1.getKeySize();
@@ -133,9 +129,9 @@ public enum ECCurves implements NamedResource, OptionalFeature {
};

public static final List<ECCurves> SORTED_KEY_SIZE =
- Collections.unmodifiableList(VALUES.stream()
- .sorted(BY_KEY_SIZE)
- .collect(Collectors.toList()));
+ Collections.unmodifiableList(VALUES.stream()
+ .sorted(BY_KEY_SIZE)
+ .collect(Collectors.toList()));

private final String name;
private final String keyType;
@@ -503,7 +499,7 @@ public enum ECCurves implements NamedResource, OptionalFeature {
};

public static final Set<ECPointCompression> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(ECPointCompression.class));
+ Collections.unmodifiableSet(EnumSet.allOf(ECPointCompression.class));

private final byte indicatorValue;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java b/sshd-common/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java
index 49ad0ab..7360b13 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/compression/BuiltinCompressions.java
@@ -71,10 +71,10 @@ public enum BuiltinCompressions implements CompressionFactory {
};

public static final Set<BuiltinCompressions> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinCompressions.class));
+ Collections.unmodifiableSet(EnumSet.allOf(BuiltinCompressions.class));

private static final Map<String, CompressionFactory> EXTENSIONS =
- new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

private final String name;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/CompressionConfigValue.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/CompressionConfigValue.java b/sshd-common/src/main/java/org/apache/sshd/common/config/CompressionConfigValue.java
index e153adc..5df4d1b 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/CompressionConfigValue.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/CompressionConfigValue.java
@@ -40,7 +40,7 @@ public enum CompressionConfigValue implements CompressionFactory {
DELAYED(BuiltinCompressions.delayedZlib);

public static final Set<CompressionConfigValue> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(CompressionConfigValue.class));
+ Collections.unmodifiableSet(EnumSet.allOf(CompressionConfigValue.class));

private final CompressionFactory factory;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/LogLevelValue.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/LogLevelValue.java b/sshd-common/src/main/java/org/apache/sshd/common/config/LogLevelValue.java
index 2fbdc80..987f178 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/LogLevelValue.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/LogLevelValue.java
@@ -35,10 +35,18 @@ public enum LogLevelValue {
* 1. DEBUG and DEBUG1 are EQUIVALENT
* 2. Order is important (!!!)
*/
- QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, DEBUG3;
+ QUIET,
+ FATAL,
+ ERROR,
+ INFO,
+ VERBOSE,
+ DEBUG,
+ DEBUG1,
+ DEBUG2,
+ DEBUG3;

public static final Set<LogLevelValue> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(LogLevelValue.class));
+ Collections.unmodifiableSet(EnumSet.allOf(LogLevelValue.class));

public static LogLevelValue fromName(String n) {
if (GenericUtils.isEmpty(n)) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java b/sshd-common/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java
index f52ae36..9a42e80 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/SyslogFacilityValue.java
@@ -30,10 +30,20 @@ import org.apache.sshd.common.util.GenericUtils;
* @see <A HREF="https://www.freebsd.org/cgi/man.cgi?query=sshd_config&sektion=5"><I>SyslogFacility</I> configuration value</A>
*/
public enum SyslogFacilityValue {
- DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7;
+ DAEMON,
+ USER,
+ AUTH,
+ LOCAL0,
+ LOCAL1,
+ LOCAL2,
+ LOCAL3,
+ LOCAL4,
+ LOCAL5,
+ LOCAL6,
+ LOCAL7;

public static final Set<SyslogFacilityValue> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(SyslogFacilityValue.class));
+ Collections.unmodifiableSet(EnumSet.allOf(SyslogFacilityValue.class));

public static SyslogFacilityValue fromName(String n) {
if (GenericUtils.isEmpty(n)) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java b/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
index 222cf84..8fed7ad 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/TimeValueConfig.java
@@ -40,7 +40,7 @@ public enum TimeValueConfig {
WEEKS('w', 'W', TimeUnit.DAYS.toMillis(7L));

public static final Set<TimeValueConfig> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(TimeValueConfig.class));
+ Collections.unmodifiableSet(EnumSet.allOf(TimeValueConfig.class));

private final char loChar;
private final char hiChar;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java b/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java
index 0e351a8..90e8b63 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/VersionProperties.java
@@ -37,7 +37,8 @@ import org.slf4j.LoggerFactory;
public final class VersionProperties {
private static final class LazyVersionPropertiesHolder {
private static final NavigableMap<String, String> PROPERTIES =
- Collections.unmodifiableNavigableMap(loadVersionProperties(LazyVersionPropertiesHolder.class));
+ Collections.unmodifiableNavigableMap(
+ loadVersionProperties(LazyVersionPropertiesHolder.class));

private LazyVersionPropertiesHolder() {
throw new UnsupportedOperationException("No instance allowed");

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java
index 70e5c8b..9fa732b 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/BuiltinIdentities.java
@@ -31,6 +31,7 @@ import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.util.Collections;
import java.util.EnumSet;
+import java.util.NavigableSet;
import java.util.Objects;
import java.util.Set;

@@ -60,8 +61,11 @@ public enum BuiltinIdentities implements Identity {
public static final Set<BuiltinIdentities> VALUES =
Collections.unmodifiableSet(EnumSet.allOf(BuiltinIdentities.class));

- public static final Set<String> NAMES =
- Collections.unmodifiableSet(
+ /**
+ * A case <u>insensitive</u> {@link NavigableSet} of all built-in identities names
+ */
+ public static final NavigableSet<String> NAMES =
+ Collections.unmodifiableNavigableSet(
GenericUtils.asSortedSet(
String.CASE_INSENSITIVE_ORDER, NamedResource.getNameList(VALUES)));


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java
index 23937c2..c8cfe9c 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/KeyUtils.java
@@ -110,7 +110,8 @@ public final class KeyUtils {
*/
public static final Set<PosixFilePermission> STRICTLY_PROHIBITED_FILE_PERMISSION =
Collections.unmodifiableSet(
- EnumSet.of(PosixFilePermission.GROUP_READ, PosixFilePermission.GROUP_WRITE, PosixFilePermission.GROUP_EXECUTE,
+ EnumSet.of(
+ PosixFilePermission.GROUP_READ, PosixFilePermission.GROUP_WRITE, PosixFilePermission.GROUP_EXECUTE,
PosixFilePermission.OTHERS_READ, PosixFilePermission.OTHERS_WRITE, PosixFilePermission.OTHERS_EXECUTE));

/**

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AESPrivateKeyObfuscator.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AESPrivateKeyObfuscator.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AESPrivateKeyObfuscator.java
index 4437945..7fbbdbe 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AESPrivateKeyObfuscator.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/AESPrivateKeyObfuscator.java
@@ -83,7 +83,8 @@ public class AESPrivateKeyObfuscator extends AbstractPrivateKeyObfuscator {
}

private static final class LazyKeyLengthsHolder {
- private static final List<Integer> KEY_LENGTHS = Collections.unmodifiableList(detectSupportedKeySizes());
+ private static final List<Integer> KEY_LENGTHS =
+ Collections.unmodifiableList(detectSupportedKeySizes());

private LazyKeyLengthsHolder() {
throw new UnsupportedOperationException("No instance allowed");

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/DESPrivateKeyObfuscator.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/DESPrivateKeyObfuscator.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/DESPrivateKeyObfuscator.java
index 2043f06..0d7735c 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/DESPrivateKeyObfuscator.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/DESPrivateKeyObfuscator.java
@@ -28,7 +28,9 @@ import java.util.List;
public class DESPrivateKeyObfuscator extends AbstractPrivateKeyObfuscator {
public static final int DEFAULT_KEY_LENGTH = 24 /* hardwired size for 3DES */;
public static final List<Integer> AVAILABLE_KEY_LENGTHS =
- Collections.unmodifiableList(Collections.singletonList(Integer.valueOf(DEFAULT_KEY_LENGTH)));
+ Collections.unmodifiableList(
+ Collections.singletonList(
+ Integer.valueOf(DEFAULT_KEY_LENGTH)));
public static final DESPrivateKeyObfuscator INSTANCE = new DESPrivateKeyObfuscator();

public DESPrivateKeyObfuscator() {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java
index 9dc2dd8..9f309ea 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/openssh/OpenSSHKeyPairResourceParser.java
@@ -64,21 +64,21 @@ public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser

public static final String BEGIN_MARKER = "BEGIN OPENSSH PRIVATE KEY";
public static final List<String> BEGINNERS =
- Collections.unmodifiableList(Collections.singletonList(BEGIN_MARKER));
+ Collections.unmodifiableList(Collections.singletonList(BEGIN_MARKER));

public static final String END_MARKER = "END OPENSSH PRIVATE KEY";
public static final List<String> ENDERS =
- Collections.unmodifiableList(Collections.singletonList(END_MARKER));
+ Collections.unmodifiableList(Collections.singletonList(END_MARKER));

public static final String AUTH_MAGIC = "openssh-key-v1";
public static final OpenSSHKeyPairResourceParser INSTANCE = new OpenSSHKeyPairResourceParser();

private static final byte[] AUTH_MAGIC_BYTES = AUTH_MAGIC.getBytes(StandardCharsets.UTF_8);
private static final Map<String, PrivateKeyEntryDecoder<?, ?>> BY_KEY_TYPE_DECODERS_MAP =
- new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

private static final Map<Class<?>, PrivateKeyEntryDecoder<?, ?>> BY_KEY_CLASS_DECODERS_MAP =
- new HashMap<>();
+ new HashMap<>();

static {
registerPrivateKeyEntryDecoder(OpenSSHRSAPrivateKeyDecoder.INSTANCE);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/DSSPEMResourceKeyPairParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/DSSPEMResourceKeyPairParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/DSSPEMResourceKeyPairParser.java
index 0c357af..5347495 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/DSSPEMResourceKeyPairParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/DSSPEMResourceKeyPairParser.java
@@ -49,11 +49,11 @@ public class DSSPEMResourceKeyPairParser extends AbstractPEMResourceKeyPairParse
// Not exactly according to standard but good enough
public static final String BEGIN_MARKER = "BEGIN DSA PRIVATE KEY";
public static final List<String> BEGINNERS =
- Collections.unmodifiableList(Collections.singletonList(BEGIN_MARKER));
+ Collections.unmodifiableList(Collections.singletonList(BEGIN_MARKER));

public static final String END_MARKER = "END DSA PRIVATE KEY";
public static final List<String> ENDERS =
- Collections.unmodifiableList(Collections.singletonList(END_MARKER));
+ Collections.unmodifiableList(Collections.singletonList(END_MARKER));

/**
* @see <A HREF="https://tools.ietf.org/html/rfc3279#section-2.3.2">RFC-3279 section 2.3.2</A>

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/ECDSAPEMResourceKeyPairParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/ECDSAPEMResourceKeyPairParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/ECDSAPEMResourceKeyPairParser.java
index dd8d2ea..a2075e4 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/ECDSAPEMResourceKeyPairParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/ECDSAPEMResourceKeyPairParser.java
@@ -53,11 +53,11 @@ import org.apache.sshd.common.util.security.SecurityUtils;
public class ECDSAPEMResourceKeyPairParser extends AbstractPEMResourceKeyPairParser {
public static final String BEGIN_MARKER = "BEGIN EC PRIVATE KEY";
public static final List<String> BEGINNERS =
- Collections.unmodifiableList(Collections.singletonList(BEGIN_MARKER));
+ Collections.unmodifiableList(Collections.singletonList(BEGIN_MARKER));

public static final String END_MARKER = "END EC PRIVATE KEY";
public static final List<String> ENDERS =
- Collections.unmodifiableList(Collections.singletonList(END_MARKER));
+ Collections.unmodifiableList(Collections.singletonList(END_MARKER));

/**
* @see <A HREF="https://tools.ietf.org/html/rfc3279#section-2.3.5">RFC-3279 section 2.3.5</A>

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/PKCS8PEMResourceKeyPairParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/PKCS8PEMResourceKeyPairParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/PKCS8PEMResourceKeyPairParser.java
index b333f23..cce1fc8 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/PKCS8PEMResourceKeyPairParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/PKCS8PEMResourceKeyPairParser.java
@@ -49,11 +49,11 @@ public class PKCS8PEMResourceKeyPairParser extends AbstractPEMResourceKeyPairPar
// Not exactly according to standard but good enough
public static final String BEGIN_MARKER = "BEGIN PRIVATE KEY";
public static final List<String> BEGINNERS =
- Collections.unmodifiableList(Collections.singletonList(BEGIN_MARKER));
+ Collections.unmodifiableList(Collections.singletonList(BEGIN_MARKER));

public static final String END_MARKER = "END PRIVATE KEY";
public static final List<String> ENDERS =
- Collections.unmodifiableList(Collections.singletonList(END_MARKER));
+ Collections.unmodifiableList(Collections.singletonList(END_MARKER));

public static final String PKCS8_FORMAT = "PKCS#8";


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/RSAPEMResourceKeyPairParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/RSAPEMResourceKeyPairParser.java b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/RSAPEMResourceKeyPairParser.java
index d760aaf..e7698f9 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/RSAPEMResourceKeyPairParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/config/keys/loader/pem/RSAPEMResourceKeyPairParser.java
@@ -50,11 +50,11 @@ public class RSAPEMResourceKeyPairParser extends AbstractPEMResourceKeyPairParse
// Not exactly according to standard but good enough
public static final String BEGIN_MARKER = "BEGIN RSA PRIVATE KEY";
public static final List<String> BEGINNERS =
- Collections.unmodifiableList(Collections.singletonList(BEGIN_MARKER));
+ Collections.unmodifiableList(Collections.singletonList(BEGIN_MARKER));

public static final String END_MARKER = "END RSA PRIVATE KEY";
public static final List<String> ENDERS =
- Collections.unmodifiableList(Collections.singletonList(END_MARKER));
+ Collections.unmodifiableList(Collections.singletonList(END_MARKER));

/**
* @see <A HREF="https://tools.ietf.org/html/rfc3279#section-2.3.1">RFC-3279 section 2.3.1</A>

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java b/sshd-common/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
index f469583..04b5811 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/digest/BuiltinDigests.java
@@ -41,7 +41,7 @@ public enum BuiltinDigests implements DigestFactory {
sha512(Constants.SHA512, "SHA-512", 64);

public static final Set<BuiltinDigests> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinDigests.class));
+ Collections.unmodifiableSet(EnumSet.allOf(BuiltinDigests.class));

private final String algorithm;
private final int blockSize;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java b/sshd-common/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java
index 5a4528d..3c7beaa 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/mac/BuiltinMacs.java
@@ -53,10 +53,10 @@ public enum BuiltinMacs implements MacFactory {
hmacsha512(Constants.HMAC_SHA2_512, "HmacSHA512", 64, 64);

public static final Set<BuiltinMacs> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinMacs.class));
+ Collections.unmodifiableSet(EnumSet.allOf(BuiltinMacs.class));

private static final Map<String, MacFactory> EXTENSIONS =
- new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

private final String factoryName;
private final String algorithm;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java b/sshd-common/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java
index 7d4e1e2..e9cd416 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/signature/BuiltinSignatures.java
@@ -105,10 +105,10 @@ public enum BuiltinSignatures implements SignatureFactory {
};

public static final Set<BuiltinSignatures> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinSignatures.class));
+ Collections.unmodifiableSet(EnumSet.allOf(BuiltinSignatures.class));

private static final Map<String, SignatureFactory> EXTENSIONS =
- new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

private final String factoryName;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/util/OsUtils.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/OsUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/OsUtils.java
index f0b2c7e..8663326 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/OsUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/OsUtils.java
@@ -54,9 +54,9 @@ public final class OsUtils {
public static final String ROOT_USER = "root";

public static final List<String> LINUX_COMMAND =
- Collections.unmodifiableList(Arrays.asList(LINUX_SHELL_COMMAND_NAME, "-i", "-l"));
+ Collections.unmodifiableList(Arrays.asList(LINUX_SHELL_COMMAND_NAME, "-i", "-l"));
public static final List<String> WINDOWS_COMMAND =
- Collections.unmodifiableList(Collections.singletonList(WINDOWS_SHELL_COMMAND_NAME));
+ Collections.unmodifiableList(Collections.singletonList(WINDOWS_SHELL_COMMAND_NAME));

private static final AtomicReference<String> CURRENT_USER_HOLDER = new AtomicReference<>(null);
private static final AtomicReference<VersionInfo> JAVA_VERSION_HOLDER = new AtomicReference<>(null);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/util/io/IoUtils.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/io/IoUtils.java b/sshd-common/src/main/java/org/apache/sshd/common/util/io/IoUtils.java
index 10aa59a..8f583ca 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/io/IoUtils.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/io/IoUtils.java
@@ -64,7 +64,8 @@ public final class IoUtils {
public static final LinkOption[] EMPTY_LINK_OPTIONS = new LinkOption[0];
public static final FileAttribute<?>[] EMPTY_FILE_ATTRIBUTES = new FileAttribute<?>[0];

- public static final List<String> WINDOWS_EXECUTABLE_EXTENSIONS = Collections.unmodifiableList(Arrays.asList(".bat", ".exe", ".cmd"));
+ public static final List<String> WINDOWS_EXECUTABLE_EXTENSIONS =
+ Collections.unmodifiableList(Arrays.asList(".bat", ".exe", ".cmd"));

/**
* Size of preferred work buffer when reading / writing data to / from streams

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/util/io/ModifiableFileWatcher.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/io/ModifiableFileWatcher.java b/sshd-common/src/main/java/org/apache/sshd/common/util/io/ModifiableFileWatcher.java
index 29ca54d..0d8009d 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/io/ModifiableFileWatcher.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/io/ModifiableFileWatcher.java
@@ -54,7 +54,9 @@ public class ModifiableFileWatcher extends AbstractLoggingBean {
*/
public static final Set<PosixFilePermission> STRICTLY_PROHIBITED_FILE_PERMISSION =
Collections.unmodifiableSet(
- EnumSet.of(PosixFilePermission.GROUP_WRITE, PosixFilePermission.OTHERS_WRITE));
+ EnumSet.of(
+ PosixFilePermission.GROUP_WRITE,
+ PosixFilePermission.OTHERS_WRITE));

protected final LinkOption[] options;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Class.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Class.java b/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Class.java
index b8351f1..855f57e 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Class.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Class.java
@@ -35,7 +35,7 @@ public enum ASN1Class {
PRIVATE((byte) 0x03);

public static final List<ASN1Class> VALUES =
- Collections.unmodifiableList(Arrays.asList(values()));
+ Collections.unmodifiableList(Arrays.asList(values()));

private final byte byteValue;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Type.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Type.java b/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Type.java
index 3dd13ca..7073b95 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Type.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/io/der/ASN1Type.java
@@ -55,7 +55,7 @@ public enum ASN1Type {
GENERALIZED_TIME((byte) 0x18);

public static final Set<ASN1Type> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(ASN1Type.class));
+ Collections.unmodifiableSet(EnumSet.allOf(ASN1Type.class));

private final byte typeValue;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java b/sshd-common/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java
index b465d14..ccb3bb1 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/net/SshdSocketAddress.java
@@ -63,7 +63,9 @@ public class SshdSocketAddress extends SocketAddress {
public static final String IPV4_ANYADDR = "0.0.0.0";

public static final Set<String> WELL_KNOWN_IPV4_ADDRESSES =
- Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.asList(LOCALHOST_IPV4, IPV4_ANYADDR)));
+ Collections.unmodifiableSet(
+ new LinkedHashSet<>(
+ Arrays.asList(LOCALHOST_IPV4, IPV4_ANYADDR)));

// 10.0.0.0 - 10.255.255.255
public static final String PRIVATE_CLASS_A_PREFIX = "10.";
@@ -89,9 +91,11 @@ public class SshdSocketAddress extends SocketAddress {
public static final String IPV6_SHORT_LOCALHOST = "::1";

public static final Set<String> WELL_KNOWN_IPV6_ADDRESSES =
- Collections.unmodifiableSet(new LinkedHashSet<>(Arrays.asList(
- IPV6_LONG_LOCALHOST, IPV6_SHORT_LOCALHOST,
- IPV6_LONG_ANY_ADDRESS, IPV6_SHORT_ANY_ADDRESS)));
+ Collections.unmodifiableSet(
+ new LinkedHashSet<>(
+ Arrays.asList(
+ IPV6_LONG_LOCALHOST, IPV6_SHORT_LOCALHOST,
+ IPV6_LONG_ANY_ADDRESS, IPV6_SHORT_ANY_ADDRESS)));

/**
* A dummy placeholder that can be used instead of {@code null}s

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/util/security/SecurityProviderRegistrar.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/security/SecurityProviderRegistrar.java b/sshd-common/src/main/java/org/apache/sshd/common/util/security/SecurityProviderRegistrar.java
index dc852eb..c32dc37 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/security/SecurityProviderRegistrar.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/security/SecurityProviderRegistrar.java
@@ -80,11 +80,11 @@ public interface SecurityProviderRegistrar extends SecurityProviderChoice, Optio
* All the entities that are used in calls to {@link #isSecurityEntitySupported(Class, String)}
*/
List<Class<?>> SECURITY_ENTITIES =
- Collections.unmodifiableList(
- Arrays.asList(
- Cipher.class, KeyFactory.class, MessageDigest.class,
- KeyPairGenerator.class, KeyAgreement.class, Mac.class,
- Signature.class, CertificateFactory.class));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ Cipher.class, KeyFactory.class, MessageDigest.class,
+ KeyPairGenerator.class, KeyAgreement.class, Mac.class,
+ Signature.class, CertificateFactory.class));

default String getBasePropertyName() {
return CONFIG_PROP_BASE + "." + getName();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleKeyPairResourceParser.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleKeyPairResourceParser.java b/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleKeyPairResourceParser.java
index 5d07e15..c2da507 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleKeyPairResourceParser.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/security/bouncycastle/BouncyCastleKeyPairResourceParser.java
@@ -55,18 +55,18 @@ import org.bouncycastle.openssl.jcajce.JcePEMDecryptorProviderBuilder;
*/
public class BouncyCastleKeyPairResourceParser extends AbstractKeyPairResourceParser {
public static final List<String> BEGINNERS =
- Collections.unmodifiableList(
- Arrays.asList(
- "BEGIN RSA PRIVATE KEY",
- "BEGIN DSA PRIVATE KEY",
- "BEGIN EC PRIVATE KEY"));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ "BEGIN RSA PRIVATE KEY",
+ "BEGIN DSA PRIVATE KEY",
+ "BEGIN EC PRIVATE KEY"));

public static final List<String> ENDERS =
- Collections.unmodifiableList(
- Arrays.asList(
- "END RSA PRIVATE KEY",
- "END DSA PRIVATE KEY",
- "END EC PRIVATE KEY"));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ "END RSA PRIVATE KEY",
+ "END DSA PRIVATE KEY",
+ "END EC PRIVATE KEY"));

public static final BouncyCastleKeyPairResourceParser INSTANCE = new BouncyCastleKeyPairResourceParser();


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/Ed25519PublicKeyDecoder.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/Ed25519PublicKeyDecoder.java b/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/Ed25519PublicKeyDecoder.java
index aa75171..c4f3b43 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/Ed25519PublicKeyDecoder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/Ed25519PublicKeyDecoder.java
@@ -47,7 +47,9 @@ public final class Ed25519PublicKeyDecoder extends AbstractPublicKeyEntryDecoder

private Ed25519PublicKeyDecoder() {
super(EdDSAPublicKey.class, EdDSAPrivateKey.class,
- Collections.unmodifiableList(Collections.singletonList(KeyPairProvider.SSH_ED25519)));
+ Collections.unmodifiableList(
+ Collections.singletonList(
+ KeyPairProvider.SSH_ED25519)));
}

@Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/OpenSSHEd25519PrivateKeyEntryDecoder.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/OpenSSHEd25519PrivateKeyEntryDecoder.java b/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/OpenSSHEd25519PrivateKeyEntryDecoder.java
index f0fdfbb..2f1d055 100644
--- a/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/OpenSSHEd25519PrivateKeyEntryDecoder.java
+++ b/sshd-common/src/main/java/org/apache/sshd/common/util/security/eddsa/OpenSSHEd25519PrivateKeyEntryDecoder.java
@@ -56,7 +56,9 @@ public class OpenSSHEd25519PrivateKeyEntryDecoder extends AbstractPrivateKeyEntr

public OpenSSHEd25519PrivateKeyEntryDecoder() {
super(EdDSAPublicKey.class, EdDSAPrivateKey.class,
- Collections.unmodifiableList(Collections.singletonList(KeyPairProvider.SSH_ED25519)));
+ Collections.unmodifiableList(
+ Collections.singletonList(
+ KeyPairProvider.SSH_ED25519)));
}

@Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java b/sshd-common/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java
index 5727e88..2b25f4a 100644
--- a/sshd-common/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java
+++ b/sshd-common/src/test/java/org/apache/sshd/common/util/GenericUtilsTest.java
@@ -44,7 +44,10 @@ public class GenericUtilsTest extends JUnitTestSupport {
@Test
public void testSplitAndJoin() {
List<String> expected = Collections.unmodifiableList(
- Arrays.asList(getClass().getPackage().getName().replace('.', '/'), getClass().getSimpleName(), getCurrentTestName()));
+ Arrays.asList(
+ getClass().getPackage().getName().replace('.', '/'),
+ getClass().getSimpleName(),
+ getCurrentTestName()));

// NOTE: we also test characters that have meaning in String.split(...) as regex ones
for (char ch : new char[]{',', '.', '*', '?'}) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java b/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
index 38dd8b0..6558c07 100644
--- a/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
+++ b/sshd-common/src/test/java/org/apache/sshd/util/test/CommonTestSupportUtils.java
@@ -105,7 +105,9 @@ public final class CommonTestSupportUtils {

public static final List<String> TARGET_FOLDER_NAMES = // NOTE: order is important
Collections.unmodifiableList(
- Arrays.asList("target" /* Maven */, "build" /* Gradle */));
+ Arrays.asList(
+ "target" /* Maven */,
+ "build" /* Gradle */));

public static final String DEFAULT_TEST_HOST_KEY_PROVIDER_ALGORITHM = KeyUtils.RSA_ALGORITHM;
// uses a cached instance to avoid re-creating the keys as it is a time-consuming effort

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java b/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java
index af74b4b..01ba808 100644
--- a/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java
+++ b/sshd-common/src/test/java/org/apache/sshd/util/test/JUnitTestSupport.java
@@ -76,11 +76,11 @@ public abstract class JUnitTestSupport extends Assert {

// useful test sizes for keys
public static final List<Integer> DSS_SIZES =
- Collections.unmodifiableList(Arrays.asList(512, 768, 1024));
+ Collections.unmodifiableList(Arrays.asList(512, 768, 1024));
public static final List<Integer> RSA_SIZES =
- Collections.unmodifiableList(Arrays.asList(1024, 2048, 3072, 4096));
+ Collections.unmodifiableList(Arrays.asList(1024, 2048, 3072, 4096));
public static final List<Integer> ED25519_SIZES =
- Collections.unmodifiableList(Arrays.asList(256));
+ Collections.unmodifiableList(Arrays.asList(256));

@Rule
public final TestName testNameHolder = new TestName();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
index 1b43902..d43e613 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/ChannelAgentForwarding.java
@@ -101,7 +101,7 @@ public class ChannelAgentForwarding extends AbstractServerChannel {
agent.close();
} catch (IOException e) {
log.error("closeImmediately0({}) Failed ({}) to close open local agent: {}",
- this, e.getClass().getSimpleName(), e.getMessage());
+ this, e.getClass().getSimpleName(), e.getMessage());
}
}
} finally {
@@ -112,9 +112,9 @@ public class ChannelAgentForwarding extends AbstractServerChannel {
@Override
protected Closeable getInnerCloseable() {
return builder()
- .close(super.getInnerCloseable())
- .run(toString(), this::closeImmediately0)
- .build();
+ .close(super.getInnerCloseable())
+ .run(toString(), this::closeImmediately0)
+ .build();
}

@Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/agent/local/LocalAgentFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/local/LocalAgentFactory.java b/sshd-core/src/main/java/org/apache/sshd/agent/local/LocalAgentFactory.java
index 0ad3664..99d8c11 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/local/LocalAgentFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/local/LocalAgentFactory.java
@@ -34,8 +34,10 @@ import org.apache.sshd.common.session.ConnectionService;

public class LocalAgentFactory implements SshAgentFactory {
public static final List<NamedFactory<Channel>> DEFAULT_FORWARDING_CHANNELS =
- Collections.unmodifiableList(
- Arrays.<NamedFactory<Channel>>asList(ChannelAgentForwardingFactory.OPENSSH, ChannelAgentForwardingFactory.IETF));
+ Collections.unmodifiableList(
+ Arrays.<NamedFactory<Channel>>asList(
+ ChannelAgentForwardingFactory.OPENSSH,
+ ChannelAgentForwardingFactory.IETF));

private final SshAgent agent;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentForwardedChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentForwardedChannel.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentForwardedChannel.java
index 1c7b95b..42ba3c7 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentForwardedChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/AgentForwardedChannel.java
@@ -71,9 +71,9 @@ public class AgentForwardedChannel extends AbstractClientChannel implements Runn
@Override
protected Closeable getInnerCloseable() {
return builder()
- .close(super.getInnerCloseable())
- .run(toString(), () -> Socket.close(socket))
- .build();
+ .close(super.getInnerCloseable())
+ .run(toString(), () -> Socket.close(socket))
+ .build();
}

@Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
index f51fa19..073c978 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/ChannelAgentForwarding.java
@@ -84,10 +84,10 @@ public class ChannelAgentForwarding extends AbstractServerChannel {

CloseableExecutorService service = getExecutorService();
forwardService = (service == null)
- ? ThreadUtils.newSingleThreadExecutor("ChannelAgentForwarding[" + authSocket + "]")
- : ThreadUtils.noClose(service);
+ ? ThreadUtils.newSingleThreadExecutor("ChannelAgentForwarding[" + authSocket + "]")
+ : ThreadUtils.noClose(service);

- final int copyBufSize = this.getIntProperty(FORWARDER_BUFFER_SIZE, DEFAULT_FORWARDER_BUF_SIZE);
+ int copyBufSize = this.getIntProperty(FORWARDER_BUFFER_SIZE, DEFAULT_FORWARDER_BUF_SIZE);
ValidateUtils.checkTrue(copyBufSize >= MIN_FORWARDER_BUF_SIZE, "Copy buf size below min.: %d", copyBufSize);
ValidateUtils.checkTrue(copyBufSize <= MAX_FORWARDER_BUF_SIZE, "Copy buf size above max.: %d", copyBufSize);

@@ -151,9 +151,9 @@ public class ChannelAgentForwarding extends AbstractServerChannel {
@Override
protected Closeable getInnerCloseable() {
return builder()
- .close(super.getInnerCloseable())
- .run(toString(), this::closeImmediately0)
- .build();
+ .close(super.getInnerCloseable())
+ .run(toString(), this::closeImmediately0)
+ .build();
}

@Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java b/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java
index d7f37ed..9c3b32d 100644
--- a/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/agent/unix/UnixAgentFactory.java
@@ -45,8 +45,10 @@ import org.apache.sshd.server.session.ServerSession;
*/
public class UnixAgentFactory implements SshAgentFactory {
public static final List<NamedFactory<Channel>> DEFAULT_FORWARDING_CHANNELS =
- Collections.unmodifiableList(
- Arrays.<NamedFactory<Channel>>asList(ChannelAgentForwardingFactory.OPENSSH, ChannelAgentForwardingFactory.IETF));
+ Collections.unmodifiableList(
+ Arrays.<NamedFactory<Channel>>asList(
+ ChannelAgentForwardingFactory.OPENSSH,
+ ChannelAgentForwardingFactory.IETF));

private Factory<CloseableExecutorService> executorServiceFactory;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/ClientBuilder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/ClientBuilder.java b/sshd-core/src/main/java/org/apache/sshd/client/ClientBuilder.java
index 743fbdf..4f069d4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/ClientBuilder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/ClientBuilder.java
@@ -57,12 +57,12 @@ public class ClientBuilder extends BaseBuilder<SshClient, ClientBuilder> {

// Compression is not enabled by default for the client
public static final List<CompressionFactory> DEFAULT_COMPRESSION_FACTORIES =
- Collections.unmodifiableList(Collections.singletonList(BuiltinCompressions.none));
+ Collections.unmodifiableList(Collections.singletonList(BuiltinCompressions.none));

public static final List<NamedFactory<Channel>> DEFAULT_CHANNEL_FACTORIES =
- Collections.unmodifiableList(Collections.singletonList(ForwardedTcpipFactory.INSTANCE));
+ Collections.unmodifiableList(Collections.singletonList(ForwardedTcpipFactory.INSTANCE));
public static final List<RequestHandler<ConnectionService>> DEFAULT_GLOBAL_REQUEST_HANDLERS =
- Collections.unmodifiableList(Collections.singletonList(OpenSshHostKeysHandler.INSTANCE));
+ Collections.unmodifiableList(Collections.singletonList(OpenSshHostKeysHandler.INSTANCE));

public static final ServerKeyVerifier DEFAULT_SERVER_KEY_VERIFIER = AcceptAllServerKeyVerifier.INSTANCE;
public static final HostConfigEntryResolver DEFAULT_HOST_CONFIG_ENTRY_RESOLVER = DefaultConfigFileHostEntryResolver.INSTANCE;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
index 33ea4d2..84339c3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/SshClient.java
@@ -141,13 +141,15 @@ public class SshClient extends AbstractFactoryManager implements ClientFactoryMa
* @see <A HREF="http://linux.die.net/man/5/ssh_config">ssh_config(5) - PreferredAuthentications</A>
*/
public static final List<NamedFactory<UserAuth>> DEFAULT_USER_AUTH_FACTORIES =
- Collections.unmodifiableList(Arrays.<NamedFactory<UserAuth>>asList(
+ Collections.unmodifiableList(
+ Arrays.<NamedFactory<UserAuth>>asList(
UserAuthPublicKeyFactory.INSTANCE,
UserAuthKeyboardInteractiveFactory.INSTANCE,
UserAuthPasswordFactory.INSTANCE
));
public static final List<ServiceFactory> DEFAULT_SERVICE_FACTORIES =
- Collections.unmodifiableList(Arrays.asList(
+ Collections.unmodifiableList(
+ Arrays.asList(
ClientUserAuthServiceFactory.INSTANCE,
ClientConnectionServiceFactory.INSTANCE
));

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/auth/BuiltinUserAuthFactories.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/auth/BuiltinUserAuthFactories.java b/sshd-core/src/main/java/org/apache/sshd/client/auth/BuiltinUserAuthFactories.java
index 670efcc..60fbd0f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/auth/BuiltinUserAuthFactories.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/auth/BuiltinUserAuthFactories.java
@@ -49,7 +49,7 @@ public enum BuiltinUserAuthFactories implements NamedFactory<UserAuthFactory> {
HOSTBASED(UserAuthHostBasedFactory.INSTANCE);

public static final Set<BuiltinUserAuthFactories> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinUserAuthFactories.class));
+ Collections.unmodifiableSet(EnumSet.allOf(BuiltinUserAuthFactories.class));

private final UserAuthFactory factory;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
index c61e271..2673031 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java
@@ -33,6 +33,7 @@ import org.apache.sshd.client.channel.exit.ExitSignalChannelRequestHandler;
import org.apache.sshd.client.channel.exit.ExitStatusChannelRequestHandler;
import org.apache.sshd.client.future.DefaultOpenFuture;
import org.apache.sshd.client.future.OpenFuture;
+import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.Closeable;
import org.apache.sshd.common.FactoryManager;
import org.apache.sshd.common.SshConstants;
@@ -101,11 +102,10 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C
});
}

-// TODO: investigate how to fix the forwarding channel failures when enabled
-// @Override
-// public ClientSession getSession() {
-// return (ClientSession) super.getSession();
-// }
+ @Override
+ public ClientSession getClientSession() {
+ return (ClientSession) super.getSession();
+ }

protected void addChannelSignalRequestHandlers(EventNotifier<String> notifier) {
addRequestHandler(new ExitStatusChannelRequestHandler(exitStatusHolder, notifier));
@@ -187,25 +187,25 @@ public abstract class AbstractClientChannel extends AbstractChannel implements C
@Override
protected Closeable getInnerCloseable() {
return builder()
- .when(openFuture)
- .run(toString(), () -> {
- // If the channel has not been opened yet,
- // skip the SSH_MSG_CHANNEL_CLOSE exchange
- if (openFuture == null) {
- gracefulFuture.setClosed();
- }
- // Close inverted streams after
- // If the inverted stream is closed before, there's a small time window
- // in which we have:
- // ChannelPipedInputStream#closed = true
- // ChannelPipedInputStream#writerClosed = false
- // which leads to an IOException("Pipe closed") when reading.
- IoUtils.closeQuietly(in, out, err);
- IoUtils.closeQuietly(invertedIn, invertedOut, invertedErr);
- })
- .parallel(asyncIn, asyncOut, asyncErr)
- .close(super.getInnerCloseable())
- .build();
+ .when(openFuture)
+ .run(toString(), () -> {
+ // If the channel has not been opened yet,
+ // skip the SSH_MSG_CHANNEL_CLOSE exchange
+ if (openFuture == null) {
+ gracefulFuture.setClosed();
+ }
+ // Close inverted streams after
+ // If the inverted stream is closed before, there's a small time window
+ // in which we have:
+ // ChannelPipedInputStream#closed = true
+ // ChannelPipedInputStream#writerClosed = false
+ // which leads to an IOException("Pipe closed") when reading.
+ IoUtils.closeQuietly(in, out, err);
+ IoUtils.closeQuietly(invertedIn, invertedOut, invertedErr);
+ })
+ .parallel(asyncIn, asyncOut, asyncErr)
+ .close(super.getInnerCloseable())
+ .build();
}

@Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java
index c7ba086..79258fb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java
@@ -118,8 +118,7 @@ public class ChannelSession extends AbstractClientChannel {
protected RequestHandler.Result handleXonXoff(Buffer buffer, boolean wantReply) throws IOException {
boolean clientCanDo = buffer.getBoolean();
if (log.isDebugEnabled()) {
- log.debug("handleXonXoff({})[want-reply={}] client-can-do={}",
- this, wantReply, clientCanDo);
+ log.debug("handleXonXoff({})[want-reply={}] client-can-do={}", this, wantReply, clientCanDo);
}

return RequestHandler.Result.ReplySuccess;
@@ -128,9 +127,9 @@ public class ChannelSession extends AbstractClientChannel {
@Override
protected Closeable getInnerCloseable() {
return builder()
- .close(super.getInnerCloseable())
- .run(toString(), this::closeImmediately0)
- .build();
+ .close(super.getInnerCloseable())
+ .run(toString(), this::closeImmediately0)
+ .build();
}

protected void closeImmediately0() {
@@ -145,7 +144,7 @@ public class ChannelSession extends AbstractClientChannel {
// we log it as DEBUG since it is relatively harmless
if (log.isDebugEnabled()) {
log.debug("doCloseImmediately({}) failed {} to shutdown stream pumper: {}",
- this, e.getClass().getSimpleName(), e.getMessage());
+ this, e.getClass().getSimpleName(), e.getMessage());
}
if (log.isTraceEnabled()) {
log.trace("doCloseImmediately(" + this + ") stream pumper shutdown error details", e);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java
index 426a0da..c5a87c4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannel.java
@@ -27,6 +27,7 @@ import java.util.Collection;
import java.util.Set;

import org.apache.sshd.client.future.OpenFuture;
+import org.apache.sshd.client.session.ClientSessionHolder;
import org.apache.sshd.common.channel.Channel;
import org.apache.sshd.common.io.IoInputStream;
import org.apache.sshd.common.io.IoOutputStream;
@@ -39,7 +40,7 @@ import org.apache.sshd.common.io.IoOutputStream;
*
* @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
*/
-public interface ClientChannel extends Channel {
+public interface ClientChannel extends Channel, ClientSessionHolder {
enum Streaming {
Async,
Sync

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannelEvent.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannelEvent.java b/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannelEvent.java
index a0a95a6..3ad4d3c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannelEvent.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/channel/ClientChannelEvent.java
@@ -54,5 +54,5 @@ public enum ClientChannelEvent {
OPENED;

public static final Set<ClientChannelEvent> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(ClientChannelEvent.class));
+ Collections.unmodifiableSet(EnumSet.allOf(ClientChannelEvent.class));
}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
index 337c956..cf00249 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGClient.java
@@ -70,8 +70,8 @@ public class DHGClient extends AbstractDHClientKeyExchange {
@Override
public String toString() {
return NamedFactory.class.getSimpleName()
- + "<" + KeyExchange.class.getSimpleName() + ">"
- + "[" + getName() + "]";
+ + "<" + KeyExchange.class.getSimpleName() + ">"
+ + "[" + getName() + "]";
}
};
}
@@ -134,9 +134,9 @@ public class DHGClient extends AbstractDHClientKeyExchange {
hash.update(buffer.array(), 0, buffer.available());
h = hash.digest();

- Signature verif = ValidateUtils.checkNotNull(NamedFactory.create(session.getSignatureFactories(), keyAlg),
- "No verifier located for algorithm=%s",
- keyAlg);
+ Signature verif = ValidateUtils.checkNotNull(
+ NamedFactory.create(session.getSignatureFactories(), keyAlg),
+ "No verifier located for algorithm=%s", keyAlg);
verif.initVerifier(serverKey);
verif.update(h);
if (!verif.verify(sig)) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
index 0ad7150..697849c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/kex/DHGEXClient.java
@@ -79,8 +79,8 @@ public class DHGEXClient extends AbstractDHClientKeyExchange {
@Override
public String toString() {
return NamedFactory.class.getSimpleName()
- + "<" + KeyExchange.class.getSimpleName() + ">"
- + "[" + getName() + "]";
+ + "<" + KeyExchange.class.getSimpleName() + ">"
+ + "[" + getName() + "]";
}
};
}
@@ -167,14 +167,13 @@ public class DHGEXClient extends AbstractDHClientKeyExchange {
h = hash.digest();

Signature verif = ValidateUtils.checkNotNull(
- NamedFactory.create(session.getSignatureFactories(), keyAlg),
- "No verifier located for algorithm=%s",
- keyAlg);
+ NamedFactory.create(session.getSignatureFactories(), keyAlg),
+ "No verifier located for algorithm=%s", keyAlg);
verif.initVerifier(serverKey);
verif.update(h);
if (!verif.verify(sig)) {
throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
- "KeyExchange signature verification failed for key type=" + keyAlg);
+ "KeyExchange signature verification failed for key type=" + keyAlg);
}
return true;
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
index 5ec3a69..2ee30e8 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/AbstractClientSession.java
@@ -102,7 +102,8 @@ public abstract class AbstractClientSession extends AbstractSession implements C

@Override
public ServerKeyVerifier getServerKeyVerifier() {
- return resolveEffectiveProvider(ServerKeyVerifier.class, serverKeyVerifier, getFactoryManager().getServerKeyVerifier());
+ ClientFactoryManager manager = getFactoryManager();
+ return resolveEffectiveProvider(ServerKeyVerifier.class, serverKeyVerifier, manager.getServerKeyVerifier());
}

@Override
@@ -112,7 +113,8 @@ public abstract class AbstractClientSession extends AbstractSession implements C

@Override
public UserInteraction getUserInteraction() {
- return resolveEffectiveProvider(UserInteraction.class, userInteraction, getFactoryManager().getUserInteraction());
+ ClientFactoryManager manager = getFactoryManager();
+ return resolveEffectiveProvider(UserInteraction.class, userInteraction, manager.getUserInteraction());
}

@Override
@@ -122,7 +124,8 @@ public abstract class AbstractClientSession extends AbstractSession implements C

@Override
public List<NamedFactory<UserAuth>> getUserAuthFactories() {
- return resolveEffectiveFactories(UserAuth.class, userAuthFactories, getFactoryManager().getUserAuthFactories());
+ ClientFactoryManager manager = getFactoryManager();
+ return resolveEffectiveFactories(UserAuth.class, userAuthFactories, manager.getUserAuthFactories());
}

@Override
@@ -137,7 +140,8 @@ public abstract class AbstractClientSession extends AbstractSession implements C

@Override
public PasswordIdentityProvider getPasswordIdentityProvider() {
- return resolveEffectiveProvider(PasswordIdentityProvider.class, passwordIdentityProvider, getFactoryManager().getPasswordIdentityProvider());
+ ClientFactoryManager manager = getFactoryManager();
+ return resolveEffectiveProvider(PasswordIdentityProvider.class, passwordIdentityProvider, manager.getPasswordIdentityProvider());
}

@Override
@@ -147,7 +151,8 @@ public abstract class AbstractClientSession extends AbstractSession implements C

@Override
public ClientProxyConnector getClientProxyConnector() {
- return resolveEffectiveProvider(ClientProxyConnector.class, proxyConnector, getFactoryManager().getClientProxyConnector());
+ ClientFactoryManager manager = getFactoryManager();
+ return resolveEffectiveProvider(ClientProxyConnector.class, proxyConnector, manager.getClientProxyConnector());
}

@Override
@@ -172,7 +177,7 @@ public abstract class AbstractClientSession extends AbstractSession implements C
}

int index = AuthenticationIdentitiesProvider.findIdentityIndex(
- identities, AuthenticationIdentitiesProvider.PASSWORD_IDENTITY_COMPARATOR, password);
+ identities, AuthenticationIdentitiesProvider.PASSWORD_IDENTITY_COMPARATOR, password);
if (index >= 0) {
return (String) identities.remove(index);
} else {
@@ -191,7 +196,7 @@ public abstract class AbstractClientSession extends AbstractSession implements C
if (log.isDebugEnabled()) {
PublicKey key = kp.getPublic();
log.debug("addPublicKeyIdentity({}) {}-{}",
- this, KeyUtils.getKeyType(key), KeyUtils.getFingerPrint(key));
+ this, KeyUtils.getKeyType(key), KeyUtils.getFingerPrint(key));
}
}

@@ -202,7 +207,7 @@ public abstract class AbstractClientSession extends AbstractSession implements C
}

int index = AuthenticationIdentitiesProvider.findIdentityIndex(
- identities, AuthenticationIdentitiesProvider.KEYPAIR_IDENTITY_COMPARATOR, kp);
+ identities, AuthenticationIdentitiesProvider.KEYPAIR_IDENTITY_COMPARATOR, kp);
if (index >= 0) {
return (KeyPair) identities.remove(index);
} else {
@@ -219,7 +224,7 @@ public abstract class AbstractClientSession extends AbstractSession implements C
proxyConnector.sendClientProxyMetadata(this);
} catch (Throwable t) {
log.warn("sendClientIdentification({}) failed ({}) to send proxy metadata: {}",
- this, t.getClass().getSimpleName(), t.getMessage());
+ this, t.getClass().getSimpleName(), t.getMessage());
if (log.isDebugEnabled()) {
log.debug("sendClientIdentification(" + this + ") proxy metadata send failure details", t);
}
@@ -433,7 +438,7 @@ public abstract class AbstractClientSession extends AbstractSession implements C
boolean verified = serverKeyVerifier.verifyServerKey(this, remoteAddress, serverKey);
if (log.isDebugEnabled()) {
log.debug("checkKeys({}) key={}-{}, verified={}",
- this, KeyUtils.getKeyType(serverKey), KeyUtils.getFingerPrint(serverKey), verified);
+ this, KeyUtils.getKeyType(serverKey), KeyUtils.getFingerPrint(serverKey), verified);
}

if (!verified) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
index 4a72296..b016ae3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSession.java
@@ -94,7 +94,7 @@ public interface ClientSession
}

Set<ClientChannelEvent> REMOTE_COMMAND_WAIT_EVENTS =
- Collections.unmodifiableSet(EnumSet.of(ClientChannelEvent.CLOSED));
+ Collections.unmodifiableSet(EnumSet.of(ClientChannelEvent.CLOSED));

/**
* Returns the original address (after having been translated through host

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
index caab2f7..0055553 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientSessionImpl.java
@@ -144,7 +144,7 @@ public class ClientSessionImpl extends AbstractClientSession {

if (log.isDebugEnabled()) {
log.debug("signalAuthFailure({}) type={}, signalled={}, message=\"{}\"",
- this, t.getClass().getSimpleName(), signalled, t.getMessage());
+ this, t.getClass().getSimpleName(), signalled, t.getMessage());
}
}
l***@apache.org
2018-10-25 09:11:03 UTC
Permalink
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
index 3b77c45..1007494 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpipServerChannel.java
@@ -146,7 +146,7 @@ public class TcpipServerChannel extends AbstractServerChannel implements Forward
boolean debugEnabled = log.isDebugEnabled();
if (debugEnabled) {
log.debug("doInit({}) Receiving request for direct tcpip: hostToConnect={}, portToConnect={}, originatorIpAddress={}, originatorPort={}",
- this, hostToConnect, portToConnect, originatorIpAddress, originatorPort);
+ this, hostToConnect, portToConnect, originatorIpAddress, originatorPort);
}

SshdSocketAddress address;
@@ -178,7 +178,8 @@ public class TcpipServerChannel extends AbstractServerChannel implements Forward
log.debug("doInit(" + this + ")[" + type + "][haveFilter=" + (filter != null) + "] filtered out " + address);
}
try {
- f.setException(new SshChannelOpenException(getId(), SshConstants.SSH_OPEN_ADMINISTRATIVELY_PROHIBITED, "Connection denied"));
+ f.setException(new SshChannelOpenException(getId(),
+ SshConstants.SSH_OPEN_ADMINISTRATIVELY_PROHIBITED, "Connection denied"));
} finally {
super.close(true);
}
@@ -296,42 +297,44 @@ public class TcpipServerChannel extends AbstractServerChannel implements Forward
@Override
protected Closeable getInnerCloseable() {
return builder()
- .run(toString(), () -> {
- /*
- * In case of graceful shutdown (e.g. when the remote channel is gently closed)
- * we also need to close the ChannelOutputStream which flushes remaining buffer
- * and sends SSH_MSG_CHANNEL_EOF back to the client.
- */
- if (out != null) {
- try {
+ .run(toString(), () -> {
+ /*
+ * In case of graceful shutdown (e.g. when the remote channel is gently closed)
+ * we also need to close the ChannelOutputStream which flushes remaining buffer
+ * and sends SSH_MSG_CHANNEL_EOF back to the client.
+ */
+ if (out != null) {
+ try {
+ if (log.isDebugEnabled()) {
log.debug("Closing channel output stream of {}", this);
- out.close();
- } catch (IOException | RuntimeException ignored) {
- log.debug("{} while closing channel output stream of {}: {}",
- ignored.getClass().getSimpleName(), this, ignored.getMessage(), ignored);
}
+ out.close();
+ } catch (IOException | RuntimeException ignored) {
+ log.debug("{} while closing channel output stream of {}: {}",
+ ignored.getClass().getSimpleName(), this, ignored.getMessage(), ignored);
}
- })
- .close(super.getInnerCloseable())
- .close(new AbstractCloseable() {
- private final CloseableExecutorService executor =
- ThreadUtils.newCachedThreadPool("TcpIpServerChannel-ConnectorCleanup[" + getSession() + "]");
-
- @Override
- @SuppressWarnings("synthetic-access")
- protected CloseFuture doCloseGracefully() {
- executor.submit(() -> connector.close(false));
- return null;
- }
+ }
+ })
+ .close(super.getInnerCloseable())
+ .close(new AbstractCloseable() {
+ private final CloseableExecutorService executor =
+ ThreadUtils.newCachedThreadPool("TcpIpServerChannel-ConnectorCleanup[" + getSession() + "]");
+
+ @Override
+ @SuppressWarnings("synthetic-access")
+ protected CloseFuture doCloseGracefully() {
+ executor.submit(() -> connector.close(false));
+ return null;
+ }

- @Override
- @SuppressWarnings("synthetic-access")
- protected void doCloseImmediately() {
- executor.submit(() -> connector.close(true).addListener(f -> executor.close(true)));
- super.doCloseImmediately();
- }
- })
- .build();
+ @Override
+ @SuppressWarnings("synthetic-access")
+ protected void doCloseImmediately() {
+ executor.submit(() -> connector.close(true).addListener(f -> executor.close(true)));
+ super.doCloseImmediately();
+ }
+ })
+ .build();
}

@Override
@@ -385,7 +388,7 @@ public class TcpipServerChannel extends AbstractServerChannel implements Forward
// SSHD-795 IOException (Broken pipe) on a socket local forwarding channel causes SSH client-server connection down
if (debugEnabled) {
log.debug("handleWriteDataFailure({})[{}] closing session={}",
- this, SshConstants.getCommandMessageName(cmd & 0xFF), ioSession);
+ this, SshConstants.getCommandMessageName(cmd & 0xFF), ioSession);
}
close(false);
} else {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java
index a27e7dc..404059f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGEXServer.java
@@ -88,8 +88,8 @@ public class DHGEXServer extends AbstractDHServerKeyExchange {
@Override
public String toString() {
return NamedFactory.class.getSimpleName()
- + "<" + KeyExchange.class.getSimpleName() + ">"
- + "[" + getName() + "]";
+ + "<" + KeyExchange.class.getSimpleName() + ">"
+ + "[" + getName() + "]";
}
};
}
@@ -176,9 +176,8 @@ public class DHGEXServer extends AbstractDHServerKeyExchange {
KeyPair kp = Objects.requireNonNull(session.getHostKey(), "No server key pair available");
String algo = session.getNegotiatedKexParameter(KexProposalOption.SERVERKEYS);
Signature sig = ValidateUtils.checkNotNull(
- NamedFactory.create(session.getSignatureFactories(), algo),
- "Unknown negotiated server keys: %s",
- algo);
+ NamedFactory.create(session.getSignatureFactories(), algo),
+ "Unknown negotiated server keys: %s", algo);
sig.initSigner(kp.getPrivate());

buffer = new ByteArrayBuffer();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java
index f9d8799..3dfefad 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/kex/DHGServer.java
@@ -69,8 +69,8 @@ public class DHGServer extends AbstractDHServerKeyExchange {
@Override
public String toString() {
return NamedFactory.class.getSimpleName()
- + "<" + KeyExchange.class.getSimpleName() + ">"
- + "[" + getName() + "]";
+ + "<" + KeyExchange.class.getSimpleName() + ">"
+ + "[" + getName() + "]";
}
};
}
@@ -93,7 +93,7 @@ public class DHGServer extends AbstractDHServerKeyExchange {

if (cmd != SshConstants.SSH_MSG_KEXDH_INIT) {
throw new SshException(SshConstants.SSH2_DISCONNECT_KEY_EXCHANGE_FAILED,
- "Protocol error: expected packet SSH_MSG_KEXDH_INIT, got " + KeyExchange.getSimpleKexOpcodeName(cmd));
+ "Protocol error: expected packet SSH_MSG_KEXDH_INIT, got " + KeyExchange.getSimpleKexOpcodeName(cmd));
}

e = buffer.getMPIntAsBytes();
@@ -103,9 +103,8 @@ public class DHGServer extends AbstractDHServerKeyExchange {
KeyPair kp = Objects.requireNonNull(session.getHostKey(), "No server key pair available");
String algo = session.getNegotiatedKexParameter(KexProposalOption.SERVERKEYS);
Signature sig = ValidateUtils.checkNotNull(
- NamedFactory.create(session.getSignatureFactories(), algo),
- "Unknown negotiated server keys: %s",
- algo);
+ NamedFactory.create(session.getSignatureFactories(), algo),
+ "Unknown negotiated server keys: %s", algo);
sig.initSigner(kp.getPrivate());

buffer = new ByteArrayBuffer();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java b/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
index b094661..04e7fd0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/AbstractServerSession.java
@@ -103,7 +103,8 @@ public abstract class AbstractServerSession extends AbstractSession implements S

@Override
public PasswordAuthenticator getPasswordAuthenticator() {
- return resolveEffectiveProvider(PasswordAuthenticator.class, passwordAuthenticator, getFactoryManager().getPasswordAuthenticator());
+ ServerFactoryManager manager = getFactoryManager();
+ return resolveEffectiveProvider(PasswordAuthenticator.class, passwordAuthenticator, manager.getPasswordAuthenticator());
}

@Override
@@ -113,7 +114,8 @@ public abstract class AbstractServerSession extends AbstractSession implements S

@Override
public PublickeyAuthenticator getPublickeyAuthenticator() {
- return resolveEffectiveProvider(PublickeyAuthenticator.class, publickeyAuthenticator, getFactoryManager().getPublickeyAuthenticator());
+ ServerFactoryManager manager = getFactoryManager();
+ return resolveEffectiveProvider(PublickeyAuthenticator.class, publickeyAuthenticator, manager.getPublickeyAuthenticator());
}

@Override
@@ -123,7 +125,8 @@ public abstract class AbstractServerSession extends AbstractSession implements S

@Override
public KeyboardInteractiveAuthenticator getKeyboardInteractiveAuthenticator() {
- return resolveEffectiveProvider(KeyboardInteractiveAuthenticator.class, interactiveAuthenticator, getFactoryManager().getKeyboardInteractiveAuthenticator());
+ ServerFactoryManager manager = getFactoryManager();
+ return resolveEffectiveProvider(KeyboardInteractiveAuthenticator.class, interactiveAuthenticator, manager.getKeyboardInteractiveAuthenticator());
}

@Override
@@ -133,7 +136,8 @@ public abstract class AbstractServerSession extends AbstractSession implements S

@Override
public GSSAuthenticator getGSSAuthenticator() {
- return resolveEffectiveProvider(GSSAuthenticator.class, gssAuthenticator, getFactoryManager().getGSSAuthenticator());
+ ServerFactoryManager manager = getFactoryManager();
+ return resolveEffectiveProvider(GSSAuthenticator.class, gssAuthenticator, manager.getGSSAuthenticator());
}

@Override
@@ -143,7 +147,8 @@ public abstract class AbstractServerSession extends AbstractSession implements S

@Override
public HostBasedAuthenticator getHostBasedAuthenticator() {
- return resolveEffectiveProvider(HostBasedAuthenticator.class, hostBasedAuthenticator, getFactoryManager().getHostBasedAuthenticator());
+ ServerFactoryManager manager = getFactoryManager();
+ return resolveEffectiveProvider(HostBasedAuthenticator.class, hostBasedAuthenticator, manager.getHostBasedAuthenticator());
}

@Override
@@ -153,7 +158,8 @@ public abstract class AbstractServerSession extends AbstractSession implements S

@Override
public List<NamedFactory<UserAuth>> getUserAuthFactories() {
- return resolveEffectiveFactories(UserAuth.class, userAuthFactories, getFactoryManager().getUserAuthFactories());
+ ServerFactoryManager manager = getFactoryManager();
+ return resolveEffectiveFactories(UserAuth.class, userAuthFactories, manager.getUserAuthFactories());
}

@Override
@@ -208,9 +214,9 @@ public abstract class AbstractServerSession extends AbstractSession implements S
public void startService(String name) throws Exception {
FactoryManager factoryManager = getFactoryManager();
currentService = ServiceFactory.create(
- factoryManager.getServiceFactories(),
- ValidateUtils.checkNotNullAndNotEmpty(name, "No service name"),
- this);
+ factoryManager.getServiceFactories(),
+ ValidateUtils.checkNotNullAndNotEmpty(name, "No service name"),
+ this);
/*
* According to RFC4253:
*
@@ -255,7 +261,7 @@ public abstract class AbstractServerSession extends AbstractSession implements S
provided = (kpp == null) ? null : kpp.getKeyTypes();
} catch (Error e) {
log.warn("resolveAvailableSignaturesProposal({}) failed ({}) to get key types: {}",
- this, e.getClass().getSimpleName(), e.getMessage());
+ this, e.getClass().getSimpleName(), e.getMessage());
if (debugEnabled) {
log.debug("resolveAvailableSignaturesProposal(" + this + ") fetch key types failure details", e);
}
@@ -272,7 +278,7 @@ public abstract class AbstractServerSession extends AbstractSession implements S
if (!supported.contains(keyType)) {
if (debugEnabled) {
log.debug("resolveAvailableSignaturesProposal({})[{}] {} not in supported list: {}",
- this, provided, keyType, supported);
+ this, provided, keyType, supported);
}
continue;
}
@@ -307,7 +313,7 @@ public abstract class AbstractServerSession extends AbstractSession implements S
protected String resolveEmptySignaturesProposal(Iterable<String> supported, Iterable<String> provided) {
if (log.isDebugEnabled()) {
log.debug("resolveEmptySignaturesProposal({})[{}] none of the keys appears in supported list: {}",
- this, provided, supported);
+ this, provided, supported);
}
return null;
}
@@ -326,7 +332,7 @@ public abstract class AbstractServerSession extends AbstractSession implements S
}
} catch (Throwable t) {
log.warn("readIdentification({}) failed ({}) to accept proxy metadata: {}",
- this, t.getClass().getSimpleName(), t.getMessage());
+ this, t.getClass().getSimpleName(), t.getMessage());
if (debugEnabled) {
log.debug("readIdentification(" + this + ") proxy metadata acceptance failure details", t);
}
@@ -368,7 +374,7 @@ public abstract class AbstractServerSession extends AbstractSession implements S
if (GenericUtils.length(errorMessage) > 0) {
IoSession networkSession = getIoSession();
networkSession.writePacket(new ByteArrayBuffer((errorMessage + "\n").getBytes(StandardCharsets.UTF_8)))
- .addListener(future -> close(true));
+ .addListener(future -> close(true));
throw new SshException(errorMessage);
}

@@ -391,7 +397,7 @@ public abstract class AbstractServerSession extends AbstractSession implements S
return provider.loadKey(keyType);
} catch (Error e) {
log.warn("getHostKey({}) failed ({}) to load key of type={}: {}",
- this, e.getClass().getSimpleName(), keyType, e.getMessage());
+ this, e.getClass().getSimpleName(), keyType, e.getMessage());
if (log.isDebugEnabled()) {
log.debug("getHostKey(" + this + ") " + keyType + " key load failure details", e);
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
index 35a3470..8f15690 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/session/ServerUserAuthService.java
@@ -90,7 +90,7 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
maxAuthRequests = s.getIntProperty(ServerAuthenticationManager.MAX_AUTH_REQUESTS, ServerAuthenticationManager.DEFAULT_MAX_AUTH_REQUESTS);

List<NamedFactory<UserAuth>> factories = ValidateUtils.checkNotNullAndNotEmpty(
- serverSession.getUserAuthFactories(), "No user auth factories for %s", s);
+ serverSession.getUserAuthFactories(), "No user auth factories for %s", s);
userAuthFactories = new ArrayList<>(factories);
// Get authentication methods
authMethods = new ArrayList<>();
@@ -111,7 +111,8 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
// Verify all required methods are supported
for (List<String> l : authMethods) {
for (String m : l) {
- NamedFactory<UserAuth> factory = NamedResource.findByName(m, String.CASE_INSENSITIVE_ORDER, userAuthFactories);
+ NamedFactory<UserAuth> factory =
+ NamedResource.findByName(m, String.CASE_INSENSITIVE_ORDER, userAuthFactories);
if (factory == null) {
throw new SshException("Configured method is not supported: " + m);
}
@@ -120,7 +121,7 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,

if (debugEnabled) {
log.debug("ServerUserAuthService({}) authorized authentication methods: {}",
- s, NamedResource.getNames(userAuthFactories));
+ s, NamedResource.getNames(userAuthFactories));
}
}

@@ -166,7 +167,7 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
String method = buffer.getString();
if (debugEnabled) {
log.debug("process({}) Received SSH_MSG_USERAUTH_REQUEST user={}, service={}, method={}",
- session, username, service, method);
+ session, username, service, method);
}

if (this.authUserName == null || this.authService == null) {
@@ -175,13 +176,14 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
} else if (this.authUserName.equals(username) && this.authService.equals(service)) {
nbAuthRequests++;
if (nbAuthRequests > maxAuthRequests) {
- session.disconnect(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR, "Too many authentication failures: " + nbAuthRequests);
+ session.disconnect(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
+ "Too many authentication failures: " + nbAuthRequests);
return;
}
} else {
session.disconnect(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
- "Change of username or service is not allowed (" + this.authUserName + ", " + this.authService + ") -> ("
- + username + ", " + service + ")");
+ "Change of username or service is not allowed (" + this.authUserName + ", " + this.authService + ") -> ("
+ + username + ", " + service + ")");
return;
}

@@ -189,7 +191,7 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
this.authMethod = method;
if (debugEnabled) {
log.debug("process({}) Authenticating user '{}' with service '{}' and method '{}' (attempt {} / {})",
- session, username, service, method, nbAuthRequests, maxAuthRequests);
+ session, username, service, method, nbAuthRequests, maxAuthRequests);
}

Factory<UserAuth> factory = NamedResource.findByName(method, String.CASE_INSENSITIVE_ORDER, userAuthFactories);
@@ -203,7 +205,7 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
} catch (Exception e) {
if (debugEnabled) {
log.debug("process({}) Failed ({}) to authenticate using factory method={}: {}",
- session, e.getClass().getSimpleName(), method, e.getMessage());
+ session, e.getClass().getSimpleName(), method, e.getMessage());
}
if (log.isTraceEnabled()) {
log.trace("process(" + session + ") factory authentication=" + method + " failure details", e);
@@ -226,7 +228,7 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,

if (debugEnabled) {
log.debug("process({}) Received authentication message={} for mechanism={}",
- session, SshConstants.getCommandMessageName(cmd), currentAuth.getName());
+ session, SshConstants.getCommandMessageName(cmd), currentAuth.getName());
}

buffer.rpos(buffer.rpos() - 1);
@@ -239,7 +241,7 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
// Continue
if (debugEnabled) {
log.debug("process({}) Failed ({}) to authenticate using current method={}: {}",
- session, e.getClass().getSimpleName(), currentAuth.getName(), e.getMessage());
+ session, e.getClass().getSimpleName(), currentAuth.getName(), e.getMessage());
}
if (log.isTraceEnabled()) {
log.trace("process(" + session + ") current authentication=" + currentAuth.getName() + " failure details", e);
@@ -272,7 +274,7 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
String username = (currentAuth == null) ? null : currentAuth.getUsername();
if (log.isDebugEnabled()) {
log.debug("handleAuthenticationInProgress({}@{}) {}",
- username, getServerSession(), SshConstants.getCommandMessageName(cmd));
+ username, getServerSession(), SshConstants.getCommandMessageName(cmd));
}
}

@@ -282,7 +284,7 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
boolean debugEnabled = log.isDebugEnabled();
if (debugEnabled) {
log.debug("handleAuthenticationSuccess({}@{}) {}",
- username, session, SshConstants.getCommandMessageName(cmd));
+ username, session, SshConstants.getCommandMessageName(cmd));
}

boolean success = false;
@@ -299,7 +301,7 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
int currentSessionCount = session.getActiveSessionCountForUser(username);
if (currentSessionCount >= maxSessionCount) {
session.disconnect(SshConstants.SSH2_DISCONNECT_TOO_MANY_CONNECTIONS,
- "Too many concurrent connections (" + currentSessionCount + ") - max. allowed: " + maxSessionCount);
+ "Too many concurrent connections (" + currentSessionCount + ") - max. allowed: " + maxSessionCount);
return;
}
}
@@ -317,9 +319,9 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
log.info("Session {}@{} authenticated", username, session.getIoSession().getRemoteAddress());
} else {
String remaining = authMethods.stream()
- .filter(GenericUtils::isNotEmpty)
- .map(l -> l.get(0))
- .collect(Collectors.joining(","));
+ .filter(GenericUtils::isNotEmpty)
+ .map(l -> l.get(0))
+ .collect(Collectors.joining(","));

if (debugEnabled) {
log.debug("handleAuthenticationSuccess({}@{}) remaining methods={}", username, session, remaining);
@@ -404,16 +406,16 @@ public class ServerUserAuthService extends AbstractCloseable implements Service,
}

String lang = PropertyResolverUtils.getStringProperty(session,
- ServerAuthenticationManager.WELCOME_BANNER_LANGUAGE,
- ServerAuthenticationManager.DEFAULT_WELCOME_BANNER_LANGUAGE);
+ ServerAuthenticationManager.WELCOME_BANNER_LANGUAGE,
+ ServerAuthenticationManager.DEFAULT_WELCOME_BANNER_LANGUAGE);
Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_BANNER,
- welcomeBanner.length() + GenericUtils.length(lang) + Long.SIZE);
+ welcomeBanner.length() + GenericUtils.length(lang) + Long.SIZE);
buffer.putString(welcomeBanner);
buffer.putString(lang);

if (log.isDebugEnabled()) {
log.debug("sendWelcomeBanner({}) send banner (length={}, lang={})",
- session, welcomeBanner.length(), lang);
+ session, welcomeBanner.length(), lang);
}
return session.writePacket(buffer);
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterInputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterInputStream.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterInputStream.java
index 715bf05..9cde926 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterInputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterInputStream.java
@@ -40,7 +40,7 @@ import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
*/
public class TtyFilterInputStream extends FilterInputStream {
public static final Set<PtyMode> INPUT_OPTIONS =
- Collections.unmodifiableSet(EnumSet.of(PtyMode.ONLCR, PtyMode.OCRNL, PtyMode.ONLRET, PtyMode.ONOCR));
+ Collections.unmodifiableSet(EnumSet.of(PtyMode.ONLCR, PtyMode.OCRNL, PtyMode.ONLRET, PtyMode.ONOCR));

private final Set<PtyMode> ttyOptions;
private Buffer buffer = new ByteArrayBuffer(Integer.SIZE, false);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java
index 2dd380a..c969002 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/shell/TtyFilterOutputStream.java
@@ -39,7 +39,7 @@ import org.apache.sshd.common.util.GenericUtils;
*/
public class TtyFilterOutputStream extends FilterOutputStream {
public static final Set<PtyMode> OUTPUT_OPTIONS =
- Collections.unmodifiableSet(EnumSet.of(PtyMode.ECHO, PtyMode.INLCR, PtyMode.ICRNL, PtyMode.IGNCR));
+ Collections.unmodifiableSet(EnumSet.of(PtyMode.ECHO, PtyMode.INLCR, PtyMode.ICRNL, PtyMode.IGNCR));

private final Set<PtyMode> ttyOptions;
private final TtyFilterInputStream echo;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java b/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java
index 0089782..78b4a50 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/cipher/CipherTest.java
@@ -68,20 +68,22 @@ public class CipherTest extends BaseTestSupport {
* NOTE !!! order is important since we build from it the C2S/S2C ciphers proposal
*/
private static final List<Object[]> PARAMETERS =
- Collections.unmodifiableList(Arrays.asList(
- new Object[]{BuiltinCiphers.aes128cbc, com.jcraft.jsch.jce.AES128CBC.class, NUM_LOADTEST_ROUNDS},
- new Object[]{BuiltinCiphers.tripledescbc, com.jcraft.jsch.jce.TripleDESCBC.class, NUM_LOADTEST_ROUNDS},
- new Object[]{BuiltinCiphers.blowfishcbc, com.jcraft.jsch.jce.BlowfishCBC.class, NUM_LOADTEST_ROUNDS},
- new Object[]{BuiltinCiphers.aes192cbc, com.jcraft.jsch.jce.AES192CBC.class, NUM_LOADTEST_ROUNDS},
- new Object[]{BuiltinCiphers.aes256cbc, com.jcraft.jsch.jce.AES256CBC.class, NUM_LOADTEST_ROUNDS},
- new Object[]{BuiltinCiphers.arcfour128, com.jcraft.jsch.jce.ARCFOUR128.class, NUM_LOADTEST_ROUNDS},
- new Object[]{BuiltinCiphers.arcfour256, com.jcraft.jsch.jce.ARCFOUR256.class, NUM_LOADTEST_ROUNDS}
- ));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ new Object[]{BuiltinCiphers.aes128cbc, com.jcraft.jsch.jce.AES128CBC.class, NUM_LOADTEST_ROUNDS},
+ new Object[]{BuiltinCiphers.tripledescbc, com.jcraft.jsch.jce.TripleDESCBC.class, NUM_LOADTEST_ROUNDS},
+ new Object[]{BuiltinCiphers.blowfishcbc, com.jcraft.jsch.jce.BlowfishCBC.class, NUM_LOADTEST_ROUNDS},
+ new Object[]{BuiltinCiphers.aes192cbc, com.jcraft.jsch.jce.AES192CBC.class, NUM_LOADTEST_ROUNDS},
+ new Object[]{BuiltinCiphers.aes256cbc, com.jcraft.jsch.jce.AES256CBC.class, NUM_LOADTEST_ROUNDS},
+ new Object[]{BuiltinCiphers.arcfour128, com.jcraft.jsch.jce.ARCFOUR128.class, NUM_LOADTEST_ROUNDS},
+ new Object[]{BuiltinCiphers.arcfour256, com.jcraft.jsch.jce.ARCFOUR256.class, NUM_LOADTEST_ROUNDS}
+ ));

private static final List<NamedResource> TEST_CIPHERS =
Collections.unmodifiableList(
- Stream.concat(PARAMETERS.stream().map(params -> (NamedResource) params[0]), Stream.of(BuiltinCiphers.none))
- .collect(Collectors.toList()));
+ Stream.concat(PARAMETERS.stream()
+ .map(params -> (NamedResource) params[0]), Stream.of(BuiltinCiphers.none))
+ .collect(Collectors.toList()));

private static final String CRYPT_NAMES = NamedResource.getNames(TEST_CIPHERS);
private static SshServer sshd;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java b/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
index b18c273..a05b05f 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/compression/CompressionTest.java
@@ -63,7 +63,7 @@ import com.jcraft.jsch.JSch;
@UseParametersRunnerFactory(JUnit4ClassRunnerWithParametersFactory.class)
public class CompressionTest extends BaseTestSupport {
private static final Collection<KexProposalOption> COMPRESSION_OPTIONS =
- Collections.unmodifiableSet(EnumSet.of(KexProposalOption.C2SCOMP, KexProposalOption.S2CCOMP));
+ Collections.unmodifiableSet(EnumSet.of(KexProposalOption.C2SCOMP, KexProposalOption.S2CCOMP));

private static SshServer sshd;
private static int port;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java b/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java
index 4d3bfa8..3ea363b 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/mac/MacTest.java
@@ -64,8 +64,8 @@ import ch.ethz.ssh2.ConnectionInfo;
@UseParametersRunnerFactory(JUnit4ClassRunnerWithParametersFactory.class)
public class MacTest extends BaseTestSupport {
private static final Collection<String> GANYMEDE_MACS =
- Collections.unmodifiableSet(
- GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER, Connection.getAvailableMACs()));
+ Collections.unmodifiableSet(
+ GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER, Connection.getAvailableMACs()));

private static SshServer sshd;
private static int port;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureFactoriesTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureFactoriesTest.java b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureFactoriesTest.java
index 0733967..164c2f1 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureFactoriesTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/signature/SignatureFactoriesTest.java
@@ -100,8 +100,8 @@ public class SignatureFactoriesTest extends BaseTestSupport implements OptionalF
for (ECCurves curve : ECCurves.VALUES) {
BuiltinSignatures factory = BuiltinSignatures.fromFactoryName(curve.getKeyType());
addTests(list, curve.getName(), factory,
- curve.isSupported() ? Collections.singletonList(curve.getKeySize()) : Collections.singletonList(-1),
- curve.isSupported() ? ECDSAPublicKeyEntryDecoder.INSTANCE : null);
+ curve.isSupported() ? Collections.singletonList(curve.getKeySize()) : Collections.singletonList(-1),
+ curve.isSupported() ? ECDSAPublicKeyEntryDecoder.INSTANCE : null);
}
} else {
for (String name : ECCurves.NAMES) {
@@ -109,7 +109,7 @@ public class SignatureFactoriesTest extends BaseTestSupport implements OptionalF
}
}
addTests(list, KeyPairProvider.SSH_ED25519, BuiltinSignatures.ed25519, ED25519_SIZES,
- SecurityUtils.isEDDSACurveSupported() ? SecurityUtils.getEDDSAPublicKeyEntryDecoder() : null);
+ SecurityUtils.isEDDSACurveSupported() ? SecurityUtils.getEDDSAPublicKeyEntryDecoder() : null);
return Collections.unmodifiableList(list);
}


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java
index ba684ce..a0226c8 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/shell/TtyFilterInputStreamTest.java
@@ -58,10 +58,9 @@ import org.junit.runners.Parameterized.UseParametersRunnerFactory;
@Category({ NoIoTestCase.class })
public class TtyFilterInputStreamTest extends BaseTestSupport {
private static final List<PtyMode> MODES =
- Collections.unmodifiableList(
- Stream.concat(Stream.of(PtyMode.ECHO),
- TtyFilterInputStream.INPUT_OPTIONS.stream())
- .collect(Collectors.toList()));
+ Collections.unmodifiableList(
+ Stream.concat(Stream.of(PtyMode.ECHO), TtyFilterInputStream.INPUT_OPTIONS.stream())
+ .collect(Collectors.toList()));

private final PtyMode mode;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSession.java
----------------------------------------------------------------------
diff --git a/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSession.java b/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSession.java
index 2bac013..44136b3 100644
--- a/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSession.java
+++ b/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSession.java
@@ -63,7 +63,8 @@ public class GitSshdSession extends AbstractLoggingBean implements RemoteSession
private final SshClient client;
private final ClientSession session;

- public GitSshdSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms) throws IOException, InterruptedException {
+ public GitSshdSession(URIish uri, CredentialsProvider credentialsProvider, FS fs, int tms)
+ throws IOException, InterruptedException {
String user = uri.getUser();
final String pass1 = uri.getPass();
String host = uri.getHost();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionProcess.java
----------------------------------------------------------------------
diff --git a/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionProcess.java b/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionProcess.java
index dc36df0..43527fb 100644
--- a/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionProcess.java
+++ b/sshd-git/src/main/java/org/apache/sshd/git/transport/GitSshdSessionProcess.java
@@ -75,7 +75,6 @@ public class GitSshdSessionProcess extends Process {
}

Collection<ClientChannelEvent> res = channel.waitFor(CLOSE_WAIT_EVENTS, waitTimeout);
-
if (traceEnabled) {
log.trace("waitFor({}) channel={} events={}", commandName, channel, res);
}
@@ -95,7 +94,7 @@ public class GitSshdSessionProcess extends Process {
}
if (log.isTraceEnabled()) {
log.trace("exitValue({}) channel={}, timeout={} millis.: {}",
- commandName, channel, waitTimeout, status);
+ commandName, channel, waitTimeout, status);
}
return status;
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-putty/src/main/java/org/apache/sshd/common/config/keys/loader/putty/PuttyKeyPairResourceParser.java
----------------------------------------------------------------------
diff --git a/sshd-putty/src/main/java/org/apache/sshd/common/config/keys/loader/putty/PuttyKeyPairResourceParser.java b/sshd-putty/src/main/java/org/apache/sshd/common/config/keys/loader/putty/PuttyKeyPairResourceParser.java
index 06443d9..f098b0f 100644
--- a/sshd-putty/src/main/java/org/apache/sshd/common/config/keys/loader/putty/PuttyKeyPairResourceParser.java
+++ b/sshd-putty/src/main/java/org/apache/sshd/common/config/keys/loader/putty/PuttyKeyPairResourceParser.java
@@ -100,11 +100,11 @@ public interface PuttyKeyPairResourceParser<PUB extends PublicKey, PRV extends P
String PPK_FILE_SUFFIX = ".ppk";

List<String> KNOWN_HEADERS =
- Collections.unmodifiableList(
- Arrays.asList(
- KEY_FILE_HEADER_PREFIX,
- PUBLIC_LINES_HEADER,
- PRIVATE_LINES_HEADER));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ KEY_FILE_HEADER_PREFIX,
+ PUBLIC_LINES_HEADER,
+ PRIVATE_LINES_HEADER));

/**
* Value (case insensitive) used to denote that private key is not encrypted

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-scp/src/main/java/org/apache/sshd/client/scp/AbstractScpClient.java
----------------------------------------------------------------------
diff --git a/sshd-scp/src/main/java/org/apache/sshd/client/scp/AbstractScpClient.java b/sshd-scp/src/main/java/org/apache/sshd/client/scp/AbstractScpClient.java
index bbea856..bf8aa22 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/client/scp/AbstractScpClient.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/client/scp/AbstractScpClient.java
@@ -40,6 +40,7 @@ import org.apache.sshd.common.SshException;
import org.apache.sshd.common.file.FileSystemFactory;
import org.apache.sshd.common.scp.ScpException;
import org.apache.sshd.common.scp.ScpHelper;
+import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.GenericUtils;
import org.apache.sshd.common.util.ValidateUtils;
import org.apache.sshd.common.util.io.IoUtils;
@@ -50,14 +51,15 @@ import org.apache.sshd.common.util.logging.AbstractLoggingBean;
*/
public abstract class AbstractScpClient extends AbstractLoggingBean implements ScpClient {
public static final Set<ClientChannelEvent> COMMAND_WAIT_EVENTS =
- Collections.unmodifiableSet(EnumSet.of(ClientChannelEvent.EXIT_STATUS, ClientChannelEvent.CLOSED));
+ Collections.unmodifiableSet(EnumSet.of(ClientChannelEvent.EXIT_STATUS, ClientChannelEvent.CLOSED));

protected AbstractScpClient() {
super();
}

public boolean isOpen() {
- return getSession().isOpen();
+ Session session = getSession();
+ return session.isOpen();
}

@Override
@@ -136,7 +138,7 @@ public abstract class AbstractScpClient extends AbstractLoggingBean implements S
} catch (UnsupportedOperationException e) {
if (log.isDebugEnabled()) {
log.debug("download({}) {} => {} - failed ({}) to close file system={}: {}",
- session, remote, local, e.getClass().getSimpleName(), fs, e.getMessage());
+ session, remote, local, e.getClass().getSimpleName(), fs, e.getMessage());
}
}
}
@@ -146,25 +148,27 @@ public abstract class AbstractScpClient extends AbstractLoggingBean implements S

@Override
public void upload(String[] local, String remote, Collection<Option> options) throws IOException {
- final Collection<String> paths = Arrays.asList(ValidateUtils.checkNotNullAndNotEmpty(local, "Invalid argument local: %s", (Object) local));
+ Collection<String> paths = Arrays.asList(ValidateUtils.checkNotNullAndNotEmpty(local, "Invalid argument local: %s", (Object) local));
runUpload(remote, options, paths, (helper, local1, sendOptions) ->
- helper.send(local1,
- sendOptions.contains(Option.Recursive),
- sendOptions.contains(Option.PreserveAttributes),
- ScpHelper.DEFAULT_SEND_BUFFER_SIZE));
+ helper.send(local1,
+ sendOptions.contains(Option.Recursive),
+ sendOptions.contains(Option.PreserveAttributes),
+ ScpHelper.DEFAULT_SEND_BUFFER_SIZE));
}

@Override
public void upload(Path[] local, String remote, Collection<Option> options) throws IOException {
- final Collection<Path> paths = Arrays.asList(ValidateUtils.checkNotNullAndNotEmpty(local, "Invalid argument local: %s", (Object) local));
+ Collection<Path> paths = Arrays.asList(ValidateUtils.checkNotNullAndNotEmpty(local, "Invalid argument local: %s", (Object) local));
runUpload(remote, options, paths, (helper, local1, sendOptions) ->
- helper.sendPaths(local1,
- sendOptions.contains(Option.Recursive),
- sendOptions.contains(Option.PreserveAttributes),
- ScpHelper.DEFAULT_SEND_BUFFER_SIZE));
+ helper.sendPaths(local1,
+ sendOptions.contains(Option.Recursive),
+ sendOptions.contains(Option.PreserveAttributes),
+ ScpHelper.DEFAULT_SEND_BUFFER_SIZE));
}

- protected abstract <T> void runUpload(String remote, Collection<Option> options, Collection<T> local, AbstractScpClient.ScpOperationExecutor<T> executor) throws IOException;
+ protected abstract <T> void runUpload(
+ String remote, Collection<Option> options, Collection<T> local, AbstractScpClient.ScpOperationExecutor<T> executor)
+ throws IOException;

/**
* Invoked by the various <code>upload/download</code> methods after having successfully
@@ -214,7 +218,8 @@ public abstract class AbstractScpClient extends AbstractLoggingBean implements S
*/
protected void handleCommandExitStatus(String cmd, Integer exitStatus) throws IOException {
if (log.isDebugEnabled()) {
- log.debug("handleCommandExitStatus({}) cmd='{}', exit-status={}", getClientSession(), cmd, ScpHelper.getExitStatusName(exitStatus));
+ log.debug("handleCommandExitStatus({}) cmd='{}', exit-status={}",
+ getClientSession(), cmd, ScpHelper.getExitStatusName(exitStatus));
}

if (exitStatus == null) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-scp/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java
----------------------------------------------------------------------
diff --git a/sshd-scp/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java b/sshd-scp/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java
index 16d0cb2..9add836 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java
@@ -87,10 +87,10 @@ public class DefaultScpClient extends AbstractScpClient {
OutputStream invIn = channel.getInvertedIn()) {
ScpHelper helper = new ScpHelper(session, invOut, invIn, fs, opener, listener);
helper.receive(local,
- options.contains(Option.Recursive),
- options.contains(Option.TargetIsDirectory),
- options.contains(Option.PreserveAttributes),
- ScpHelper.DEFAULT_RECEIVE_BUFFER_SIZE);
+ options.contains(Option.Recursive),
+ options.contains(Option.TargetIsDirectory),
+ options.contains(Option.PreserveAttributes),
+ ScpHelper.DEFAULT_RECEIVE_BUFFER_SIZE);
handleCommandExitStatus(cmd, channel);
} finally {
channel.close(false);
@@ -121,7 +121,9 @@ public class DefaultScpClient extends AbstractScpClient {
}

@Override
- protected <T> void runUpload(String remote, Collection<Option> options, Collection<T> local, AbstractScpClient.ScpOperationExecutor<T> executor) throws IOException {
+ protected <T> void runUpload(
+ String remote, Collection<Option> options, Collection<T> local, AbstractScpClient.ScpOperationExecutor<T> executor)
+ throws IOException {
local = ValidateUtils.checkNotNullAndNotEmpty(local, "Invalid argument local: %s", local);
remote = ValidateUtils.checkNotNullAndNotEmpty(remote, "Invalid argument remote: %s", remote);
if (local.size() > 1) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-scp/src/main/java/org/apache/sshd/server/scp/ScpCommand.java
----------------------------------------------------------------------
diff --git a/sshd-scp/src/main/java/org/apache/sshd/server/scp/ScpCommand.java b/sshd-scp/src/main/java/org/apache/sshd/server/scp/ScpCommand.java
index eee542f..bd628a9 100644
--- a/sshd-scp/src/main/java/org/apache/sshd/server/scp/ScpCommand.java
+++ b/sshd-scp/src/main/java/org/apache/sshd/server/scp/ScpCommand.java
@@ -187,7 +187,7 @@ public class ScpCommand
} catch (IOException e2) {
if (debugEnabled) {
log.debug("run({})[{}] Failed ({}) to send error response: {}",
- session, command, e.getClass().getSimpleName(), e.getMessage());
+ session, command, e.getClass().getSimpleName(), e.getMessage());
}
if (log.isTraceEnabled()) {
log.trace("run(" + session + ")[" + command + "] error response failure details", e2);
@@ -196,7 +196,7 @@ public class ScpCommand

if (debugEnabled) {
log.debug("run({})[{}] Failed ({}) to run command: {}",
- session, command, e.getClass().getSimpleName(), e.getMessage());
+ session, command, e.getClass().getSimpleName(), e.getMessage());
}
if (log.isTraceEnabled()) {
log.trace("run(" + session + ")[" + command + "] command execution failure details", e);
@@ -211,7 +211,7 @@ public class ScpCommand
protected void writeCommandResponseMessage(String command, int exitValue, String exitMessage) throws IOException {
if (log.isDebugEnabled()) {
log.debug("writeCommandResponseMessage({}) command='{}', exit-status={}: {}",
- getServerSession(), command, exitValue, exitMessage);
+ getServerSession(), command, exitValue, exitMessage);
}
ScpHelper.sendResponseMessage(out, exitValue, exitMessage);
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpClient.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpClient.java b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpClient.java
index 43cc619..d990470 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpClient.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpClient.java
@@ -81,12 +81,12 @@ public interface SftpClient extends SubsystemClient {
* The {@link Set} of {@link OpenOption}-s supported by {@link #fromOpenOptions(Collection)}
*/
public static final Set<OpenOption> SUPPORTED_OPTIONS =
- Collections.unmodifiableSet(
- EnumSet.of(
- StandardOpenOption.READ, StandardOpenOption.APPEND,
- StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING,
- StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW,
- StandardOpenOption.SPARSE));
+ Collections.unmodifiableSet(
+ EnumSet.of(
+ StandardOpenOption.READ, StandardOpenOption.APPEND,
+ StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING,
+ StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW,
+ StandardOpenOption.SPARSE));

/**
* Converts {@link StandardOpenOption}-s into {@link OpenMode}-s
@@ -566,7 +566,7 @@ public interface SftpClient extends SubsystemClient {
* Default modes for opening a channel if no specific modes specified
*/
Set<OpenMode> DEFAULT_CHANNEL_MODES =
- Collections.unmodifiableSet(EnumSet.of(OpenMode.Read, OpenMode.Write));
+ Collections.unmodifiableSet(EnumSet.of(OpenMode.Read, OpenMode.Write));

/**
* @return The negotiated SFTP protocol version

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java
index 9074a45..ed16a26 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystem.java
@@ -32,6 +32,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.NavigableMap;
+import java.util.NavigableSet;
import java.util.Objects;
import java.util.Queue;
import java.util.Set;
@@ -52,10 +53,9 @@ public class SftpFileSystem extends BaseFileSystem<SftpPath> implements ClientSe
public static final String POOL_SIZE_PROP = "sftp-fs-pool-size";
public static final int DEFAULT_POOL_SIZE = 8;

- public static final Set<String> UNIVERSAL_SUPPORTED_VIEWS =
- Collections.unmodifiableSet(
- GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER,
- "basic", "posix", "owner"));
+ public static final NavigableSet<String> UNIVERSAL_SUPPORTED_VIEWS =
+ Collections.unmodifiableNavigableSet(
+ GenericUtils.asSortedSet(String.CASE_INSENSITIVE_ORDER, "basic", "posix", "owner"));

private final String id;
private final ClientSession clientSession;
@@ -70,7 +70,10 @@ public class SftpFileSystem extends BaseFileSystem<SftpPath> implements ClientSe
private int writeBufferSize = SftpClient.DEFAULT_WRITE_BUFFER_SIZE;
private final List<FileStore> stores;

- public SftpFileSystem(SftpFileSystemProvider provider, String id, ClientSession session, SftpClientFactory factory, SftpVersionSelector selector) throws IOException {
+ public SftpFileSystem(
+ SftpFileSystemProvider provider, String id, ClientSession session,
+ SftpClientFactory factory, SftpVersionSelector selector)
+ throws IOException {
super(provider);
this.id = id;
this.clientSession = Objects.requireNonNull(session, "No client session");
@@ -590,7 +593,6 @@ public class SftpFileSystem extends BaseFileSystem<SftpPath> implements ClientSe
}

public static class DefaultGroupPrincipal extends DefaultUserPrincipal implements GroupPrincipal {
-
public DefaultGroupPrincipal(String name) {
super(name);
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemProvider.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemProvider.java b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemProvider.java
index 9810ba1..d4db7c7 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemProvider.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpFileSystemProvider.java
@@ -119,10 +119,11 @@ public class SftpFileSystemProvider extends FileSystemProvider {
public static final String VERSION_PARAM = "version";

public static final Set<Class<? extends FileAttributeView>> UNIVERSAL_SUPPORTED_VIEWS =
- Collections.unmodifiableSet(GenericUtils.asSet(
- PosixFileAttributeView.class,
- FileOwnerAttributeView.class,
- BasicFileAttributeView.class
+ Collections.unmodifiableSet(
+ GenericUtils.asSet(
+ PosixFileAttributeView.class,
+ FileOwnerAttributeView.class,
+ BasicFileAttributeView.class
));

protected final Logger log;
@@ -208,8 +209,8 @@ public class SftpFileSystemProvider extends FileSystemProvider {
ClientSession session = null;
try {
session = client.connect(username, host, port)
- .verify(maxConnectTime)
- .getSession();
+ .verify(maxConnectTime)
+ .getSession();
if (GenericUtils.size(params) > 0) {
// Cannot use forEach because the session is not effectively final
for (Map.Entry<String, ?> pe : params.entrySet()) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpRemotePathChannel.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpRemotePathChannel.java b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpRemotePathChannel.java
index 9195009..5ea348d 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpRemotePathChannel.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/SftpRemotePathChannel.java
@@ -54,11 +54,15 @@ public class SftpRemotePathChannel extends FileChannel {
public static final int DEFAULT_TRANSFER_BUFFER_SIZE = IoUtils.DEFAULT_COPY_SIZE;

public static final Set<SftpClient.OpenMode> READ_MODES =
- Collections.unmodifiableSet(EnumSet.of(SftpClient.OpenMode.Read));
+ Collections.unmodifiableSet(EnumSet.of(SftpClient.OpenMode.Read));

public static final Set<SftpClient.OpenMode> WRITE_MODES =
- Collections.unmodifiableSet(
- EnumSet.of(SftpClient.OpenMode.Write, SftpClient.OpenMode.Append, SftpClient.OpenMode.Create, SftpClient.OpenMode.Truncate));
+ Collections.unmodifiableSet(
+ EnumSet.of(
+ SftpClient.OpenMode.Write,
+ SftpClient.OpenMode.Append,
+ SftpClient.OpenMode.Create,
+ SftpClient.OpenMode.Truncate));

private final String path;
private final Collection<SftpClient.OpenMode> modes;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/BuiltinSftpClientExtensions.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/BuiltinSftpClientExtensions.java b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/BuiltinSftpClientExtensions.java
index 9e83837..25ce157 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/BuiltinSftpClientExtensions.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/BuiltinSftpClientExtensions.java
@@ -112,7 +112,7 @@ public enum BuiltinSftpClientExtensions implements SftpClientExtensionFactory {
};

public static final Set<BuiltinSftpClientExtensions> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinSftpClientExtensions.class));
+ Collections.unmodifiableSet(EnumSet.allOf(BuiltinSftpClientExtensions.class));

private final String name;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/AbstractSftpClient.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/AbstractSftpClient.java b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/AbstractSftpClient.java
index 70d0279..2ef5039 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/AbstractSftpClient.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/AbstractSftpClient.java
@@ -196,8 +196,8 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
protected void checkResponseStatus(int cmd, int id, int substatus, String msg, String lang) throws IOException {
if (log.isTraceEnabled()) {
log.trace("checkResponseStatus({})[id={}] cmd={} status={} lang={} msg={}",
- getClientChannel(), id, SftpConstants.getCommandMessageName(cmd),
- SftpConstants.getStatusName(substatus), lang, msg);
+ getClientChannel(), id, SftpConstants.getCommandMessageName(cmd),
+ SftpConstants.getStatusName(substatus), lang, msg);
}

if (substatus != SftpConstants.SSH_FX_OK) {
@@ -238,8 +238,8 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
String lang = buffer.getString();
if (log.isTraceEnabled()) {
log.trace("checkHandleResponse({})[id={}] {} - status: {} [{}] {}",
- getClientChannel(), id, SftpConstants.getCommandMessageName(cmd),
- SftpConstants.getStatusName(substatus), lang, msg);
+ getClientChannel(), id, SftpConstants.getCommandMessageName(cmd),
+ SftpConstants.getStatusName(substatus), lang, msg);
}
throwStatusException(cmd, id, substatus, msg, lang);
}
@@ -250,7 +250,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
protected byte[] handleUnexpectedHandlePacket(int cmd, int id, int type, int length, Buffer buffer) throws IOException {
handleUnexpectedPacket(cmd, SftpConstants.SSH_FXP_HANDLE, id, type, length, buffer);
throw new SshException("No handling for unexpected handle packet id=" + id
- + ", type=" + SftpConstants.getCommandMessageName(type) + ", length=" + length);
+ + ", type=" + SftpConstants.getCommandMessageName(type) + ", length=" + length);
}

/**
@@ -282,8 +282,8 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
String lang = buffer.getString();
if (log.isTraceEnabled()) {
log.trace("checkAttributesResponse()[id={}] {} - status: {} [{}] {}",
- getClientChannel(), id, SftpConstants.getCommandMessageName(cmd),
- SftpConstants.getStatusName(substatus), lang, msg);
+ getClientChannel(), id, SftpConstants.getCommandMessageName(cmd),
+ SftpConstants.getStatusName(substatus), lang, msg);
}
throwStatusException(cmd, id, substatus, msg, lang);
}
@@ -339,8 +339,8 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
// TODO decide what to do if not-null and not TRUE
if (log.isTraceEnabled()) {
log.trace("checkOneNameResponse({})[id={}] {} ({})[{}] eol={}: {}",
- getClientChannel(), id, SftpConstants.getCommandMessageName(cmd),
- name, longName, indicator, attrs);
+ getClientChannel(), id, SftpConstants.getCommandMessageName(cmd),
+ name, longName, indicator, attrs);
}
return name;
}
@@ -351,8 +351,8 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
String lang = buffer.getString();
if (log.isTraceEnabled()) {
log.trace("checkOneNameResponse({})[id={}] {} status: {} [{}] {}",
- getClientChannel(), id, SftpConstants.getCommandMessageName(cmd),
- SftpConstants.getStatusName(substatus), lang, msg);
+ getClientChannel(), id, SftpConstants.getCommandMessageName(cmd),
+ SftpConstants.getStatusName(substatus), lang, msg);
}

throwStatusException(cmd, id, substatus, msg, lang);
@@ -676,7 +676,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme

CloseableHandle handle = new DefaultCloseableHandle(this, path, checkHandle(SftpConstants.SSH_FXP_OPEN, buffer));
if (log.isTraceEnabled()) {
- log.trace("open({})[{}] options={}: {}", getClientSession(), path, options, handle);
+ log.trace("open({})[{}] options={}: {}", getClientChannel(), path, options, handle);
}
return handle;
}
@@ -688,7 +688,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
}

if (log.isTraceEnabled()) {
- log.trace("close({}) {}", getClientSession(), handle);
+ log.trace("close({}) {}", getClientChannel(), handle);
}

byte[] id = Objects.requireNonNull(handle, "No handle").getIdentifier();
@@ -704,7 +704,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
}

if (log.isDebugEnabled()) {
- log.debug("remove({}) {}", getClientSession(), path);
+ log.debug("remove({}) {}", getClientChannel(), path);
}

Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE /* some extra fields */, false);
@@ -719,7 +719,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
}

if (log.isDebugEnabled()) {
- log.debug("rename({}) {} => {}", getClientSession(), oldPath, newPath);
+ log.debug("rename({}) {} => {}", getClientChannel(), oldPath, newPath);
}

Buffer buffer = new ByteArrayBuffer(oldPath.length() + newPath.length() + Long.SIZE /* some extra fields */, false);
@@ -746,13 +746,14 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
buffer.putInt(opts);
} else if (numOptions > 0) {
throw new UnsupportedOperationException("rename(" + oldPath + " => " + newPath + ")"
- + " - copy options can not be used with this SFTP version: " + options);
+ + " - copy options can not be used with this SFTP version: " + options);
}
checkCommandStatus(SftpConstants.SSH_FXP_RENAME, buffer);
}

@Override
- public int read(Handle handle, long fileOffset, byte[] dst, int dstOffset, int len, AtomicReference<Boolean> eofSignalled) throws IOException {
+ public int read(Handle handle, long fileOffset, byte[] dst, int dstOffset, int len, AtomicReference<Boolean> eofSignalled)
+ throws IOException {
if (eofSignalled != null) {
eofSignalled.set(null);
}
@@ -792,8 +793,8 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
Boolean indicator = SftpHelper.getEndOfFileIndicatorValue(buffer, getVersion());
if (log.isTraceEnabled()) {
log.trace("checkDataResponse({}][id={}] {} offset={}, len={}, EOF={}",
- getClientChannel(), SftpConstants.getCommandMessageName(cmd),
- id, dstoff, len, indicator);
+ getClientChannel(), SftpConstants.getCommandMessageName(cmd),
+ id, dstoff, len, indicator);
}
if (eofSignalled != null) {
eofSignalled.set(indicator);
@@ -808,8 +809,8 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
String lang = buffer.getString();
if (log.isTraceEnabled()) {
log.trace("checkDataResponse({})[id={}] {} status: {} [{}] {}",
- getClientChannel(), id, SftpConstants.getCommandMessageName(cmd),
- SftpConstants.getStatusName(substatus), lang, msg);
+ getClientChannel(), id, SftpConstants.getCommandMessageName(cmd),
+ SftpConstants.getStatusName(substatus), lang, msg);
}

if (substatus == SftpConstants.SSH_FX_EOF) {
@@ -850,7 +851,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme

if (log.isTraceEnabled()) {
log.trace("write({}) handle={}, file-offset={}, buf-offset={}, len={}",
- getClientChannel(), handle, fileOffset, srcOffset, len);
+ getClientChannel(), handle, fileOffset, srcOffset, len);
}

byte[] id = Objects.requireNonNull(handle, "No handle").getIdentifier();
@@ -868,7 +869,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
}

if (log.isDebugEnabled()) {
- log.debug("mkdir({}) {}", getClientSession(), path);
+ log.debug("mkdir({}) {}", getClientChannel(), path);
}

Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE /* some extra fields */, false);
@@ -890,7 +891,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
}

if (log.isDebugEnabled()) {
- log.debug("rmdir({}) {}", getClientSession(), path);
+ log.debug("rmdir({}) {}", getClientChannel(), path);
}

Buffer buffer = new ByteArrayBuffer(path.length() + Long.SIZE /* some extra fields */, false);
@@ -909,7 +910,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme

CloseableHandle handle = new DefaultCloseableHandle(this, path, checkHandle(SftpConstants.SSH_FXP_OPENDIR, buffer));
if (log.isTraceEnabled()) {
- log.trace("openDir({})[{}}: {}", getClientSession(), path, handle);
+ log.trace("openDir({})[{}}: {}", getClientChannel(), path, handle);
}

return handle;
@@ -963,7 +964,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
Attributes attrs = readAttributes(cmd, buffer, nameIndex);
if (traceEnabled) {
log.trace("checkDirResponse({})[id={}][{}] ({})[{}]: {}",
- channel, id, i, name, longName, attrs);
+ channel, id, i, name, longName, attrs);
}

entries.add(new DirEntry(name, longName, attrs));
@@ -986,7 +987,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
String lang = buffer.getString();
if (traceEnabled) {
log.trace("checkDirResponse({})[id={}] - status: {} [{}] {}",
- getClientChannel(), id, SftpConstants.getStatusName(substatus), lang, msg);
+ getClientChannel(), id, SftpConstants.getStatusName(substatus), lang, msg);
}

if (substatus == SftpConstants.SSH_FX_EOF) {
@@ -1009,8 +1010,8 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme

protected IOException handleUnexpectedPacket(int cmd, int expected, int id, int type, int length, Buffer buffer) throws IOException {
throw new SshException("Unexpected SFTP packet received while awaiting " + SftpConstants.getCommandMessageName(expected)
- + " response to " + SftpConstants.getCommandMessageName(cmd)
- + ": type=" + SftpConstants.getCommandMessageName(type) + ", id=" + id + ", length=" + length);
+ + " response to " + SftpConstants.getCommandMessageName(cmd)
+ + ": type=" + SftpConstants.getCommandMessageName(type) + ", id=" + id + ", length=" + length);
}

@Override
@@ -1083,7 +1084,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
}

if (log.isDebugEnabled()) {
- log.debug("setStat({})[{}]: {}", getClientSession(), path, attributes);
+ log.debug("setStat({})[{}]: {}", getClientChannel(), path, attributes);
}

Buffer buffer = new ByteArrayBuffer();
@@ -1099,7 +1100,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
}

if (log.isDebugEnabled()) {
- log.debug("setStat({})[{}]: {}", getClientSession(), handle, attributes);
+ log.debug("setStat({})[{}]: {}", getClientChannel(), handle, attributes);
}
byte[] id = Objects.requireNonNull(handle, "No handle").getIdentifier();
Buffer buffer = new ByteArrayBuffer(id.length + (2 * Long.SIZE) /* some extras */, false);
@@ -1126,7 +1127,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
}

if (log.isDebugEnabled()) {
- log.debug("link({})[symbolic={}] {} => {}", getClientSession(), symbolic, linkPath, targetPath);
+ log.debug("link({})[symbolic={}] {} => {}", getClientChannel(), symbolic, linkPath, targetPath);
}

Buffer buffer = new ByteArrayBuffer(linkPath.length() + targetPath.length() + Long.SIZE /* some extra fields */, false);
@@ -1156,7 +1157,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme

if (log.isDebugEnabled()) {
log.debug("lock({})[{}] offset={}, length={}, mask=0x{}",
- getClientSession(), handle, offset, length, Integer.toHexString(mask));
+ getClientChannel(), handle, offset, length, Integer.toHexString(mask));
}

byte[] id = Objects.requireNonNull(handle, "No handle").getIdentifier();
@@ -1175,7 +1176,7 @@ public abstract class AbstractSftpClient extends AbstractSubsystemClient impleme
}

if (log.isDebugEnabled()) {
- log.debug("unlock({})[{}] offset={}, length={}", getClientSession(), handle, offset, length);
+ log.debug("unlock({})[{}] offset={}, length={}", getClientChannel(), handle, offset, length);
}

byte[] id = Objects.requireNonNull(handle, "No handle").getIdentifier();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/DefaultSftpClient.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/DefaultSftpClient.java b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/DefaultSftpClient.java
index d1f5a12..2ac227c 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/DefaultSftpClient.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/client/subsystem/sftp/impl/DefaultSftpClient.java
@@ -247,7 +247,7 @@ public class DefaultSftpClient extends AbstractSftpClient {

if (log.isTraceEnabled()) {
log.trace("process({}) id={}, type={}, len={}",
- getClientChannel(), id, SftpConstants.getCommandMessageName(type), length);
+ getClientChannel(), id, SftpConstants.getCommandMessageName(type), length);
}

synchronized (messages) {
@@ -262,7 +262,7 @@ public class DefaultSftpClient extends AbstractSftpClient {
int len = buffer.available();
if (log.isTraceEnabled()) {
log.trace("send({}) cmd={}, len={}, id={}",
- getClientChannel(), SftpConstants.getCommandMessageName(cmd), len, id);
+ getClientChannel(), SftpConstants.getCommandMessageName(cmd), len, id);
}

OutputStream dos = channel.getInvertedIn();
@@ -377,7 +377,7 @@ public class DefaultSftpClient extends AbstractSftpClient {
boolean traceEnabled = log.isTraceEnabled();
if (traceEnabled) {
log.trace("init({}) id={} type={} len={}",
- getClientChannel(), id, SftpConstants.getCommandMessageName(type), length);
+ getClientChannel(), id, SftpConstants.getCommandMessageName(type), length);
}

if (type == SftpConstants.SSH_FXP_VERSION) {
@@ -404,7 +404,7 @@ public class DefaultSftpClient extends AbstractSftpClient {
String lang = buffer.getString();
if (traceEnabled) {
log.trace("init({})[id={}] - status: {} [{}] {}",
- getClientChannel(), id, SftpConstants.getStatusName(substatus), lang, msg);
+ getClientChannel(), id, SftpConstants.getStatusName(substatus), lang, msg);
}

throwStatusException(SftpConstants.SSH_FXP_INIT, id, substatus, msg, lang);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpConstants.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpConstants.java b/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpConstants.java
index 02adb12..5d91044 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpConstants.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpConstants.java
@@ -312,7 +312,8 @@ public final class SftpConstants {

private static final class LazyStatusNameHolder {
private static final Map<Integer, String> STATUS_MAP =
- Collections.unmodifiableMap(LoggingUtils.generateMnemonicMap(SftpConstants.class, "SSH_FX_"));
+ Collections.unmodifiableMap(
+ LoggingUtils.generateMnemonicMap(SftpConstants.class, "SSH_FX_"));

private LazyStatusNameHolder() {
throw new UnsupportedOperationException("No instance allowed");

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpUniversalOwnerAndGroup.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpUniversalOwnerAndGroup.java b/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpUniversalOwnerAndGroup.java
index 68ab055..0732924 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpUniversalOwnerAndGroup.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/SftpUniversalOwnerAndGroup.java
@@ -43,7 +43,7 @@ public enum SftpUniversalOwnerAndGroup implements NamedResource {
Service; // Access from a system service.

public static final Set<SftpUniversalOwnerAndGroup> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(SftpUniversalOwnerAndGroup.class));
+ Collections.unmodifiableSet(EnumSet.allOf(SftpUniversalOwnerAndGroup.class));

private final String name;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/AclSupportedParser.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/AclSupportedParser.java b/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/AclSupportedParser.java
index 2e57fff..a724507 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/AclSupportedParser.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/AclSupportedParser.java
@@ -102,10 +102,11 @@ public class AclSupportedParser extends AbstractParser<AclCapabilities> {

private static final class LazyAclCapabilityNameHolder {
private static final String ACL_CAP_NAME_PREFIX = "SSH_ACL_CAP_";
- private static final Map<Integer, String> ACL_VALUES_MAP =
+ private static final NavigableMap<Integer, String> ACL_VALUES_MAP =
LoggingUtils.generateMnemonicMap(SftpConstants.class, ACL_CAP_NAME_PREFIX);
private static final NavigableMap<String, Integer> ACL_NAMES_MAP =
- Collections.unmodifiableNavigableMap(GenericUtils.flipMap(ACL_VALUES_MAP, GenericUtils.caseInsensitiveMap(), false));
+ Collections.unmodifiableNavigableMap(
+ GenericUtils.flipMap(ACL_VALUES_MAP, GenericUtils.caseInsensitiveMap(), false));

private LazyAclCapabilityNameHolder() {
throw new UnsupportedOperationException("No instance allowed");
@@ -113,7 +114,7 @@ public class AclSupportedParser extends AbstractParser<AclCapabilities> {
}

@SuppressWarnings("synthetic-access")
- public static Map<String, Integer> getAclCapabilityNamesMap() {
+ public static NavigableMap<String, Integer> getAclCapabilityNamesMap() {
return LazyAclCapabilityNameHolder.ACL_NAMES_MAP;
}

@@ -137,7 +138,7 @@ public class AclSupportedParser extends AbstractParser<AclCapabilities> {
}

@SuppressWarnings("synthetic-access")
- public static Map<Integer, String> getAclCapabilityValuesMap() {
+ public static NavigableMap<Integer, String> getAclCapabilityValuesMap() {
return LazyAclCapabilityNameHolder.ACL_VALUES_MAP;
}


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/ParserUtils.java
----------------------------------------------------------------------
diff --git a/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/ParserUtils.java b/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/ParserUtils.java
index e565ab4..958c84f 100644
--- a/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/ParserUtils.java
+++ b/sshd-sftp/src/main/java/org/apache/sshd/common/subsystem/sftp/extensions/ParserUtils.java
@@ -45,21 +45,21 @@ import org.apache.sshd.common.util.GenericUtils;
*/
public final class ParserUtils {
public static final Collection<ExtensionParser<?>> BUILT_IN_PARSERS =
- Collections.unmodifiableList(
- Arrays.<ExtensionParser<?>>asList(
- VendorIdParser.INSTANCE,
- NewlineParser.INSTANCE,
- VersionsParser.INSTANCE,
- SupportedParser.INSTANCE,
- Supported2Parser.INSTANCE,
- AclSupportedParser.INSTANCE,
- // OpenSSH extensions
- PosixRenameExtensionParser.INSTANCE,
- StatVfsExtensionParser.INSTANCE,
- FstatVfsExtensionParser.INSTANCE,
- HardLinkExtensionParser.INSTANCE,
- FsyncExtensionParser.INSTANCE
- ));
+ Collections.unmodifiableList(
+ Arrays.<ExtensionParser<?>>asList(
+ VendorIdParser.INSTANCE,
+ NewlineParser.INSTANCE,
+ VersionsParser.INSTANCE,
+ SupportedParser.INSTANCE,
+ Supported2Parser.INSTANCE,
+ AclSupportedParser.INSTANCE,
+ // OpenSSH extensions
+ PosixRenameExtensionParser.INSTANCE,
+ StatVfsExtensionParser.INSTANCE,
+ FstatVfsExtensionParser.INSTANCE,
+ HardLinkExtensionParser.INSTANCE,
+ FsyncExtensionParser.INSTANCE
+ ));

private static final Map<String, ExtensionParser<?>> PARSERS_MAP;
l***@apache.org
2018-10-25 09:10:59 UTC
Permalink
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-common/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
----------------------------------------------------------------------
diff --git a/sshd-common/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java b/sshd-common/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
new file mode 100644
index 0000000..baaa1e6
--- /dev/null
+++ b/sshd-common/src/test/java/org/apache/sshd/common/file/util/BasePathTest.java
@@ -0,0 +1,548 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sshd.common.file.util;
+
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.FileSystem;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.nio.file.attribute.UserPrincipalLookupService;
+import java.nio.file.spi.FileSystemProvider;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.util.test.JUnitTestSupport;
+import org.apache.sshd.util.test.NoIoTestCase;
+import org.junit.Before;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+import org.mockito.Mockito;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@Category({ NoIoTestCase.class })
+@SuppressWarnings("checkstyle:MethodCount")
+public class BasePathTest extends JUnitTestSupport {
+ private TestFileSystem fileSystem;
+
+ public BasePathTest() {
+ super();
+ }
+
+ @Before
+ public void setUp() {
+ fileSystem = new TestFileSystem(Mockito.mock(FileSystemProvider.class));
+ }
+
+ @Test
+ public void testBasicPathParsing() {
+ assertPathEquals("/", "/");
+ assertPathEquals("/foo", "/foo");
+ assertPathEquals("/foo", "/", "foo");
+ assertPathEquals("/foo/bar", "/foo/bar");
+ assertPathEquals("/foo/bar", "/", "foo", "bar");
+ assertPathEquals("/foo/bar", "/foo", "bar");
+ assertPathEquals("/foo/bar", "/", "foo/bar");
+ assertPathEquals("foo/bar/baz", "foo/bar/baz");
+ assertPathEquals("foo/bar/baz", "foo", "bar", "baz");
+ assertPathEquals("foo/bar/baz", "foo/bar", "baz");
+ assertPathEquals("foo/bar/baz", "foo", "bar/baz");
+ }
+
+ @Test
+ public void testPathParsingWithExtraSeparators() {
+ assertPathEquals("/foo/bar", "///foo/bar");
+ assertPathEquals("/foo/bar", "/foo///bar//");
+ assertPathEquals("/foo/bar/baz", "/foo", "/bar", "baz/");
+ //assertPathEquals("/foo/bar/baz", "/foo\\/bar//\\\\/baz\\/");
+ }
+
+ @Test
+ public void testRootPath() {
+ new PathTester(fileSystem, "/")
+ .root("/")
+ .test("/");
+ }
+
+ @Test
+ public void testRelativePathSingleName() {
+ new PathTester(fileSystem, "test")
+ .names("test")
+ .test("test");
+
+ Path path = parsePath("test");
+ assertEquals(path, path.getFileName());
+ }
+
+ @Test
+ public void testRelativePathTwoNames() {
+ new PathTester(fileSystem, "foo/bar")
+ .names("foo", "bar")
+ .test("foo/bar");
+ }
+
+ @Test
+ public void testRelativePathFourNames() {
+ new PathTester(fileSystem, "foo/bar/baz/test")
+ .names("foo", "bar", "baz", "test")
+ .test("foo/bar/baz/test");
+ }
+
+ @Test
+ public void testAbsolutePathSingleName() {
+ new PathTester(fileSystem, "/foo")
+ .root("/")
+ .names("foo")
+ .test("/foo");
+ }
+
+ @Test
+ public void testAbsolutePathTwoNames() {
+ new PathTester(fileSystem, "/foo/bar")
+ .root("/")
+ .names("foo", "bar")
+ .test("/foo/bar");
+ }
+
+ @Test
+ public void testAbsoluteMultiNamePathFourNames() {
+ new PathTester(fileSystem, "/foo/bar/baz/test")
+ .root("/")
+ .names("foo", "bar", "baz", "test")
+ .test("/foo/bar/baz/test");
+ }
+
+ @Test
+ public void testResolveFromRoot() {
+ Path root = parsePath("/");
+ assertResolvedPathEquals("/foo", root, "foo");
+ assertResolvedPathEquals("/foo/bar", root, "foo/bar");
+ assertResolvedPathEquals("/foo/bar", root, "foo", "bar");
+ assertResolvedPathEquals("/foo/bar/baz/test", root, "foo/bar/baz/test");
+ assertResolvedPathEquals("/foo/bar/baz/test", root, "foo", "bar/baz", "test");
+ }
+
+ @Test
+ public void testResolveFromAbsolute() {
+ Path path = parsePath("/foo");
+ assertResolvedPathEquals("/foo/bar", path, "bar");
+ assertResolvedPathEquals("/foo/bar/baz/test", path, "bar/baz/test");
+ assertResolvedPathEquals("/foo/bar/baz/test", path, "bar/baz", "test");
+ assertResolvedPathEquals("/foo/bar/baz/test", path, "bar", "baz", "test");
+ }
+
+ @Test
+ public void testResolveFromRelative() {
+ Path path = parsePath("foo");
+ assertResolvedPathEquals("foo/bar", path, "bar");
+ assertResolvedPathEquals("foo/bar/baz/test", path, "bar/baz/test");
+ assertResolvedPathEquals("foo/bar/baz/test", path, "bar", "baz", "test");
+ assertResolvedPathEquals("foo/bar/baz/test", path, "bar/baz", "test");
+ }
+
+ @Test
+ public void testResolveWithThisAndParentDirNames() {
+ Path path = parsePath("/foo");
+ assertResolvedPathEquals("/foo/bar/../baz", path, "bar/../baz");
+ assertResolvedPathEquals("/foo/bar/../baz", path, "bar", "..", "baz");
+ assertResolvedPathEquals("/foo/./bar/baz", path, "./bar/baz");
+ assertResolvedPathEquals("/foo/./bar/baz", path, ".", "bar/baz");
+ }
+
+ @Test
+ public void testResolveGivenAbsolutePath() {
+ assertResolvedPathEquals("/test", parsePath("/foo"), "/test");
+ assertResolvedPathEquals("/test", parsePath("foo"), "/test");
+ }
+
+ @Test
+ public void testResolveGivenEmptyPath() {
+ assertResolvedPathEquals("/foo", parsePath("/foo"), "");
+ assertResolvedPathEquals("foo", parsePath("foo"), "");
+ }
+
+ @Test
+ public void testResolveAgainstEmptyPath() {
+ assertResolvedPathEquals("foo/bar", parsePath(""), "foo/bar");
+ }
+
+ @Test
+ public void testResolveSiblingGivenEmptyPath() {
+ Path path = parsePath("foo/bar");
+ Path resolved = path.resolveSibling("");
+ assertPathEquals("foo", resolved);
+
+ path = parsePath("foo");
+ resolved = path.resolveSibling("");
+ assertPathEquals("", resolved);
+ }
+
+ @Test
+ public void testResolveSiblingAgainstEmptyPath() {
+ Path path = parsePath("");
+ Path resolved = path.resolveSibling("foo");
+ assertPathEquals("foo", resolved);
+
+ path = parsePath("");
+ resolved = path.resolveSibling("");
+ assertPathEquals("", resolved);
+ }
+
+ @Test
+ public void testRelativizeBothAbsolute() {
+ assertRelativizedPathEquals("b/c", parsePath("/a"), "/a/b/c");
+ assertRelativizedPathEquals("c/d", parsePath("/a/b"), "/a/b/c/d");
+ }
+
+ @Test
+ public void testRelativizeBothRelative() {
+ assertRelativizedPathEquals("b/c", parsePath("a"), "a/b/c");
+ assertRelativizedPathEquals("d", parsePath("a/b/c"), "a/b/c/d");
+ }
+
+ @Test
+ public void testRelativizeAgainstEmptyPath() {
+ assertRelativizedPathEquals("foo/bar", parsePath(""), "foo/bar");
+ }
+
+ @Test
+ public void testRelativizeOneAbsoluteOneRelative() {
+ try {
+ Path result = parsePath("/foo/bar").relativize(parsePath("foo"));
+ fail("Unexpected 2-level result: " + result);
+ } catch (IllegalArgumentException expected) {
+ // ignored
+ }
+
+ try {
+ Path result = parsePath("foo").relativize(parsePath("/foo/bar"));
+ fail("Unexpected 1-level result: " + result);
+ } catch (IllegalArgumentException expected) {
+ // ignored
+ }
+ }
+
+ @Test
+ public void testNormalizeWithParentDirName() {
+ assertNormalizedPathEquals("/foo/baz", "/foo/bar/../baz");
+ assertNormalizedPathEquals("/foo/baz", "/foo", "bar", "..", "baz");
+ }
+
+ @Test
+ public void testNormalizeWithThisDirName() {
+ assertNormalizedPathEquals("/foo/bar/baz", "/foo/bar/./baz");
+ assertNormalizedPathEquals("/foo/bar/baz", "/foo", "bar", ".", "baz");
+ }
+
+ @Test
+ public void testNormalizeWithThisAndParentDirNames() {
+ assertNormalizedPathEquals("foo/test", "foo/./bar/../././baz/../test");
+ }
+
+ @Test
+ public void testNormalizeWithLeadingParentDirNames() {
+ assertNormalizedPathEquals("../../foo/baz", "../../foo/bar/../baz");
+ }
+
+ @Test
+ public void testNormalizeWithLeadingThisAndParentDirNames() {
+ assertNormalizedPathEquals("../../foo/baz", "./.././.././foo/bar/../baz");
+ }
+
+ @Test
+ public void testNormalizeWithExtraParentDirNamesAtRoot() {
+ assertNormalizedPathEquals("/", "/..");
+ assertNormalizedPathEquals("/", "/../../..");
+ assertNormalizedPathEquals("/", "/foo/../../..");
+ assertNormalizedPathEquals("/", "/../foo/../../bar/baz/../../../..");
+ }
+
+ @Test
+ public void testPathWithExtraSlashes() {
+ assertPathEquals("/foo/bar/baz", parsePath("/foo/bar/baz/"));
+ assertPathEquals("/foo/bar/baz", parsePath("/foo//bar///baz"));
+ assertPathEquals("/foo/bar/baz", parsePath("///foo/bar/baz"));
+ }
+
+ private void assertResolvedPathEquals(
+ String expected, Path path, String firstResolvePath, String... moreResolvePaths) {
+ Path resolved = path.resolve(firstResolvePath);
+ for (String additionalPath : moreResolvePaths) {
+ resolved = resolved.resolve(additionalPath);
+ }
+ assertPathEquals(expected, resolved);
+
+ Path relative = parsePath(firstResolvePath, moreResolvePaths);
+ resolved = path.resolve(relative);
+ assertPathEquals(expected, resolved);
+
+ // assert the invariant that p.relativize(p.resolve(q)).equals(q) when q does not have a root
+ // p = path, q = relative, p.resolve(q) = resolved
+ if (relative.getRoot() == null) {
+ assertEquals(relative, path.relativize(resolved));
+ }
+ }
+
+ private void assertRelativizedPathEquals(String expected, Path path, String relativizePath) {
+ Path relativized = path.relativize(parsePath(relativizePath));
+ assertPathEquals(expected, relativized);
+ }
+
+ private void assertNormalizedPathEquals(String expected, String first, String... more) {
+ assertPathEquals(expected, parsePath(first, more).normalize());
+ }
+
+ private void assertPathEquals(String expected, String first, String... more) {
+ assertPathEquals(expected, parsePath(first, more));
+ }
+
+ private void assertPathEquals(String expected, Path path) {
+ assertEquals(parsePath(expected), path);
+ }
+
+ private Path parsePath(String first, String... more) {
+ return fileSystem.getPath(first, more);
+ }
+
+ private static class TestFileSystem extends BaseFileSystem<TestPath> {
+ TestFileSystem(FileSystemProvider fileSystemProvider) {
+ super(fileSystemProvider);
+ }
+
+ @Override
+ protected TestPath create(String root, List<String> names) {
+ return new TestPath(this, root, names);
+ }
+
+ @Override
+ public void close() throws IOException {
+ // ignored
+ }
+
+ @Override
+ public boolean isOpen() {
+ return false;
+ }
+
+ @Override
+ public Set<String> supportedFileAttributeViews() {
+ return null;
+ }
+
+ @Override
+ public UserPrincipalLookupService getUserPrincipalLookupService() {
+ return null;
+ }
+ }
+
+ private static class TestPath extends BasePath<TestPath, TestFileSystem> {
+ TestPath(TestFileSystem fileSystem, String root, List<String> names) {
+ super(fileSystem, root, names);
+ }
+
+ @Override
+ protected TestPath create(String root, List<String> names) {
+ return new TestPath(getFileSystem(), root, names);
+ }
+
+ @Override
+ public URI toUri() {
+ return null;
+ }
+
+ @Override
+ public Path toRealPath(LinkOption... options) throws IOException {
+ return null;
+ }
+ }
+
+ public static class PathTester {
+ private final FileSystem fileSystem;
+ private final String string;
+ private String root;
+ private List<String> names = Collections.emptyList();
+
+ public PathTester(FileSystem fileSystem, String string) {
+ this.fileSystem = fileSystem;
+ this.string = string;
+ }
+
+ public PathTester root(String root) {
+ this.root = root;
+ return this;
+ }
+
+ public PathTester names(Collection<String> names) {
+ this.names = GenericUtils.unmodifiableList(names);
+ return this;
+ }
+
+ public PathTester names(String... names) {
+ return names(Arrays.asList(names));
+ }
+
+ public void test(String first, String... more) {
+ Path path = fileSystem.getPath(first, more);
+ test(path);
+ }
+
+ public void test(Path path) {
+ assertEquals("Mismatched path value", string, path.toString());
+
+ testRoot(path);
+ testNames(path);
+ testParents(path);
+ testStartsWith(path);
+ testEndsWith(path);
+ testSubpaths(path);
+ }
+
+ protected void testRoot(Path path) {
+ if (root != null) {
+ assertTrue(path + ".isAbsolute() ?", path.isAbsolute());
+ assertNotNull(path + ".getRoot() <> null ?", path.getRoot());
+ assertEquals("Mismatched root path value", root, path.getRoot().toString());
+ } else {
+ assertFalse(path + ".is(Not)Absolute() ?", path.isAbsolute());
+ assertNull(path + ".getRoot() == null ?", path.getRoot());
+ }
+ }
+
+ protected void testNames(Path path) {
+ assertEquals("Mismatched names count", names.size(), path.getNameCount());
+ assertListEquals("Mismatched path names", names, names(path));
+
+ for (int i = 0; i < names.size(); i++) {
+ String nameAtIndex = names.get(i);
+ Path pathAtIndex = path.getName(i);
+ assertEquals("Mismatched component name at index=" + i, nameAtIndex, pathAtIndex.toString());
+ // don't test individual names if this is an individual name
+ if (names.size() > 1) {
+ new PathTester(fileSystem, nameAtIndex)
+ .names(nameAtIndex)
+ .test(pathAtIndex);
+ }
+ }
+
+ if (names.size() > 0) {
+ String fileName = names.get(names.size() - 1);
+ assertEquals("Mismatched last component name", fileName, path.getFileName().toString());
+ // don't test individual names if this is an individual name
+ if (names.size() > 1) {
+ new PathTester(fileSystem, fileName)
+ .names(fileName)
+ .test(path.getFileName());
+ }
+ }
+ }
+
+ protected void testParents(Path path) {
+ Path parent = path.getParent();
+ if (((root != null) && (names.size() >= 1)) || (names.size() > 1)) {
+ assertNotNull("No parent", parent);
+ }
+
+ if (parent != null) {
+ String parentName = names.size() == 1 ? root : string.substring(0, string.lastIndexOf('/'));
+ new PathTester(fileSystem, parentName)
+ .root(root)
+ .names(names.subList(0, names.size() - 1))
+ .test(parent);
+ }
+ }
+
+ protected void testSubpaths(Path path) {
+ int nameCount = path.getNameCount();
+ if (path.getRoot() == null) {
+ assertEquals(path, path.subpath(0, nameCount));
+ }
+
+ if (nameCount > 1) {
+ String stringWithoutRoot = root == null ? string : string.substring(root.length());
+
+ // test start + 1 to end and start to end - 1 subpaths... this recursively tests all subpaths
+ // actually tests most possible subpaths multiple times but... eh
+ Path startSubpath = path.subpath(1, nameCount);
+ List<String> startNames = split(stringWithoutRoot, '/')
+ .subList(1, nameCount);
+ new PathTester(fileSystem, GenericUtils.join(startNames, '/'))
+ .names(startNames)
+ .test(startSubpath);
+
+ Path endSubpath = path.subpath(0, nameCount - 1);
+ List<String> endNames = split(stringWithoutRoot, '/')
+ .subList(0, nameCount - 1);
+ new PathTester(fileSystem, GenericUtils.join(endNames, '/'))
+ .names(endNames)
+ .test(endSubpath);
+ }
+ }
+
+ protected void testStartsWith(Path path) {
+ // empty path doesn't start with any path
+ if ((root != null) || (!names.isEmpty())) {
+ Path other = path;
+ while (other != null) {
+ assertTrue(path + ".startsWith(" + other + ")[path] ?", path.startsWith(other));
+ assertTrue(path + ".startsWith(" + other + ")[string] ?", path.startsWith(other.toString()));
+ other = other.getParent();
+ }
+ }
+ }
+
+ protected void testEndsWith(Path path) {
+ // empty path doesn't start with any path
+ if ((root != null) || (!names.isEmpty())) {
+ Path other = path;
+ while (other != null) {
+ assertTrue(path + ".endsWith(" + other + ")[path] ?", path.endsWith(other));
+ assertTrue(path + ".endsWith(" + other + ")[string] ?", path.endsWith(other.toString()));
+
+ int otherNameCount = other.getNameCount();
+ if ((other.getRoot() != null) && (otherNameCount > 0)) {
+ other = other.subpath(0, otherNameCount);
+ } else if (otherNameCount > 1) {
+ other = other.subpath(1, otherNameCount);
+ } else {
+ other = null;
+ }
+ }
+ }
+ }
+
+ private static List<String> names(Path path) {
+ List<String> list = new ArrayList<>();
+ for (Path p : path) {
+ list.add(p.toString());
+ }
+ return list;
+ }
+
+ private static List<String> split(String string, char sep) {
+ return Arrays.asList(GenericUtils.split(string, sep));
+ }
+ }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemAware.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemAware.java b/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemAware.java
deleted file mode 100644
index e73c37d..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/FileSystemAware.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.common.file;
-
-import java.nio.file.FileSystem;
-
-/**
- * Interface that can be implemented by a command to be able to access the
- * file system in which this command will be used.
- */
-@FunctionalInterface
-public interface FileSystemAware {
- /**
- * Set the file system in which this shell will be executed.
- *
- * @param fileSystem the file system
- */
- void setFileSystem(FileSystem fileSystem);
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystem.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystem.java b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystem.java
deleted file mode 100644
index 1b9a71c..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystem.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.common.file.root;
-
-import java.io.IOException;
-import java.nio.file.FileStore;
-import java.nio.file.FileSystem;
-import java.nio.file.Path;
-import java.nio.file.attribute.UserPrincipalLookupService;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import org.apache.sshd.common.file.util.BaseFileSystem;
-
-/**
- * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class RootedFileSystem extends BaseFileSystem<RootedPath> {
-
- private final Path rootPath;
- private final FileSystem rootFs;
-
- public RootedFileSystem(RootedFileSystemProvider fileSystemProvider, Path root, Map<String, ?> env) {
- super(fileSystemProvider);
- this.rootPath = Objects.requireNonNull(root, "No root path");
- this.rootFs = root.getFileSystem();
- }
-
- public FileSystem getRootFileSystem() {
- return rootFs;
- }
-
- public Path getRoot() {
- return rootPath;
- }
-
- @Override
- public RootedFileSystemProvider provider() {
- return (RootedFileSystemProvider) super.provider();
- }
-
- @Override
- public void close() throws IOException {
- if (log.isDebugEnabled()) {
- log.debug("close({})", this);
- }
- }
-
- @Override
- public boolean isOpen() {
- return rootFs.isOpen();
- }
-
- @Override
- public boolean isReadOnly() {
- return rootFs.isReadOnly();
- }
-
- @Override
- public Set<String> supportedFileAttributeViews() {
- return rootFs.supportedFileAttributeViews();
- }
-
- @Override
- public UserPrincipalLookupService getUserPrincipalLookupService() {
- return rootFs.getUserPrincipalLookupService();
- }
-
- @Override
- protected RootedPath create(String root, List<String> names) {
- return new RootedPath(this, root, names);
- }
-
- @Override
- public Iterable<FileStore> getFileStores() {
- return rootFs.getFileStores();
- }
-
- @Override
- public String toString() {
- return rootPath.toString();
- }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
deleted file mode 100644
index 8765f47..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedFileSystemProvider.java
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.common.file.root;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.channels.AsynchronousFileChannel;
-import java.nio.channels.FileChannel;
-import java.nio.channels.SeekableByteChannel;
-import java.nio.file.AccessMode;
-import java.nio.file.CopyOption;
-import java.nio.file.DirectoryStream;
-import java.nio.file.FileStore;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystemAlreadyExistsException;
-import java.nio.file.FileSystemNotFoundException;
-import java.nio.file.Files;
-import java.nio.file.InvalidPathException;
-import java.nio.file.LinkOption;
-import java.nio.file.OpenOption;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.ProviderMismatchException;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.nio.file.attribute.FileAttribute;
-import java.nio.file.attribute.FileAttributeView;
-import java.nio.file.spi.FileSystemProvider;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-
-import org.apache.sshd.common.util.ValidateUtils;
-import org.apache.sshd.common.util.io.IoUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * File system provider which provides a rooted file system.
- * The file system only gives access to files under the root directory.
- *
- * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class RootedFileSystemProvider extends FileSystemProvider {
- protected final Logger log;
- private final Map<Path, RootedFileSystem> fileSystems = new HashMap<>();
-
- public RootedFileSystemProvider() {
- log = LoggerFactory.getLogger(getClass());
- }
-
- @Override
- public String getScheme() {
- return "root";
- }
-
- @Override
- public FileSystem newFileSystem(URI uri, Map<String, ?> env) throws IOException {
- return newFileSystem(uri, uriToPath(uri), env);
- }
-
- @Override
- public FileSystem getFileSystem(URI uri) {
- return getFileSystem(uriToPath(uri));
- }
-
- @Override
- public FileSystem newFileSystem(Path path, Map<String, ?> env) throws IOException {
- return newFileSystem(path, path, env);
- }
-
- protected FileSystem newFileSystem(Object src, Path path, Map<String, ?> env) throws IOException {
- Path root = ensureDirectory(path).toRealPath();
- RootedFileSystem rootedFs = null;
- synchronized (fileSystems) {
- if (!this.fileSystems.containsKey(root)) {
- rootedFs = new RootedFileSystem(this, path, env);
- this.fileSystems.put(root, rootedFs);
- }
- }
-
- // do all the throwing outside the synchronized block to minimize its lock time
- if (rootedFs == null) {
- throw new FileSystemAlreadyExistsException("newFileSystem(" + src + ") already mapped " + root);
- }
-
- if (log.isTraceEnabled()) {
- log.trace("newFileSystem({}): {}", src, rootedFs);
- }
-
- return rootedFs;
- }
-
- protected Path uriToPath(URI uri) {
- String scheme = uri.getScheme();
- String expected = getScheme();
- if ((scheme == null) || (!scheme.equalsIgnoreCase(expected))) {
- throw new IllegalArgumentException("URI scheme (" + scheme + ") is not '" + expected + "'");
- }
-
- String root = uri.getRawSchemeSpecificPart();
- int i = root.indexOf("!/");
- if (i != -1) {
- root = root.substring(0, i);
- }
-
- try {
- return Paths.get(new URI(root)).toAbsolutePath();
- } catch (URISyntaxException e) {
- throw new IllegalArgumentException(root + ": " + e.getMessage(), e);
- }
- }
-
- private static Path ensureDirectory(Path path) {
- return IoUtils.ensureDirectory(path, IoUtils.getLinkOptions(true));
- }
-
- @Override
- public Path getPath(URI uri) {
- String str = uri.getSchemeSpecificPart();
- int i = str.indexOf("!/");
- if (i == -1) {
- throw new IllegalArgumentException("URI: " + uri + " does not contain path info - e.g., root:file://foo/bar!/");
- }
-
- FileSystem fs = getFileSystem(uri);
- String subPath = str.substring(i + 1);
- Path p = fs.getPath(subPath);
- if (log.isTraceEnabled()) {
- log.trace("getPath({}): {}", uri, p);
- }
- return p;
- }
-
- @Override
- public InputStream newInputStream(Path path, OpenOption... options) throws IOException {
- Path r = unroot(path);
- FileSystemProvider p = provider(r);
- return p.newInputStream(r, options);
- }
-
- @Override
- public OutputStream newOutputStream(Path path, OpenOption... options) throws IOException {
- Path r = unroot(path);
- FileSystemProvider p = provider(r);
- return p.newOutputStream(r, options);
- }
-
- @Override
- public FileChannel newFileChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
- Path r = unroot(path);
- FileSystemProvider p = provider(r);
- return p.newFileChannel(r, options, attrs);
- }
-
- @Override
- public AsynchronousFileChannel newAsynchronousFileChannel(
- Path path, Set<? extends OpenOption> options, ExecutorService executor, FileAttribute<?>... attrs)
- throws IOException {
- Path r = unroot(path);
- FileSystemProvider p = provider(r);
- return p.newAsynchronousFileChannel(r, options, executor, attrs);
- }
-
- @Override
- public SeekableByteChannel newByteChannel(Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
- Path r = unroot(path);
- FileSystemProvider p = provider(r);
- return p.newByteChannel(r, options, attrs);
- }
-
- @Override
- public DirectoryStream<Path> newDirectoryStream(Path dir, DirectoryStream.Filter<? super Path> filter) throws IOException {
- Path r = unroot(dir);
- FileSystemProvider p = provider(r);
- return root(((RootedPath) dir).getFileSystem(), p.newDirectoryStream(r, filter));
- }
-
- protected DirectoryStream<Path> root(RootedFileSystem rfs, DirectoryStream<Path> ds) {
- return new DirectoryStream<Path>() {
- @Override
- public Iterator<Path> iterator() {
- return root(rfs, ds.iterator());
- }
-
- @Override
- public void close() throws IOException {
- ds.close();
- }
- };
- }
-
- protected Iterator<Path> root(RootedFileSystem rfs, Iterator<Path> iter) {
- return new Iterator<Path>() {
- @Override
- public boolean hasNext() {
- return iter.hasNext();
- }
-
- @Override
- public Path next() {
- return root(rfs, iter.next());
- }
- };
- }
-
- @Override
- public void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOException {
- Path r = unroot(dir);
- FileSystemProvider p = provider(r);
- p.createDirectory(r, attrs);
- }
-
- @Override
- public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs) throws IOException {
- createLink(link, target, true, attrs);
- }
-
- @Override
- public void createLink(Path link, Path existing) throws IOException {
- createLink(link, existing, false);
- }
-
- protected void createLink(Path link, Path target, boolean symLink, FileAttribute<?>... attrs) throws IOException {
- Path l = unroot(link);
- Path t = unroot(target);
- /*
- * For a symbolic link preserve the relative path
- */
- if (symLink && (!target.isAbsolute())) {
- RootedFileSystem rfs = ((RootedPath) target).getFileSystem();
- Path root = rfs.getRoot();
- t = root.relativize(t);
- }
-
- FileSystemProvider p = provider(l);
- if (symLink) {
- p.createSymbolicLink(l, t, attrs);
- } else {
- p.createLink(l, t);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("createLink(symbolic={}) {} => {}", symLink, l, t);
- }
- }
-
- @Override
- public void delete(Path path) throws IOException {
- Path r = unroot(path);
- if (log.isTraceEnabled()) {
- log.trace("delete({}): {}", path, r);
- }
- FileSystemProvider p = provider(r);
- p.delete(r);
- }
-
- @Override
- public boolean deleteIfExists(Path path) throws IOException {
- Path r = unroot(path);
- if (log.isTraceEnabled()) {
- log.trace("deleteIfExists({}): {}", path, r);
- }
- FileSystemProvider p = provider(r);
- return p.deleteIfExists(r);
- }
-
- @Override
- public Path readSymbolicLink(Path link) throws IOException {
- Path r = unroot(link);
- FileSystemProvider p = provider(r);
- Path t = p.readSymbolicLink(r);
- Path target = root((RootedFileSystem) link.getFileSystem(), t);
- if (log.isTraceEnabled()) {
- log.trace("readSymbolicLink({})[{}]: {}[{}]", link, r, target, t);
- }
- return target;
- }
-
- @Override
- public void copy(Path source, Path target, CopyOption... options) throws IOException {
- Path s = unroot(source);
- Path t = unroot(target);
- if (log.isTraceEnabled()) {
- log.trace("copy({})[{}]: {}[{}]", source, s, target, t);
- }
- FileSystemProvider p = provider(s);
- p.copy(s, t, options);
- }
-
- @Override
- public void move(Path source, Path target, CopyOption... options) throws IOException {
- Path s = unroot(source);
- Path t = unroot(target);
- if (log.isTraceEnabled()) {
- log.trace("move({})[{}]: {}[{}]", source, s, target, t);
- }
- FileSystemProvider p = provider(s);
- p.move(s, t, options);
- }
-
- @Override
- public boolean isSameFile(Path path, Path path2) throws IOException {
- Path r = unroot(path);
- Path r2 = unroot(path2);
- FileSystemProvider p = provider(r);
- return p.isSameFile(r, r2);
- }
-
- @Override
- public boolean isHidden(Path path) throws IOException {
- Path r = unroot(path);
- FileSystemProvider p = provider(r);
- return p.isHidden(r);
- }
-
- @Override
- public FileStore getFileStore(Path path) throws IOException {
- RootedFileSystem fileSystem = getFileSystem(path);
- Path root = fileSystem.getRoot();
- return Files.getFileStore(root);
- }
-
- protected RootedFileSystem getFileSystem(Path path) throws FileSystemNotFoundException {
- Path real = unroot(path);
- Path rootInstance = null;
- RootedFileSystem fsInstance = null;
- synchronized (fileSystems) {
- // Cannot use forEach because the referenced variable are not effectively final
- for (Map.Entry<Path, RootedFileSystem> fse : fileSystems.entrySet()) {
- Path root = fse.getKey();
- RootedFileSystem fs = fse.getValue();
- if (real.equals(root)) {
- return fs; // we were lucky to have the root
- }
-
- if (!real.startsWith(root)) {
- continue;
- }
-
- // if already have a candidate prefer the longer match since both are prefixes of the real path
- if ((rootInstance == null) || (rootInstance.getNameCount() < root.getNameCount())) {
- rootInstance = root;
- fsInstance = fs;
- }
- }
- }
-
- if (fsInstance == null) {
- throw new FileSystemNotFoundException(path.toString());
- }
-
- if (log.isTraceEnabled()) {
- log.trace("getFileSystem({}): {}", path, fsInstance);
- }
-
- return fsInstance;
- }
-
- @Override
- public void checkAccess(Path path, AccessMode... modes) throws IOException {
- Path r = unroot(path);
- FileSystemProvider p = provider(r);
- p.checkAccess(r, modes);
- }
-
- @Override
- public <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
- Path r = unroot(path);
- FileSystemProvider p = provider(r);
- return p.getFileAttributeView(r, type, options);
- }
-
- @Override
- public <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException {
- Path r = unroot(path);
- if (log.isTraceEnabled()) {
- log.trace("readAttributes({})[{}] type={}", path, r, type.getSimpleName());
- }
-
- FileSystemProvider p = provider(r);
- return p.readAttributes(r, type, options);
- }
-
- @Override
- public Map<String, Object> readAttributes(Path path, String attributes, LinkOption... options) throws IOException {
- Path r = unroot(path);
- FileSystemProvider p = provider(r);
- Map<String, Object> attrs = p.readAttributes(r, attributes, options);
- if (log.isTraceEnabled()) {
- log.trace("readAttributes({})[{}] {}: {}", path, r, attributes, attrs);
- }
- return attrs;
- }
-
- @Override
- public void setAttribute(Path path, String attribute, Object value, LinkOption... options) throws IOException {
- Path r = unroot(path);
- if (log.isTraceEnabled()) {
- log.trace("setAttribute({})[{}] {}={}", path, r, attribute, value);
- }
- FileSystemProvider p = provider(r);
- p.setAttribute(r, attribute, value, options);
- }
-
- protected FileSystemProvider provider(Path path) {
- FileSystem fs = path.getFileSystem();
- return fs.provider();
- }
-
- protected Path root(RootedFileSystem rfs, Path nat) {
- if (nat.isAbsolute()) {
- Path root = rfs.getRoot();
- Path rel = root.relativize(nat);
- return rfs.getPath("/" + rel.toString());
- } else {
- return rfs.getPath(nat.toString());
- }
- }
-
- /**
- * @param path The original (rooted) {@link Path}
- * @return The actual <U>absolute <B>local</B></U> {@link Path} represented
- * by the rooted one
- * @see #resolveLocalPath(RootedPath)
- * @throws IllegalArgumentException if {@code null} path argument
- * @throws ProviderMismatchException if not a {@link RootedPath}
- */
- protected Path unroot(Path path) {
- Objects.requireNonNull(path, "No path to unroot");
- if (!(path instanceof RootedPath)) {
- throw new ProviderMismatchException("unroot(" + path + ") is not a " + RootedPath.class.getSimpleName()
- + " but rather a " + path.getClass().getSimpleName());
- }
-
- return resolveLocalPath((RootedPath) path);
- }
-
- /**
- * @param path The original {@link RootedPath} - never {@code null}
- * @return The actual <U>absolute <B>local</B></U> {@link Path} represented
- * by the rooted one
- * @throws InvalidPathException If the resolved path is not a proper sub-path
- * of the rooted file system
- */
- protected Path resolveLocalPath(RootedPath path) {
- RootedPath absPath = Objects.requireNonNull(path, "No rooted path to resolve").toAbsolutePath();
- RootedFileSystem rfs = absPath.getFileSystem();
- Path root = rfs.getRoot();
- FileSystem lfs = root.getFileSystem();
-
- String rSep = ValidateUtils.checkNotNullAndNotEmpty(rfs.getSeparator(), "No rooted file system separator");
- ValidateUtils.checkTrue(rSep.length() == 1, "Bad rooted file system separator: %s", rSep);
- char rootedSeparator = rSep.charAt(0);
-
- String lSep = ValidateUtils.checkNotNullAndNotEmpty(lfs.getSeparator(), "No local file system separator");
- ValidateUtils.checkTrue(lSep.length() == 1, "Bad local file system separator: %s", lSep);
- char localSeparator = lSep.charAt(0);
-
- String r = absPath.toString();
- String subPath = r.substring(1);
- if (rootedSeparator != localSeparator) {
- subPath = subPath.replace(rootedSeparator, localSeparator);
- }
-
- Path resolved = root.resolve(subPath);
- resolved = resolved.normalize();
- resolved = resolved.toAbsolutePath();
- if (log.isTraceEnabled()) {
- log.trace("resolveLocalPath({}): {}", absPath, resolved);
- }
-
- /*
- * This can happen for Windows since we represent its paths as /C:/some/path,
- * so substring(1) yields C:/some/path - which is resolved as an absolute path
- * (which we don't want).
- */
- if (!resolved.startsWith(root)) {
- throw new InvalidPathException(r, "Not under root");
- }
- return resolved;
- }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedPath.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedPath.java b/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedPath.java
deleted file mode 100644
index e708aed..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/root/RootedPath.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.common.file.root;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.FileSystem;
-import java.nio.file.LinkOption;
-import java.nio.file.Path;
-import java.nio.file.spi.FileSystemProvider;
-import java.util.List;
-
-import org.apache.sshd.common.file.util.BasePath;
-
-/**
- * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class RootedPath extends BasePath<RootedPath, RootedFileSystem> {
- public RootedPath(RootedFileSystem fileSystem, String root, List<String> names) {
- super(fileSystem, root, names);
- }
-
- @Override
- public File toFile() {
- RootedPath absolute = toAbsolutePath();
- RootedFileSystem fs = getFileSystem();
- Path path = fs.getRoot();
- for (String n : absolute.names) {
- path = path.resolve(n);
- }
- return path.toFile();
- }
-
- @Override
- public RootedPath toRealPath(LinkOption... options) throws IOException {
- RootedPath absolute = toAbsolutePath();
- FileSystem fs = getFileSystem();
- FileSystemProvider provider = fs.provider();
- provider.checkAccess(absolute);
- return absolute;
- }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java b/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
deleted file mode 100644
index 6287ce1..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/util/BaseFileSystem.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.common.file.util;
-
-import java.io.IOException;
-import java.nio.file.FileStore;
-import java.nio.file.FileSystem;
-import java.nio.file.Path;
-import java.nio.file.PathMatcher;
-import java.nio.file.WatchService;
-import java.nio.file.spi.FileSystemProvider;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Objects;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.sshd.common.util.GenericUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public abstract class BaseFileSystem<T extends Path> extends FileSystem {
- protected final Logger log;
- private final FileSystemProvider fileSystemProvider;
-
- public BaseFileSystem(FileSystemProvider fileSystemProvider) {
- this.log = LoggerFactory.getLogger(getClass());
- this.fileSystemProvider = Objects.requireNonNull(fileSystemProvider, "No file system provider");
- }
-
- public T getDefaultDir() {
- return getPath("/");
- }
-
- @Override
- public boolean isReadOnly() {
- return false;
- }
-
- @Override
- public FileSystemProvider provider() {
- return fileSystemProvider;
- }
-
- @Override
- public String getSeparator() {
- return "/";
- }
-
- @Override
- public Iterable<Path> getRootDirectories() {
- return Collections.singleton(create("/"));
- }
-
- @Override
- public Iterable<FileStore> getFileStores() {
- throw new UnsupportedOperationException("No file stores available");
- }
-
- @Override
- public T getPath(String first, String... more) {
- StringBuilder sb = new StringBuilder();
- if (!GenericUtils.isEmpty(first)) {
- appendDedupSep(sb, first.replace('\\', '/')); // in case we are running on Windows
- }
-
- if (GenericUtils.length(more) > 0) {
- for (String segment : more) {
- if ((sb.length() > 0) && (sb.charAt(sb.length() - 1) != '/')) {
- sb.append('/');
- }
- // in case we are running on Windows
- appendDedupSep(sb, segment.replace('\\', '/'));
- }
- }
-
- if ((sb.length() > 1) && (sb.charAt(sb.length() - 1) == '/')) {
- sb.setLength(sb.length() - 1);
- }
-
- String path = sb.toString();
- String root = null;
- if (path.startsWith("/")) {
- root = "/";
- path = path.substring(1);
- }
-
- String[] names = GenericUtils.split(path, '/');
- T p = create(root, names);
- if (log.isTraceEnabled()) {
- log.trace("getPath({}, {}): {}", first, Arrays.toString(more), p);
- }
-
- return p;
- }
-
- protected void appendDedupSep(StringBuilder sb, CharSequence s) {
- for (int i = 0; i < s.length(); i++) {
- char ch = s.charAt(i);
- if ((ch != '/') || (sb.length() == 0) || (sb.charAt(sb.length() - 1) != '/')) {
- sb.append(ch);
- }
- }
- }
-
- @Override
- public PathMatcher getPathMatcher(String syntaxAndPattern) {
- int colonIndex = Objects.requireNonNull(syntaxAndPattern, "No argument").indexOf(':');
- if ((colonIndex <= 0) || (colonIndex == syntaxAndPattern.length() - 1)) {
- throw new IllegalArgumentException("syntaxAndPattern must have form \"syntax:pattern\" but was \"" + syntaxAndPattern + "\"");
- }
-
- String syntax = syntaxAndPattern.substring(0, colonIndex);
- String pattern = syntaxAndPattern.substring(colonIndex + 1);
- String expr;
- switch (syntax) {
- case "glob":
- expr = globToRegex(pattern);
- break;
- case "regex":
- expr = pattern;
- break;
- default:
- throw new UnsupportedOperationException("Unsupported path matcher syntax: \'" + syntax + "\'");
- }
- if (log.isTraceEnabled()) {
- log.trace("getPathMatcher({}): {}", syntaxAndPattern, expr);
- }
-
- Pattern regex = Pattern.compile(expr);
- return path -> {
- Matcher m = regex.matcher(path.toString());
- return m.matches();
- };
- }
-
- protected String globToRegex(String pattern) {
- StringBuilder sb = new StringBuilder(Objects.requireNonNull(pattern, "No pattern").length());
- int inGroup = 0;
- int inClass = 0;
- int firstIndexInClass = -1;
- char[] arr = pattern.toCharArray();
- for (int i = 0; i < arr.length; i++) {
- char ch = arr[i];
- switch (ch) {
- case '\\':
- i++;
- if (i >= arr.length) {
- sb.append('\\');
- } else {
- char next = arr[i];
- switch (next) {
- case ',':
- // escape not needed
- break;
- case 'Q':
- case 'E':
- // extra escape needed
- sb.append("\\\\");
- break;
- default:
- sb.append('\\');
- break;
- }
- sb.append(next);
- }
- break;
- case '*':
- sb.append((inClass == 0) ? ".*" : "*");
- break;
- case '?':
- sb.append((inClass == 0) ? '.' : '?');
- break;
- case '[':
- inClass++;
- firstIndexInClass = i + 1;
- sb.append('[');
- break;
- case ']':
- inClass--;
- sb.append(']');
- break;
- case '.':
- case '(':
- case ')':
- case '+':
- case '|':
- case '^':
- case '$':
- case '@':
- case '%':
- if ((inClass == 0) || ((firstIndexInClass == i) && (ch == '^'))) {
- sb.append('\\');
- }
- sb.append(ch);
- break;
- case '!':
- sb.append((firstIndexInClass == i) ? '^' : '!');
- break;
- case '{':
- inGroup++;
- sb.append('(');
- break;
- case '}':
- inGroup--;
- sb.append(')');
- break;
- case ',':
- sb.append((inGroup > 0) ? '|' : ',');
- break;
- default:
- sb.append(ch);
- }
- }
-
- String regex = sb.toString();
- if (log.isTraceEnabled()) {
- log.trace("globToRegex({}): {}", pattern, regex);
- }
-
- return regex;
- }
-
- @Override
- public WatchService newWatchService() throws IOException {
- throw new UnsupportedOperationException("Watch service N/A");
- }
-
- protected T create(String root, String... names) {
- return create(root, GenericUtils.unmodifiableList(names));
- }
-
- protected T create(String root, Collection<String> names) {
- return create(root, GenericUtils.unmodifiableList(names));
- }
-
- protected abstract T create(String root, List<String> names);
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java b/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java
deleted file mode 100644
index d073548..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/util/BasePath.java
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.sshd.common.file.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.nio.file.FileSystem;
-import java.nio.file.Path;
-import java.nio.file.ProviderMismatchException;
-import java.nio.file.WatchEvent;
-import java.nio.file.WatchKey;
-import java.nio.file.WatchService;
-import java.util.AbstractList;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Deque;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-
-import org.apache.sshd.common.util.GenericUtils;
-
-public abstract class BasePath<T extends BasePath<T, FS>, FS extends BaseFileSystem<T>> implements Path {
-
- protected final String root;
- protected final List<String> names;
- private final FS fileSystem;
- private String strValue;
- private int hashValue;
-
- public BasePath(FS fileSystem, String root, List<String> names) {
- this.fileSystem = Objects.requireNonNull(fileSystem, "No file system provided");
- this.root = root;
- this.names = names;
- }
-
- @SuppressWarnings("unchecked")
- protected T asT() {
- return (T) this;
- }
-
- protected T create(String root, String... names) {
- return create(root, GenericUtils.unmodifiableList(names));
- }
-
- protected T create(String root, Collection<String> names) {
- return create(root, GenericUtils.unmodifiableList(names));
- }
-
- protected T create(String root, List<String> names) {
- return fileSystem.create(root, names);
- }
-
- @Override
- public FS getFileSystem() {
- return fileSystem;
- }
-
- @Override
- public boolean isAbsolute() {
- return root != null;
- }
-
- @Override
- public T getRoot() {
- if (isAbsolute()) {
- return create(root);
- }
- return null;
- }
-
- @Override
- public T getFileName() {
- if (!names.isEmpty()) {
- return create(null, names.get(names.size() - 1));
- }
- return null;
- }
-
- @Override
- public T getParent() {
- if (names.isEmpty() || ((names.size() == 1) && (root == null))) {
- return null;
- }
- return create(root, names.subList(0, names.size() - 1));
- }
-
- @Override
- public int getNameCount() {
- return names.size();
- }
-
- @Override
- public T getName(int index) {
- int maxIndex = getNameCount();
- if ((index < 0) || (index >= maxIndex)) {
- throw new IllegalArgumentException("Invalid name index " + index + " - not in range [0-" + maxIndex + "]");
- }
- return create(null, names.subList(index, index + 1));
- }
-
- @Override
- public T subpath(int beginIndex, int endIndex) {
- int maxIndex = getNameCount();
- if ((beginIndex < 0) || (beginIndex >= maxIndex) || (endIndex > maxIndex) || (beginIndex >= endIndex)) {
- throw new IllegalArgumentException("subpath(" + beginIndex + "," + endIndex + ") bad index range - allowed [0-" + maxIndex + "]");
- }
- return create(null, names.subList(beginIndex, endIndex));
- }
-
- protected boolean startsWith(List<?> list, List<?> other) {
- return list.size() >= other.size() && list.subList(0, other.size()).equals(other);
- }
-
- @Override
- public boolean startsWith(Path other) {
- T p1 = asT();
- T p2 = checkPath(other);
- return Objects.equals(p1.getFileSystem(), p2.getFileSystem())
- && Objects.equals(p1.root, p2.root)
- && startsWith(p1.names, p2.names);
- }
-
- @Override
- public boolean startsWith(String other) {
- return startsWith(getFileSystem().getPath(other));
- }
-
- protected boolean endsWith(List<?> list, List<?> other) {
- return other.size() <= list.size() && list.subList(list.size() - other.size(), list.size()).equals(other);
- }
-
- @Override
- public boolean endsWith(Path other) {
- T p1 = asT();
- T p2 = checkPath(other);
- if (p2.isAbsolute()) {
- return p1.compareTo(p2) == 0;
- }
- return endsWith(p1.names, p2.names);
- }
-
- @Override
- public boolean endsWith(String other) {
- return endsWith(getFileSystem().getPath(other));
- }
-
- protected boolean isNormal() {
- int count = getNameCount();
- if ((count == 0) || ((count == 1) && !isAbsolute())) {
- return true;
- }
- boolean foundNonParentName = isAbsolute(); // if there's a root, the path doesn't start with ..
- boolean normal = true;
- for (String name : names) {
- if (name.equals("..")) {
- if (foundNonParentName) {
- normal = false;
- break;
- }
- } else {
- if (name.equals(".")) {
- normal = false;
- break;
- }
- foundNonParentName = true;
- }
- }
- return normal;
- }
-
- @Override
- public T normalize() {
- if (isNormal()) {
- return asT();
- }
-
- Deque<String> newNames = new ArrayDeque<>();
- for (String name : names) {
- if (name.equals("..")) {
- String lastName = newNames.peekLast();
- if (lastName != null && !lastName.equals("..")) {
- newNames.removeLast();
- } else if (!isAbsolute()) {
- // if there's a root and we have an extra ".." that would go up above the root, ignore it
- newNames.add(name);
- }
- } else if (!name.equals(".")) {
- newNames.add(name);
- }
- }
-
- return newNames.equals(names) ? asT() : create(root, newNames);
- }
-
- @Override
- public T resolve(Path other) {
- T p1 = asT();
- T p2 = checkPath(other);
- if (p2.isAbsolute()) {
- return p2;
- }
- if (p2.names.isEmpty()) {
- return p1;
- }
- String[] names = new String[p1.names.size() + p2.names.size()];
- int index = 0;
- for (String p : p1.names) {
- names[index++] = p;
- }
- for (String p : p2.names) {
- names[index++] = p;
- }
- return create(p1.root, names);
- }
-
- @Override
- public T resolve(String other) {
- return resolve(getFileSystem().getPath(other, GenericUtils.EMPTY_STRING_ARRAY));
- }
-
- @Override
- public Path resolveSibling(Path other) {
- Objects.requireNonNull(other, "Missing sibling path argument");
- T parent = getParent();
- return parent == null ? other : parent.resolve(other);
- }
-
- @Override
- public Path resolveSibling(String other) {
- return resolveSibling(getFileSystem().getPath(other, GenericUtils.EMPTY_STRING_ARRAY));
- }
-
- @Override
- public T relativize(Path other) {
- T p1 = asT();
- T p2 = checkPath(other);
- if (!Objects.equals(p1.getRoot(), p2.getRoot())) {
- throw new IllegalArgumentException("Paths have different roots: " + this + ", " + other);
- }
- if (p2.equals(p1)) {
- return create(null);
- }
- if (p1.root == null && p1.names.isEmpty()) {
- return p2;
- }
- // Common subsequence
- int sharedSubsequenceLength = 0;
- for (int i = 0; i < Math.min(p1.names.size(), p2.names.size()); i++) {
- if (p1.names.get(i).equals(p2.names.get(i))) {
- sharedSubsequenceLength++;
- } else {
- break;
- }
- }
- int extraNamesInThis = Math.max(0, p1.names.size() - sharedSubsequenceLength);
- List<String> extraNamesInOther = (p2.names.size() <= sharedSubsequenceLength)
- ? Collections.emptyList()
- : p2.names.subList(sharedSubsequenceLength, p2.names.size());
- List<String> parts = new ArrayList<>(extraNamesInThis + extraNamesInOther.size());
- // add .. for each extra name in this path
- parts.addAll(Collections.nCopies(extraNamesInThis, ".."));
- // add each extra name in the other path
- parts.addAll(extraNamesInOther);
- return create(null, parts);
- }
-
- @Override
- public T toAbsolutePath() {
- if (isAbsolute()) {
- return asT();
- }
- return fileSystem.getDefaultDir().resolve(this);
- }
-
- @Override
- public URI toUri() {
- File file = toFile();
- return file.toURI();
- }
-
- @Override
- public File toFile() {
- throw new UnsupportedOperationException("To file " + toAbsolutePath() + " N/A");
- }
-
- @Override
- public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) throws IOException {
- return register(watcher, events, (WatchEvent.Modifier[]) null);
- }
-
- @Override
- public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException {
- throw new UnsupportedOperationException("Register to watch " + toAbsolutePath() + " N/A");
- }
-
- @Override
- public Iterator<Path> iterator() {
- return new AbstractList<Path>() {
- @Override
- public Path get(int index) {
- return getName(index);
- }
-
- @Override
- public int size() {
- return getNameCount();
- }
- }.iterator();
- }
-
- @Override
- public int compareTo(Path paramPath) {
- T p1 = asT();
- T p2 = checkPath(paramPath);
- int c = compare(p1.root, p2.root);
- if (c != 0) {
- return c;
- }
- for (int i = 0; i < Math.min(p1.names.size(), p2.names.size()); i++) {
- String n1 = p1.names.get(i);
- String n2 = p2.names.get(i);
- c = compare(n1, n2);
- if (c != 0) {
- return c;
- }
- }
- return p1.names.size() - p2.names.size();
- }
-
- protected int compare(String s1, String s2) {
- if (s1 == null) {
- return s2 == null ? 0 : -1;
- } else {
- return s2 == null ? +1 : s1.compareTo(s2);
- }
- }
-
- @SuppressWarnings("unchecked")
- protected T checkPath(Path paramPath) {
- Objects.requireNonNull(paramPath, "Missing path argument");
- if (paramPath.getClass() != getClass()) {
- throw new ProviderMismatchException("Path is not of this class: " + paramPath + "[" + paramPath.getClass().getSimpleName() + "]");
- }
- T t = (T) paramPath;
-
- FileSystem fs = t.getFileSystem();
- if (fs.provider() != this.fileSystem.provider()) {
- throw new ProviderMismatchException("Mismatched providers for " + t);
- }
- return t;
- }
-
- @Override
- public int hashCode() {
- synchronized (this) {
- if (hashValue == 0) {
- hashValue = calculatedHashCode();
- if (hashValue == 0) {
- hashValue = 1;
- }
- }
- }
-
- return hashValue;
- }
-
- protected int calculatedHashCode() {
- return Objects.hash(getFileSystem(), root, names);
- }
-
- @Override
- public boolean equals(Object obj) {
- return (obj instanceof Path) && (compareTo((Path) obj) == 0);
- }
-
- @Override
- public String toString() {
- synchronized (this) {
- if (strValue == null) {
- strValue = asString();
- }
- }
-
- return strValue;
- }
-
- protected String asString() {
- StringBuilder sb = new StringBuilder();
- if (root != null) {
- sb.append(root);
- }
-
- String separator = getFileSystem().getSeparator();
- for (String name : names) {
- if ((sb.length() > 0) && (sb.charAt(sb.length() - 1) != '/')) {
- sb.append(separator);
- }
- sb.append(name);
- }
-
- return sb.toString();
- }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-core/src/main/java/org/apache/sshd/common/file/util/MockFileSystem.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/util/MockFileSystem.java b/sshd-core/src/main/java/org/apache/sshd/common/file/util/MockFileSystem.java
deleted file mode 100644
index 9181c2d..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/util/MockFileSystem.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.common.file.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.FileStore;
-import java.nio.file.FileSystem;
-import java.nio.file.Path;
-import java.nio.file.PathMatcher;
-import java.nio.file.WatchService;
-import java.nio.file.attribute.UserPrincipalLookupService;
-import java.nio.file.spi.FileSystemProvider;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class MockFileSystem extends FileSystem {
- private final AtomicBoolean open = new AtomicBoolean(true);
- private final String name;
-
- public MockFileSystem(String name) {
- this.name = name;
- }
-
- @Override
- public FileSystemProvider provider() {
- throw new UnsupportedOperationException("provider() N/A");
- }
-
- @Override
- public void close() throws IOException {
- if (open.getAndSet(false)) {
- //noinspection UnnecessaryReturnStatement
- return; // debug breakpoint
- }
- }
-
- @Override
- public boolean isOpen() {
- return open.get();
- }
-
- @Override
- public boolean isReadOnly() {
- return true;
- }
-
- @Override
- public String getSeparator() {
- return File.separator;
- }
-
- @Override
- public Iterable<Path> getRootDirectories() {
- return Collections.emptyList();
- }
-
- @Override
- public Iterable<FileStore> getFileStores() {
- return Collections.emptyList();
- }
-
- @Override
- public Set<String> supportedFileAttributeViews() {
- return Collections.emptySet();
- }
-
- @Override
- public Path getPath(String first, String... more) {
- throw new UnsupportedOperationException("getPath(" + first + ") " + Arrays.toString(more));
- }
-
- @Override
- public PathMatcher getPathMatcher(String syntaxAndPattern) {
- throw new UnsupportedOperationException("getPathMatcher(" + syntaxAndPattern + ")");
- }
-
- @Override
- public UserPrincipalLookupService getUserPrincipalLookupService() {
- throw new UnsupportedOperationException("getUserPrincipalLookupService() N/A");
- }
-
- @Override
- public WatchService newWatchService() throws IOException {
- throw new IOException("newWatchService() N/A");
- }
-
- @Override
- public String toString() {
- return name;
- }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-core/src/main/java/org/apache/sshd/common/file/util/MockPath.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/file/util/MockPath.java b/sshd-core/src/main/java/org/apache/sshd/common/file/util/MockPath.java
deleted file mode 100644
index 2f781b8..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/common/file/util/MockPath.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.common.file.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URI;
-import java.nio.file.FileSystem;
-import java.nio.file.LinkOption;
-import java.nio.file.Path;
-import java.nio.file.WatchEvent.Kind;
-import java.nio.file.WatchEvent.Modifier;
-import java.nio.file.WatchKey;
-import java.nio.file.WatchService;
-import java.util.Collections;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class MockPath implements Path {
- private final String path;
- private final FileSystem fs;
-
- public MockPath(String path) {
- this.path = path;
- this.fs = new MockFileSystem(path);
- }
-
- @Override
- public FileSystem getFileSystem() {
- return fs;
- }
-
- @Override
- public boolean isAbsolute() {
- return true;
- }
-
- @Override
- public Path getRoot() {
- return this;
- }
-
- @Override
- public Path getFileName() {
- return this;
- }
-
- @Override
- public Path getParent() {
- return null;
- }
-
- @Override
- public int getNameCount() {
- return 0;
- }
-
- @Override
- public Path getName(int index) {
- if (index == 0) {
- return this;
- } else {
- throw new IllegalArgumentException("getName - bad index: " + index);
- }
- }
-
- @Override
- public Path subpath(int beginIndex, int endIndex) {
- throw new UnsupportedOperationException("subPath(" + beginIndex + "," + endIndex + ") N/A");
- }
-
- @Override
- public boolean startsWith(Path other) {
- return startsWith(other.toString());
- }
-
- @Override
- public boolean startsWith(String other) {
- return path.startsWith(other);
- }
-
- @Override
- public boolean endsWith(Path other) {
- return endsWith(other.toString());
- }
-
- @Override
- public boolean endsWith(String other) {
- return path.endsWith(other);
- }
-
- @Override
- public Path normalize() {
- return this;
- }
-
- @Override
- public Path resolve(Path other) {
- return resolve(other.toString());
- }
-
- @Override
- public Path resolve(String other) {
- throw new UnsupportedOperationException("resolve(" + other + ") N/A");
- }
-
- @Override
- public Path resolveSibling(Path other) {
- return resolveSibling(other.toString());
- }
-
- @Override
- public Path resolveSibling(String other) {
- throw new UnsupportedOperationException("resolveSibling(" + other + ") N/A");
- }
-
- @Override
- public Path relativize(Path other) {
- throw new UnsupportedOperationException("relativize(" + other + ") N/A");
- }
-
- @Override
- public URI toUri() {
- throw new UnsupportedOperationException("toUri() N/A");
- }
-
- @Override
- public Path toAbsolutePath() {
- return this;
- }
-
- @Override
- public Path toRealPath(LinkOption... options) throws IOException {
- return this;
- }
-
- @Override
- public File toFile() {
- throw new UnsupportedOperationException("toFile() N/A");
- }
-
- @Override
- public WatchKey register(WatchService watcher, Kind<?>... events) throws IOException {
- return register(watcher, events, (Modifier[]) null);
- }
-
- @Override
- public WatchKey register(WatchService watcher, Kind<?>[] events, Modifier... modifiers) throws IOException {
- throw new IOException("register(" + path + ") N/A");
- }
-
- @Override
- public Iterator<Path> iterator() {
- return Collections.<Path>singleton(this).iterator();
- }
-
- @Override
- public int compareTo(Path other) {
- return path.compareTo(other.toString());
- }
-
- @Override
- public String toString() {
- return path;
- }
-
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/98ac7c2c/sshd-core/src/test/java/org/apache/sshd/common/file/root/AssertableFile.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/file/root/AssertableFile.java b/sshd-core/src/test/java/org/apache/sshd/common/file/root/AssertableFile.java
deleted file mode 100644
index 3d056ae..0000000
--- a/sshd-core/src/test/java/org/apache/sshd/common/file/root/AssertableFile.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.sshd.common.file.root;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-import org.apache.sshd.common.util.NumberUtils;
-import org.apache.sshd.util.test.BaseTestSupport;
-
-/**
- * TODO upgrade to default methods in JDK 8
- * @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public abstract class AssertableFile extends BaseTestSupport {
- protected AssertableFile() {
- super();
- }
-
- public static boolean notExists(Path p) {
- boolean cond = !Files.exists(p);
- assertTrue(p + " does not exist", cond);
- return cond;
- }
-
- public static boolean exists(Path p) {
- boolean cond = Files.exists(p);
- assertTrue(p + " exists", cond);
- return cond;
- }
-
- public static boolean isDir(Path p) {
- boolean cond = Files.isDirectory(p);
- assertTrue(p + " is directory", cond);
- return cond;
- }
-
- public static boolean isReadable(Path p) {
- boolean cond = Files.isReadable(p);
- assertTrue(p + " is readable by user", cond);
- return cond;
- }
-
- public static boolean isNonEmpty(byte[] bytes) {
- boolean cond = !NumberUtils.isEmpty(bytes);
- assertTrue("bytes are non empty", cond);
- return cond;
- }
-
- public static boolean isRootedAt(Path root, Path check) {
- boolean cond = check.toAbsolutePath().normalize().startsWith(root.toAbsolutePath().normalize());
- assertTrue(check + " is subpath of parent " + root, cond);
- return cond;
- }
-}
l***@apache.org
2018-10-25 09:11:04 UTC
Permalink
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
index 96460d8..56e397f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientUserAuthService.java
@@ -71,7 +71,7 @@ public class ClientUserAuthService
public ClientUserAuthService(Session s) {
clientSession = ValidateUtils.checkInstanceOf(s, ClientSessionImpl.class, "Client side service used on server side: %s", s);
authFactories = ValidateUtils.checkNotNullAndNotEmpty(
- clientSession.getUserAuthFactories(), "No user auth factories for %s", s);
+ clientSession.getUserAuthFactories(), "No user auth factories for %s", s);
clientMethods = new ArrayList<>();

String prefs = s.getString(ClientAuthenticationManager.PREFERRED_AUTHS);
@@ -86,7 +86,8 @@ public class ClientUserAuthService
}

for (String pref : GenericUtils.split(prefs, ',')) {
- NamedFactory<UserAuth> factory = NamedResource.findByName(pref, String.CASE_INSENSITIVE_ORDER, authFactories);
+ NamedFactory<UserAuth> factory =
+ NamedResource.findByName(pref, String.CASE_INSENSITIVE_ORDER, authFactories);
if (factory != null) {
clientMethods.add(pref);
} else {
@@ -151,7 +152,8 @@ public class ClientUserAuthService
}

String username = session.getUsername();
- Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST, username.length() + service.length() + Integer.SIZE);
+ Buffer buffer = session.createBuffer(SshConstants.SSH_MSG_USERAUTH_REQUEST,
+ username.length() + service.length() + Integer.SIZE);
buffer.putString(username);
buffer.putString(service);
buffer.putString("none");
@@ -167,13 +169,13 @@ public class ClientUserAuthService
boolean debugEnabled = log.isDebugEnabled();
if ((authFuture != null) && authFuture.isSuccess()) {
log.error("process({}) unexpected authenticated client command: {}",
- session, SshConstants.getCommandMessageName(cmd));
+ session, SshConstants.getCommandMessageName(cmd));
throw new IllegalStateException("UserAuth message delivered to authenticated client");
} else if ((authFuture != null) && authFuture.isDone()) {
// ignore for now; TODO: random packets
if (debugEnabled) {
log.debug("process({}) Ignoring random message - cmd={}",
- session, SshConstants.getCommandMessageName(cmd));
+ session, SshConstants.getCommandMessageName(cmd));
}
} else if (cmd == SshConstants.SSH_MSG_USERAUTH_BANNER) {
String welcome = buffer.getString();
@@ -189,7 +191,7 @@ public class ClientUserAuthService
}
} catch (Error e) {
log.warn("process({}) failed ({}) to consult interaction: {}",
- session, e.getClass().getSimpleName(), e.getMessage());
+ session, e.getClass().getSimpleName(), e.getMessage());
if (debugEnabled) {
log.debug("process(" + session + ") interaction consultation failure details", e);
}
@@ -214,7 +216,7 @@ public class ClientUserAuthService
if (cmd == SshConstants.SSH_MSG_USERAUTH_SUCCESS) {
if (log.isDebugEnabled()) {
log.debug("processUserAuth({}) SSH_MSG_USERAUTH_SUCCESS Succeeded with {}",
- session, (userAuth == null) ? "<unknown>" : userAuth.getName());
+ session, (userAuth == null) ? "<unknown>" : userAuth.getName());
}
if (userAuth != null) {
try {
@@ -237,7 +239,7 @@ public class ClientUserAuthService
boolean partial = buffer.getBoolean();
if (log.isDebugEnabled()) {
log.debug("processUserAuth({}) Received SSH_MSG_USERAUTH_FAILURE - partial={}, methods={}",
- session, partial, mths);
+ session, partial, mths);
}
if (partial || (serverMethods == null)) {
serverMethods = Arrays.asList(GenericUtils.split(mths, ','));
@@ -261,7 +263,7 @@ public class ClientUserAuthService

if (log.isDebugEnabled()) {
log.debug("processUserAuth({}) delegate processing of {} to {}",
- session, SshConstants.getCommandMessageName(cmd), userAuth.getName());
+ session, SshConstants.getCommandMessageName(cmd), userAuth.getName());
}

buffer.rpos(buffer.rpos() - 1);
@@ -278,7 +280,7 @@ public class ClientUserAuthService
if (userAuth == null) {
if (debugEnabled) {
log.debug("tryNext({}) starting authentication mechanisms: client={}, server={}",
- session, clientMethods, serverMethods);
+ session, clientMethods, serverMethods);
}
} else if (!userAuth.process(null)) {
if (debugEnabled) {
@@ -310,12 +312,13 @@ public class ClientUserAuthService
if (currentMethod >= clientMethods.size()) {
if (debugEnabled) {
log.debug("tryNext({}) exhausted all methods - client={}, server={}",
- session, clientMethods, serverMethods);
+ session, clientMethods, serverMethods);
}

// also wake up anyone sitting in waitFor
AuthFuture authFuture = Objects.requireNonNull(authFutureHolder.get(), "No current future");
- authFuture.setException(new SshException(SshConstants.SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE, "No more authentication methods available"));
+ authFuture.setException(new SshException(
+ SshConstants.SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE, "No more authentication methods available"));
return;
}


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java b/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
index 0def8b4..bce2283 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/BaseBuilder.java
@@ -69,20 +69,21 @@ public class BaseBuilder<T extends AbstractFactoryManager, S extends BaseBuilder
* as specified by <A HREF="https://www.freebsd.org/cgi/man.cgi?query=ssh_config&sektion=5">ssh_config(5)</A>
*/
public static final List<BuiltinCiphers> DEFAULT_CIPHERS_PREFERENCE =
- Collections.unmodifiableList(Arrays.asList(
- BuiltinCiphers.aes128ctr,
- BuiltinCiphers.aes192ctr,
- BuiltinCiphers.aes256ctr,
- BuiltinCiphers.arcfour256,
- BuiltinCiphers.arcfour128,
- BuiltinCiphers.aes128cbc,
- BuiltinCiphers.tripledescbc,
- BuiltinCiphers.blowfishcbc,
- // TODO add support for cast128-cbc cipher
- BuiltinCiphers.aes192cbc,
- BuiltinCiphers.aes256cbc
- // TODO add support for arcfour cipher
- ));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ BuiltinCiphers.aes128ctr,
+ BuiltinCiphers.aes192ctr,
+ BuiltinCiphers.aes256ctr,
+ BuiltinCiphers.arcfour256,
+ BuiltinCiphers.arcfour128,
+ BuiltinCiphers.aes128cbc,
+ BuiltinCiphers.tripledescbc,
+ BuiltinCiphers.blowfishcbc,
+ // TODO add support for cast128-cbc cipher
+ BuiltinCiphers.aes192cbc,
+ BuiltinCiphers.aes256cbc
+ // TODO add support for arcfour cipher
+ ));

/**
* The default {@link BuiltinDHFactories} setup in order of preference
@@ -90,22 +91,23 @@ public class BaseBuilder<T extends AbstractFactoryManager, S extends BaseBuilder
* ssh_config(5)</A>
*/
public static final List<BuiltinDHFactories> DEFAULT_KEX_PREFERENCE =
- Collections.unmodifiableList(Arrays.asList(
- BuiltinDHFactories.ecdhp521,
- BuiltinDHFactories.ecdhp384,
- BuiltinDHFactories.ecdhp256,
-
- BuiltinDHFactories.dhgex256,
- BuiltinDHFactories.dhgex,
-
- BuiltinDHFactories.dhg18_512,
- BuiltinDHFactories.dhg17_512,
- BuiltinDHFactories.dhg16_512,
- BuiltinDHFactories.dhg15_512,
- BuiltinDHFactories.dhg14_256,
- BuiltinDHFactories.dhg14,
- BuiltinDHFactories.dhg1
- ));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ BuiltinDHFactories.ecdhp521,
+ BuiltinDHFactories.ecdhp384,
+ BuiltinDHFactories.ecdhp256,
+
+ BuiltinDHFactories.dhgex256,
+ BuiltinDHFactories.dhgex,
+
+ BuiltinDHFactories.dhg18_512,
+ BuiltinDHFactories.dhg17_512,
+ BuiltinDHFactories.dhg16_512,
+ BuiltinDHFactories.dhg15_512,
+ BuiltinDHFactories.dhg14_256,
+ BuiltinDHFactories.dhg14,
+ BuiltinDHFactories.dhg1
+ ));

/**
* The default {@link BuiltinMacs} setup in order of preference
@@ -113,14 +115,15 @@ public class BaseBuilder<T extends AbstractFactoryManager, S extends BaseBuilder
* ssh_config(5)</A>
*/
public static final List<BuiltinMacs> DEFAULT_MAC_PREFERENCE =
- Collections.unmodifiableList(Arrays.asList(
- BuiltinMacs.hmacmd5,
- BuiltinMacs.hmacsha1,
- BuiltinMacs.hmacsha256,
- BuiltinMacs.hmacsha512,
- BuiltinMacs.hmacsha196,
- BuiltinMacs.hmacmd596
- ));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ BuiltinMacs.hmacmd5,
+ BuiltinMacs.hmacsha1,
+ BuiltinMacs.hmacsha256,
+ BuiltinMacs.hmacsha512,
+ BuiltinMacs.hmacsha196,
+ BuiltinMacs.hmacmd596
+ ));

/**
* Preferred {@link BuiltinSignatures} according to
@@ -128,14 +131,15 @@ public class BaseBuilder<T extends AbstractFactoryManager, S extends BaseBuilder
* {@code HostKeyAlgorithms} recommendation
*/
public static final List<BuiltinSignatures> DEFAULT_SIGNATURE_PREFERENCE =
- Collections.unmodifiableList(Arrays.asList(
- BuiltinSignatures.nistp256,
- BuiltinSignatures.nistp384,
- BuiltinSignatures.nistp521,
- BuiltinSignatures.ed25519,
- BuiltinSignatures.rsa,
- BuiltinSignatures.dsa
- ));
+ Collections.unmodifiableList(
+ Arrays.asList(
+ BuiltinSignatures.nistp256,
+ BuiltinSignatures.nistp384,
+ BuiltinSignatures.nistp521,
+ BuiltinSignatures.ed25519,
+ BuiltinSignatures.rsa,
+ BuiltinSignatures.dsa
+ ));

public static final UnknownChannelReferenceHandler DEFAULT_UNKNOWN_CHANNEL_REFERENCE_HANDLER =
DefaultUnknownChannelReferenceHandler.INSTANCE;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
index a6c11ca..0f1892c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/AbstractChannel.java
@@ -120,12 +120,15 @@ public abstract class AbstractChannel
this(discriminator, client, Collections.emptyList(), null);
}

- protected AbstractChannel(String discriminator, boolean client, Collection<? extends RequestHandler<Channel>> handlers, CloseableExecutorService executorService) {
+ protected AbstractChannel(String discriminator, boolean client,
+ Collection<? extends RequestHandler<Channel>> handlers,
+ CloseableExecutorService executorService) {
super(discriminator);
gracefulFuture = new DefaultCloseFuture(discriminator, lock);
localWindow = new Window(this, null, client, true);
remoteWindow = new Window(this, null, client, false);
- channelListenerProxy = EventListenerUtils.proxyWrapper(ChannelListener.class, getClass().getClassLoader(), channelListeners);
+ channelListenerProxy = EventListenerUtils.proxyWrapper(
+ ChannelListener.class, getClass().getClassLoader(), channelListeners);
executor = executorService;
addRequestHandlers(handlers);
}
@@ -268,12 +271,12 @@ public abstract class AbstractChannel
result = handler.process(this, req, wantReply, buffer);
} catch (Throwable e) {
log.warn("handleRequest({}) {} while {}#process({})[want-reply={}]: {}",
- this, e.getClass().getSimpleName(), handler.getClass().getSimpleName(),
- req, wantReply, e.getMessage());
+ this, e.getClass().getSimpleName(), handler.getClass().getSimpleName(),
+ req, wantReply, e.getMessage());
if (debugEnabled) {
log.debug("handleRequest(" + this + ") request=" + req
- + "[want-reply=" + wantReply + "] processing failure details",
- e);
+ + "[want-reply=" + wantReply + "] processing failure details",
+ e);
}
result = RequestHandler.Result.ReplyFailure;
}
@@ -282,7 +285,7 @@ public abstract class AbstractChannel
if (RequestHandler.Result.Unsupported.equals(result)) {
if (traceEnabled) {
log.trace("handleRequest({})[{}#process({})[want-reply={}]]: {}",
- this, handler.getClass().getSimpleName(), req, wantReply, result);
+ this, handler.getClass().getSimpleName(), req, wantReply, result);
}
} else {
sendResponse(buffer, req, result, wantReply);
@@ -327,8 +330,7 @@ public abstract class AbstractChannel
*/
protected RequestHandler.Result handleInternalRequest(String req, boolean wantReply, Buffer buffer) throws IOException {
if (log.isDebugEnabled()) {
- log.debug("handleInternalRequest({})[want-reply={}] unknown type: {}",
- this, wantReply, req);
+ log.debug("handleInternalRequest({})[want-reply={}] unknown type: {}", this, wantReply, req);
}
return RequestHandler.Result.Unsupported;
}
@@ -347,8 +349,8 @@ public abstract class AbstractChannel
}

byte cmd = RequestHandler.Result.ReplySuccess.equals(result)
- ? SshConstants.SSH_MSG_CHANNEL_SUCCESS
- : SshConstants.SSH_MSG_CHANNEL_FAILURE;
+ ? SshConstants.SSH_MSG_CHANNEL_SUCCESS
+ : SshConstants.SSH_MSG_CHANNEL_FAILURE;
Session session = getSession();
Buffer rsp = session.createBuffer(cmd, Integer.BYTES);
rsp.putInt(recipient);
@@ -434,7 +436,7 @@ public abstract class AbstractChannel
} catch (Throwable err) {
Throwable ignored = GenericUtils.peelException(err);
log.warn("signalChannelOpenFailure({}) failed ({}) to inform listener of open failure={}: {}",
- this, ignored.getClass().getSimpleName(), reason.getClass().getSimpleName(), ignored.getMessage());
+ this, ignored.getClass().getSimpleName(), reason.getClass().getSimpleName(), ignored.getMessage());
if (log.isDebugEnabled()) {
log.debug("doInit(" + this + ") inform listener open failure details", ignored);
}
@@ -467,7 +469,7 @@ public abstract class AbstractChannel
} catch (Throwable err) {
Throwable e = GenericUtils.peelException(err);
log.warn("notifyStateChanged({})[{}] {} while signal channel state change: {}",
- this, hint, e.getClass().getSimpleName(), e.getMessage());
+ this, hint, e.getClass().getSimpleName(), e.getMessage());
if (log.isDebugEnabled()) {
log.debug("notifyStateChanged(" + this + ")[" + hint + "] channel state signalling failure details", e);
}
@@ -552,13 +554,13 @@ public abstract class AbstractChannel
@Override
protected Closeable getInnerCloseable() {
return builder()
- .sequential(new GracefulChannelCloseable(), getExecutorService())
- .run(toString(), () -> {
- if (service != null) {
- service.unregisterChannel(AbstractChannel.this);
- }
- })
- .build();
+ .sequential(new GracefulChannelCloseable(), getExecutorService())
+ .run(toString(), () -> {
+ if (service != null) {
+ service.unregisterChannel(AbstractChannel.this);
+ }
+ })
+ .build();
}

public class GracefulChannelCloseable extends IoBaseCloseable {
@@ -613,7 +615,8 @@ public abstract class AbstractChannel
buffer.putInt(getRecipient());

try {
- long timeout = channel.getLongProperty(FactoryManager.CHANNEL_CLOSE_TIMEOUT, FactoryManager.DEFAULT_CHANNEL_CLOSE_TIMEOUT);
+ long timeout = channel.getLongProperty(
+ FactoryManager.CHANNEL_CLOSE_TIMEOUT, FactoryManager.DEFAULT_CHANNEL_CLOSE_TIMEOUT);
s.writePacket(buffer, timeout, TimeUnit.MILLISECONDS).addListener(future -> {
if (future.isWritten()) {
handleClosePacketWritten(channel, immediately);
@@ -624,7 +627,7 @@ public abstract class AbstractChannel
} catch (IOException e) {
if (debugEnabled) {
log.debug("close({})[immediately={}] {} while writing SSH_MSG_CHANNEL_CLOSE packet on channel: {}",
- channel, immediately, e.getClass().getSimpleName(), e.getMessage());
+ channel, immediately, e.getClass().getSimpleName(), e.getMessage());
}

if (log.isTraceEnabled()) {
@@ -639,7 +642,7 @@ public abstract class AbstractChannel
Collection<?> running = service.shutdownNow();
if (debugEnabled) {
log.debug("close({})[immediately={}] shutdown executor service on close - running count={}",
- channel, immediately, GenericUtils.size(running));
+ channel, immediately, GenericUtils.size(running));
}
}

@@ -649,7 +652,7 @@ public abstract class AbstractChannel
protected void handleClosePacketWritten(Channel channel, boolean immediately) {
if (log.isDebugEnabled()) {
log.debug("handleClosePacketWritten({})[immediately={}] SSH_MSG_CHANNEL_CLOSE written on channel",
- channel, immediately);
+ channel, immediately);
}

if (gracefulState.compareAndSet(GracefulState.Opened, GracefulState.CloseSent)) {
@@ -663,7 +666,7 @@ public abstract class AbstractChannel
protected void handleClosePacketWriteFailure(Channel channel, boolean immediately, Throwable t) {
if (log.isDebugEnabled()) {
log.debug("handleClosePacketWriteFailure({})[immediately={}] failed ({}) to write SSH_MSG_CHANNEL_CLOSE on channel: {}",
- this, immediately, t.getClass().getSimpleName(), t.getMessage());
+ this, immediately, t.getClass().getSimpleName(), t.getMessage());
}
if (log.isTraceEnabled()) {
log.trace("handleClosePacketWriteFailure(" + channel + ") SSH_MSG_CHANNEL_CLOSE failure details", t);
@@ -791,7 +794,7 @@ public abstract class AbstractChannel
}
if (log.isTraceEnabled()) {
BufferUtils.dumpHex(getSimplifiedLogger(), BufferUtils.DEFAULT_HEXDUMP_LEVEL, "handleData(" + this + ")",
- this, BufferUtils.DEFAULT_HEX_SEPARATOR, buffer.array(), buffer.rpos(), (int) len);
+ this, BufferUtils.DEFAULT_HEX_SEPARATOR, buffer.array(), buffer.rpos(), (int) len);
}
if (isEofSignalled()) {
// TODO consider throwing an exception
@@ -821,7 +824,7 @@ public abstract class AbstractChannel
}
if (log.isTraceEnabled()) {
BufferUtils.dumpHex(getSimplifiedLogger(), BufferUtils.DEFAULT_HEXDUMP_LEVEL, "handleExtendedData(" + this + ")",
- this, BufferUtils.DEFAULT_HEX_SEPARATOR, buffer.array(), buffer.rpos(), (int) len);
+ this, BufferUtils.DEFAULT_HEX_SEPARATOR, buffer.array(), buffer.rpos(), (int) len);
}
if (isEofSignalled()) {
// TODO consider throwing an exception
@@ -953,8 +956,8 @@ public abstract class AbstractChannel
@SuppressWarnings("unchecked")
public <T> T setAttribute(AttributeKey<T> key, T value) {
return (T) attributes.put(
- Objects.requireNonNull(key, "No key"),
- Objects.requireNonNull(value, "No value"));
+ Objects.requireNonNull(key, "No key"),
+ Objects.requireNonNull(value, "No value"));
}

@Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/channel/PtyMode.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/PtyMode.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/PtyMode.java
index 827a877..21af35e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/PtyMode.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/PtyMode.java
@@ -24,6 +24,7 @@ import java.util.Comparator;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Map;
+import java.util.NavigableMap;
import java.util.Set;
import java.util.function.Function;

@@ -291,11 +292,12 @@ public enum PtyMode {
/**
* An un-modifiable {@link Set} of all defined {@link PtyMode}s
*/
- public static final Set<PtyMode> MODES = Collections.unmodifiableSet(EnumSet.allOf(PtyMode.class));
+ public static final Set<PtyMode> MODES =
+ Collections.unmodifiableSet(EnumSet.allOf(PtyMode.class));

- private static final Map<Integer, PtyMode> COMMANDS =
- Collections.unmodifiableMap(
- GenericUtils.toSortedMap(MODES, PtyMode::toInt, Function.identity(), Comparator.naturalOrder()));
+ private static final NavigableMap<Integer, PtyMode> COMMANDS =
+ Collections.unmodifiableNavigableMap(
+ GenericUtils.toSortedMap(MODES, PtyMode::toInt, Function.identity(), Comparator.naturalOrder()));

private final int v;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/channel/RequestHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/channel/RequestHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/channel/RequestHandler.java
index d7e796f..0bba136 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/channel/RequestHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/channel/RequestHandler.java
@@ -41,7 +41,7 @@ public interface RequestHandler<T> {
ReplyFailure;

public static final Set<Result> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(Result.class));
+ Collections.unmodifiableSet(EnumSet.allOf(Result.class));

/**
* @param name The result name - ignored if {@code null}/empty

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwardingFilter.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwardingFilter.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwardingFilter.java
index a5cae0d..2644751 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwardingFilter.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/DefaultForwardingFilter.java
@@ -90,7 +90,7 @@ public class DefaultForwardingFilter
public static final long DEFAULT_FORWARD_REQUEST_TIMEOUT = TimeUnit.SECONDS.toMillis(15L);

public static final Set<ClientChannelEvent> STATIC_IO_MSG_RECEIVED_EVENTS =
- Collections.unmodifiableSet(EnumSet.of(ClientChannelEvent.OPENED, ClientChannelEvent.CLOSED));
+ Collections.unmodifiableSet(EnumSet.of(ClientChannelEvent.OPENED, ClientChannelEvent.CLOSED));

private final ConnectionService service;
private final IoHandlerFactory socksProxyIoHandlerFactory = () -> new SocksProxy(getConnectionService());

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
index 498d61f..82d6d2f 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipClientChannel.java
@@ -57,7 +57,7 @@ public class TcpipClientChannel extends AbstractClientChannel implements Forward
Forwarded("forwarded-tcpip");

public static final Set<Type> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(Type.class));
+ Collections.unmodifiableSet(EnumSet.allOf(Type.class));

private final String channelType;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/global/AbstractOpenSshHostKeysHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/global/AbstractOpenSshHostKeysHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/global/AbstractOpenSshHostKeysHandler.java
index 8518fad..bcb70ea 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/global/AbstractOpenSshHostKeysHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/global/AbstractOpenSshHostKeysHandler.java
@@ -71,7 +71,7 @@ public abstract class AbstractOpenSshHostKeysHandler extends AbstractConnectionS
PublicKey key = buffer.getPublicKey(p);
if (debugEnabled) {
log.debug("process({})[{}] key type={}, fingerprint={}",
- connectionService, request, KeyUtils.getKeyType(key), KeyUtils.getFingerPrint(key));
+ connectionService, request, KeyUtils.getKeyType(key), KeyUtils.getFingerPrint(key));
}
if (key != null) {
keys.add(key);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java b/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
index da4dd90..7c437b5 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/io/BuiltinIoServiceFactoryFactories.java
@@ -37,7 +37,7 @@ public enum BuiltinIoServiceFactoryFactories implements NamedFactory<IoServiceFa
NETTY("org.apache.sshd.netty.NettyIoServiceFactoryFactory");

public static final Set<BuiltinIoServiceFactoryFactories> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinIoServiceFactoryFactories.class));
+ Collections.unmodifiableSet(EnumSet.allOf(BuiltinIoServiceFactoryFactories.class));

private final Class<? extends IoServiceFactoryFactory> factoryClass;
private final String factoryClassName;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java
index aea3d19..7c19f54 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/BuiltinDHFactories.java
@@ -228,10 +228,10 @@ public enum BuiltinDHFactories implements DHFactory {
};

public static final Set<BuiltinDHFactories> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinDHFactories.class));
+ Collections.unmodifiableSet(EnumSet.allOf(BuiltinDHFactories.class));

private static final Map<String, DHFactory> EXTENSIONS =
- new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+ new TreeMap<>(String.CASE_INSENSITIVE_ORDER);

private final String factoryName;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java
index f18ed95..ae20311 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/KexProposalOption.java
@@ -46,7 +46,7 @@ public enum KexProposalOption {
* Compares values according to {@link KexProposalOption#getProposalIndex()}
*/
public static final Comparator<KexProposalOption> BY_PROPOSAL_INDEX =
- Comparator.comparingInt(KexProposalOption::getProposalIndex);
+ Comparator.comparingInt(KexProposalOption::getProposalIndex);

/**
* A {@link List} of all the options <U>sorted</U> according to {@link #getProposalIndex()}
@@ -55,9 +55,10 @@ public enum KexProposalOption {
*/
public static final List<KexProposalOption> VALUES =
Collections.unmodifiableList(
- EnumSet.allOf(KexProposalOption.class).stream()
- .sorted(BY_PROPOSAL_INDEX)
- .collect(Collectors.toList()));
+ EnumSet.allOf(KexProposalOption.class)
+ .stream()
+ .sorted(BY_PROPOSAL_INDEX)
+ .collect(Collectors.toList()));

public static final int PROPOSAL_MAX = VALUES.size();


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/kex/KexState.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/KexState.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/KexState.java
index da5d65c..bd794f3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/kex/KexState.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/KexState.java
@@ -35,5 +35,6 @@ public enum KexState {
KEYS,
DONE;

- public static final Set<KexState> VALUES = Collections.unmodifiableSet(EnumSet.allOf(KexState.class));
+ public static final Set<KexState> VALUES =
+ Collections.unmodifiableSet(EnumSet.allOf(KexState.class));
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchange.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchange.java b/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchange.java
index 05f7863..f1b23b6 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchange.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/kex/KeyExchange.java
@@ -20,7 +20,7 @@ package org.apache.sshd.common.kex;

import java.security.PublicKey;
import java.util.Collections;
-import java.util.Map;
+import java.util.NavigableMap;

import org.apache.sshd.common.NamedResource;
import org.apache.sshd.common.SshConstants;
@@ -36,11 +36,13 @@ import org.apache.sshd.common.util.logging.LoggingUtils;
* @author <a href="mailto:***@mina.apache.org">Apache MINA SSHD Project</a>
*/
public interface KeyExchange extends NamedResource {
- Map<Integer, String> GROUP_KEX_OPCODES_MAP =
- Collections.unmodifiableMap(LoggingUtils.generateMnemonicMap(SshConstants.class, "SSH_MSG_KEX_DH_GEX_"));
+ NavigableMap<Integer, String> GROUP_KEX_OPCODES_MAP =
+ Collections.unmodifiableNavigableMap(
+ LoggingUtils.generateMnemonicMap(SshConstants.class, "SSH_MSG_KEX_DH_GEX_"));

- Map<Integer, String> SIMPLE_KEX_OPCODES_MAP =
- Collections.unmodifiableMap(LoggingUtils.generateMnemonicMap(SshConstants.class, "SSH_MSG_KEXDH_"));
+ NavigableMap<Integer, String> SIMPLE_KEX_OPCODES_MAP =
+ Collections.unmodifiableNavigableMap(
+ LoggingUtils.generateMnemonicMap(SshConstants.class, "SSH_MSG_KEXDH_"));

/**
* Initialize the key exchange algorithm.

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
index 215b907..c66a7e3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
@@ -262,9 +262,9 @@ public abstract class AbstractConnectionService
@Override
protected Closeable getInnerCloseable() {
return builder()
- .sequential(forwarderHolder.get(), agentForwardHolder.get(), x11ForwardHolder.get())
- .parallel(toString(), channels.values())
- .build();
+ .sequential(forwarderHolder.get(), agentForwardHolder.get(), x11ForwardHolder.get())
+ .parallel(toString(), channels.values())
+ .build();
}

protected int getNextChannelId() {
@@ -304,7 +304,7 @@ public abstract class AbstractConnectionService
protected void handleChannelRegistrationFailure(Channel channel, int channelId) throws IOException {
RuntimeException reason = new IllegalStateException("Channel id=" + channelId + " not registered because session is being closed: " + this);
AbstractChannel notifier =
- ValidateUtils.checkInstanceOf(channel, AbstractChannel.class, "Non abstract channel for id=%d", channelId);
+ ValidateUtils.checkInstanceOf(channel, AbstractChannel.class, "Non abstract channel for id=%d", channelId);
notifier.signalChannelClosed(reason);
throw reason;
}
@@ -410,7 +410,7 @@ public abstract class AbstractConnectionService
long rmpsize = buffer.getUInt();
if (log.isDebugEnabled()) {
log.debug("channelOpenConfirmation({}) SSH_MSG_CHANNEL_OPEN_CONFIRMATION sender={}, window-size={}, packet-size={}",
- channel, sender, rwsize, rmpsize);
+ channel, sender, rwsize, rmpsize);
}
/*
* NOTE: the 'sender' of the SSH_MSG_CHANNEL_OPEN_CONFIRMATION is the
@@ -580,7 +580,7 @@ public abstract class AbstractConnectionService
if (handler == null) {
// Throw a special exception - SSHD-777
throw new SshChannelNotFoundException(recipient,
- "Received " + SshConstants.getCommandMessageName(cmd) + " on unknown channel " + recipient);
+ "Received " + SshConstants.getCommandMessageName(cmd) + " on unknown channel " + recipient);

}

@@ -610,12 +610,13 @@ public abstract class AbstractConnectionService
boolean debugEnabled = log.isDebugEnabled();
if (debugEnabled) {
log.debug("channelOpen({}) SSH_MSG_CHANNEL_OPEN sender={}, type={}, window-size={}, packet-size={}",
- this, sender, type, rwsize, rmpsize);
+ this, sender, type, rwsize, rmpsize);
}

if (isClosing()) {
// TODO add language tag configurable control
- sendChannelOpenFailure(buffer, sender, SshConstants.SSH_OPEN_CONNECT_FAILED, "Server is shutting down while attempting to open channel type=" + type, "");
+ sendChannelOpenFailure(buffer, sender, SshConstants.SSH_OPEN_CONNECT_FAILED,
+ "Server is shutting down while attempting to open channel type=" + type, "");
return;
}

@@ -642,7 +643,7 @@ public abstract class AbstractConnectionService
Window window = channel.getLocalWindow();
if (debugEnabled) {
log.debug("operationComplete({}) send SSH_MSG_CHANNEL_OPEN_CONFIRMATION recipient={}, sender={}, window-size={}, packet-size={}",
- channel, sender, channelId, window.getSize(), window.getPacketSize());
+ channel, sender, channelId, window.getSize(), window.getPacketSize());
}
Buffer buf = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN_CONFIRMATION, Integer.SIZE);
buf.putInt(sender); // remote (server side) identifier
@@ -662,7 +663,7 @@ public abstract class AbstractConnectionService
}
} else {
log.warn("operationComplete({}) no exception on closed future={}",
- AbstractConnectionService.this, future);
+ AbstractConnectionService.this, future);
}

Buffer buf = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN_FAILURE, message.length() + Long.SIZE);
@@ -681,12 +682,12 @@ public abstract class AbstractConnectionService
protected IoWriteFuture sendChannelOpenFailure(Buffer buffer, int sender, int reasonCode, String message, String lang) throws IOException {
if (log.isDebugEnabled()) {
log.debug("sendChannelOpenFailure({}) sender={}, reason={}, lang={}, message='{}'",
- this, sender, SshConstants.getOpenErrorCodeName(reasonCode), lang, message);
+ this, sender, SshConstants.getOpenErrorCodeName(reasonCode), lang, message);
}

AbstractSession session = getSession();
Buffer buf = session.createBuffer(SshConstants.SSH_MSG_CHANNEL_OPEN_FAILURE,
- Long.SIZE + GenericUtils.length(message) + GenericUtils.length(lang));
+ Long.SIZE + GenericUtils.length(message) + GenericUtils.length(lang));
buf.putInt(sender);
buf.putInt(reasonCode);
buf.putString(message);
@@ -708,8 +709,7 @@ public abstract class AbstractConnectionService
boolean wantReply = buffer.getBoolean();
boolean debugEnabled = log.isDebugEnabled();
if (debugEnabled) {
- log.debug("globalRequest({}) received SSH_MSG_GLOBAL_REQUEST {} want-reply={}",
- this, req, wantReply);
+ log.debug("globalRequest({}) received SSH_MSG_GLOBAL_REQUEST {} want-reply={}", this, req, wantReply);
}

AbstractSession session = getSession();
@@ -723,7 +723,7 @@ public abstract class AbstractConnectionService
result = handler.process(this, req, wantReply, buffer);
} catch (Throwable e) {
log.warn("globalRequest({})[{}, want-reply={}] failed ({}) to process: {}",
- this, req, wantReply, e.getClass().getSimpleName(), e.getMessage());
+ this, req, wantReply, e.getClass().getSimpleName(), e.getMessage());
if (debugEnabled) {
log.debug("globalRequest(" + this + ")[" + req + ", want-reply=" + wantReply + "] failure details", e);
}
@@ -734,7 +734,7 @@ public abstract class AbstractConnectionService
if (RequestHandler.Result.Unsupported.equals(result)) {
if (traceEnabled) {
log.trace("globalRequest({}) {}#process({})[want-reply={}] : {}",
- this, handler.getClass().getSimpleName(), req, wantReply, result);
+ this, handler.getClass().getSimpleName(), req, wantReply, result);
}
} else {
return sendGlobalResponse(buffer, req, result, wantReply);
@@ -764,8 +764,8 @@ public abstract class AbstractConnectionService
}

byte cmd = RequestHandler.Result.ReplySuccess.equals(result)
- ? SshConstants.SSH_MSG_REQUEST_SUCCESS
- : SshConstants.SSH_MSG_REQUEST_FAILURE;
+ ? SshConstants.SSH_MSG_REQUEST_SUCCESS
+ : SshConstants.SSH_MSG_REQUEST_FAILURE;
AbstractSession session = getSession();
Buffer rsp = session.createBuffer(cmd, 2);
return session.writePacket(rsp);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
index 3a55e21..ac6b081 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
@@ -289,7 +289,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
Throwable e = GenericUtils.peelException(err);
if (log.isDebugEnabled()) {
log.debug("Failed ({}) to announce session={} created: {}",
- e.getClass().getSimpleName(), ioSession, e.getMessage());
+ e.getClass().getSimpleName(), ioSession, e.getMessage());
}
if (log.isTraceEnabled()) {
log.trace("Session=" + ioSession + " creation failure details", e);
@@ -661,7 +661,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
if (result != null) {
if (debugEnabled) {
log.debug("handleFirstKexPacketFollows({})[{}] 1st follow KEX packet {} option mismatch: client={}, server={}",
- this, SshConstants.getCommandMessageName(cmd), option, result.getKey(), result.getValue());
+ this, SshConstants.getCommandMessageName(cmd), option, result.getKey(), result.getValue());
}
return false;
}
@@ -780,7 +780,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
protected void handleDisconnect(int code, String msg, String lang, Buffer buffer) throws Exception {
if (log.isDebugEnabled()) {
log.debug("handleDisconnect({}) SSH_MSG_DISCONNECT reason={}, [lang={}] msg={}",
- this, SshConstants.getDisconnectReasonName(code), lang, msg);
+ this, SshConstants.getDisconnectReasonName(code), lang, msg);
}

close(true);
@@ -803,7 +803,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
} catch (Throwable e) {
if (debugEnabled) {
log.debug("handleServiceRequest({}) Service {} rejected: {} = {}",
- this, serviceName, e.getClass().getSimpleName(), e.getMessage());
+ this, serviceName, e.getClass().getSimpleName(), e.getMessage());
}

if (log.isTraceEnabled()) {
@@ -915,7 +915,9 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
}
}

- protected List<SimpleImmutableEntry<PendingWriteFuture, IoWriteFuture>> sendPendingPackets(Queue<PendingWriteFuture> packetsQueue) throws IOException {
+ protected List<SimpleImmutableEntry<PendingWriteFuture, IoWriteFuture>> sendPendingPackets(
+ Queue<PendingWriteFuture> packetsQueue)
+ throws IOException {
if (GenericUtils.isEmpty(packetsQueue)) {
return Collections.emptyList();
}
@@ -956,7 +958,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
if ((!State.Opened.equals(curState)) && (!State.Graceful.equals(curState))) {
if (log.isDebugEnabled()) {
log.debug("exceptionCaught({}) ignore {} due to state={}, message='{}'",
- this, t.getClass().getSimpleName(), curState, t.getMessage());
+ this, t.getClass().getSimpleName(), curState, t.getMessage());
}
if (log.isTraceEnabled()) {
log.trace("exceptionCaught(" + this + ")[state=" + curState + "] ignored exception details", t);
@@ -979,7 +981,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
} catch (Throwable t2) {
if (log.isDebugEnabled()) {
log.debug("exceptionCaught({}) {} while disconnect with code={}: {}",
- this, t2.getClass().getSimpleName(), SshConstants.getDisconnectReasonName(code), t2.getMessage());
+ this, t2.getClass().getSimpleName(), SshConstants.getDisconnectReasonName(code), t2.getMessage());
}
if (log.isTraceEnabled()) {
log.trace("exceptionCaught(" + this + ")[code=" + SshConstants.getDisconnectReasonName(code) + "] disconnect exception details", t2);
@@ -1071,7 +1073,8 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
});
} catch (Throwable err) {
Throwable e = GenericUtils.peelException(err);
- log.warn("signalSessionClosed({}) {} while signal session closed: {}", this, e.getClass().getSimpleName(), e.getMessage());
+ log.warn("signalSessionClosed({}) {} while signal session closed: {}",
+ this, e.getClass().getSimpleName(), e.getMessage());
if (log.isDebugEnabled()) {
log.debug("signalSessionClosed(" + this + ") signal session closed exception details", e);
}
@@ -1126,8 +1129,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
synchronized (pendingPackets) {
if (!KexState.DONE.equals(kexState.get())) {
if (pendingPackets.isEmpty()) {
- log.debug("writePacket({})[{}] Start flagging packets as pending until key exchange is done",
- this, cmdName);
+ log.debug("writePacket({})[{}] Start flagging packets as pending until key exchange is done", this, cmdName);
}
PendingWriteFuture future = new PendingWriteFuture(cmdName, buffer);
pendingPackets.add(future);
@@ -1289,7 +1291,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen

if (debugEnabled) {
log.debug("request({}) request={}, timeout={} {}, result received={}",
- this, request, timeout, unit, result != null);
+ this, request, timeout, unit, result != null);
}

if (result == null) {
@@ -1620,7 +1622,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
*/
protected List<String> doReadIdentification(Buffer buffer, boolean server) {
int maxIdentSize = PropertyResolverUtils.getIntProperty(this,
- FactoryManager.MAX_IDENTIFICATION_SIZE, FactoryManager.DEFAULT_MAX_IDENTIFICATION_SIZE);
+ FactoryManager.MAX_IDENTIFICATION_SIZE, FactoryManager.DEFAULT_MAX_IDENTIFICATION_SIZE);
List<String> ident = null;
int rpos = buffer.rpos();
for (byte[] data = new byte[MAX_VERSION_LINE_LENGTH];;) {
@@ -1697,22 +1699,22 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
protected Map<KexProposalOption, String> createProposal(String hostKeyTypes) {
Map<KexProposalOption, String> proposal = new EnumMap<>(KexProposalOption.class);
proposal.put(KexProposalOption.ALGORITHMS,
- NamedResource.getNames(
- ValidateUtils.checkNotNullAndNotEmpty(getKeyExchangeFactories(), "No KEX factories")));
+ NamedResource.getNames(
+ ValidateUtils.checkNotNullAndNotEmpty(getKeyExchangeFactories(), "No KEX factories")));
proposal.put(KexProposalOption.SERVERKEYS, hostKeyTypes);

String ciphers = NamedResource.getNames(
- ValidateUtils.checkNotNullAndNotEmpty(getCipherFactories(), "No cipher factories"));
+ ValidateUtils.checkNotNullAndNotEmpty(getCipherFactories(), "No cipher factories"));
proposal.put(KexProposalOption.S2CENC, ciphers);
proposal.put(KexProposalOption.C2SENC, ciphers);

String macs = NamedResource.getNames(
- ValidateUtils.checkNotNullAndNotEmpty(getMacFactories(), "No MAC factories"));
+ ValidateUtils.checkNotNullAndNotEmpty(getMacFactories(), "No MAC factories"));
proposal.put(KexProposalOption.S2CMAC, macs);
proposal.put(KexProposalOption.C2SMAC, macs);

String compressions = NamedResource.getNames(
- ValidateUtils.checkNotNullAndNotEmpty(getCompressionFactories(), "No compression factories"));
+ ValidateUtils.checkNotNullAndNotEmpty(getCompressionFactories(), "No compression factories"));
proposal.put(KexProposalOption.S2CCOMP, compressions);
proposal.put(KexProposalOption.C2SCOMP, compressions);

@@ -1744,7 +1746,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
boolean traceEnabled = log.isTraceEnabled();
if (traceEnabled) {
log.trace("sendKexInit({}) cookie={}",
- this, BufferUtils.toHex(buffer.array(), p, SshConstants.MSG_KEX_COOKIE_SIZE, ':'));
+ this, BufferUtils.toHex(buffer.array(), p, SshConstants.MSG_KEX_COOKIE_SIZE, ':'));
}

for (KexProposalOption paramType : KexProposalOption.VALUES) {
@@ -1786,7 +1788,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
boolean traceEnabled = log.isTraceEnabled();
if (traceEnabled) {
log.trace("receiveKexInit({}) cookie={}",
- this, BufferUtils.toHex(d, cookieStartPos, SshConstants.MSG_KEX_COOKIE_SIZE, ':'));
+ this, BufferUtils.toHex(d, cookieStartPos, SshConstants.MSG_KEX_COOKIE_SIZE, ':'));
}

// Read proposal
@@ -1960,7 +1962,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
maxRekeyBlocks.set(this.getLongProperty(FactoryManager.REKEY_BLOCKS_LIMIT, recommendedByteRekeyBlocks));
if (debugEnabled) {
log.debug("receiveNewKeys({}) inCipher={}, outCipher={}, recommended blocks limit={}, actual={}",
- this, inCipher, outCipher, recommendedByteRekeyBlocks, maxRekeyBlocks);
+ this, inCipher, outCipher, recommendedByteRekeyBlocks, maxRekeyBlocks);
}

inBytesCount.set(0L);
@@ -2103,7 +2105,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
String value = guess.get(paramType);
if (value == null) {
String message = "Unable to negotiate key exchange for " + paramType.getDescription()
- + " (client: " + clientParamValue + " / server: " + serverParamValue + ")";
+ + " (client: " + clientParamValue + " / server: " + serverParamValue + ")";
// OK if could not negotiate languages
if (KexProposalOption.S2CLANG.equals(paramType) || KexProposalOption.C2SLANG.equals(paramType)) {
if (traceEnabled) {
@@ -2115,7 +2117,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
} else {
if (traceEnabled) {
log.trace("negotiate(" + this + ")[" + paramType.getDescription() + "] guess=" + value
- + " (client: " + clientParamValue + " / server: " + serverParamValue + ")");
+ + " (client: " + clientParamValue + " / server: " + serverParamValue + ")");
}
}
}
@@ -2193,13 +2195,13 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen

if (log.isDebugEnabled()) {
log.debug("setNegotiationResult({}) Kex: server->client {} {} {}", this,
- guess.get(KexProposalOption.S2CENC),
- guess.get(KexProposalOption.S2CMAC),
- guess.get(KexProposalOption.S2CCOMP));
+ guess.get(KexProposalOption.S2CENC),
+ guess.get(KexProposalOption.S2CMAC),
+ guess.get(KexProposalOption.S2CCOMP));
log.debug("setNegotiationResult({}) Kex: client->server {} {} {}", this,
- guess.get(KexProposalOption.C2SENC),
- guess.get(KexProposalOption.C2SMAC),
- guess.get(KexProposalOption.C2SCOMP));
+ guess.get(KexProposalOption.C2SENC),
+ guess.get(KexProposalOption.C2SMAC),
+ guess.get(KexProposalOption.C2SCOMP));
}

return guess;
@@ -2245,8 +2247,8 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
@SuppressWarnings("unchecked")
public <T> T setAttribute(AttributeKey<T> key, T value) {
return (T) attributes.put(
- Objects.requireNonNull(key, "No key"),
- Objects.requireNonNull(value, "No value"));
+ Objects.requireNonNull(key, "No key"),
+ Objects.requireNonNull(value, "No value"));
}

@Override
@@ -2272,7 +2274,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
@Override
public ReservedSessionMessagesHandler getReservedSessionMessagesHandler() {
return resolveEffectiveProvider(ReservedSessionMessagesHandler.class,
- reservedSessionMessagesHandler, getFactoryManager().getReservedSessionMessagesHandler());
+ reservedSessionMessagesHandler, getFactoryManager().getReservedSessionMessagesHandler());
}

@Override
@@ -2425,7 +2427,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
Throwable t = GenericUtils.peelException(err);
if (log.isDebugEnabled()) {
log.debug("sendSessionEvent({})[{}] failed ({}) to inform listeners: {}",
- this, event, t.getClass().getSimpleName(), t.getMessage());
+ this, event, t.getClass().getSimpleName(), t.getMessage());
}
if (log.isTraceEnabled()) {
log.trace("sendSessionEvent(" + this + ")[" + event + "] listener inform details", t);
@@ -2550,8 +2552,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
if (rekey) {
if (log.isDebugEnabled()) {
log.debug("isRekeyTimeIntervalExceeded({}) re-keying: last={}, now={}, diff={}, max={}",
- this, new Date(lastKeyTimeValue.get()), new Date(now),
- rekeyDiff, maxRekeyInterval);
+ this, new Date(lastKeyTimeValue.get()), new Date(now), rekeyDiff, maxRekeyInterval);
}
}

@@ -2567,7 +2568,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
if (rekey) {
if (log.isDebugEnabled()) {
log.debug("isRekeyPacketCountsExceeded({}) re-keying: in={}, out={}, max={}",
- this, inPacketsCount, outPacketsCount, maxRekyPackets);
+ this, inPacketsCount, outPacketsCount, maxRekyPackets);
}
}

@@ -2583,7 +2584,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
if (rekey) {
if (log.isDebugEnabled()) {
log.debug("isRekeyDataSizeExceeded({}) re-keying: in={}, out={}, max={}",
- this, inBytesCount, outBytesCount, maxRekeyBytes);
+ this, inBytesCount, outBytesCount, maxRekeyBytes);
}
}

@@ -2600,7 +2601,7 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
if (rekey) {
if (log.isDebugEnabled()) {
log.debug("isRekeyBlocksCountExceeded({}) re-keying: in={}, out={}, max={}",
- this, inBlocksCount, outBlocksCount, maxBlocks);
+ this, inBlocksCount, outBlocksCount, maxBlocks);
}
}

@@ -2702,7 +2703,9 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
protected abstract void receiveKexInit(Map<KexProposalOption, String> proposal, byte[] seed) throws IOException;

// returns the proposal argument
- protected Map<KexProposalOption, String> mergeProposals(Map<KexProposalOption, String> current, Map<KexProposalOption, String> proposal) {
+ protected Map<KexProposalOption, String> mergeProposals(
+ Map<KexProposalOption, String> current, Map<KexProposalOption, String> proposal) {
+ // Checking references by design
if (current == proposal) {
return proposal; // nothing to merge
}
@@ -2826,7 +2829,9 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
protected SimpleImmutableEntry<TimeoutStatus, String> checkAuthenticationTimeout(long now, long authTimeoutMs) {
long authDiff = now - authTimeoutStart;
if ((!authed) && (authTimeoutMs > 0L) && (authDiff > authTimeoutMs)) {
- return new SimpleImmutableEntry<>(TimeoutStatus.AuthTimeout, "Session has timed out waiting for authentication after " + authTimeoutMs + " ms.");
+ return new SimpleImmutableEntry<>(
+ TimeoutStatus.AuthTimeout,
+ "Session has timed out waiting for authentication after " + authTimeoutMs + " ms.");
} else {
return null;
}
@@ -2844,7 +2849,9 @@ public abstract class AbstractSession extends AbstractKexFactoryManager implemen
protected SimpleImmutableEntry<TimeoutStatus, String> checkIdleTimeout(long now, long idleTimeoutMs) {
long idleDiff = now - idleTimeoutStart;
if ((idleTimeoutMs > 0L) && (idleDiff > idleTimeoutMs)) {
- return new SimpleImmutableEntry<>(TimeoutStatus.IdleTimeout, "User session has timed out idling after " + idleTimeoutMs + " ms.");
+ return new SimpleImmutableEntry<>(
+ TimeoutStatus.IdleTimeout,
+ "User session has timed out idling after " + idleTimeoutMs + " ms.");
} else {
return null;
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java b/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java
index aa6c75b..2698eab 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/ServerBuilder.java
@@ -60,25 +60,30 @@ public class ServerBuilder extends BaseBuilder<SshServer, ServerBuilder> {
: DHGServer.newFactory(factory);

public static final List<NamedFactory<Channel>> DEFAULT_CHANNEL_FACTORIES =
- Collections.unmodifiableList(Arrays.<NamedFactory<Channel>>asList(
- ChannelSessionFactory.INSTANCE,
- DirectTcpipFactory.INSTANCE
- ));
+ Collections.unmodifiableList(
+ Arrays.<NamedFactory<Channel>>asList(
+ ChannelSessionFactory.INSTANCE,
+ DirectTcpipFactory.INSTANCE
+ ));

public static final List<RequestHandler<ConnectionService>> DEFAULT_GLOBAL_REQUEST_HANDLERS =
- Collections.unmodifiableList(Arrays.<RequestHandler<ConnectionService>>asList(
- KeepAliveHandler.INSTANCE,
- NoMoreSessionsHandler.INSTANCE,
- TcpipForwardHandler.INSTANCE,
- CancelTcpipForwardHandler.INSTANCE,
- OpenSshHostKeysHandler.INSTANCE
- ));
+ Collections.unmodifiableList(
+ Arrays.<RequestHandler<ConnectionService>>asList(
+ KeepAliveHandler.INSTANCE,
+ NoMoreSessionsHandler.INSTANCE,
+ TcpipForwardHandler.INSTANCE,
+ CancelTcpipForwardHandler.INSTANCE,
+ OpenSshHostKeysHandler.INSTANCE
+ ));

public static final PublickeyAuthenticator DEFAULT_PUBLIC_KEY_AUTHENTICATOR = DefaultAuthorizedKeysAuthenticator.INSTANCE;
public static final KeyboardInteractiveAuthenticator DEFAULT_INTERACTIVE_AUTHENTICATOR = DefaultKeyboardInteractiveAuthenticator.INSTANCE;
public static final List<CompressionFactory> DEFAULT_COMPRESSION_FACTORIES =
- Collections.unmodifiableList(Arrays.<CompressionFactory>asList(
- BuiltinCompressions.none, BuiltinCompressions.zlib, BuiltinCompressions.delayedZlib));
+ Collections.unmodifiableList(
+ Arrays.<CompressionFactory>asList(
+ BuiltinCompressions.none,
+ BuiltinCompressions.zlib,
+ BuiltinCompressions.delayedZlib));

protected PublickeyAuthenticator pubkeyAuthenticator;
protected KeyboardInteractiveAuthenticator interactiveAuthenticator;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/Signal.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/Signal.java b/sshd-core/src/main/java/org/apache/sshd/server/Signal.java
index bbbddb6..79f2eef 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/Signal.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/Signal.java
@@ -21,7 +21,7 @@ package org.apache.sshd.server;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
-import java.util.Map;
+import java.util.NavigableMap;
import java.util.Set;
import java.util.function.Function;

@@ -68,24 +68,25 @@ public enum Signal {
/**
* An un-modifiable {@link Set} of all the available {@link Signal}s
*/
- public static final Set<Signal> SIGNALS = Collections.unmodifiableSet(EnumSet.allOf(Signal.class));
+ public static final Set<Signal> SIGNALS =
+ Collections.unmodifiableSet(EnumSet.allOf(Signal.class));

/**
- * An un-modifiable <U>case-insensitive</U> {@link Map} of the names of all available {@link Signal}s
+ * An un-modifiable <U>case-insensitive</U> {@link NavigableMap} of the names of all available {@link Signal}s
* @see #SIGNALS
*/
- public static final Map<String, Signal> NAME_LOOKUP_TABLE =
- Collections.unmodifiableMap(
- GenericUtils.toSortedMap(SIGNALS, Signal::name, Function.identity(), String.CASE_INSENSITIVE_ORDER));
+ public static final NavigableMap<String, Signal> NAME_LOOKUP_TABLE =
+ Collections.unmodifiableNavigableMap(
+ GenericUtils.toSortedMap(SIGNALS, Signal::name, Function.identity(), String.CASE_INSENSITIVE_ORDER));

/**
- * An un-modifiable {@link Map} of the numeric values of all available {@link Signal}s
+ * An un-modifiable {@link NavigableMap} of the numeric values of all available {@link Signal}s
* @see #SIGNALS
* @see #getNumeric()
*/
- public static final Map<Integer, Signal> NUMERIC_LOOKUP_TABLE =
- Collections.unmodifiableMap(
- GenericUtils.toSortedMap(SIGNALS, Signal::getNumeric, Function.identity(), Comparator.naturalOrder()));
+ public static final NavigableMap<Integer, Signal> NUMERIC_LOOKUP_TABLE =
+ Collections.unmodifiableNavigableMap(
+ GenericUtils.toSortedMap(SIGNALS, Signal::getNumeric, Function.identity(), Comparator.naturalOrder()));

private final int numeric;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
index f648eb1..ea8f74a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/SshServer.java
@@ -87,10 +87,10 @@ public class SshServer extends AbstractFactoryManager implements ServerFactoryMa
public static final Factory<SshServer> DEFAULT_SSH_SERVER_FACTORY = SshServer::new;

public static final List<ServiceFactory> DEFAULT_SERVICE_FACTORIES =
- Collections.unmodifiableList(Arrays.asList(
+ Collections.unmodifiableList(
+ Arrays.asList(
ServerUserAuthServiceFactory.INSTANCE,
- ServerConnectionServiceFactory.INSTANCE
- ));
+ ServerConnectionServiceFactory.INSTANCE));


protected IoAcceptor acceptor;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/auth/BuiltinUserAuthFactories.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/BuiltinUserAuthFactories.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/BuiltinUserAuthFactories.java
index a77512d..6477019 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/BuiltinUserAuthFactories.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/BuiltinUserAuthFactories.java
@@ -51,7 +51,7 @@ public enum BuiltinUserAuthFactories implements NamedFactory<UserAuthFactory> {
GSS(UserAuthGSSFactory.INSTANCE);

public static final Set<BuiltinUserAuthFactories> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(BuiltinUserAuthFactories.class));
+ Collections.unmodifiableSet(EnumSet.allOf(BuiltinUserAuthFactories.class));

private final UserAuthFactory factory;


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/auth/WelcomeBannerPhase.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/auth/WelcomeBannerPhase.java b/sshd-core/src/main/java/org/apache/sshd/server/auth/WelcomeBannerPhase.java
index 66becc1..0e1e52e 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/auth/WelcomeBannerPhase.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/auth/WelcomeBannerPhase.java
@@ -49,5 +49,5 @@ public enum WelcomeBannerPhase {
NEVER;

public static final Set<WelcomeBannerPhase> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(WelcomeBannerPhase.class));
+ Collections.unmodifiableSet(EnumSet.allOf(WelcomeBannerPhase.class));
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
index 5e12821..4349e1b 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/AbstractServerChannel.java
@@ -51,16 +51,12 @@ public abstract class AbstractServerChannel extends AbstractChannel implements S
super("", false, Collections.emptyList(), executor);
}

- protected AbstractServerChannel(String discriminator, Collection<? extends RequestHandler<Channel>> handlers, CloseableExecutorService executor) {
+ protected AbstractServerChannel(String discriminator,
+ Collection<? extends RequestHandler<Channel>> handlers,
+ CloseableExecutorService executor) {
super(discriminator, false, handlers, executor);
}

-// TODO: investigate how to fix the forwarding channel failures when enabled
-// @Override
-// public ServerSession getSession() {
-// return (ServerSession) super.getSession();
-// }
-
@Override
public ServerSession getServerSession() {
return (ServerSession) getSession();

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
index 16e16b7..e54e0e4 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/ChannelSession.java
@@ -123,10 +123,10 @@ public class ChannelSession extends AbstractServerChannel {
@Override
protected Closeable getInnerCloseable() {
return builder()
- .sequential(new CommandCloseable(), super.getInnerCloseable())
- .parallel(asyncOut, asyncErr)
- .run(toString(), this::closeImmediately0)
- .build();
+ .sequential(new CommandCloseable(), super.getInnerCloseable())
+ .parallel(asyncOut, asyncErr)
+ .run(toString(), this::closeImmediately0)
+ .build();
}

public class CommandCloseable extends IoBaseCloseable {
@@ -160,14 +160,15 @@ public class ChannelSession extends AbstractServerChannel {
commandExitFuture.setClosed();
} else if (!commandExitFuture.isClosed()) {
IOException e = IoUtils.closeQuietly(receiver);
+ boolean debugEnabled = log.isDebugEnabled();
if (e != null) {
- if (log.isDebugEnabled()) {
+ if (debugEnabled) {
log.debug("close({})[immediately={}] failed ({}) to close receiver: {}",
- this, immediately, e.getClass().getSimpleName(), e.getMessage());
+ this, immediately, e.getClass().getSimpleName(), e.getMessage());
}
}

- final TimerTask task = new TimerTask() {
+ TimerTask task = new TimerTask() {
@Override
public void run() {
commandExitFuture.setClosed();
@@ -175,9 +176,9 @@ public class ChannelSession extends AbstractServerChannel {
};

ChannelSession channel = ChannelSession.this;
- long timeout = PropertyResolverUtils.getLongProperty(
- channel, ServerFactoryManager.COMMAND_EXIT_TIMEOUT, ServerFactoryManager.DEFAULT_COMMAND_EXIT_TIMEOUT);
- if (log.isDebugEnabled()) {
+ long timeout = PropertyResolverUtils.getLongProperty(channel,
+ ServerFactoryManager.COMMAND_EXIT_TIMEOUT, ServerFactoryManager.DEFAULT_COMMAND_EXIT_TIMEOUT);
+ if (debugEnabled) {
log.debug("Wait {} ms for shell to exit cleanly on {}", timeout, channel);
}

@@ -198,7 +199,7 @@ public class ChannelSession extends AbstractServerChannel {
commandInstance.destroy();
} catch (Throwable e) {
log.warn("doCloseImmediately({}) failed ({}) to destroy command: {}",
- this, e.getClass().getSimpleName(), e.getMessage());
+ this, e.getClass().getSimpleName(), e.getMessage());
if (debugEnabled) {
log.debug("doCloseImmediately(" + this + ") command destruction failure details", e);
}
@@ -211,7 +212,7 @@ public class ChannelSession extends AbstractServerChannel {
if (e != null) {
if (debugEnabled) {
log.debug("doCloseImmediately({}) failed ({}) to close resources: {}",
- this, e.getClass().getSimpleName(), e.getMessage());
+ this, e.getClass().getSimpleName(), e.getMessage());
}

if (log.isTraceEnabled()) {
@@ -233,7 +234,7 @@ public class ChannelSession extends AbstractServerChannel {
if (e != null) {
if (log.isDebugEnabled()) {
log.debug("handleEof({}) failed ({}) to close receiver: {}",
- this, e.getClass().getSimpleName(), e.getMessage());
+ this, e.getClass().getSimpleName(), e.getMessage());
}

if (log.isTraceEnabled()) {
@@ -293,7 +294,7 @@ public class ChannelSession extends AbstractServerChannel {
} else {
if (log.isDebugEnabled()) {
log.debug("handleInternalRequest({})[want-reply={}] type already set for request={}: {}",
- this, wantReply, requestType, this.type);
+ this, wantReply, requestType, this.type);
}
return RequestHandler.Result.ReplyFailure;
}
@@ -307,7 +308,7 @@ public class ChannelSession extends AbstractServerChannel {
} else {
if (log.isDebugEnabled()) {
log.debug("handleInternalRequest({})[want-reply={}] type already set for request={}: {}",
- this, wantReply, requestType, this.type);
+ this, wantReply, requestType, this.type);
}
return RequestHandler.Result.ReplyFailure;
}
@@ -321,7 +322,7 @@ public class ChannelSession extends AbstractServerChannel {
} else {
if (log.isDebugEnabled()) {
log.debug("handleInternalRequest({})[want-reply={}] type already set for request={}: {}",
- this, wantReply, requestType, this.type);
+ this, wantReply, requestType, this.type);
}
return RequestHandler.Result.ReplyFailure;
}
@@ -417,7 +418,7 @@ public class ChannelSession extends AbstractServerChannel {

if (log.isDebugEnabled()) {
log.debug("handlePtyReq({}): term={}, size=({} - {}), pixels=({}, {}), modes=[{}]",
- this, term, tColumns, tRows, tWidth, tHeight, ptyModes);
+ this, term, tColumns, tRows, tWidth, tHeight, ptyModes);
}

addEnvVariable(Environment.ENV_TERM, term);
@@ -432,8 +433,7 @@ public class ChannelSession extends AbstractServerChannel {
int tWidth = buffer.getInt();
int tHeight = buffer.getInt();
if (log.isDebugEnabled()) {
- log.debug("handleWindowChange({}): ({} - {}), ({}, {})",
- this, tColumns, tRows, tWidth, tHeight);
+ log.debug("handleWindowChange({}): ({} - {}), ({}, {})", this, tColumns, tRows, tWidth, tHeight);
}

StandardEnvironment e = getEnvironment();
@@ -492,7 +492,7 @@ public class ChannelSession extends AbstractServerChannel {
commandInstance = factory.create();
} catch (RuntimeException | Error e) {
log.warn("handleShell({}) Failed ({}) to create shell: {}",
- this, e.getClass().getSimpleName(), e.getMessage());
+ this, e.getClass().getSimpleName(), e.getMessage());
if (log.isDebugEnabled()) {
log.debug("handleShell(" + this + ") shell creation failure details", e);
}
@@ -532,7 +532,7 @@ public class ChannelSession extends AbstractServerChannel {
commandInstance = factory.createCommand(commandLine);
} catch (RuntimeException | Error e) {
log.warn("handleExec({}) Failed ({}) to create command for {}: {}",
- this, e.getClass().getSimpleName(), commandLine, e.getMessage());
+ this, e.getClass().getSimpleName(), commandLine, e.getMessage());
if (debugEnabled) {
log.debug("handleExec(" + this + ") command=" + commandLine + " creation failure details", e);
}
@@ -551,8 +551,7 @@ public class ChannelSession extends AbstractServerChannel {
protected RequestHandler.Result handleSubsystem(String request, Buffer buffer, boolean wantReply) throws IOException {
String subsystem = buffer.getString();
if (log.isDebugEnabled()) {
- log.debug("handleSubsystem({})[want-reply={}] subsystem={}",
- this, wantReply, subsystem);
+ log.debug("handleSubsystem({})[want-reply={}] subsystem={}", this, wantReply, subsystem);
}

ServerFactoryManager manager = Objects.requireNonNull(getServerSession(), "No server session").getFactoryManager();
@@ -566,7 +565,7 @@ public class ChannelSession extends AbstractServerChannel {
commandInstance = NamedFactory.create(factories, subsystem);
} catch (RuntimeException | Error e) {
log.warn("handleSubsystem({}) Failed ({}) to create command for subsystem={}: {}",
- this, e.getClass().getSimpleName(), subsystem, e.getMessage());
+ this, e.getClass().getSimpleName(), subsystem, e.getMessage());
if (log.isDebugEnabled()) {
log.debug("handleSubsystem(" + this + ") subsystem=" + subsystem + " creation failure details", e);
}
@@ -693,7 +692,7 @@ public class ChannelSession extends AbstractServerChannel {
}
} catch (IOException e) {
log.warn("onExit({}) code={} message='{}' {} closing shell: {}",
- ChannelSession.this, exitValue, exitMessage, e.getClass().getSimpleName(), e.getMessage());
+ ChannelSession.this, exitValue, exitMessage, e.getClass().getSimpleName(), e.getMessage());
}
});

@@ -715,7 +714,8 @@ public class ChannelSession extends AbstractServerChannel {
try {
if ((factory == null) || (filter == null) || (!filter.canForwardAgent(session, requestType))) {
if (debugEnabled) {
- log.debug("handleAgentForwarding(" + this + ")[haveFactory=" + (factory != null) + ",haveFilter=" + (filter != null) + "] filtered out request=" + requestType);
+ log.debug("handleAgentForwarding(" + this + ")[haveFactory=" + (factory != null)
+ + ",haveFilter=" + (filter != null) + "] filtered out request=" + requestType);
}
return RequestHandler.Result.ReplyFailure;
}
@@ -755,13 +755,13 @@ public class ChannelSession extends AbstractServerChannel {
if ((filter == null) || (!filter.canForwardX11(session, requestType))) {
if (debugEnabled) {
log.debug("handleX11Forwarding({}) single={}, protocol={}, cookie={}, screen={}, filter={}: filtered request={}",
- this, singleConnection, authProtocol, authCookie, screenId, filter, requestType);
+ this, singleConnection, authProtocol, authCookie, screenId, filter, requestType);
}
return RequestHandler.Result.ReplyFailure;
}
} catch (Error e) {
log.warn("handleX11Forwarding({}) failed ({}) to consult forwarding filter for '{}': {}",
- this, e.getClass().getSimpleName(), requestType, e.getMessage());
+ this, e.getClass().getSimpleName(), requestType, e.getMessage());
if (debugEnabled) {
log.debug("handleX11Forwarding(" + this + ")[" + requestType + "] filter consultation failure details", e);
}
@@ -772,7 +772,7 @@ public class ChannelSession extends AbstractServerChannel {
if (x11Forward == null) {
if (debugEnabled) {
log.debug("handleX11Forwarding({}) single={}, protocol={}, cookie={}, screen={} - no forwarder'",
- this, singleConnection, authProtocol, authCookie, screenId);
+ this, singleConnection, authProtocol, authCookie, screenId);
}
return RequestHandler.Result.ReplyFailure;
}
@@ -780,7 +780,7 @@ public class ChannelSession extends AbstractServerChannel {
String display = x11Forward.createDisplay(singleConnection, authProtocol, authCookie, screenId);
if (debugEnabled) {
log.debug("handleX11Forwarding({}) single={}, protocol={}, cookie={}, screen={} - display='{}'",
- this, singleConnection, authProtocol, authCookie, screenId, display);
+ this, singleConnection, authProtocol, authCookie, screenId, display);
}
if (GenericUtils.isEmpty(display)) {
return RequestHandler.Result.ReplyFailure;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java b/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
index fd71753..a5eabe1 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/channel/PuttyRequestHandler.java
@@ -41,7 +41,7 @@ public class PuttyRequestHandler extends AbstractChannelRequestHandler {
public static final String REQUEST_SUFFIX = "@putty.projects.tartarus.org";

public static final Set<PtyMode> PUTTY_OPTIONS =
- Collections.unmodifiableSet(EnumSet.of(PtyMode.ECHO, PtyMode.ICRNL, PtyMode.ONLCR));
+ Collections.unmodifiableSet(EnumSet.of(PtyMode.ECHO, PtyMode.ICRNL, PtyMode.ONLCR));

public static final PuttyRequestHandler INSTANCE = new PuttyRequestHandler();


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractFileSystemCommand.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractFileSystemCommand.java b/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractFileSystemCommand.java
index b1049e1..be5e578 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractFileSystemCommand.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/command/AbstractFileSystemCommand.java
@@ -58,7 +58,7 @@ public abstract class AbstractFileSystemCommand extends AbstractCommandSupport i
} catch (UnsupportedOperationException | IOException e) {
if (log.isDebugEnabled()) {
log.debug("destroy({}) - failed ({}) to close file system={}: {}",
- this, e.getClass().getSimpleName(), fileSystem, e.getMessage());
+ this, e.getClass().getSimpleName(), fileSystem, e.getMessage());
}
} finally {
fileSystem = null;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/config/AllowTcpForwardingValue.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/config/AllowTcpForwardingValue.java b/sshd-core/src/main/java/org/apache/sshd/server/config/AllowTcpForwardingValue.java
index ed6d7f8..f346744 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/config/AllowTcpForwardingValue.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/config/AllowTcpForwardingValue.java
@@ -79,7 +79,7 @@ public enum AllowTcpForwardingValue implements TcpForwardingFilter {
};

public static final Set<AllowTcpForwardingValue> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(AllowTcpForwardingValue.class));
+ Collections.unmodifiableSet(EnumSet.allOf(AllowTcpForwardingValue.class));

// NOTE: it also interprets "yes" as "all" and "no" as "none"
public static AllowTcpForwardingValue fromString(String s) {

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/612ee385/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpForwardingFilter.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpForwardingFilter.java b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpForwardingFilter.java
index 3f0aaa7..2cbf468 100644
--- a/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpForwardingFilter.java
+++ b/sshd-core/src/main/java/org/apache/sshd/server/forward/TcpForwardingFilter.java
@@ -78,7 +78,7 @@ public interface TcpForwardingFilter {
Forwarded("forwarded-tcpip");

public static final Set<Type> VALUES =
- Collections.unmodifiableSet(EnumSet.allOf(Type.class));
+ Collections.unmodifiableSet(EnumSet.allOf(Type.class));

private final String name;

Loading...