Update CommandHandler classes to reflect permission-related reply codes in the class javadoc
git-svn-id: svn://svn.code.sf.net/p/mockftpserver/code@201 531de8e6-9941-0410-b38b-9a92acbe0330
diff --git a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/AbstractStoreFileCommandHandler.java b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/AbstractStoreFileCommandHandler.java
index 8fd3c73..f13e780 100644
--- a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/AbstractStoreFileCommandHandler.java
+++ b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/AbstractStoreFileCommandHandler.java
@@ -30,6 +30,9 @@
* <li>If the user has not logged in, then reply with 530 and terminate</li>
* <li>If the pathname parameter is required but missing, then reply with 501 and terminate</li>
* <li>If the required pathname parameter does not specify a valid filename, then reply with 553 and terminate</li>
+ * <li>If the current user does not have write access to the named file, if it already exists, or else to its
+ * parent directory, then reply with 553 and terminate</li>
+ * <li>If the current user does not have execute access to the parent directory, then reply with 553 and terminate</li>
* <li>Send an initial reply of 150</li>
* <li>Read all available bytes from the data connection and store/append to the named file in the server file system</li>
* <li>If file write/store fails, then reply with 553 and terminate</li>
@@ -94,6 +97,9 @@
/**
* Return the path (absolute or relative) for the output file. The default behavior is to return
* the required first parameter for the specified Command. Subclasses may override the default behavior.
+ *
+ * @param command - the Command
+ * @return the output file name
*/
protected String getOutputFile(Command command) {
return command.getRequiredParameter(0);
diff --git a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/AppeCommandHandler.java b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/AppeCommandHandler.java
index 5652fab..b5a7a7e 100644
--- a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/AppeCommandHandler.java
+++ b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/AppeCommandHandler.java
@@ -21,6 +21,9 @@
* <li>If the user has not logged in, then reply with 530 and terminate</li>
* <li>If the required pathname parameter is missing, then reply with 501 and terminate</li>
* <li>If the pathname parameter does not specify a valid filename, then reply with 553 and terminate</li>
+ * <li>If the current user does not have write access to the named file, if it already exists, or else to its
+ * parent directory, then reply with 553 and terminate</li>
+ * <li>If the current user does not have execute access to the parent directory, then reply with 553 and terminate</li>
* <li>Send an initial reply of 150</li>
* <li>Read all available bytes from the data connection and append to the named file in the server file system</li>
* <li>If file write/store fails, then reply with 553 and terminate</li>
diff --git a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/DeleCommandHandler.java b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/DeleCommandHandler.java
index d955086..a59a6af 100644
--- a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/DeleCommandHandler.java
+++ b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/DeleCommandHandler.java
@@ -25,6 +25,7 @@
* <li>If the user has not logged in, then reply with 530</li>
* <li>If the required pathname parameter is missing, then reply with 501</li>
* <li>If the pathname parameter does not specify an existing file then reply with 550</li>
+ * <li>If the current user does not have write access to the parent directory, then reply with 550</li>
* <li>Otherwise, delete the named file and reply with 250</li>
* </ol>
* The supplied pathname may be absolute or relative to the current directory.
diff --git a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/ListCommandHandler.java b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/ListCommandHandler.java
index b2c2929..e6d7865 100644
--- a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/ListCommandHandler.java
+++ b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/ListCommandHandler.java
@@ -30,6 +30,7 @@
* <ol>
* <li>If the user has not logged in, then reply with 530 and terminate</li>
* <li>Send an initial reply of 150</li>
+ * <li>If the current user does not have read access to the file or directory to be listed, then reply with 550 and terminate</li>
* <li>If an error occurs during processing, then send a reply of 451 and terminate</li>
* <li>If the optional pathname parameter is missing, then send a directory listing for
* the current directory across the data connection</li>
@@ -65,12 +66,11 @@
FileSystemEntry entry = (FileSystemEntry) iter.next();
lines.add(getFileSystem().formatDirectoryListing(entry));
}
-// List lines = fileEntries.collect { this.fileSystem.formatDirectoryListing(it) }
String result = StringUtil.join(lines, endOfLine());
session.openDataConnection();
LOG.info("Sending [" + result + "]");
- session.sendData(result.toString().getBytes(), result.length());
+ session.sendData(result.getBytes(), result.length());
session.closeDataConnection();
sendReply(session, ReplyCodes.TRANSFER_DATA_FINAL_OK);
diff --git a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/MkdCommandHandler.java b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/MkdCommandHandler.java
index c28b44e..3087254 100644
--- a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/MkdCommandHandler.java
+++ b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/MkdCommandHandler.java
@@ -27,6 +27,7 @@
* <li>If the required pathname parameter is missing, then reply with 501</li>
* <li>If the parent directory of the specified pathname does not exist, then reply with 550</li>
* <li>If the pathname parameter specifies an existing file or directory, or if the create directory fails, then reply with 550</li>
+ * <li>If the current user does not have write and execute access to the parent directory, then reply with 550</li>
* <li>Otherwise, reply with 257</li>
* </ol>
* The supplied pathname may be absolute or relative to the current directory.
diff --git a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/NlstCommandHandler.java b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/NlstCommandHandler.java
index 27eade4..573e2d9 100644
--- a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/NlstCommandHandler.java
+++ b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/NlstCommandHandler.java
@@ -27,6 +27,7 @@
* <ol>
* <li>If the user has not logged in, then reply with 530 and terminate</li>
* <li>Send an initial reply of 150</li>
+ * <li>If the current user does not have read access to the file or directory to be listed, then reply with 550 and terminate</li>
* <li>If an error occurs during processing, then send a reply of 451 and terminate</li>
* <li>If the optional pathname parameter is missing, then send a directory listing for
* the current directory across the data connection</li>
diff --git a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/RmdCommandHandler.java b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/RmdCommandHandler.java
index 0956343..db5b537 100644
--- a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/RmdCommandHandler.java
+++ b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/RmdCommandHandler.java
@@ -25,6 +25,7 @@
* <li>If the user has not logged in, then reply with 530</li>
* <li>If the required pathname parameter is missing, then reply with 501</li>
* <li>If the pathname parameter does not specify an existing, empty directory, then reply with 550</li>
+ * <li>If the current user does not have write access to the parent directory, then reply with 550</li>
* <li>Otherwise, delete the named directory and reply with 250</li>
* </ol>
* The supplied pathname may be absolute or relative to the current directory.
diff --git a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/RnfrCommandHandler.java b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/RnfrCommandHandler.java
index 62f634b..a22b581 100644
--- a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/RnfrCommandHandler.java
+++ b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/RnfrCommandHandler.java
@@ -26,6 +26,7 @@
* <li>If the user has not logged in, then reply with 530</li>
* <li>If the required FROM pathname parameter is missing, then reply with 501</li>
* <li>If the FROM pathname parameter does not specify a valid file, then reply with 550</li>
+ * <li>If the current user does not have read access to the path, then reply with 550</li>
* <li>Otherwise, reply with 350 and store the FROM path in the session</li>
* </ol>
* The supplied pathname may be absolute or relative to the current directory.
diff --git a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/RntoCommandHandler.java b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/RntoCommandHandler.java
index 069b645..a3cdb14 100644
--- a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/RntoCommandHandler.java
+++ b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/RntoCommandHandler.java
@@ -28,6 +28,7 @@
* <li>If the required TO pathname parameter is missing, then reply with 501</li>
* <li>If the TO pathname parameter does not specify a valid filename, then reply with 553</li>
* <li>If the TO pathname parameter specifies an existing directory, then reply with 553</li>
+ * <li>If the current user does not have write access to the parent directory, then reply with 553</li>
* <li>Otherwise, rename the file, remove the FROM path stored in the session by the RNFR command, and reply with 250</li>
* </ol>
* The supplied pathname may be absolute or relative to the current directory.
diff --git a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/StorCommandHandler.java b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/StorCommandHandler.java
index 591bbfc..492b83e 100644
--- a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/StorCommandHandler.java
+++ b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/StorCommandHandler.java
@@ -21,6 +21,9 @@
* <li>If the user has not logged in, then reply with 530 and terminate</li>
* <li>If the required pathname parameter is missing, then reply with 501 and terminate</li>
* <li>If the pathname parameter does not specify a valid filename, then reply with 553 and terminate</li>
+ * <li>If the current user does not have write access to the named file, if it already exists, or else to its
+ * parent directory, then reply with 553 and terminate</li>
+ * <li>If the current user does not have execute access to the parent directory, then reply with 553 and terminate</li>
* <li>Send an initial reply of 150</li>
* <li>Read all available bytes from the data connection and write out to the named file in the server file system</li>
* <li>If file write/store fails, then reply with 553 and terminate</li>
diff --git a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/StouCommandHandler.java b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/StouCommandHandler.java
index 5d51050..2379c53 100644
--- a/MockFtpServer/src/main/java/org/mockftpserver/fake/command/StouCommandHandler.java
+++ b/MockFtpServer/src/main/java/org/mockftpserver/fake/command/StouCommandHandler.java
@@ -21,7 +21,10 @@
* CommandHandler for the STOU command. Handler logic:
* <ol>
* <li>If the user has not logged in, then reply with 530 and terminate</li>
- * <li>Create a new file within the current directory with a unique name</li>
+ * <li>Create new unique filename within the current directory</li>
+ * <li>If the current user does not have write access to the named file, if it already exists, or else to its
+ * parent directory, then reply with 553 and terminate</li>
+ * <li>If the current user does not have execute access to the parent directory, then reply with 553 and terminate</li>
* <li>Send an initial reply of 150</li>
* <li>Read all available bytes from the data connection and write out to the unique file in the server file system</li>
* <li>If file write/store fails, then reply with 553 and terminate</li>