You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2016/02/23 17:38:28 UTC

[8/8] mina-sshd git commit: Fixed Maven bundle plugin warnings "Export XXX, has 1, private references [XXX]"

Fixed Maven bundle plugin warnings "Export XXX, has 1, private references [XXX]"


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

Branch: refs/heads/master
Commit: 3f69f2292349fa98654e2ed89a275b95d7e4c496
Parents: 7d64120
Author: Lyor Goldstein <ly...@gmail.com>
Authored: Tue Feb 23 18:38:59 2016 +0200
Committer: Lyor Goldstein <ly...@gmail.com>
Committed: Tue Feb 23 18:38:59 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/sshd/client/SshClient.java  |    4 +-
 .../sshd/client/scp/DefaultScpClient.java       |    2 +-
 .../client/session/AbstractClientSession.java   |    2 +-
 .../client/session/ClientConnectionService.java |    2 +-
 .../sshd/client/session/ClientSessionImpl.java  |    2 +-
 .../sshd/client/session/SessionFactory.java     |    2 +-
 .../extensions/BuiltinSftpClientExtensions.java |   20 +-
 .../helpers/AbstractCheckFileExtension.java     |   77 +
 .../helpers/AbstractMD5HashExtension.java       |   74 +
 .../helpers/AbstractSftpClientExtension.java    |  205 ++
 .../helpers/CheckFileHandleExtensionImpl.java   |   44 +
 .../helpers/CheckFileNameExtensionImpl.java     |   43 +
 .../helpers/CopyDataExtensionImpl.java          |   55 +
 .../helpers/CopyFileExtensionImpl.java          |   50 +
 .../helpers/MD5FileExtensionImpl.java           |   42 +
 .../helpers/MD5HandleExtensionImpl.java         |   43 +
 .../helpers/SpaceAvailableExtensionImpl.java    |   53 +
 .../impl/AbstractCheckFileExtension.java        |   77 -
 .../impl/AbstractMD5HashExtension.java          |   74 -
 .../impl/AbstractSftpClientExtension.java       |  205 --
 .../impl/CheckFileHandleExtensionImpl.java      |   44 -
 .../impl/CheckFileNameExtensionImpl.java        |   43 -
 .../extensions/impl/CopyDataExtensionImpl.java  |   55 -
 .../extensions/impl/CopyFileExtensionImpl.java  |   50 -
 .../extensions/impl/MD5FileExtensionImpl.java   |   42 -
 .../extensions/impl/MD5HandleExtensionImpl.java |   43 -
 .../impl/SpaceAvailableExtensionImpl.java       |   53 -
 .../AbstractOpenSSHStatCommandExtension.java    |   57 +
 .../helpers/OpenSSHFsyncExtensionImpl.java      |   49 +
 .../helpers/OpenSSHStatHandleExtensionImpl.java |   44 +
 .../helpers/OpenSSHStatPathExtensionImpl.java   |   43 +
 .../AbstractOpenSSHStatCommandExtension.java    |   57 -
 .../openssh/impl/OpenSSHFsyncExtensionImpl.java |   49 -
 .../impl/OpenSSHStatHandleExtensionImpl.java    |   44 -
 .../impl/OpenSSHStatPathExtensionImpl.java      |   43 -
 .../org/apache/sshd/common/BaseBuilder.java     |    2 +-
 .../sshd/common/config/SshConfigFileReader.java |    2 +-
 .../global/AbstractOpenSshHostKeysHandler.java  |    2 +-
 .../common/helpers/AbstractFactoryManager.java  |  389 +++
 .../common/impl/AbstractFactoryManager.java     |  389 ---
 .../common/kex/dh/AbstractDHKeyExchange.java    |    2 +-
 .../org/apache/sshd/common/scp/ScpHelper.java   |    6 +-
 .../scp/helpers/DefaultScpFileOpener.java       |   63 +
 .../LocalFileScpSourceStreamResolver.java       |   97 +
 .../LocalFileScpTargetStreamResolver.java       |  158 ++
 .../common/scp/impl/DefaultScpFileOpener.java   |   63 -
 .../impl/LocalFileScpSourceStreamResolver.java  |   97 -
 .../impl/LocalFileScpTargetStreamResolver.java  |  158 --
 .../helpers/AbstractConnectionService.java      |  664 +++++
 ...AbstractConnectionServiceRequestHandler.java |   46 +
 .../common/session/helpers/AbstractSession.java | 2258 ++++++++++++++++++
 .../session/helpers/AbstractSessionFactory.java |   53 +
 .../helpers/AbstractSessionIoHandler.java       |   82 +
 .../session/helpers/PendingWriteFuture.java     |   61 +
 .../ReservedSessionMessagesHandlerAdapter.java  |   69 +
 .../session/helpers/SessionTimeoutListener.java |   86 +
 .../session/impl/AbstractConnectionService.java |  664 -----
 ...AbstractConnectionServiceRequestHandler.java |   46 -
 .../common/session/impl/AbstractSession.java    | 2258 ------------------
 .../session/impl/AbstractSessionFactory.java    |   53 -
 .../session/impl/AbstractSessionIoHandler.java  |   82 -
 .../common/session/impl/PendingWriteFuture.java |   61 -
 .../ReservedSessionMessagesHandlerAdapter.java  |   69 -
 .../session/impl/SessionTimeoutListener.java    |   86 -
 .../java/org/apache/sshd/server/SshServer.java  |    4 +-
 .../global/CancelTcpipForwardHandler.java       |    2 +-
 .../sshd/server/global/KeepAliveHandler.java    |    2 +-
 .../server/global/NoMoreSessionsHandler.java    |    2 +-
 .../sshd/server/global/TcpipForwardHandler.java |    2 +-
 .../org/apache/sshd/server/scp/ScpCommand.java  |    2 +-
 .../server/session/AbstractServerSession.java   |    2 +-
 .../server/session/ServerConnectionService.java |    2 +-
 .../sshd/server/session/SessionFactory.java     |    2 +-
 .../java/org/apache/sshd/client/ClientTest.java |    2 +-
 .../org/apache/sshd/client/scp/ScpTest.java     |    2 +-
 .../helpers/AbstractCheckFileExtensionTest.java |  239 ++
 .../helpers/AbstractMD5HashExtensionTest.java   |  187 ++
 .../helpers/CopyDataExtensionImplTest.java      |  200 ++
 .../helpers/CopyFileExtensionImplTest.java      |  109 +
 .../SpaceAvailableExtensionImplTest.java        |  108 +
 .../impl/AbstractCheckFileExtensionTest.java    |  239 --
 .../impl/AbstractMD5HashExtensionTest.java      |  187 --
 .../impl/CopyDataExtensionImplTest.java         |  200 --
 .../impl/CopyFileExtensionImplTest.java         |  109 -
 .../impl/SpaceAvailableExtensionImplTest.java   |  108 -
 .../openssh/helpers/OpenSSHExtensionsTest.java  |  220 ++
 .../openssh/impl/OpenSSHExtensionsTest.java     |  220 --
 .../common/config/SshConfigFileReaderTest.java  |    2 +-
 .../ReservedSessionMessagesHandlerTest.java     |    2 +-
 .../session/helpers/AbstractSessionTest.java    |  347 +++
 .../session/impl/AbstractSessionTest.java       |  346 ---
 .../java/org/apache/sshd/server/ServerTest.java |    4 +-
 92 files changed, 6355 insertions(+), 6354 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/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 c295f85..3db77f7 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
@@ -101,13 +101,13 @@ import org.apache.sshd.common.config.SshConfigFileReader;
 import org.apache.sshd.common.config.keys.FilePasswordProvider;
 import org.apache.sshd.common.config.keys.KeyUtils;
 import org.apache.sshd.common.future.SshFutureListener;
-import org.apache.sshd.common.impl.AbstractFactoryManager;
+import org.apache.sshd.common.helpers.AbstractFactoryManager;
 import org.apache.sshd.common.io.IoConnectFuture;
 import org.apache.sshd.common.io.IoConnector;
 import org.apache.sshd.common.io.IoSession;
 import org.apache.sshd.common.keyprovider.AbstractFileKeyPairProvider;
 import org.apache.sshd.common.keyprovider.KeyPairProvider;
-import org.apache.sshd.common.session.impl.AbstractSession;
+import org.apache.sshd.common.session.helpers.AbstractSession;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.OsUtils;
 import org.apache.sshd.common.util.SecurityUtils;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java b/sshd-core/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java
index 99ef3e4..b7309d5 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/scp/DefaultScpClient.java
@@ -47,7 +47,7 @@ import org.apache.sshd.common.scp.ScpHelper;
 import org.apache.sshd.common.scp.ScpLocation;
 import org.apache.sshd.common.scp.ScpTimestamp;
 import org.apache.sshd.common.scp.ScpTransferEventListener;
-import org.apache.sshd.common.scp.impl.DefaultScpFileOpener;
+import org.apache.sshd.common.scp.helpers.DefaultScpFileOpener;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.io.NoCloseInputStream;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/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 2da9d05..ed80394 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
@@ -53,7 +53,7 @@ import org.apache.sshd.common.io.IoSession;
 import org.apache.sshd.common.scp.ScpFileOpener;
 import org.apache.sshd.common.scp.ScpTransferEventListener;
 import org.apache.sshd.common.session.ConnectionService;
-import org.apache.sshd.common.session.impl.AbstractSession;
+import org.apache.sshd.common.session.helpers.AbstractSession;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.net.SshdSocketAddress;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
index 4ddcae1..6bd60ff 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/ClientConnectionService.java
@@ -30,7 +30,7 @@ import org.apache.sshd.common.SshConstants;
 import org.apache.sshd.common.SshException;
 import org.apache.sshd.common.io.AbstractIoWriteFuture;
 import org.apache.sshd.common.io.IoWriteFuture;
-import org.apache.sshd.common.session.impl.AbstractConnectionService;
+import org.apache.sshd.common.session.helpers.AbstractConnectionService;
 import org.apache.sshd.common.util.buffer.Buffer;
 import org.apache.sshd.server.x11.X11ForwardSupport;
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/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 8479370..4528e9b 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
@@ -50,7 +50,7 @@ import org.apache.sshd.common.kex.KexProposalOption;
 import org.apache.sshd.common.kex.KexState;
 import org.apache.sshd.common.session.ConnectionService;
 import org.apache.sshd.common.session.SessionListener;
-import org.apache.sshd.common.session.impl.AbstractConnectionService;
+import org.apache.sshd.common.session.helpers.AbstractConnectionService;
 import org.apache.sshd.common.util.GenericUtils;
 import org.apache.sshd.common.util.ValidateUtils;
 import org.apache.sshd.common.util.buffer.Buffer;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/session/SessionFactory.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/session/SessionFactory.java b/sshd-core/src/main/java/org/apache/sshd/client/session/SessionFactory.java
index b90e92b..9442d3c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/session/SessionFactory.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/session/SessionFactory.java
@@ -20,7 +20,7 @@ package org.apache.sshd.client.session;
 
 import org.apache.sshd.client.ClientFactoryManager;
 import org.apache.sshd.common.io.IoSession;
-import org.apache.sshd.common.session.impl.AbstractSessionFactory;
+import org.apache.sshd.common.session.helpers.AbstractSessionFactory;
 
 /**
  * A factory of client sessions.

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/BuiltinSftpClientExtensions.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/BuiltinSftpClientExtensions.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/BuiltinSftpClientExtensions.java
index 4b43deb..c95d8fd 100644
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/BuiltinSftpClientExtensions.java
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/BuiltinSftpClientExtensions.java
@@ -26,19 +26,19 @@ import java.util.Set;
 
 import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
 import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.extensions.impl.CheckFileHandleExtensionImpl;
-import org.apache.sshd.client.subsystem.sftp.extensions.impl.CheckFileNameExtensionImpl;
-import org.apache.sshd.client.subsystem.sftp.extensions.impl.CopyDataExtensionImpl;
-import org.apache.sshd.client.subsystem.sftp.extensions.impl.CopyFileExtensionImpl;
-import org.apache.sshd.client.subsystem.sftp.extensions.impl.MD5FileExtensionImpl;
-import org.apache.sshd.client.subsystem.sftp.extensions.impl.MD5HandleExtensionImpl;
-import org.apache.sshd.client.subsystem.sftp.extensions.impl.SpaceAvailableExtensionImpl;
+import org.apache.sshd.client.subsystem.sftp.extensions.helpers.CheckFileHandleExtensionImpl;
+import org.apache.sshd.client.subsystem.sftp.extensions.helpers.CheckFileNameExtensionImpl;
+import org.apache.sshd.client.subsystem.sftp.extensions.helpers.CopyDataExtensionImpl;
+import org.apache.sshd.client.subsystem.sftp.extensions.helpers.CopyFileExtensionImpl;
+import org.apache.sshd.client.subsystem.sftp.extensions.helpers.MD5FileExtensionImpl;
+import org.apache.sshd.client.subsystem.sftp.extensions.helpers.MD5HandleExtensionImpl;
+import org.apache.sshd.client.subsystem.sftp.extensions.helpers.SpaceAvailableExtensionImpl;
 import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHFsyncExtension;
 import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHStatHandleExtension;
 import org.apache.sshd.client.subsystem.sftp.extensions.openssh.OpenSSHStatPathExtension;
-import org.apache.sshd.client.subsystem.sftp.extensions.openssh.impl.OpenSSHFsyncExtensionImpl;
-import org.apache.sshd.client.subsystem.sftp.extensions.openssh.impl.OpenSSHStatHandleExtensionImpl;
-import org.apache.sshd.client.subsystem.sftp.extensions.openssh.impl.OpenSSHStatPathExtensionImpl;
+import org.apache.sshd.client.subsystem.sftp.extensions.openssh.helpers.OpenSSHFsyncExtensionImpl;
+import org.apache.sshd.client.subsystem.sftp.extensions.openssh.helpers.OpenSSHStatHandleExtensionImpl;
+import org.apache.sshd.client.subsystem.sftp.extensions.openssh.helpers.OpenSSHStatPathExtensionImpl;
 import org.apache.sshd.common.NamedResource;
 import org.apache.sshd.common.subsystem.sftp.SftpConstants;
 import org.apache.sshd.common.subsystem.sftp.extensions.ParserUtils;

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtension.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtension.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtension.java
new file mode 100644
index 0000000..2ab6069
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractCheckFileExtension.java
@@ -0,0 +1,77 @@
+/*
+ * 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.client.subsystem.sftp.extensions.helpers;
+
+import java.io.IOException;
+import java.io.StreamCorruptedException;
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.common.subsystem.sftp.SftpConstants;
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.Pair;
+import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.buffer.BufferUtils;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public abstract class AbstractCheckFileExtension extends AbstractSftpClientExtension {
+    protected AbstractCheckFileExtension(String name, SftpClient client, RawSftpClient raw, Collection<String> extras) {
+        super(name, client, raw, extras);
+    }
+
+    protected Pair<String, Collection<byte[]>> doGetHash(Object target, Collection<String> algorithms, long offset, long length, int blockSize) throws IOException {
+        Buffer buffer = getCommandBuffer(target, Byte.MAX_VALUE);
+        putTarget(buffer, target);
+        buffer.putString(GenericUtils.join(algorithms, ','));
+        buffer.putLong(offset);
+        buffer.putLong(length);
+        buffer.putInt(blockSize);
+
+        if (log.isDebugEnabled()) {
+            log.debug("doGetHash({})[{}] - offset={}, length={}, block-size={}",
+                    getName(), (target instanceof CharSequence) ? target : BufferUtils.toHex(BufferUtils.EMPTY_HEX_SEPARATOR, (byte[]) target),
+                    offset, length, blockSize);
+        }
+
+        buffer = checkExtendedReplyBuffer(receive(sendExtendedCommand(buffer)));
+        if (buffer == null) {
+            throw new StreamCorruptedException("Missing extended reply data");
+        }
+
+        String targetType = buffer.getString();
+        if (String.CASE_INSENSITIVE_ORDER.compare(targetType, SftpConstants.EXT_CHECK_FILE) != 0) {
+            throw new StreamCorruptedException("Mismatched reply type: expected=" + SftpConstants.EXT_CHECK_FILE + ", actual=" + targetType);
+        }
+
+        String algo = buffer.getString();
+        Collection<byte[]> hashes = new LinkedList<>();
+        while (buffer.available() > 0) {
+            byte[] hashValue = buffer.getBytes();
+            hashes.add(hashValue);
+        }
+
+        return new Pair<String, Collection<byte[]>>(algo, hashes);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtension.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtension.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtension.java
new file mode 100644
index 0000000..482a1f0
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractMD5HashExtension.java
@@ -0,0 +1,74 @@
+/*
+ * 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.client.subsystem.sftp.extensions.helpers;
+
+import java.io.IOException;
+import java.io.StreamCorruptedException;
+import java.util.Collection;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.NumberUtils;
+import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.buffer.BufferUtils;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public abstract class AbstractMD5HashExtension extends AbstractSftpClientExtension {
+    protected AbstractMD5HashExtension(String name, SftpClient client, RawSftpClient raw, Collection<String> extras) {
+        super(name, client, raw, extras);
+    }
+
+    protected byte[] doGetHash(Object target, long offset, long length, byte[] quickHash) throws IOException {
+        Buffer buffer = getCommandBuffer(target, Long.SIZE + 2 * (Long.SIZE / Byte.SIZE) + (Integer.SIZE / Byte.SIZE) + NumberUtils.length(quickHash));
+        String opcode = getName();
+        putTarget(buffer, target);
+        buffer.putLong(offset);
+        buffer.putLong(length);
+        buffer.putBytes((quickHash == null) ? GenericUtils.EMPTY_BYTE_ARRAY : quickHash);
+
+        if (log.isDebugEnabled()) {
+            log.debug("doGetHash({})[{}] - offset={}, length={}, quick-hash={}",
+                    opcode, (target instanceof CharSequence) ? target : BufferUtils.toHex(BufferUtils.EMPTY_HEX_SEPARATOR, (byte[]) target),
+                    offset, length, BufferUtils.toHex(':', quickHash));
+        }
+
+        buffer = checkExtendedReplyBuffer(receive(sendExtendedCommand(buffer)));
+        if (buffer == null) {
+            throw new StreamCorruptedException("Missing extended reply data");
+        }
+
+        String targetType = buffer.getString();
+        if (String.CASE_INSENSITIVE_ORDER.compare(targetType, opcode) != 0) {
+            throw new StreamCorruptedException("Mismatched reply target type: expected=" + opcode + ", actual=" + targetType);
+        }
+
+        byte[] hashValue = buffer.getBytes();
+        if (log.isDebugEnabled()) {
+            log.debug("doGetHash({})[{}] - offset={}, length={}, quick-hash={} - result={}",
+                    opcode, target, offset, length,
+                    BufferUtils.toHex(':', quickHash), BufferUtils.toHex(':', hashValue));
+        }
+
+        return hashValue;
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractSftpClientExtension.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractSftpClientExtension.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractSftpClientExtension.java
new file mode 100644
index 0000000..853332e
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/AbstractSftpClientExtension.java
@@ -0,0 +1,205 @@
+/*
+ * 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.client.subsystem.sftp.extensions.helpers;
+
+import java.io.IOException;
+import java.io.StreamCorruptedException;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient.Handle;
+import org.apache.sshd.client.subsystem.sftp.extensions.SftpClientExtension;
+import org.apache.sshd.common.SshException;
+import org.apache.sshd.common.subsystem.sftp.SftpConstants;
+import org.apache.sshd.common.subsystem.sftp.SftpException;
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.ValidateUtils;
+import org.apache.sshd.common.util.buffer.Buffer;
+import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
+import org.apache.sshd.common.util.logging.AbstractLoggingBean;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public abstract class AbstractSftpClientExtension extends AbstractLoggingBean implements SftpClientExtension, RawSftpClient {
+    private final String name;
+    private final SftpClient client;
+    private final RawSftpClient raw;
+    private final boolean supported;
+
+    protected AbstractSftpClientExtension(String name, SftpClient client, RawSftpClient raw, Collection<String> extras) {
+        this(name, client, raw, GenericUtils.isEmpty(extras) ? false : extras.contains(name));
+    }
+
+    protected AbstractSftpClientExtension(String name, SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
+        this(name, client, raw, GenericUtils.isEmpty(extensions) ? false : extensions.containsKey(name));
+    }
+
+    protected AbstractSftpClientExtension(String name, SftpClient client, RawSftpClient raw, boolean supported) {
+        this.name = ValidateUtils.checkNotNullAndNotEmpty(name, "No extension name");
+        this.client = ValidateUtils.checkNotNull(client, "No client instance");
+        this.raw = ValidateUtils.checkNotNull(raw, "No raw access");
+        this.supported = supported;
+    }
+
+    @Override
+    public final String getName() {
+        return name;
+    }
+
+    @Override
+    public final SftpClient getClient() {
+        return client;
+    }
+
+    protected void sendAndCheckExtendedCommandStatus(Buffer buffer) throws IOException {
+        int reqId = sendExtendedCommand(buffer);
+        if (log.isDebugEnabled()) {
+            log.debug("sendAndCheckExtendedCommandStatus(" + getName() + ") id=" + reqId);
+        }
+        checkStatus(receive(reqId));
+    }
+
+    protected int sendExtendedCommand(Buffer buffer) throws IOException {
+        return send(SftpConstants.SSH_FXP_EXTENDED, buffer);
+    }
+
+    @Override
+    public int send(int cmd, Buffer buffer) throws IOException {
+        return raw.send(cmd, buffer);
+    }
+
+    @Override
+    public Buffer receive(int id) throws IOException {
+        return raw.receive(id);
+    }
+
+    @Override
+    public final boolean isSupported() {
+        return supported;
+    }
+
+    protected void checkStatus(Buffer buffer) throws IOException {
+        if (checkExtendedReplyBuffer(buffer) != null) {
+            throw new StreamCorruptedException("Unexpected extended reply received");
+        }
+    }
+
+    /**
+     * @param buffer The {@link Buffer}
+     * @param target A target path {@link String} or {@link Handle} or {@code byte[]}
+     *               to be encoded in the buffer
+     * @return The updated buffer
+     * @throws UnsupportedOperationException If target is not one of the above
+     *                                       supported types
+     */
+    public Buffer putTarget(Buffer buffer, Object target) {
+        if (target instanceof CharSequence) {
+            buffer.putString(target.toString());
+        } else if (target instanceof byte[]) {
+            buffer.putBytes((byte[]) target);
+        } else if (target instanceof Handle) {
+            buffer.putBytes(((Handle) target).getIdentifier());
+        } else {
+            throw new UnsupportedOperationException("Unknown target type: " + target);
+        }
+
+        return buffer;
+    }
+
+    /**
+     * @param target A target path {@link String} or {@link Handle} or {@code byte[]}
+     *               to be encoded in the buffer
+     * @return A {@link Buffer} with the extension name set
+     * @see #getCommandBuffer(Object, int)
+     */
+    protected Buffer getCommandBuffer(Object target) {
+        return getCommandBuffer(target, 0);
+    }
+
+    /**
+     * @param target    A target path {@link String} or {@link Handle} or {@code byte[]}
+     *                  to be encoded in the buffer
+     * @param extraSize Extra size - beyond the path/handle to be allocated
+     * @return A {@link Buffer} with the extension name set
+     * @see #getCommandBuffer(int)
+     */
+    protected Buffer getCommandBuffer(Object target, int extraSize) {
+        if (target instanceof CharSequence) {
+            return getCommandBuffer((Integer.SIZE / Byte.SIZE) + ((CharSequence) target).length() + extraSize);
+        } else if (target instanceof byte[]) {
+            return getCommandBuffer((Integer.SIZE / Byte.SIZE) + ((byte[]) target).length + extraSize);
+        } else if (target instanceof Handle) {
+            return getCommandBuffer((Integer.SIZE / Byte.SIZE) + ((Handle) target).length() + extraSize);
+        } else {
+            return getCommandBuffer(extraSize);
+        }
+    }
+
+    /**
+     * @param extraSize Extra size - besides the extension name
+     * @return A {@link Buffer} with the extension name set
+     */
+    protected Buffer getCommandBuffer(int extraSize) {
+        String opcode = getName();
+        Buffer buffer = new ByteArrayBuffer((Integer.SIZE / Byte.SIZE) + GenericUtils.length(opcode) + extraSize + Byte.SIZE, false);
+        buffer.putString(opcode);
+        return buffer;
+    }
+
+    /**
+     * @param buffer The {@link Buffer} to check
+     * @return The {@link Buffer} if this is an {@link SftpConstants#SSH_FXP_EXTENDED_REPLY},
+     * or {@code null} if this is a {@link SftpConstants#SSH_FXP_STATUS} carrying
+     * an {@link SftpConstants#SSH_FX_OK} result
+     * @throws IOException If a non-{@link SftpConstants#SSH_FX_OK} result or
+     *                     not a {@link SftpConstants#SSH_FXP_EXTENDED_REPLY} buffer
+     */
+    protected Buffer checkExtendedReplyBuffer(Buffer buffer) throws IOException {
+        int length = buffer.getInt();
+        int type = buffer.getUByte();
+        int id = buffer.getInt();
+        if (type == SftpConstants.SSH_FXP_STATUS) {
+            int substatus = buffer.getInt();
+            String msg = buffer.getString();
+            String lang = buffer.getString();
+            if (log.isDebugEnabled()) {
+                log.debug("checkStatus({}}[id={}] - status: {} [{}] {}",
+                        getName(), id, substatus, lang, msg);
+            }
+
+            if (substatus != SftpConstants.SSH_FX_OK) {
+                throwStatusException(id, substatus, msg, lang);
+            }
+
+            return null;
+        } else if (type == SftpConstants.SSH_FXP_EXTENDED_REPLY) {
+            return buffer;
+        } else {
+            throw new SshException("Unexpected SFTP packet received: type=" + type + ", id=" + id + ", length=" + length);
+        }
+    }
+
+    protected void throwStatusException(int id, int substatus, String msg, String lang) throws IOException {
+        throw new SftpException(substatus, msg);
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CheckFileHandleExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CheckFileHandleExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CheckFileHandleExtensionImpl.java
new file mode 100644
index 0000000..4fba6a1
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CheckFileHandleExtensionImpl.java
@@ -0,0 +1,44 @@
+/*
+ * 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.client.subsystem.sftp.extensions.helpers;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient.Handle;
+import org.apache.sshd.client.subsystem.sftp.extensions.CheckFileHandleExtension;
+import org.apache.sshd.common.subsystem.sftp.SftpConstants;
+import org.apache.sshd.common.util.Pair;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class CheckFileHandleExtensionImpl extends AbstractCheckFileExtension implements CheckFileHandleExtension {
+    public CheckFileHandleExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extras) {
+        super(SftpConstants.EXT_CHECK_FILE_HANDLE, client, raw, extras);
+    }
+
+    @Override
+    public Pair<String, Collection<byte[]>> checkFileHandle(Handle handle, Collection<String> algorithms, long startOffset, long length, int blockSize) throws IOException {
+        return doGetHash(handle.getIdentifier(), algorithms, startOffset, length, blockSize);
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CheckFileNameExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CheckFileNameExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CheckFileNameExtensionImpl.java
new file mode 100644
index 0000000..4dffc1f
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CheckFileNameExtensionImpl.java
@@ -0,0 +1,43 @@
+/*
+ * 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.client.subsystem.sftp.extensions.helpers;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.client.subsystem.sftp.extensions.CheckFileNameExtension;
+import org.apache.sshd.common.subsystem.sftp.SftpConstants;
+import org.apache.sshd.common.util.Pair;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class CheckFileNameExtensionImpl extends AbstractCheckFileExtension implements CheckFileNameExtension {
+    public CheckFileNameExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extras) {
+        super(SftpConstants.EXT_CHECK_FILE_NAME, client, raw, extras);
+    }
+
+    @Override
+    public Pair<String, Collection<byte[]>> checkFileName(String name, Collection<String> algorithms, long startOffset, long length, int blockSize) throws IOException {
+        return doGetHash(name, algorithms, startOffset, length, blockSize);
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImpl.java
new file mode 100644
index 0000000..ac75a09
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyDataExtensionImpl.java
@@ -0,0 +1,55 @@
+/*
+ * 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.client.subsystem.sftp.extensions.helpers;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient.Handle;
+import org.apache.sshd.client.subsystem.sftp.extensions.CopyDataExtension;
+import org.apache.sshd.common.subsystem.sftp.SftpConstants;
+import org.apache.sshd.common.util.NumberUtils;
+import org.apache.sshd.common.util.buffer.Buffer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class CopyDataExtensionImpl extends AbstractSftpClientExtension implements CopyDataExtension {
+    public CopyDataExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extra) {
+        super(SftpConstants.EXT_COPY_DATA, client, raw, extra);
+    }
+
+    @Override
+    public void copyData(Handle readHandle, long readOffset, long readLength, Handle writeHandle, long writeOffset) throws IOException {
+        byte[] srcId = readHandle.getIdentifier();
+        byte[] dstId = writeHandle.getIdentifier();
+        Buffer buffer = getCommandBuffer((Integer.SIZE / Byte.SIZE) + NumberUtils.length(srcId)
+                + (Integer.SIZE / Byte.SIZE) + NumberUtils.length(dstId)
+                + (3 * (Long.SIZE + (Integer.SIZE / Byte.SIZE))));
+        buffer.putBytes(srcId);
+        buffer.putLong(readOffset);
+        buffer.putLong(readLength);
+        buffer.putBytes(dstId);
+        buffer.putLong(writeOffset);
+        sendAndCheckExtendedCommandStatus(buffer);
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyFileExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyFileExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyFileExtensionImpl.java
new file mode 100644
index 0000000..bb32bb7
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/CopyFileExtensionImpl.java
@@ -0,0 +1,50 @@
+/*
+ * 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.client.subsystem.sftp.extensions.helpers;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.client.subsystem.sftp.extensions.CopyFileExtension;
+import org.apache.sshd.common.subsystem.sftp.SftpConstants;
+import org.apache.sshd.common.util.GenericUtils;
+import org.apache.sshd.common.util.buffer.Buffer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class CopyFileExtensionImpl extends AbstractSftpClientExtension implements CopyFileExtension {
+    public CopyFileExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extra) {
+        super(SftpConstants.EXT_COPY_FILE, client, raw, extra);
+    }
+
+    @Override
+    public void copyFile(String src, String dst, boolean overwriteDestination) throws IOException {
+        Buffer buffer = getCommandBuffer((Integer.SIZE / Byte.SIZE) + GenericUtils.length(src)
+                + (Integer.SIZE / Byte.SIZE) + GenericUtils.length(dst)
+                + 1 /* override destination */);
+        buffer.putString(src);
+        buffer.putString(dst);
+        buffer.putBoolean(overwriteDestination);
+        sendAndCheckExtendedCommandStatus(buffer);
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/MD5FileExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/MD5FileExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/MD5FileExtensionImpl.java
new file mode 100644
index 0000000..ee27b4f
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/MD5FileExtensionImpl.java
@@ -0,0 +1,42 @@
+/*
+ * 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.client.subsystem.sftp.extensions.helpers;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.client.subsystem.sftp.extensions.MD5FileExtension;
+import org.apache.sshd.common.subsystem.sftp.SftpConstants;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class MD5FileExtensionImpl extends AbstractMD5HashExtension implements MD5FileExtension {
+    public MD5FileExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extra) {
+        super(SftpConstants.EXT_MD5_HASH, client, raw, extra);
+    }
+
+    @Override
+    public byte[] getHash(String path, long offset, long length, byte[] quickHash) throws IOException {
+        return doGetHash(path, offset, length, quickHash);
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/MD5HandleExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/MD5HandleExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/MD5HandleExtensionImpl.java
new file mode 100644
index 0000000..5a67abd
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/MD5HandleExtensionImpl.java
@@ -0,0 +1,43 @@
+/*
+ * 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.client.subsystem.sftp.extensions.helpers;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.client.subsystem.sftp.extensions.MD5HandleExtension;
+import org.apache.sshd.common.subsystem.sftp.SftpConstants;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class MD5HandleExtensionImpl extends AbstractMD5HashExtension implements MD5HandleExtension {
+    public MD5HandleExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extra) {
+        super(SftpConstants.EXT_MD5_HASH_HANDLE, client, raw, extra);
+    }
+
+    @Override
+    public byte[] getHash(SftpClient.Handle handle, long offset, long length, byte[] quickHash) throws IOException {
+        return doGetHash(handle.getIdentifier(), offset, length, quickHash);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/SpaceAvailableExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/SpaceAvailableExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/SpaceAvailableExtensionImpl.java
new file mode 100644
index 0000000..4185366
--- /dev/null
+++ b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/helpers/SpaceAvailableExtensionImpl.java
@@ -0,0 +1,53 @@
+/*
+ * 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.client.subsystem.sftp.extensions.helpers;
+
+import java.io.IOException;
+import java.io.StreamCorruptedException;
+import java.util.Collection;
+
+import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
+import org.apache.sshd.client.subsystem.sftp.SftpClient;
+import org.apache.sshd.client.subsystem.sftp.extensions.SpaceAvailableExtension;
+import org.apache.sshd.common.subsystem.sftp.SftpConstants;
+import org.apache.sshd.common.subsystem.sftp.extensions.SpaceAvailableExtensionInfo;
+import org.apache.sshd.common.util.buffer.Buffer;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class SpaceAvailableExtensionImpl extends AbstractSftpClientExtension implements SpaceAvailableExtension {
+    public SpaceAvailableExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extra) {
+        super(SftpConstants.EXT_SPACE_AVAILABLE, client, raw, extra);
+    }
+
+    @Override
+    public SpaceAvailableExtensionInfo available(String path) throws IOException {
+        Buffer buffer = getCommandBuffer(path);
+        buffer.putString(path);
+        buffer = checkExtendedReplyBuffer(receive(sendExtendedCommand(buffer)));
+
+        if (buffer == null) {
+            throw new StreamCorruptedException("Missing extended reply data");
+        }
+
+        return new SpaceAvailableExtensionInfo(buffer);
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/AbstractCheckFileExtension.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/AbstractCheckFileExtension.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/AbstractCheckFileExtension.java
deleted file mode 100644
index 52a7f78..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/AbstractCheckFileExtension.java
+++ /dev/null
@@ -1,77 +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.client.subsystem.sftp.extensions.impl;
-
-import java.io.IOException;
-import java.io.StreamCorruptedException;
-import java.util.Collection;
-import java.util.LinkedList;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.common.subsystem.sftp.SftpConstants;
-import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.common.util.Pair;
-import org.apache.sshd.common.util.buffer.Buffer;
-import org.apache.sshd.common.util.buffer.BufferUtils;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public abstract class AbstractCheckFileExtension extends AbstractSftpClientExtension {
-    protected AbstractCheckFileExtension(String name, SftpClient client, RawSftpClient raw, Collection<String> extras) {
-        super(name, client, raw, extras);
-    }
-
-    protected Pair<String, Collection<byte[]>> doGetHash(Object target, Collection<String> algorithms, long offset, long length, int blockSize) throws IOException {
-        Buffer buffer = getCommandBuffer(target, Byte.MAX_VALUE);
-        putTarget(buffer, target);
-        buffer.putString(GenericUtils.join(algorithms, ','));
-        buffer.putLong(offset);
-        buffer.putLong(length);
-        buffer.putInt(blockSize);
-
-        if (log.isDebugEnabled()) {
-            log.debug("doGetHash({})[{}] - offset={}, length={}, block-size={}",
-                    getName(), (target instanceof CharSequence) ? target : BufferUtils.toHex(BufferUtils.EMPTY_HEX_SEPARATOR, (byte[]) target),
-                    offset, length, blockSize);
-        }
-
-        buffer = checkExtendedReplyBuffer(receive(sendExtendedCommand(buffer)));
-        if (buffer == null) {
-            throw new StreamCorruptedException("Missing extended reply data");
-        }
-
-        String targetType = buffer.getString();
-        if (String.CASE_INSENSITIVE_ORDER.compare(targetType, SftpConstants.EXT_CHECK_FILE) != 0) {
-            throw new StreamCorruptedException("Mismatched reply type: expected=" + SftpConstants.EXT_CHECK_FILE + ", actual=" + targetType);
-        }
-
-        String algo = buffer.getString();
-        Collection<byte[]> hashes = new LinkedList<>();
-        while (buffer.available() > 0) {
-            byte[] hashValue = buffer.getBytes();
-            hashes.add(hashValue);
-        }
-
-        return new Pair<String, Collection<byte[]>>(algo, hashes);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/AbstractMD5HashExtension.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/AbstractMD5HashExtension.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/AbstractMD5HashExtension.java
deleted file mode 100644
index a6cb290..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/AbstractMD5HashExtension.java
+++ /dev/null
@@ -1,74 +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.client.subsystem.sftp.extensions.impl;
-
-import java.io.IOException;
-import java.io.StreamCorruptedException;
-import java.util.Collection;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.common.util.NumberUtils;
-import org.apache.sshd.common.util.buffer.Buffer;
-import org.apache.sshd.common.util.buffer.BufferUtils;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public abstract class AbstractMD5HashExtension extends AbstractSftpClientExtension {
-    protected AbstractMD5HashExtension(String name, SftpClient client, RawSftpClient raw, Collection<String> extras) {
-        super(name, client, raw, extras);
-    }
-
-    protected byte[] doGetHash(Object target, long offset, long length, byte[] quickHash) throws IOException {
-        Buffer buffer = getCommandBuffer(target, Long.SIZE + 2 * (Long.SIZE / Byte.SIZE) + (Integer.SIZE / Byte.SIZE) + NumberUtils.length(quickHash));
-        String opcode = getName();
-        putTarget(buffer, target);
-        buffer.putLong(offset);
-        buffer.putLong(length);
-        buffer.putBytes((quickHash == null) ? GenericUtils.EMPTY_BYTE_ARRAY : quickHash);
-
-        if (log.isDebugEnabled()) {
-            log.debug("doGetHash({})[{}] - offset={}, length={}, quick-hash={}",
-                    opcode, (target instanceof CharSequence) ? target : BufferUtils.toHex(BufferUtils.EMPTY_HEX_SEPARATOR, (byte[]) target),
-                    offset, length, BufferUtils.toHex(':', quickHash));
-        }
-
-        buffer = checkExtendedReplyBuffer(receive(sendExtendedCommand(buffer)));
-        if (buffer == null) {
-            throw new StreamCorruptedException("Missing extended reply data");
-        }
-
-        String targetType = buffer.getString();
-        if (String.CASE_INSENSITIVE_ORDER.compare(targetType, opcode) != 0) {
-            throw new StreamCorruptedException("Mismatched reply target type: expected=" + opcode + ", actual=" + targetType);
-        }
-
-        byte[] hashValue = buffer.getBytes();
-        if (log.isDebugEnabled()) {
-            log.debug("doGetHash({})[{}] - offset={}, length={}, quick-hash={} - result={}",
-                    opcode, target, offset, length,
-                    BufferUtils.toHex(':', quickHash), BufferUtils.toHex(':', hashValue));
-        }
-
-        return hashValue;
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/AbstractSftpClientExtension.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/AbstractSftpClientExtension.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/AbstractSftpClientExtension.java
deleted file mode 100644
index 836f189..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/AbstractSftpClientExtension.java
+++ /dev/null
@@ -1,205 +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.client.subsystem.sftp.extensions.impl;
-
-import java.io.IOException;
-import java.io.StreamCorruptedException;
-import java.util.Collection;
-import java.util.Map;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient.Handle;
-import org.apache.sshd.client.subsystem.sftp.extensions.SftpClientExtension;
-import org.apache.sshd.common.SshException;
-import org.apache.sshd.common.subsystem.sftp.SftpConstants;
-import org.apache.sshd.common.subsystem.sftp.SftpException;
-import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.common.util.ValidateUtils;
-import org.apache.sshd.common.util.buffer.Buffer;
-import org.apache.sshd.common.util.buffer.ByteArrayBuffer;
-import org.apache.sshd.common.util.logging.AbstractLoggingBean;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public abstract class AbstractSftpClientExtension extends AbstractLoggingBean implements SftpClientExtension, RawSftpClient {
-    private final String name;
-    private final SftpClient client;
-    private final RawSftpClient raw;
-    private final boolean supported;
-
-    protected AbstractSftpClientExtension(String name, SftpClient client, RawSftpClient raw, Collection<String> extras) {
-        this(name, client, raw, GenericUtils.isEmpty(extras) ? false : extras.contains(name));
-    }
-
-    protected AbstractSftpClientExtension(String name, SftpClient client, RawSftpClient raw, Map<String, byte[]> extensions) {
-        this(name, client, raw, GenericUtils.isEmpty(extensions) ? false : extensions.containsKey(name));
-    }
-
-    protected AbstractSftpClientExtension(String name, SftpClient client, RawSftpClient raw, boolean supported) {
-        this.name = ValidateUtils.checkNotNullAndNotEmpty(name, "No extension name");
-        this.client = ValidateUtils.checkNotNull(client, "No client instance");
-        this.raw = ValidateUtils.checkNotNull(raw, "No raw access");
-        this.supported = supported;
-    }
-
-    @Override
-    public final String getName() {
-        return name;
-    }
-
-    @Override
-    public final SftpClient getClient() {
-        return client;
-    }
-
-    protected void sendAndCheckExtendedCommandStatus(Buffer buffer) throws IOException {
-        int reqId = sendExtendedCommand(buffer);
-        if (log.isDebugEnabled()) {
-            log.debug("sendAndCheckExtendedCommandStatus(" + getName() + ") id=" + reqId);
-        }
-        checkStatus(receive(reqId));
-    }
-
-    protected int sendExtendedCommand(Buffer buffer) throws IOException {
-        return send(SftpConstants.SSH_FXP_EXTENDED, buffer);
-    }
-
-    @Override
-    public int send(int cmd, Buffer buffer) throws IOException {
-        return raw.send(cmd, buffer);
-    }
-
-    @Override
-    public Buffer receive(int id) throws IOException {
-        return raw.receive(id);
-    }
-
-    @Override
-    public final boolean isSupported() {
-        return supported;
-    }
-
-    protected void checkStatus(Buffer buffer) throws IOException {
-        if (checkExtendedReplyBuffer(buffer) != null) {
-            throw new StreamCorruptedException("Unexpected extended reply received");
-        }
-    }
-
-    /**
-     * @param buffer The {@link Buffer}
-     * @param target A target path {@link String} or {@link Handle} or {@code byte[]}
-     *               to be encoded in the buffer
-     * @return The updated buffer
-     * @throws UnsupportedOperationException If target is not one of the above
-     *                                       supported types
-     */
-    public Buffer putTarget(Buffer buffer, Object target) {
-        if (target instanceof CharSequence) {
-            buffer.putString(target.toString());
-        } else if (target instanceof byte[]) {
-            buffer.putBytes((byte[]) target);
-        } else if (target instanceof Handle) {
-            buffer.putBytes(((Handle) target).getIdentifier());
-        } else {
-            throw new UnsupportedOperationException("Unknown target type: " + target);
-        }
-
-        return buffer;
-    }
-
-    /**
-     * @param target A target path {@link String} or {@link Handle} or {@code byte[]}
-     *               to be encoded in the buffer
-     * @return A {@link Buffer} with the extension name set
-     * @see #getCommandBuffer(Object, int)
-     */
-    protected Buffer getCommandBuffer(Object target) {
-        return getCommandBuffer(target, 0);
-    }
-
-    /**
-     * @param target    A target path {@link String} or {@link Handle} or {@code byte[]}
-     *                  to be encoded in the buffer
-     * @param extraSize Extra size - beyond the path/handle to be allocated
-     * @return A {@link Buffer} with the extension name set
-     * @see #getCommandBuffer(int)
-     */
-    protected Buffer getCommandBuffer(Object target, int extraSize) {
-        if (target instanceof CharSequence) {
-            return getCommandBuffer((Integer.SIZE / Byte.SIZE) + ((CharSequence) target).length() + extraSize);
-        } else if (target instanceof byte[]) {
-            return getCommandBuffer((Integer.SIZE / Byte.SIZE) + ((byte[]) target).length + extraSize);
-        } else if (target instanceof Handle) {
-            return getCommandBuffer((Integer.SIZE / Byte.SIZE) + ((Handle) target).length() + extraSize);
-        } else {
-            return getCommandBuffer(extraSize);
-        }
-    }
-
-    /**
-     * @param extraSize Extra size - besides the extension name
-     * @return A {@link Buffer} with the extension name set
-     */
-    protected Buffer getCommandBuffer(int extraSize) {
-        String opcode = getName();
-        Buffer buffer = new ByteArrayBuffer((Integer.SIZE / Byte.SIZE) + GenericUtils.length(opcode) + extraSize + Byte.SIZE, false);
-        buffer.putString(opcode);
-        return buffer;
-    }
-
-    /**
-     * @param buffer The {@link Buffer} to check
-     * @return The {@link Buffer} if this is an {@link SftpConstants#SSH_FXP_EXTENDED_REPLY},
-     * or {@code null} if this is a {@link SftpConstants#SSH_FXP_STATUS} carrying
-     * an {@link SftpConstants#SSH_FX_OK} result
-     * @throws IOException If a non-{@link SftpConstants#SSH_FX_OK} result or
-     *                     not a {@link SftpConstants#SSH_FXP_EXTENDED_REPLY} buffer
-     */
-    protected Buffer checkExtendedReplyBuffer(Buffer buffer) throws IOException {
-        int length = buffer.getInt();
-        int type = buffer.getUByte();
-        int id = buffer.getInt();
-        if (type == SftpConstants.SSH_FXP_STATUS) {
-            int substatus = buffer.getInt();
-            String msg = buffer.getString();
-            String lang = buffer.getString();
-            if (log.isDebugEnabled()) {
-                log.debug("checkStatus({}}[id={}] - status: {} [{}] {}",
-                        getName(), id, substatus, lang, msg);
-            }
-
-            if (substatus != SftpConstants.SSH_FX_OK) {
-                throwStatusException(id, substatus, msg, lang);
-            }
-
-            return null;
-        } else if (type == SftpConstants.SSH_FXP_EXTENDED_REPLY) {
-            return buffer;
-        } else {
-            throw new SshException("Unexpected SFTP packet received: type=" + type + ", id=" + id + ", length=" + length);
-        }
-    }
-
-    protected void throwStatusException(int id, int substatus, String msg, String lang) throws IOException {
-        throw new SftpException(substatus, msg);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CheckFileHandleExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CheckFileHandleExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CheckFileHandleExtensionImpl.java
deleted file mode 100644
index 56bad26..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CheckFileHandleExtensionImpl.java
+++ /dev/null
@@ -1,44 +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.client.subsystem.sftp.extensions.impl;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient.Handle;
-import org.apache.sshd.client.subsystem.sftp.extensions.CheckFileHandleExtension;
-import org.apache.sshd.common.subsystem.sftp.SftpConstants;
-import org.apache.sshd.common.util.Pair;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class CheckFileHandleExtensionImpl extends AbstractCheckFileExtension implements CheckFileHandleExtension {
-    public CheckFileHandleExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extras) {
-        super(SftpConstants.EXT_CHECK_FILE_HANDLE, client, raw, extras);
-    }
-
-    @Override
-    public Pair<String, Collection<byte[]>> checkFileHandle(Handle handle, Collection<String> algorithms, long startOffset, long length, int blockSize) throws IOException {
-        return doGetHash(handle.getIdentifier(), algorithms, startOffset, length, blockSize);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CheckFileNameExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CheckFileNameExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CheckFileNameExtensionImpl.java
deleted file mode 100644
index 89dbd28..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CheckFileNameExtensionImpl.java
+++ /dev/null
@@ -1,43 +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.client.subsystem.sftp.extensions.impl;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.extensions.CheckFileNameExtension;
-import org.apache.sshd.common.subsystem.sftp.SftpConstants;
-import org.apache.sshd.common.util.Pair;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class CheckFileNameExtensionImpl extends AbstractCheckFileExtension implements CheckFileNameExtension {
-    public CheckFileNameExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extras) {
-        super(SftpConstants.EXT_CHECK_FILE_NAME, client, raw, extras);
-    }
-
-    @Override
-    public Pair<String, Collection<byte[]>> checkFileName(String name, Collection<String> algorithms, long startOffset, long length, int blockSize) throws IOException {
-        return doGetHash(name, algorithms, startOffset, length, blockSize);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CopyDataExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CopyDataExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CopyDataExtensionImpl.java
deleted file mode 100644
index 0d4ad89..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CopyDataExtensionImpl.java
+++ /dev/null
@@ -1,55 +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.client.subsystem.sftp.extensions.impl;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient.Handle;
-import org.apache.sshd.client.subsystem.sftp.extensions.CopyDataExtension;
-import org.apache.sshd.common.subsystem.sftp.SftpConstants;
-import org.apache.sshd.common.util.NumberUtils;
-import org.apache.sshd.common.util.buffer.Buffer;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class CopyDataExtensionImpl extends AbstractSftpClientExtension implements CopyDataExtension {
-    public CopyDataExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extra) {
-        super(SftpConstants.EXT_COPY_DATA, client, raw, extra);
-    }
-
-    @Override
-    public void copyData(Handle readHandle, long readOffset, long readLength, Handle writeHandle, long writeOffset) throws IOException {
-        byte[] srcId = readHandle.getIdentifier();
-        byte[] dstId = writeHandle.getIdentifier();
-        Buffer buffer = getCommandBuffer((Integer.SIZE / Byte.SIZE) + NumberUtils.length(srcId)
-                + (Integer.SIZE / Byte.SIZE) + NumberUtils.length(dstId)
-                + (3 * (Long.SIZE + (Integer.SIZE / Byte.SIZE))));
-        buffer.putBytes(srcId);
-        buffer.putLong(readOffset);
-        buffer.putLong(readLength);
-        buffer.putBytes(dstId);
-        buffer.putLong(writeOffset);
-        sendAndCheckExtendedCommandStatus(buffer);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CopyFileExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CopyFileExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CopyFileExtensionImpl.java
deleted file mode 100644
index fc4584f..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/CopyFileExtensionImpl.java
+++ /dev/null
@@ -1,50 +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.client.subsystem.sftp.extensions.impl;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.extensions.CopyFileExtension;
-import org.apache.sshd.common.subsystem.sftp.SftpConstants;
-import org.apache.sshd.common.util.GenericUtils;
-import org.apache.sshd.common.util.buffer.Buffer;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class CopyFileExtensionImpl extends AbstractSftpClientExtension implements CopyFileExtension {
-    public CopyFileExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extra) {
-        super(SftpConstants.EXT_COPY_FILE, client, raw, extra);
-    }
-
-    @Override
-    public void copyFile(String src, String dst, boolean overwriteDestination) throws IOException {
-        Buffer buffer = getCommandBuffer((Integer.SIZE / Byte.SIZE) + GenericUtils.length(src)
-                + (Integer.SIZE / Byte.SIZE) + GenericUtils.length(dst)
-                + 1 /* override destination */);
-        buffer.putString(src);
-        buffer.putString(dst);
-        buffer.putBoolean(overwriteDestination);
-        sendAndCheckExtendedCommandStatus(buffer);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/MD5FileExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/MD5FileExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/MD5FileExtensionImpl.java
deleted file mode 100644
index 99fedc6..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/MD5FileExtensionImpl.java
+++ /dev/null
@@ -1,42 +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.client.subsystem.sftp.extensions.impl;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.extensions.MD5FileExtension;
-import org.apache.sshd.common.subsystem.sftp.SftpConstants;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class MD5FileExtensionImpl extends AbstractMD5HashExtension implements MD5FileExtension {
-    public MD5FileExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extra) {
-        super(SftpConstants.EXT_MD5_HASH, client, raw, extra);
-    }
-
-    @Override
-    public byte[] getHash(String path, long offset, long length, byte[] quickHash) throws IOException {
-        return doGetHash(path, offset, length, quickHash);
-    }
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/MD5HandleExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/MD5HandleExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/MD5HandleExtensionImpl.java
deleted file mode 100644
index 23402d1..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/MD5HandleExtensionImpl.java
+++ /dev/null
@@ -1,43 +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.client.subsystem.sftp.extensions.impl;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.extensions.MD5HandleExtension;
-import org.apache.sshd.common.subsystem.sftp.SftpConstants;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class MD5HandleExtensionImpl extends AbstractMD5HashExtension implements MD5HandleExtension {
-    public MD5HandleExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extra) {
-        super(SftpConstants.EXT_MD5_HASH_HANDLE, client, raw, extra);
-    }
-
-    @Override
-    public byte[] getHash(SftpClient.Handle handle, long offset, long length, byte[] quickHash) throws IOException {
-        return doGetHash(handle.getIdentifier(), offset, length, quickHash);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/3f69f229/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/SpaceAvailableExtensionImpl.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/SpaceAvailableExtensionImpl.java b/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/SpaceAvailableExtensionImpl.java
deleted file mode 100644
index 52807e5..0000000
--- a/sshd-core/src/main/java/org/apache/sshd/client/subsystem/sftp/extensions/impl/SpaceAvailableExtensionImpl.java
+++ /dev/null
@@ -1,53 +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.client.subsystem.sftp.extensions.impl;
-
-import java.io.IOException;
-import java.io.StreamCorruptedException;
-import java.util.Collection;
-
-import org.apache.sshd.client.subsystem.sftp.RawSftpClient;
-import org.apache.sshd.client.subsystem.sftp.SftpClient;
-import org.apache.sshd.client.subsystem.sftp.extensions.SpaceAvailableExtension;
-import org.apache.sshd.common.subsystem.sftp.SftpConstants;
-import org.apache.sshd.common.subsystem.sftp.extensions.SpaceAvailableExtensionInfo;
-import org.apache.sshd.common.util.buffer.Buffer;
-
-/**
- * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class SpaceAvailableExtensionImpl extends AbstractSftpClientExtension implements SpaceAvailableExtension {
-    public SpaceAvailableExtensionImpl(SftpClient client, RawSftpClient raw, Collection<String> extra) {
-        super(SftpConstants.EXT_SPACE_AVAILABLE, client, raw, extra);
-    }
-
-    @Override
-    public SpaceAvailableExtensionInfo available(String path) throws IOException {
-        Buffer buffer = getCommandBuffer(path);
-        buffer.putString(path);
-        buffer = checkExtendedReplyBuffer(receive(sendExtendedCommand(buffer)));
-
-        if (buffer == null) {
-            throw new StreamCorruptedException("Missing extended reply data");
-        }
-
-        return new SpaceAvailableExtensionInfo(buffer);
-    }
-}