You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2013/01/17 14:09:52 UTC

svn commit: r1434658 [3/6] - in /mina/sshd/trunk: sshd-core/src/docs/ sshd-core/src/main/java/org/apache/sshd/server/filesystem/ sshd-sftp/ sshd-sftp/src/main/java/org/apache/sshd/sftp/ sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/ sshd-sftp/src/...

Modified: mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/filesystem/NativeSshFile.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/filesystem/NativeSshFile.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/filesystem/NativeSshFile.java (original)
+++ mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/server/filesystem/NativeSshFile.java Thu Jan 17 13:09:51 2013
@@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory;
  */
 public class NativeSshFile implements SshFile {
 
-    private final Logger LOG = LoggerFactory.getLogger(NativeSshFile.class);
+    private static final Logger LOG = LoggerFactory.getLogger(NativeSshFile.class);
 
     // the file name with respect to the user root.
     // The path separator character will be '/' and
@@ -588,4 +588,9 @@ public class NativeSshFile implements Ss
     public File getPhysicalFile() {
     	return file;
     }
+
+    @Override
+    public String toString() {
+        return fileName;
+    }
 }

Modified: mina/sshd/trunk/sshd-sftp/pom.xml
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/pom.xml?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/pom.xml (original)
+++ mina/sshd/trunk/sshd-sftp/pom.xml Thu Jan 17 13:09:51 2013
@@ -43,6 +43,27 @@
             <groupId>org.apache.sshd</groupId>
             <artifactId>sshd-core</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.jcraft</groupId>
+            <artifactId>jsch</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>bouncycastle</groupId>
+            <artifactId>bcprov-jdk15</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Handle.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Handle.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Handle.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Handle.java Thu Jan 17 13:09:51 2013
@@ -20,6 +20,7 @@ package org.apache.sshd.sftp;
 
 import org.apache.sshd.server.SshFile;
 
+import java.io.Closeable;
 import java.io.IOException;
 
 /**
@@ -27,20 +28,10 @@ import java.io.IOException;
  *
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public abstract class Handle {
+public interface Handle extends Closeable {
 
-    protected SshFile file;
+    String getId();
 
-    public Handle(SshFile file) {
-        this.file = file;
-    }
-
-    public SshFile getFile() {
-        return file;
-    }
-
-    public void close() throws IOException {
-        file.handleClose();
-    }
+    SshFile getFile();
 
 }

Copied: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Reply.java (from r1434657, mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/Reply.java)
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Reply.java?p2=mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Reply.java&p1=mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/Reply.java&r1=1434657&r2=1434658&rev=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/Reply.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Reply.java Thu Jan 17 13:09:51 2013
@@ -16,7 +16,9 @@
 * specific language governing permissions and limitations
 * under the License.
 */
-package org.apache.sshd.sftp.reply;
+package org.apache.sshd.sftp;
+
+import org.apache.sshd.sftp.subsystem.SftpConstants;
 
 /**
  * Common ssh reply interface.
@@ -25,10 +27,17 @@ package org.apache.sshd.sftp.reply;
  */
 public interface Reply {
 
+    /**
+     * Returns the reply message type.
+     *
+     * @return the message type
+     */
+    SftpConstants.Type getMessage();
+
 	/**
 	 * Returns the name of the reply code.
 	 * 
 	 * @return The name of the reply code.
 	 */
-	String getReplyCodeName();
+	String getName();
 }

Copied: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Request.java (from r1434657, mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Handle.java)
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Request.java?p2=mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Request.java&p1=mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Handle.java&r1=1434657&r2=1434658&rev=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Handle.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Request.java Thu Jan 17 13:09:51 2013
@@ -18,29 +18,33 @@
 */
 package org.apache.sshd.sftp;
 
-import org.apache.sshd.server.SshFile;
-
-import java.io.IOException;
+import org.apache.sshd.sftp.subsystem.SftpConstants;
 
 /**
- * A sftp handle.
+ * Common ssh request interface.
  *
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public abstract class Handle {
-
-    protected SshFile file;
-
-    public Handle(SshFile file) {
-        this.file = file;
-    }
-
-    public SshFile getFile() {
-        return file;
-    }
-
-    public void close() throws IOException {
-        file.handleClose();
-    }
+public interface Request {
 
+    /**
+     * Returns the request id.
+     *
+     * @return The request id.
+     */
+    int getId();
+
+    /**
+     * Returns the message type.
+     *
+     * @return The message type.
+     */
+    SftpConstants.Type getMessage();
+
+    /**
+     * Returns the request name.
+     *
+     * @return The request name.
+     */
+    String getName();
 }

Added: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/SftpSession.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/SftpSession.java?rev=1434658&view=auto
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/SftpSession.java (added)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/SftpSession.java Thu Jan 17 13:09:51 2013
@@ -0,0 +1,36 @@
+/*
+ * 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.sftp;
+
+import org.apache.sshd.common.Session;
+import org.apache.sshd.server.SshFile;
+
+public interface SftpSession {
+
+    int getVersion();
+
+    Session getSession();
+
+    Handle getHandle(String id);
+
+    Handle createFileHandle(SshFile file, int flags);
+
+    Handle createDirectoryHandle(SshFile file);
+
+}

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Sftplet.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Sftplet.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Sftplet.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/Sftplet.java Thu Jan 17 13:09:51 2013
@@ -18,11 +18,10 @@
 */
 package org.apache.sshd.sftp;
 
+import org.apache.sshd.common.Session;
+
 import java.io.IOException;
 
-import org.apache.sshd.server.session.ServerSession;
-import org.apache.sshd.sftp.reply.Reply;
-import org.apache.sshd.sftp.request.Request;
 
 
 /**
@@ -39,14 +38,14 @@ public interface Sftplet {
 	 * 
 	 * @param session The according session.
 	 */
-	void onConnect(ServerSession session);
+	void onConnect(SftpSession session);
 
 	/**
 	 * Client disconnect notification method.
 	 * 
 	 * @param session The according session.
 	 */
-	void onDisconnect(ServerSession session);
+	void onDisconnect(SftpSession session);
 
 	/**
 	 * Called before the server invoke the command.
@@ -57,7 +56,7 @@ public interface Sftplet {
 	 * @return If null, the standard processing goes on.
 	 *         If not null, there will be no further processing and this reply will be returned to client.
 	 */
-	Reply beforeCommand(ServerSession session, Request sftpRequest);
+	Reply beforeCommand(SftpSession session, Request sftpRequest);
 
 	/**
 	 * Called after the server as invoked the command.
@@ -71,5 +70,5 @@ public interface Sftplet {
 	 *         
 	 * @throws IOException If an error occured. 
 	 */
-	Reply afterCommand(ServerSession session, Request sftpRequest, Reply sftpReply) throws IOException;
+	Reply afterCommand(SftpSession session, Request sftpRequest, Reply sftpReply) throws IOException;
 }

Added: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/BaseReply.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/BaseReply.java?rev=1434658&view=auto
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/BaseReply.java (added)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/BaseReply.java Thu Jan 17 13:09:51 2013
@@ -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.sftp.reply;
+
+import org.apache.sshd.sftp.Reply;
+
+public abstract class BaseReply implements Reply {
+
+    private final int id;
+
+    /**
+     * Creates a Request instance.
+     *
+     * @param id The request id.
+     */
+    public BaseReply(final int id) {
+        this.id = id;
+    }
+
+    /**
+     * Returns the request id.
+     *
+     * @return The request id.
+     */
+    public int getId() {
+        return id;
+    }
+
+    /**
+     * Returns the request name.
+     *
+     * @return The request name.
+     */
+    public String getName() {
+        return getMessage().toString();
+    }
+}

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/FileAttributes.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/FileAttributes.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/FileAttributes.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/FileAttributes.java Thu Jan 17 13:09:51 2013
@@ -18,6 +18,10 @@
 */
 package org.apache.sshd.sftp.reply;
 
+import org.apache.sshd.server.SshFile;
+
+import static org.apache.sshd.sftp.subsystem.SftpConstants.*;
+
 /**
  * Data container for file attributes in relies.
  * TODO: implement
@@ -25,4 +29,101 @@ package org.apache.sshd.sftp.reply;
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
 public class FileAttributes {
+
+    int flags = 0;
+    byte type;
+    long size;
+    long allocationSize;
+    String owner;
+    String group;
+    int permissions;
+    long accessTime;
+    int accessTimeNanos;
+    long modifyTime;
+    int modifyTimeNanos;
+    long createTime;
+    int createTimeNanos;
+    String acl;
+    int attribBits;
+    int attribBitsValid;
+    byte textHint;
+    String mimeType;
+    int linkCount;
+    String untranslatedName;
+    int extended;
+
+    public FileAttributes() {
+    }
+
+    public FileAttributes(SshFile file, int flags) {
+        // Type
+        if (file.isFile()) {
+            setType((byte) SSH_FILEXFER_TYPE_REGULAR);
+        } else if (file.isDirectory()) {
+            setType((byte) SSH_FILEXFER_TYPE_DIRECTORY);
+        } else {
+            setType((byte) SSH_FILEXFER_TYPE_UNKNOWN);
+        }
+        // Size
+        if ((flags & SSH_FILEXFER_ATTR_SIZE) != 0) {
+            setSize(file.getSize());
+        }
+        // Permissions
+        if ((flags & SSH_FILEXFER_ATTR_PERMISSIONS) != 0) {
+            setPermissions((file.isReadable() ? S_IRUSR : 0) | (file.isWritable() ? S_IWUSR : 0) | (file.isExecutable() ? S_IXUSR : 0));
+        }
+    }
+
+    public int getFlags() {
+        return flags;
+    }
+
+    public byte getType() {
+        return type;
+    }
+
+    public void setType(byte type) {
+        this.type = type;
+    }
+
+    public long getSize() {
+        return size;
+    }
+
+    public void setSize(long size) {
+        this.flags |= SSH_FILEXFER_ATTR_SIZE;
+        this.size = size;
+    }
+
+    public long getAllocationSize() {
+        return allocationSize;
+    }
+
+    public void setAllocationSize(long allocationSize) {
+        this.flags |= SSH_FILEXFER_ATTR_ALLOCATION_SIZE;
+        this.allocationSize = allocationSize;
+    }
+
+    public String getOwner() {
+        return owner;
+    }
+
+    public String getGroup() {
+        return group;
+    }
+
+    public void setOwnerGroup(String owner, String group) {
+        this.flags |= SSH_FILEXFER_ATTR_OWNERGROUP;
+        this.owner = owner;
+        this.group = group;
+    }
+
+    public int getPermissions() {
+        return permissions;
+    }
+
+    public void setPermissions(int permissions) {
+        this.flags |= SSH_FILEXFER_ATTR_PERMISSIONS;
+        this.permissions = permissions;
+    }
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpAttrsReply.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpAttrsReply.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpAttrsReply.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpAttrsReply.java Thu Jan 17 13:09:51 2013
@@ -19,90 +19,49 @@
 package org.apache.sshd.sftp.reply;
 
 import org.apache.sshd.server.SshFile;
+import org.apache.sshd.sftp.subsystem.SftpConstants;
 
 /**
  * Data container for 'SSH_FXP_ATTRS' reply.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpAttrsReply implements Reply {
+public class SshFxpAttrsReply extends BaseReply {
 
-	private int id;
-	private final SshFile file;
-	private final Integer flags;
+    private final FileAttributes attrs;
 
-	/**
-	 * Creates a SshFxpAttrsReply instance.
-	 * 
-	 * @param id    The reply id.
-	 * @param file  The according file.
-	 * @param flags The file flags.
-	 */
-	public SshFxpAttrsReply(final int id, final SshFile file, final int flags) {
-		this.id = id;
-		this.file = file;
-		this.flags = flags;
-	}
-
-	/**
-	 * Creates a SshFxpAttrsReply instance.
-	 * 
-	 * @param id    The reply id.
-	 * @param file  The according file.
-	 */
-	public SshFxpAttrsReply(final int id, final SshFile file) {
-		this.id = id;
-		this.file = file;
-		this.flags = null;
-	}
+    /**
+     * Creates a SshFxpAttrsReply instance.
+     *
+     * @param id    The reply id.
+     * @param attrs The attributes.
+     */
+    public SshFxpAttrsReply(final int id, final FileAttributes attrs) {
+        super(id);
+        this.attrs = attrs;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getReplyCodeName() {
-		return "SSH_FXP_ATTRS";
+	public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_ATTRS;
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-		StringBuffer sb = new StringBuffer();
-		sb.append(getReplyCodeName());
-		sb.append(": id=");
-		sb.append(id);
-		sb.append(", file=");
-		sb.append(file.getAbsolutePath());
-		sb.append(", flags=");
-		sb.append(flags);
-
-		return sb.toString();
+        return getName() + "[attrs=" + attrs + "]";
 	}
 
 	/**
-	 * Returns the id.
+	 * Returns the attributes.
 	 * 
-	 * @return The id.
+	 * @return the attributes.
 	 */
-	public int getId() {
-		return id;
+	public FileAttributes getAttributes() {
+		return attrs;
 	}
 
-	/**
-	 * Returns the file.
-	 * 
-	 * @return the file.
-	 */
-	public SshFile getFile() {
-		return file;
-	}
-
-	/**
-	 * Returns the flags.
-	 * 
-	 * @return The flags.
-	 */
-	public Integer getFlags() {
-		return flags;
-	}
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpDataReply.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpDataReply.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpDataReply.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpDataReply.java Thu Jan 17 13:09:51 2013
@@ -18,18 +18,19 @@
 */
 package org.apache.sshd.sftp.reply;
 
-import java.util.Arrays;
+import org.apache.sshd.sftp.subsystem.SftpConstants;
 
 /**
  * Data container for 'SSH_FXP_DATA' reply.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpDataReply implements Reply {
+public class SshFxpDataReply extends BaseReply {
 
-	private final int id;
-	private final Boolean lenFlag;
 	private final byte[] data;
+    private final int offset;
+    private final int length;
+    private final boolean eof;
 
 	/**
 	 * Creates a SshFxpData instance.
@@ -38,55 +39,38 @@ public class SshFxpDataReply implements 
 	 * @param data The transfer data.
 	 */
 	public SshFxpDataReply(final int id, final byte[] data) {
-		this.id   = id;
-		this.data = Arrays.copyOfRange(data, 0, data.length);
-		lenFlag  = null;
+        this(id, data, 0, data.length, false);
 	}
 
 	/**
 	 * Creates a SshFxpData instance.
 	 * 
 	 * @param id      The reply id.
-	 * @param data    The transfer data.
-	 * @param lenFlag LenFlag.
-	 */
-	public SshFxpDataReply(final int id, final byte[] data, final boolean lenFlag) {
-		this.id   = id;
-		this.data = Arrays.copyOfRange(data, 0, data.length);
-		this.lenFlag  = lenFlag;
+     * @param data    The transfer data.
+     * @param offset  The offset in the data.
+     * @param length  The length of data.
+	 * @param eof     The EOF flag.
+	 */
+	public SshFxpDataReply(final int id, final byte[] data, final int offset, final int length, final boolean eof) {
+        super(id);
+		this.data = data;
+        this.offset = offset;
+        this.length = length;
+		this.eof  = eof;
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getReplyCodeName() {
-		return "SSH_FXP_DATA";
+	public SftpConstants.Type getMessage() {
+		return SftpConstants.Type.SSH_FXP_DATA;
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-		StringBuffer fs = new StringBuffer();
-		fs.append(getReplyCodeName());
-		fs.append(": id=");
-		fs.append(id);
-		fs.append(", data=<data(len=" + data.length + ")>");
-		if (lenFlag != null) {
-			fs.append(", len=");
-			fs.append(lenFlag);
-		}
-
-		return fs.toString();
-	}
-
-	/**
-	 * Returns the id.
-	 * 
-	 * @return The id.
-	 */
-	public long getId() {
-		return id;
+        return getName() + "[data=<data(len=" + length + ")>, eof=" + eof + "]";
 	}
 
 	/**
@@ -95,15 +79,18 @@ public class SshFxpDataReply implements 
 	 * @return The data.
 	 */
 	public byte[] getData() {
-		return Arrays.copyOf(data, data.length);
+		return data;
 	}
 
-	/**
-	 * Returns the lenflag.
-	 * 
-	 * @return The lenflag.
-	 */
-	public Boolean getLenFlag() {
-		return lenFlag;
-	}
+    public int getOffset() {
+        return offset;
+    }
+
+    public int getLength() {
+        return length;
+    }
+
+    public boolean isEof() {
+        return eof;
+    }
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpHandleReply.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpHandleReply.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpHandleReply.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpHandleReply.java Thu Jan 17 13:09:51 2013
@@ -19,52 +19,40 @@
 package org.apache.sshd.sftp.reply;
 
 import org.apache.sshd.sftp.Handle;
+import org.apache.sshd.sftp.subsystem.SftpConstants;
 
 /**
  * Data container for 'SSH_FXP_HANDLE' reply.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpHandleReply implements Reply {
+public class SshFxpHandleReply extends BaseReply {
 
-	private final String handle;
-	private final Handle handleRef;
-	private final int id;
+	private final Handle handle;
 
 	/**
 	 * Creates a SshFxpHandleReply instance.
 	 * 
 	 * @param id       The reply id.
-	 * @param handle The handle name.
-	 * @param handleRef   The handle.
+	 * @param handle   The handle.
 	 */
-	public SshFxpHandleReply(final int id, final String handle, final Handle handleRef) {
-		this.id = id;
+	public SshFxpHandleReply(final int id, final Handle handle) {
+        super(id);
 		this.handle = handle;
-		this.handleRef = handleRef;
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getReplyCodeName() {
-		return "SSH_FXP_HANDLE";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_HANDLE;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-		return getReplyCodeName() + ": handle=" + handle + ", file=" + handleRef.getFile().getAbsolutePath();
-	}
-
-	/**
-	 * Returns the id.
-	 * 
-	 * @return The id.
-	 */
-	public int getId() {
-		return id;
+		return getName() + "[handle=" + handle.getId() + ", file=" + handle.getFile().getAbsolutePath();
 	}
 
 	/**
@@ -72,7 +60,7 @@ public class SshFxpHandleReply implement
 	 * 
 	 * @return The handle.
 	 */
-	public String getHandle() {
+	public Handle getHandle() {
 		return handle;
 	}
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpNameReply.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpNameReply.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpNameReply.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpNameReply.java Thu Jan 17 13:09:51 2013
@@ -20,121 +20,101 @@ package org.apache.sshd.sftp.reply;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.sshd.server.SshFile;
+import org.apache.sshd.sftp.subsystem.SftpConstants;
 
 /**
  * Data container for 'SSH_FXP_NAME' reply.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpNameReply implements Reply {
+public class SshFxpNameReply extends BaseReply {
 	/**
 	 * Contains informations of requested files.
 	 */
 	public static class ReplyFile {
 
-		private final String filename;
-		private final String longname;
-		private final Integer x;
+        private final SshFile file;
+		private final String fileName;
+		private final String longName;
 		private final FileAttributes attrs;
 
 		/**
 		 * Creates ReplyFile instance.
 		 * 
-		 * @param filename The file name.
-		 * @param longname The virtual absolute file path.
-		 * @param x        Do not know.
+		 * @param fileName The file name.
+		 * @param longName The virtual absolute file path.
+		 * @param attrs    File attributes.
 		 */
-		public ReplyFile(final String filename, final String longname, final int x) {
-			this.filename = filename;
-			this.longname = longname;
-			this.x = x;
-			attrs = null;
-		}
-
-		/**
-		 * Creates ReplyFile instance.
-		 * 
-		 * @param filename The file name.
-		 * @param longname The virtual absolute file path.
-		 * @param attrs    The file attributes.
-		 */
-		public ReplyFile(final String filename, final String longname, final FileAttributes attrs) {
-			this.filename = filename;
-			this.longname = longname;
+		public ReplyFile(final SshFile file, final String fileName, final String longName, final FileAttributes attrs) {
+            this.file = file;
+			this.fileName = fileName;
+			this.longName = longName;
 			this.attrs = attrs;
-			x = null;
 		}
 
-		/**
-		 * {@inheritDoc}
-		 */
-		public String toString() {
-			return "filename=" + filename + ", longname=" + longname;
-		}
+        public SshFile getFile() {
+            return file;
+        }
+
+        public String getFileName() {
+            return fileName;
+        }
+
+        public String getLongName() {
+            return longName;
+        }
+
+        /**
+         * Returns the file attributes.
+         *
+         * @return The file attributes.
+         */
+        public FileAttributes getAttrs() {
+            return attrs;
+        }
+
+        public String toString() {
+            return "fileName=" + fileName + ", longName=" + longName;
+        }
 
-		/**
-		 * Returns x. Do not know the meaning.
-		 * 
-		 * @return x value.
-		 */
-		public int getX() {
-			return x;
-		}
-
-		/**
-		 * Returns the file attributes.
-		 * 
-		 * @return The file attributes.
-		 */
-		public FileAttributes getAttrs() {
-			return attrs;
-		}
-	}
+    }
 
-	private List<ReplyFile> fileList = new ArrayList<ReplyFile>();
-	private final int id;
-	private int count = 0;
-	private Collection<SshFile> sshFiles = new ArrayList<SshFile>();
-	private final boolean isSendPath;
+	private List<ReplyFile> files = new ArrayList<ReplyFile>();
+    private boolean eol;
 
-	/**
+    /**
 	 * Creates a SshFxpHandleReply instance.
 	 * 
 	 * @param id         The reply id.
-	 * @param isSendPath If true, it's a send path reply.
 	 */
-	public SshFxpNameReply(final int id, final boolean isSendPath) {
-		this.id = id;
-		this.isSendPath = isSendPath;
-	}
+	public SshFxpNameReply(final int id) {
+		super(id);
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getReplyCodeName() {
-		return "SSH_FXP_NAME";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_NAME;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
 		StringBuffer fs = new StringBuffer();
-		fs.append(getReplyCodeName());
-		fs.append(": id=");
-		fs.append(id);
-		fs.append(", count=");
-		fs.append(count);
-		fs.append(",");
+		fs.append(getName());
+        fs.append("[");
 		fs.append("\n");
-		for (ReplyFile f : fileList) {
+		for (ReplyFile f : files) {
+            fs.append("    ");
 			fs.append(f.toString());
-			fs.append(";\n");
+			fs.append(",\n");
 	    }
+        fs.append("]");
 
 		return fs.toString();
 	}
@@ -145,38 +125,10 @@ public class SshFxpNameReply implements 
 	 * @param sshFile  The ssh file.
 	 * @param filename The file name.
 	 * @param longname The long file message.
-	 * @param x        Don't know!
-	 */
-	public void addFile(final SshFile sshFile, final String filename, final String longname, final int x) {
-		ReplyFile file = new ReplyFile(filename, longname, x);
-		fileList.add(file);
-		sshFiles.add(sshFile);
-		count++;
-	}
-
-	/**
-	 * Add a file to the reply.
-	 * 
-	 * @param sshFile  The ssh file.
-	 * @param filename The file name.
-	 * @param longname The long file message.
 	 * @param attrs    The file attributes.
 	 */
-	public void addFile(final SshFile sshFile, final String filename, final String longname,
-			final FileAttributes attrs) {
-		ReplyFile file = new ReplyFile(filename, longname, attrs);
-		fileList.add(file);
-		sshFiles.add(sshFile);
-		count++;
-	}
-
-	/**
-	 * Returns the id.
-	 * 
-	 * @return The id.
-	 */
-	public int getId() {
-		return id;
+	public void addFile(final SshFile sshFile, final String filename, final String longname, final FileAttributes attrs) {
+		files.add(new ReplyFile(sshFile, filename, longname, attrs));
 	}
 
 	/**
@@ -184,16 +136,15 @@ public class SshFxpNameReply implements 
 	 * 
 	 * @return the files.
 	 */
-	public Iterator<SshFile> getFiles() {
-		return sshFiles.iterator();
+	public Collection<ReplyFile> getFiles() {
+		return files;
 	}
 
-	/**
-	 * Returns the send path reply flag.
-	 * 
-	 * @return True, it's a send path reply.
-	 */
-	public boolean isSendPath() {
-		return isSendPath;
-	}
+    public boolean isEol() {
+        return eol;
+    }
+
+    public void setEol(boolean eol) {
+        this.eol = eol;
+    }
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpStatusReply.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpStatusReply.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpStatusReply.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpStatusReply.java Thu Jan 17 13:09:51 2013
@@ -21,19 +21,34 @@ package org.apache.sshd.sftp.reply;
 import java.io.IOException;
 
 import org.apache.sshd.server.sftp.SftpSubsystem;
+import org.apache.sshd.sftp.subsystem.SftpConstants;
 
 /**
  * Data container for 'SSH_FXP_STATUS' reply.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpStatusReply implements Reply {
+public class SshFxpStatusReply extends BaseReply {
+
 	private String substatusAsSTR;
-	private int id;
 	private String msg;
 	private String lang;
 	private final int substatus;
 
+    /**
+     * Creates a SshFxpStatusReply instance.
+     *
+     * @param id        The reply id.
+     * @param substatus The sub status.
+     * @param msg       The status message.
+     *
+     * @throws IOException If the given reply is unsupported.
+     */
+    public SshFxpStatusReply(final int id, final int substatus, final String msg)
+            throws IOException {
+        this(id, substatus, msg, "");
+    }
+
 	/**
 	 * Creates a SshFxpStatusReply instance.
 	 * 
@@ -46,9 +61,9 @@ public class SshFxpStatusReply implement
 	 */
 	public SshFxpStatusReply(final int id, final int substatus, final String msg, final String lang)
 			throws IOException {
+        super(id);
 		this.substatus = substatus;
 		this.lang = lang;
-		this.id = id;
 		this.msg = msg;
 
     	switch (substatus) {
@@ -118,24 +133,14 @@ public class SshFxpStatusReply implement
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-		return getReplyCodeName()
-			+ "/" + substatusAsSTR + ": id=" + id + "; msg=" + msg + "; lang=" + lang;
+		return getName() + "[status=" + substatusAsSTR + ", msg=" + msg + "]";
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getReplyCodeName() {
-		return "SSH_FXP_STATUS";
-	}
-
-	/**
-	 * Returns the id.
-	 * 
-	 * @return The id.
-	 */
-	public int getId() {
-		return id;
+	public SftpConstants.Type getMessage() {
+		return SftpConstants.Type.SSH_FXP_STATUS;
 	}
 
 	/**

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpVersionReply.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpVersionReply.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpVersionReply.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/reply/SshFxpVersionReply.java Thu Jan 17 13:09:51 2013
@@ -18,13 +18,14 @@
 */
 package org.apache.sshd.sftp.reply;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_VERSION' reply.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpVersionReply implements Reply {
-	private final int version;
+public class SshFxpVersionReply extends BaseReply {
 
 	/**
 	 * Creates a SshFxpVersionReply instance.
@@ -32,21 +33,21 @@ public class SshFxpVersionReply implemen
 	 * @param version The requested version.
 	 */
 	public SshFxpVersionReply(final int version) {
-		this.version = version;
+		super(version);
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getReplyCodeName() {
-		return "SSH_FXP_VERSION";
+	public SftpConstants.Type getMessage() {
+		return SftpConstants.Type.SSH_FXP_VERSION;
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-		return getReplyCodeName() + ": version=" + version;
+		return getName() + "[version=" + getId() + "]";
 	}
 
 	/**
@@ -55,6 +56,6 @@ public class SshFxpVersionReply implemen
 	 * @return The requested version.
 	 */
 	public int getVersion() {
-		return version;
+		return getId();
 	}
 }

Copied: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/BaseRequest.java (from r1434657, mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/Request.java)
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/BaseRequest.java?p2=mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/BaseRequest.java&p1=mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/Request.java&r1=1434657&r2=1434658&rev=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/Request.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/BaseRequest.java Thu Jan 17 13:09:51 2013
@@ -18,20 +18,23 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.Request;
+
 /**
  * Common ssh request interface.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public abstract class Request {
-	private int id;
+public abstract class BaseRequest implements Request {
+
+	private final int id;
 	
 	/**
 	 * Creates a Request instance.
 	 * 
 	 * @param id The request id.
 	 */
-	public Request(final int id) {
+	public BaseRequest(final int id) {
 		this.id = id;
 	}
 
@@ -49,5 +52,7 @@ public abstract class Request {
 	 * 
 	 * @return The request name.
 	 */
-	public abstract String getName();
+	public String getName() {
+        return getMessage().toString();
+    }
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpCloseRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpCloseRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpCloseRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpCloseRequest.java Thu Jan 17 13:09:51 2013
@@ -19,13 +19,14 @@
 package org.apache.sshd.sftp.request;
 
 import org.apache.sshd.sftp.Handle;
+import org.apache.sshd.sftp.subsystem.SftpConstants;
 
 /**
  * Data container for 'SSH_FXP_CLOSE' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpCloseRequest extends Request {
+public class SshFxpCloseRequest extends BaseRequest {
 	private final Handle handle;
 	private final String handleId;
 
@@ -45,8 +46,8 @@ public class SshFxpCloseRequest extends 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_CLOSE";
+	public SftpConstants.Type getMessage() {
+		return SftpConstants.Type.SSH_FXP_CLOSE;
 	}
 
 	/**
@@ -59,7 +60,7 @@ public class SshFxpCloseRequest extends 
 		} else {
 			sh = "";
 		}
-        return "Status=" + getName() + "; Message=handle=" + handleId + ", file=" + sh + ";";
+        return getName() + "[handle=" + handleId + ", file=" + sh + "]";
 	}
 
 	/**

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpFsetstatRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpFsetstatRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpFsetstatRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpFsetstatRequest.java Thu Jan 17 13:09:51 2013
@@ -18,12 +18,14 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_FSETSTAT' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpFsetstatRequest extends Request {
+public class SshFxpFsetstatRequest extends BaseRequest {
 
 	/**
 	 * Creates a SshFxpFsetstatRequest instance.
@@ -37,14 +39,14 @@ public class SshFxpFsetstatRequest exten
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_FSETSTAT";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_SETSTAT;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-        return "Status=" + getName();
+        return getName() + "[]";
 	}
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpFstatRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpFstatRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpFstatRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpFstatRequest.java Thu Jan 17 13:09:51 2013
@@ -19,13 +19,14 @@
 package org.apache.sshd.sftp.request;
 
 import org.apache.sshd.sftp.Handle;
+import org.apache.sshd.sftp.subsystem.SftpConstants;
 
 /**
  * Data container for 'SSH_FXP_FSTAT' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpFstatRequest extends Request {
+public class SshFxpFstatRequest extends BaseRequest {
 	private final String handle;
 	private final Handle handleRef;
 
@@ -45,9 +46,9 @@ public class SshFxpFstatRequest extends 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_FSTAT";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_FSTAT;
+    }
 
 	/**
 	 * {@inheritDoc}
@@ -59,7 +60,7 @@ public class SshFxpFstatRequest extends 
 		} else {
 			ps = "";
 		}
-        return "Status=" + getName() + "; Message=handle=" + handle + ", file=" + ps + ";";
+        return getName() + "[handle=" + handle + ", file=" + ps + "]";
 	}
 
 	/**

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpInitRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpInitRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpInitRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpInitRequest.java Thu Jan 17 13:09:51 2013
@@ -18,12 +18,14 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_INIT' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpInitRequest extends Request {
+public class SshFxpInitRequest extends BaseRequest {
 	/**
 	 * Creates a SshFxpInitRequest instance.
 	 * 
@@ -36,13 +38,14 @@ public class SshFxpInitRequest extends R
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_INIT";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_INIT;
+    }
+
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-        return "Status=" + getName();
+        return getName() + "[version=" + getId() + "]";
 	}
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpLstatRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpLstatRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpLstatRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpLstatRequest.java Thu Jan 17 13:09:51 2013
@@ -18,37 +18,43 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_STAT' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpLstatRequest extends Request {
+public class SshFxpLstatRequest extends BaseRequest {
+
 	private final String path;
+    private final int flags;
 
 	/**
 	 * Creates a SshFxpLstatRequest instance.
 	 * 
-	 * @param id   The request id.
-	 * @param path The requested path.
+	 * @param id    The request id.
+     * @param path  The requested path.
+     * @param flags The stat flags.
 	 */
-	public SshFxpLstatRequest(final int id, final String path) {
+	public SshFxpLstatRequest(final int id, final String path, final int flags) {
 		super(id);
 		this.path = path;
+        this.flags = flags;
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_STAT";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_STAT;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-        return "Status=" + getName() + "; Message=path=" + path + ";";
+        return getName() + "[path=" + path + "]";
 	}
 
 	/**
@@ -59,4 +65,8 @@ public class SshFxpLstatRequest extends 
 	public String getPath() {
 		return path;
 	}
+
+    public int getFlags() {
+        return flags;
+    }
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpMkdirRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpMkdirRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpMkdirRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpMkdirRequest.java Thu Jan 17 13:09:51 2013
@@ -18,12 +18,14 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_MKDIR' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpMkdirRequest extends Request {
+public class SshFxpMkdirRequest extends BaseRequest {
 	
 	private final String path;
 
@@ -41,15 +43,15 @@ public class SshFxpMkdirRequest extends 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_MKDIR";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_MKDIR;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-        return "Status=" + getName() + "; Message=mkdir " + path + ";";
+        return getName() + "[path=" + path + "]";
 	}
 
 	/**

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpOpenRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpOpenRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpOpenRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpOpenRequest.java Thu Jan 17 13:09:51 2013
@@ -18,28 +18,27 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_OPEN' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpOpenRequest extends Request {
-	private final int pflags;
-	private final Integer acc;
-	private final String path;
+public class SshFxpOpenRequest extends BaseRequest {
+    private final String path;
+    private final int acc;
+	private final int flags;
 
 	/**
 	 * Creates a SshFxpOpenRequest instance.
 	 * 
 	 * @param id     The request id.
 	 * @param path   The path.
-	 * @param pflags The flags.
+	 * @param flags  The flags.
 	 */
-	public SshFxpOpenRequest(final int id, String path, final int pflags) {
-		super(id);
-		this.path = path;
-		this.pflags = pflags;
-		this.acc = null;
+	public SshFxpOpenRequest(final int id, String path, final int flags) {
+        this(id, path, 0, flags);
 	}
 
 	/**
@@ -48,27 +47,27 @@ public class SshFxpOpenRequest extends R
 	 * @param id     The request id.
 	 * @param path   The path.
 	 * @param acc    The acc.
-	 * @param pflags The flags.
+	 * @param flags  The flags.
 	 */
 	public SshFxpOpenRequest(final int id, String path, final int acc, final int flags) {
 		super(id);
 		this.path = path;
 		this.acc = acc;
-		this.pflags = flags;
+		this.flags = flags;
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_OPEN";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_OPEN;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-        return "Status=" + getName();
+        return getName() + "[path=" + path + ", acc=" + acc + ", flags=" + flags + "]";
 	}
 
 	/**
@@ -86,7 +85,7 @@ public class SshFxpOpenRequest extends R
 	 * @return The flags.
 	 */
 	public int getFlags() {
-		return pflags;
+		return flags;
 	}
 
 	/**
@@ -94,7 +93,7 @@ public class SshFxpOpenRequest extends R
 	 * 
 	 * @return The acc.
 	 */
-	public Integer getAcc() {
+	public int getAcc() {
 		return acc;
 	}
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpOpendirRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpOpendirRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpOpendirRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpOpendirRequest.java Thu Jan 17 13:09:51 2013
@@ -18,12 +18,14 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_OPENDIR' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpOpendirRequest extends Request {
+public class SshFxpOpendirRequest extends BaseRequest {
 	private final String path;
 
 	/**
@@ -40,15 +42,15 @@ public class SshFxpOpendirRequest extend
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_OPENDIR";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_OPENDIR;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-        return "Status=" + getName() + "; Message=open directory " + path + ";";
+        return getName() + "[path=" + path + "]";
 	}
 
 	/**

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpReadRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpReadRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpReadRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpReadRequest.java Thu Jan 17 13:09:51 2013
@@ -19,17 +19,18 @@
 package org.apache.sshd.sftp.request;
 
 import org.apache.sshd.sftp.Handle;
+import org.apache.sshd.sftp.subsystem.SftpConstants;
 
 /**
  * Data container for 'SSH_FXP_READ' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpReadRequest extends Request {
+public class SshFxpReadRequest extends BaseRequest {
 	private final String handleId;
 	private final long offset;
 	private final Handle handle;
-	private final int len;
+	private final int length;
 
 	/**
 	 * Creates a SshFxpReadRequest instance.
@@ -37,31 +38,36 @@ public class SshFxpReadRequest extends R
 	 * @param id       The request id.
 	 * @param handleId The according file handle id.
 	 * @param offset   The read offset.
-	 * @param lenFlag  The lenFlag.
+	 * @param length   The length.
 	 * @param handle   The according file handle.
 	 */
 	public SshFxpReadRequest(
-			final int id, final String handleId, final long offset, final int len, final Handle handle) {
+			final int id, final String handleId, final long offset, final int length, final Handle handle) {
 		super(id);
 		this.handleId = handleId;
 		this.offset = offset;
-		this.len = len;
+		this.length = length;
 		this.handle = handle;
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_READ";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_READ;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-        return "Status=" + getName() + "; Message=handle=" + handleId + ", file="
-        		+ getHandle().getFile().getAbsolutePath() + ", offset=" + offset + ";";
+        String ps;
+        if (handle != null && handle.getFile() != null) {
+            ps = handle.getFile().getAbsolutePath();
+        } else {
+            ps = "";
+        }
+        return getName() + "[handle=" + handleId + ", file=" + ps + ", offset=" + offset + ", length=" + length + "]";
 	}
 
 	/**
@@ -83,12 +89,12 @@ public class SshFxpReadRequest extends R
 	}
 
 	/**
-	 * Returns the len flag.
+	 * Returns the length.
 	 * 
-	 * @return The len flag.
+	 * @return The length.
 	 */
-	public int isLen() {
-		return len;
+	public int getLength() {
+		return length;
 	}
 
 	/**
@@ -100,8 +106,4 @@ public class SshFxpReadRequest extends R
 		return offset;
 	}
 
-	public int getLen() {
-		// TODO Auto-generated method stub
-		return 0;
-	}
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpReaddirRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpReaddirRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpReaddirRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpReaddirRequest.java Thu Jan 17 13:09:51 2013
@@ -19,13 +19,14 @@
 package org.apache.sshd.sftp.request;
 
 import org.apache.sshd.sftp.Handle;
+import org.apache.sshd.sftp.subsystem.SftpConstants;
 
 /**
  * Data container for 'SSH_FXP_READDIR' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpReaddirRequest extends Request {
+public class SshFxpReaddirRequest extends BaseRequest {
 	private final String handleId;
 	private final Handle handle;
 
@@ -45,16 +46,21 @@ public class SshFxpReaddirRequest extend
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_READDIR";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_READDIR;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-        return "Status=" + getName() + "; Message="
-        	+ "handle=" + handleId + ", file=" + handle.getFile().getAbsolutePath() + ";";
+        String ps;
+        if (handle != null && handle.getFile() != null) {
+            ps = handle.getFile().getAbsolutePath();
+        } else {
+            ps = "";
+        }
+        return getName() + "[handle=" + handleId + ", file=" + ps + "]";
 	}
 
 	/**

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRealpathRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRealpathRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRealpathRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRealpathRequest.java Thu Jan 17 13:09:51 2013
@@ -18,12 +18,14 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_REALPATH' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpRealpathRequest extends Request {
+public class SshFxpRealpathRequest extends BaseRequest {
 	private final String path;
 
 	/**
@@ -40,15 +42,15 @@ public class SshFxpRealpathRequest exten
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_REALPATH";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_REALPATH;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-        return "Status=" + getName() + "; Message=real path " + path + ";";
+        return getName() + "[path=" + path + "]";
 	}
 
 	/**

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRemoveRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRemoveRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRemoveRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRemoveRequest.java Thu Jan 17 13:09:51 2013
@@ -18,12 +18,14 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_REMOVE' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpRemoveRequest extends Request {
+public class SshFxpRemoveRequest extends BaseRequest {
 	private final String path;
 
 	/**
@@ -40,15 +42,15 @@ public class SshFxpRemoveRequest extends
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_REMOVE";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_REMOVE;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-	    return "Status=" + getName() + "; Message=remove " + path  + ";";
+        return getName() + "[path=" + path + "]";
 	}
 
 	/**

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRenameRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRenameRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRenameRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRenameRequest.java Thu Jan 17 13:09:51 2013
@@ -18,12 +18,14 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_RENAME' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpRenameRequest extends Request {
+public class SshFxpRenameRequest extends BaseRequest {
 	private final String oldPath;
 	private final String newPath;
 
@@ -43,15 +45,15 @@ public class SshFxpRenameRequest extends
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_RENAME";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_RENAME;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-	    return "Status=" + getName() + "; Message=rename" + oldPath + " to " + newPath + ";";
+        return getName() + "[old=" + oldPath + ", new=" + newPath + "]";
 	}
 
 	/**

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRmdirRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRmdirRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRmdirRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpRmdirRequest.java Thu Jan 17 13:09:51 2013
@@ -18,12 +18,14 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_RMDIR' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpRmdirRequest extends Request {
+public class SshFxpRmdirRequest extends BaseRequest {
 	private final String path;
 
 	/**
@@ -40,15 +42,15 @@ public class SshFxpRmdirRequest extends 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_RMDIR";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_RMDIR;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-	    return "Status=" + getName() + "; Message=rmdir " + path + ";";
+        return getName() + "[path=" + path + "]";
 	}
 
 	/**

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpSetstatRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpSetstatRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpSetstatRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpSetstatRequest.java Thu Jan 17 13:09:51 2013
@@ -18,12 +18,14 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_SETSTAT' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpSetstatRequest extends Request {
+public class SshFxpSetstatRequest extends BaseRequest {
 
 	/**
 	 * Creates a SshFxpSetstatRequest instance.
@@ -37,14 +39,14 @@ public class SshFxpSetstatRequest extend
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_SETSTAT";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_SETSTAT;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-        return "Status=" + getName();
+        return getName() + "[]";
 	}
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpStatRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpStatRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpStatRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpStatRequest.java Thu Jan 17 13:09:51 2013
@@ -18,13 +18,17 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for 'SSH_FXP_STAT' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpStatRequest extends Request {
+public class SshFxpStatRequest extends BaseRequest {
+
 	private final String path;
+    private final int flags;
 
 	/**
 	 * Create a SshFxpStatRequest instance.
@@ -32,23 +36,24 @@ public class SshFxpStatRequest extends R
 	 * @param id   The request id.
 	 * @param path The requested file path.
 	 */
-	public SshFxpStatRequest(final int id, final String path) {
+	public SshFxpStatRequest(final int id, final String path, final int flags) {
 		super(id);
 		this.path = path;
+        this.flags = flags;
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_STAT";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_STAT;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-	    return "Status=" + getName() + "; Message=path=" + path + ";";
+        return getName() + "[path=" + path + "]";
 	}
 
 	/**
@@ -59,4 +64,8 @@ public class SshFxpStatRequest extends R
 	public String getPath() {
 		return path;
 	}
+
+    public int getFlags() {
+        return flags;
+    }
 }

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpWriteRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpWriteRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpWriteRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/SshFxpWriteRequest.java Thu Jan 17 13:09:51 2013
@@ -21,13 +21,14 @@ package org.apache.sshd.sftp.request;
 import java.util.Arrays;
 
 import org.apache.sshd.sftp.Handle;
+import org.apache.sshd.sftp.subsystem.SftpConstants;
 
 /**
  * Data container for 'SSH_FXP_WRITE' request.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class SshFxpWriteRequest extends Request {
+public class SshFxpWriteRequest extends BaseRequest {
 	private final String handleId;
 	private final long offset;
 	private final Handle handle;
@@ -63,16 +64,21 @@ public class SshFxpWriteRequest extends 
 	/**
 	 * {@inheritDoc}
 	 */
-	public String getName() {
-		return "SSH_FXP_WRITE";
-	}
+    public SftpConstants.Type getMessage() {
+        return SftpConstants.Type.SSH_FXP_WRITE;
+    }
 
 	/**
 	 * {@inheritDoc}
 	 */
 	public String toString() {
-	    return "Status=" + getName() + "; Message=handle=" + handleId + ", file="
-	    	+ handle.getFile().getAbsolutePath() + ", offset=" + offset + ";";
+        String ps;
+        if (handle != null && handle.getFile() != null) {
+            ps = handle.getFile().getAbsolutePath();
+        } else {
+            ps = "";
+        }
+        return getName() + "[handle=" + handleId + ", file=" + ps + ", offset=" + offset + ", length=" + data.length + "]";
 	}
 
 	/**

Modified: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/UnsupportedRequest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/UnsupportedRequest.java?rev=1434658&r1=1434657&r2=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/UnsupportedRequest.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/request/UnsupportedRequest.java Thu Jan 17 13:09:51 2013
@@ -18,12 +18,14 @@
 */
 package org.apache.sshd.sftp.request;
 
+import org.apache.sshd.sftp.subsystem.SftpConstants;
+
 /**
  * Data container for unknown or unsupported requests.
  * 
  * @author <a href="http://mina.apache.org">Apache MINA Project</a>
  */
-public class UnsupportedRequest extends Request {
+public class UnsupportedRequest extends BaseRequest {
 
 	private final int type;
 
@@ -44,4 +46,11 @@ public class UnsupportedRequest extends 
 	public String getName() {
 		return "Unsupported request: " + type;
 	}
+
+    /**
+     * {@inheritDoc}
+     */
+    public SftpConstants.Type getMessage() {
+        return null;
+    }
 }

Added: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/BaseHandle.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/BaseHandle.java?rev=1434658&view=auto
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/BaseHandle.java (added)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/BaseHandle.java Thu Jan 17 13:09:51 2013
@@ -0,0 +1,48 @@
+/*
+ * 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.sftp.subsystem;
+
+import org.apache.sshd.server.SshFile;
+import org.apache.sshd.sftp.Handle;
+
+import java.io.IOException;
+
+public class BaseHandle implements Handle {
+
+    private final String id;
+    private final SshFile file;
+
+    public BaseHandle(String id, SshFile file) {
+        this.id = id;
+        this.file = file;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public SshFile getFile() {
+        return file;
+    }
+
+    public void close() throws IOException {
+        file.handleClose();
+    }
+
+}

Copied: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/DefaultSftpletContainer.java (from r1434657, mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/DefaultSftpletContainer.java)
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/DefaultSftpletContainer.java?p2=mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/DefaultSftpletContainer.java&p1=mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/DefaultSftpletContainer.java&r1=1434657&r2=1434658&rev=1434658&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/DefaultSftpletContainer.java (original)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/DefaultSftpletContainer.java Thu Jan 17 13:09:51 2013
@@ -16,15 +16,19 @@
 * specific language governing permissions and limitations
 * under the License.
 */
-package org.apache.sshd.sftp;
+package org.apache.sshd.sftp.subsystem;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.sshd.common.Session;
 import org.apache.sshd.server.session.ServerSession;
-import org.apache.sshd.sftp.reply.Reply;
-import org.apache.sshd.sftp.request.Request;
+import org.apache.sshd.sftp.Reply;
+import org.apache.sshd.sftp.Request;
+import org.apache.sshd.sftp.SftpSession;
+import org.apache.sshd.sftp.Sftplet;
+import org.apache.sshd.sftp.request.BaseRequest;
 
 
 /**
@@ -39,7 +43,7 @@ public class DefaultSftpletContainer imp
     /**
      * {@inheritDoc}
      */
-    public void onConnect(final ServerSession session) {
+    public void onConnect(final SftpSession session) {
 		for (Sftplet sftpLet : sftpLetList) {
 			sftpLet.onConnect(session);
 		}
@@ -48,7 +52,7 @@ public class DefaultSftpletContainer imp
     /**
      * {@inheritDoc}
      */
-	public void onDisconnect(final ServerSession session) {
+	public void onDisconnect(final SftpSession session) {
 		for (Sftplet sftpLet : sftpLetList) {
 			sftpLet.onDisconnect(session);
 		}
@@ -57,7 +61,7 @@ public class DefaultSftpletContainer imp
     /**
      * {@inheritDoc}
      */
-	public Reply beforeCommand(final ServerSession session, final Request sftpRequest) {
+	public Reply beforeCommand(final SftpSession session, final Request sftpRequest) {
 		Reply reply = null;
 		for (Sftplet sftpLet : sftpLetList) {
 			reply = sftpLet.beforeCommand(session, sftpRequest);
@@ -68,7 +72,7 @@ public class DefaultSftpletContainer imp
     /**
      * {@inheritDoc}
      */
-	public Reply afterCommand(final ServerSession session, final Request sftpRequest, final Reply sftpReply)
+	public Reply afterCommand(final SftpSession session, final Request sftpRequest, final Reply sftpReply)
 			throws IOException {
 		Reply reply = sftpReply;
 		for (Sftplet sftpLet : sftpLetList) {

Added: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/DirectoryHandle.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/DirectoryHandle.java?rev=1434658&view=auto
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/DirectoryHandle.java (added)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/DirectoryHandle.java Thu Jan 17 13:09:51 2013
@@ -0,0 +1,65 @@
+/*
+ * 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.sftp.subsystem;
+
+import org.apache.sshd.server.SshFile;
+
+import java.util.Iterator;
+import java.util.List;
+
+public class DirectoryHandle extends BaseHandle implements Iterator<SshFile> {
+
+    boolean done;
+    // the directory should be read once at "open directory"
+    List<SshFile> fileList = null;
+    int fileIndex;
+
+    public DirectoryHandle(String id, SshFile file) {
+        super(id, file);
+        fileList = file.listSshFiles();
+        fileIndex = 0;
+    }
+
+    public boolean isDone() {
+        return done;
+    }
+
+    public void setDone(boolean done) {
+        this.done = done;
+    }
+
+    public boolean hasNext() {
+        return fileIndex < fileList.size();
+    }
+
+    public SshFile next() {
+        SshFile f = fileList.get(fileIndex);
+        fileIndex++;
+        return f;
+    }
+
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+
+    public void clearFileList() {
+        // allow the garbage collector to do the job
+        fileList = null;
+    }
+}

Added: mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/FileHandle.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/FileHandle.java?rev=1434658&view=auto
==============================================================================
--- mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/FileHandle.java (added)
+++ mina/sshd/trunk/sshd-sftp/src/main/java/org/apache/sshd/sftp/subsystem/FileHandle.java Thu Jan 17 13:09:51 2013
@@ -0,0 +1,78 @@
+/*
+ * 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.sftp.subsystem;
+
+import org.apache.sshd.common.util.IoUtils;
+import org.apache.sshd.server.SshFile;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class FileHandle extends BaseHandle {
+
+    int flags;
+    OutputStream output;
+    long outputPos;
+    InputStream input;
+    long inputPos;
+
+    public FileHandle(String id, SshFile sshFile, int flags) {
+        super(id, sshFile);
+        this.flags = flags;
+    }
+
+    public int getFlags() {
+        return flags;
+    }
+
+    public int read(byte[] data, long offset) throws IOException {
+        if (input != null && offset != inputPos) {
+            IoUtils.closeQuietly(input);
+            input = null;
+        }
+        if (input == null) {
+            input = getFile().createInputStream(offset);
+            inputPos = offset;
+        }
+        int read = input.read(data);
+        inputPos += read;
+        return read;
+    }
+
+    public void write(byte[] data, long offset) throws IOException {
+        if (output != null && offset != outputPos) {
+            IoUtils.closeQuietly(output);
+            output = null;
+        }
+        if (output == null) {
+            output = getFile().createOutputStream(offset);
+        }
+        output.write(data);
+        outputPos += data.length;
+    }
+
+    @Override
+    public void close() throws IOException {
+        IoUtils.closeQuietly(output, input);
+        output = null;
+        input = null;
+        super.close();
+    }
+}