You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ng...@apache.org on 2008/08/17 21:52:49 UTC
svn commit: r686637 [15/16] - in /mina/ftpserver/trunk:
core/src/main/java/org/apache/ftpserver/
core/src/main/java/org/apache/ftpserver/command/
core/src/main/java/org/apache/ftpserver/config/spring/
core/src/main/java/org/apache/ftpserver/filesystem/...
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/test/TestUtil.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/test/TestUtil.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/test/TestUtil.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/test/TestUtil.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.test;
@@ -35,6 +35,12 @@
import org.apache.ftpserver.util.IoUtils;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class TestUtil {
private static final int DEFAULT_PORT = 12321;
@@ -42,16 +48,17 @@
public static File getBaseDir() {
// check Maven system prop first and use if set
String basedir = System.getProperty("basedir");
- if(basedir != null) {
+ if (basedir != null) {
return new File(basedir);
} else {
return new File(".");
}
}
-
+
/**
* Attempts to find a free port or fallback to a default
- * @throws IOException
+ *
+ * @throws IOException
*
* @throws IOException
*/
@@ -61,25 +68,26 @@
// first try the default port
try {
tmpSocket = new ServerSocket(DEFAULT_PORT);
-
+
port = DEFAULT_PORT;
} catch (IOException e) {
System.out.println("Failed to use default port");
- // didn't work, try to find one dynamically
+ // didn't work, try to find one dynamically
try {
int attempts = 0;
while (port < 1024 && attempts < 1000) {
- attempts++;
+ attempts++;
- tmpSocket = new ServerSocket(0);
+ tmpSocket = new ServerSocket(0);
port = tmpSocket.getLocalPort();
}
} catch (IOException e1) {
- throw new IOException("Failed to find a port to use for testing: "
- + e1.getMessage());
+ throw new IOException(
+ "Failed to find a port to use for testing: "
+ + e1.getMessage());
}
} finally {
if (tmpSocket != null) {
@@ -96,59 +104,62 @@
}
public static String[] getHostAddresses() throws Exception {
- Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
-
+ Enumeration<NetworkInterface> nifs = NetworkInterface
+ .getNetworkInterfaces();
+
List<String> hostIps = new ArrayList<String>();
while (nifs.hasMoreElements()) {
NetworkInterface nif = (NetworkInterface) nifs.nextElement();
Enumeration<InetAddress> ips = nif.getInetAddresses();
-
+
while (ips.hasMoreElements()) {
InetAddress ip = (InetAddress) ips.nextElement();
- if(ip instanceof java.net.Inet4Address) {
- hostIps.add(ip.getHostAddress());
+ if (ip instanceof java.net.Inet4Address) {
+ hostIps.add(ip.getHostAddress());
} else {
- // IPv6 not tested
+ // IPv6 not tested
}
}
}
-
+
return hostIps.toArray(new String[0]);
}
public static InetAddress findNonLocalhostIp() throws Exception {
- Enumeration<NetworkInterface> nifs = NetworkInterface.getNetworkInterfaces();
-
+ Enumeration<NetworkInterface> nifs = NetworkInterface
+ .getNetworkInterfaces();
+
while (nifs.hasMoreElements()) {
NetworkInterface nif = (NetworkInterface) nifs.nextElement();
Enumeration<InetAddress> ips = nif.getInetAddresses();
-
+
while (ips.hasMoreElements()) {
InetAddress ip = (InetAddress) ips.nextElement();
- if(ip instanceof java.net.Inet4Address && !ip.isLoopbackAddress()) {
+ if (ip instanceof java.net.Inet4Address
+ && !ip.isLoopbackAddress()) {
return ip;
} else {
// IPv6 not tested
}
}
}
-
+
return null;
}
-
- public static void writeDataToFile(File file, byte[] data) throws IOException {
+ public static void writeDataToFile(File file, byte[] data)
+ throws IOException {
FileOutputStream fos = null;
-
- try{
+
+ try {
fos = new FileOutputStream(file);
-
+
fos.write(data);
} finally {
IoUtils.close(fos);
}
}
-
+
public static void assertFileEqual(byte[] expected, File file)
throws Exception {
ByteArrayOutputStream baos = null;
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/BaseUserTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/BaseUserTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/BaseUserTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/BaseUserTest.java Sun Aug 17 12:52:42 2008
@@ -15,19 +15,23 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.usermanager;
-
-
import junit.framework.TestCase;
import org.apache.ftpserver.ftplet.Authority;
import org.apache.ftpserver.ftplet.AuthorizationRequest;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class BaseUserTest extends TestCase {
-
+
private static final Authority ALWAYS_ALLOW_AUTHORITY = new Authority() {
public AuthorizationRequest authorize(AuthorizationRequest request) {
return request;
@@ -42,7 +46,7 @@
public AuthorizationRequest authorize(AuthorizationRequest request) {
return null;
}
-
+
public boolean canAuthorize(AuthorizationRequest request) {
return true;
}
@@ -52,66 +56,56 @@
public AuthorizationRequest authorize(AuthorizationRequest request) {
return null;
}
-
+
public boolean canAuthorize(AuthorizationRequest request) {
return false;
}
};
-
- private static final AuthorizationRequest REQUEST = new AuthorizationRequest(){};
-
+
+ private static final AuthorizationRequest REQUEST = new AuthorizationRequest() {
+ };
+
private BaseUser user = new BaseUser();
-
+
public void testAllow() {
- Authority[] authorities = new Authority[]{
- ALWAYS_ALLOW_AUTHORITY
- };
-
-
+ Authority[] authorities = new Authority[] { ALWAYS_ALLOW_AUTHORITY };
+
user.setAuthorities(authorities);
-
+
assertSame(REQUEST, user.authorize(REQUEST));
}
public void testDisallow() {
- Authority[] authorities = new Authority[]{
- NEVER_ALLOW_AUTHORITY
- };
-
+ Authority[] authorities = new Authority[] { NEVER_ALLOW_AUTHORITY };
+
user.setAuthorities(authorities);
-
+
assertNull(user.authorize(REQUEST));
}
public void testMultipleDisallowLast() {
- Authority[] authorities = new Authority[]{
- ALWAYS_ALLOW_AUTHORITY,
- NEVER_ALLOW_AUTHORITY
- };
-
+ Authority[] authorities = new Authority[] { ALWAYS_ALLOW_AUTHORITY,
+ NEVER_ALLOW_AUTHORITY };
+
user.setAuthorities(authorities);
-
+
assertNull(user.authorize(REQUEST));
}
public void testMultipleAllowLast() {
- Authority[] authorities = new Authority[]{
- NEVER_ALLOW_AUTHORITY,
- ALWAYS_ALLOW_AUTHORITY
- };
-
+ Authority[] authorities = new Authority[] { NEVER_ALLOW_AUTHORITY,
+ ALWAYS_ALLOW_AUTHORITY };
+
user.setAuthorities(authorities);
-
+
assertNull(user.authorize(REQUEST));
}
public void testNonCanAuthorize() {
- Authority[] authorities = new Authority[]{
- CANT_AUTHORITY
- };
-
+ Authority[] authorities = new Authority[] { CANT_AUTHORITY };
+
user.setAuthorities(authorities);
-
+
assertNull(user.authorize(REQUEST));
}
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/ConcurrentLoginPermissionTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/ConcurrentLoginPermissionTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/ConcurrentLoginPermissionTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/ConcurrentLoginPermissionTest.java Sun Aug 17 12:52:42 2008
@@ -15,63 +15,74 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.usermanager;
-
-
import junit.framework.TestCase;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class ConcurrentLoginPermissionTest extends TestCase {
-
+
public void testCanAuthorize() {
- ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4, 2);
+ ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4,
+ 2);
ConcurrentLoginRequest request = new ConcurrentLoginRequest(1, 1);
-
+
assertTrue(permission.canAuthorize(request));
}
public void testAllowBoth() {
- ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4, 2);
+ ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4,
+ 2);
ConcurrentLoginRequest request = new ConcurrentLoginRequest(1, 1);
-
+
assertNotNull(permission.authorize(request));
}
public void testMaxValuesBoth() {
- ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4, 2);
+ ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4,
+ 2);
ConcurrentLoginRequest request = new ConcurrentLoginRequest(4, 2);
-
+
assertNotNull(permission.authorize(request));
}
public void testMaxLoginsTooLarge() {
- ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4, 2);
+ ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4,
+ 2);
ConcurrentLoginRequest request = new ConcurrentLoginRequest(5, 2);
-
+
assertNull(permission.authorize(request));
}
public void testMaxLoginsPerIPTooLarge() {
- ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4, 2);
+ ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4,
+ 2);
ConcurrentLoginRequest request = new ConcurrentLoginRequest(3, 3);
-
+
assertNull(permission.authorize(request));
}
public void testAllowAnyMaxLogins() {
- ConcurrentLoginPermission permission = new ConcurrentLoginPermission(0, 2);
+ ConcurrentLoginPermission permission = new ConcurrentLoginPermission(0,
+ 2);
ConcurrentLoginRequest request = new ConcurrentLoginRequest(5, 2);
-
+
assertNotNull(permission.authorize(request));
}
public void testAllowAnyMaxLoginsPerIP() {
- ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4, 0);
+ ConcurrentLoginPermission permission = new ConcurrentLoginPermission(4,
+ 0);
ConcurrentLoginRequest request = new ConcurrentLoginRequest(3, 3);
-
+
assertNotNull(permission.authorize(request));
}
-
+
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/DbUserManagerTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/DbUserManagerTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/DbUserManagerTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/DbUserManagerTest.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.usermanager;
@@ -30,40 +30,57 @@
import org.apache.ftpserver.util.IoUtils;
import org.hsqldb.jdbc.jdbcDataSource;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class DbUserManagerTest extends UserManagerTestTemplate {
- private static final File INIT_SQL_SCRIPT = new File(TestUtil.getBaseDir(), "src/test/resources/dbusermanagertest-hsql.sql");
-
+ private static final File INIT_SQL_SCRIPT = new File(TestUtil.getBaseDir(),
+ "src/test/resources/dbusermanagertest-hsql.sql");
+
private jdbcDataSource ds;
+
private Connection conn;
-
+
private void createDatabase() throws Exception {
conn = ds.getConnection();
conn.setAutoCommit(true);
-
+
String ddl = IoUtils.readFully(new FileReader(INIT_SQL_SCRIPT));
-
+
Statement stm = conn.createStatement();
stm.execute(ddl);
}
-
+
protected UserManager createUserManager() throws FtpException {
DbUserManager manager = new DbUserManager();
-
+
manager.setDataSource(ds);
- manager.setSqlUserInsert("INSERT INTO FTP_USER (userid, userpassword, homedirectory, enableflag, writepermission, idletime, uploadrate, downloadrate, maxloginnumber, maxloginperip) VALUES ('{userid}', '{userpassword}', '{homedirectory}', '{enableflag}', '{writepermission}', {idletime}, {uploadrate}, {downloadrate}, {maxloginnumber}, {maxloginperip})");
- manager.setSqlUserUpdate("UPDATE FTP_USER SET userpassword='{userpassword}',homedirectory='{homedirectory}',enableflag='{enableflag}',writepermission='{writepermission}',idletime={idletime},uploadrate={uploadrate},downloadrate={downloadrate},maxloginnumber={maxloginnumber}, maxloginperip={maxloginperip} WHERE userid='{userid}'");
- manager.setSqlUserDelete("DELETE FROM FTP_USER WHERE userid = '{userid}'");
- manager.setSqlUserSelect("SELECT * FROM FTP_USER WHERE userid = '{userid}'");
- manager.setSqlUserSelectAll("SELECT userid FROM FTP_USER ORDER BY userid");
- manager.setSqlUserAuthenticate("SELECT userid FROM FTP_USER WHERE userid='{userid}' AND userpassword='{userpassword}'");
- manager.setSqlUserAdmin("SELECT userid FROM FTP_USER WHERE userid='{userid}' AND userid='admin'");
-
+ manager
+ .setSqlUserInsert("INSERT INTO FTP_USER (userid, userpassword, homedirectory, enableflag, writepermission, idletime, uploadrate, downloadrate, maxloginnumber, maxloginperip) VALUES ('{userid}', '{userpassword}', '{homedirectory}', '{enableflag}', '{writepermission}', {idletime}, {uploadrate}, {downloadrate}, {maxloginnumber}, {maxloginperip})");
+ manager
+ .setSqlUserUpdate("UPDATE FTP_USER SET userpassword='{userpassword}',homedirectory='{homedirectory}',enableflag='{enableflag}',writepermission='{writepermission}',idletime={idletime},uploadrate={uploadrate},downloadrate={downloadrate},maxloginnumber={maxloginnumber}, maxloginperip={maxloginperip} WHERE userid='{userid}'");
+ manager
+ .setSqlUserDelete("DELETE FROM FTP_USER WHERE userid = '{userid}'");
+ manager
+ .setSqlUserSelect("SELECT * FROM FTP_USER WHERE userid = '{userid}'");
+ manager
+ .setSqlUserSelectAll("SELECT userid FROM FTP_USER ORDER BY userid");
+ manager
+ .setSqlUserAuthenticate("SELECT userid FROM FTP_USER WHERE userid='{userid}' AND userpassword='{userpassword}'");
+ manager
+ .setSqlUserAdmin("SELECT userid FROM FTP_USER WHERE userid='{userid}' AND userid='admin'");
+
return manager;
-
+
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
@@ -71,19 +88,17 @@
ds.setDatabase("jdbc:hsqldb:mem:ftpd");
ds.setUser("sa");
ds.setPassword("");
-
-
+
createDatabase();
-
+
super.setUp();
}
-
protected void tearDown() throws Exception {
Statement stm = conn.createStatement();
stm.execute("SHUTDOWN");
-
+
super.tearDown();
}
-
+
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/PropertiesUserManagerTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/PropertiesUserManagerTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/PropertiesUserManagerTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/PropertiesUserManagerTest.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.usermanager;
@@ -28,16 +28,23 @@
import org.apache.ftpserver.ftplet.UserManager;
import org.apache.ftpserver.util.IoUtils;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class PropertiesUserManagerTest extends UserManagerTestTemplate {
private static final File TEST_DIR = new File("test-tmp");
+
private static final File USERS_FILE = new File(TEST_DIR, "users.props");
-
+
private void createUserFile() throws IOException {
Properties users = new Properties();
users.setProperty("FtpServer.user.user1.userpassword", "pw1");
users.setProperty("FtpServer.user.user1.homedirectory", "home");
-
+
users.setProperty("FtpServer.user.user2.userpassword", "pw2");
users.setProperty("FtpServer.user.user2.homedirectory", "home");
users.setProperty("FtpServer.user.user2.writepermission", "true");
@@ -50,42 +57,41 @@
users.setProperty("FtpServer.user.user3.userpassword", "");
users.setProperty("FtpServer.user.user3.homedirectory", "home");
-
+
FileOutputStream fos = new FileOutputStream(USERS_FILE);
users.store(fos, null);
-
+
fos.close();
}
-
-
protected UserManager createUserManager() throws FtpException {
PropertiesUserManager um = new PropertiesUserManager();
um.setPropFile(USERS_FILE);
um.setEncryptPasswords(false);
um.configure();
-
+
return um;
-
+
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
-
+
TEST_DIR.mkdirs();
-
+
createUserFile();
-
+
super.setUp();
}
-
protected void tearDown() throws Exception {
super.tearDown();
-
+
IoUtils.delete(TEST_DIR);
}
-
+
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/UserManagerTestTemplate.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/UserManagerTestTemplate.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/UserManagerTestTemplate.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/UserManagerTestTemplate.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.usermanager;
@@ -30,13 +30,21 @@
import org.apache.ftpserver.ftplet.User;
import org.apache.ftpserver.ftplet.UserManager;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public abstract class UserManagerTestTemplate extends TestCase {
protected UserManager userManager;
protected abstract UserManager createUserManager() throws Exception;
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
@@ -44,55 +52,62 @@
}
public void testAuthenticate() throws Exception {
- assertNotNull(userManager.authenticate(new UsernamePasswordAuthentication("user1", "pw1")));
+ assertNotNull(userManager
+ .authenticate(new UsernamePasswordAuthentication("user1", "pw1")));
}
public void testAuthenticateWrongPassword() throws Exception {
try {
- userManager.authenticate(new UsernamePasswordAuthentication("user1", "foo"));
+ userManager.authenticate(new UsernamePasswordAuthentication(
+ "user1", "foo"));
fail("Must throw AuthenticationFailedException");
- } catch(AuthenticationFailedException e) {
+ } catch (AuthenticationFailedException e) {
// ok
}
}
public void testAuthenticateUnknownUser() throws Exception {
try {
- userManager.authenticate(new UsernamePasswordAuthentication("foo", "foo"));
+ userManager.authenticate(new UsernamePasswordAuthentication("foo",
+ "foo"));
fail("Must throw AuthenticationFailedException");
- } catch(AuthenticationFailedException e) {
+ } catch (AuthenticationFailedException e) {
// ok
}
}
-
+
public void testAuthenticateEmptyPassword() throws Exception {
- assertNotNull(userManager.authenticate(new UsernamePasswordAuthentication("user3", "")));
+ assertNotNull(userManager
+ .authenticate(new UsernamePasswordAuthentication("user3", "")));
}
public void testAuthenticateNullPassword() throws Exception {
- assertNotNull(userManager.authenticate(new UsernamePasswordAuthentication("user3", null)));
+ assertNotNull(userManager
+ .authenticate(new UsernamePasswordAuthentication("user3", null)));
+ }
+
+ public static class FooAuthentication implements Authentication {
}
- public static class FooAuthentication implements Authentication {}
-
public void testAuthenticateNullUser() throws Exception {
try {
- userManager.authenticate(new UsernamePasswordAuthentication(null, "foo"));
+ userManager.authenticate(new UsernamePasswordAuthentication(null,
+ "foo"));
fail("Must throw AuthenticationFailedException");
- } catch(AuthenticationFailedException e) {
+ } catch (AuthenticationFailedException e) {
// ok
}
}
-
+
public void testAuthenticateUnknownAuthentication() throws Exception {
try {
userManager.authenticate(new FooAuthentication());
fail("Must throw IllegalArgumentException");
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
// ok
}
}
-
+
public void testDoesExist() throws Exception {
assertTrue(userManager.doesExist("user1"));
assertTrue(userManager.doesExist("user2"));
@@ -142,7 +157,7 @@
public void testGetUserByName() throws Exception {
User user = userManager.getUserByName("user2");
-
+
assertEquals("user2", user.getName());
assertNull("Password must not be set", user.getPassword());
assertEquals("home", user.getHomeDirectory());
@@ -161,9 +176,10 @@
private int getMaxDownloadRate(User user) {
TransferRateRequest transferRateRequest = new TransferRateRequest();
- transferRateRequest = (TransferRateRequest) user.authorize(transferRateRequest);
-
- if(transferRateRequest != null) {
+ transferRateRequest = (TransferRateRequest) user
+ .authorize(transferRateRequest);
+
+ if (transferRateRequest != null) {
return transferRateRequest.getMaxDownloadRate();
} else {
return 0;
@@ -172,37 +188,42 @@
private int getMaxUploadRate(User user) {
TransferRateRequest transferRateRequest = new TransferRateRequest();
- transferRateRequest = (TransferRateRequest) user.authorize(transferRateRequest);
-
- if(transferRateRequest != null) {
+ transferRateRequest = (TransferRateRequest) user
+ .authorize(transferRateRequest);
+
+ if (transferRateRequest != null) {
return transferRateRequest.getMaxUploadRate();
} else {
return 0;
- }
+ }
}
private int getMaxLoginNumber(User user) {
- ConcurrentLoginRequest concurrentLoginRequest = new ConcurrentLoginRequest(0, 0);
- concurrentLoginRequest = (ConcurrentLoginRequest) user.authorize(concurrentLoginRequest);
-
- if(concurrentLoginRequest != null) {
+ ConcurrentLoginRequest concurrentLoginRequest = new ConcurrentLoginRequest(
+ 0, 0);
+ concurrentLoginRequest = (ConcurrentLoginRequest) user
+ .authorize(concurrentLoginRequest);
+
+ if (concurrentLoginRequest != null) {
return concurrentLoginRequest.getMaxConcurrentLogins();
} else {
return 0;
- }
+ }
}
private int getMaxLoginPerIP(User user) {
- ConcurrentLoginRequest concurrentLoginRequest = new ConcurrentLoginRequest(0, 0);
- concurrentLoginRequest = (ConcurrentLoginRequest) user.authorize(concurrentLoginRequest);
-
- if(concurrentLoginRequest != null) {
+ ConcurrentLoginRequest concurrentLoginRequest = new ConcurrentLoginRequest(
+ 0, 0);
+ concurrentLoginRequest = (ConcurrentLoginRequest) user
+ .authorize(concurrentLoginRequest);
+
+ if (concurrentLoginRequest != null) {
return concurrentLoginRequest.getMaxConcurrentLoginsPerIP();
} else {
return 0;
- }
+ }
}
-
+
public void testSave() throws Exception {
BaseUser user = new BaseUser();
user.setName("newuser");
@@ -218,12 +239,11 @@
user.setAuthorities(authorities.toArray(new Authority[0]));
userManager.save(user);
-
+
UserManager newUserManager = createUserManager();
-
User actualUser = newUserManager.getUserByName("newuser");
-
+
assertEquals(user.getName(), actualUser.getName());
assertNull(actualUser.getPassword());
assertEquals(user.getHomeDirectory(), actualUser.getHomeDirectory());
@@ -241,9 +261,9 @@
user.setName("user2");
user.setHomeDirectory("newhome");
userManager.save(user);
-
+
User actualUser = userManager.getUserByName("user2");
-
+
assertEquals("user2", actualUser.getName());
assertNull(actualUser.getPassword());
assertEquals("newhome", actualUser.getHomeDirectory());
@@ -261,11 +281,11 @@
user.setName("newuser");
user.setPassword("newpw");
userManager.save(user);
-
+
UserManager newUserManager = createUserManager();
-
+
User actualUser = newUserManager.getUserByName("newuser");
-
+
assertEquals(user.getName(), actualUser.getName());
assertNull(actualUser.getPassword());
assertEquals("/", actualUser.getHomeDirectory());
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/UsernamePasswordAuthenticationTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/UsernamePasswordAuthenticationTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/UsernamePasswordAuthenticationTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/UsernamePasswordAuthenticationTest.java Sun Aug 17 12:52:42 2008
@@ -15,33 +15,42 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.usermanager;
import junit.framework.TestCase;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class UsernamePasswordAuthenticationTest extends TestCase {
-
+
public void testConstructor() {
- UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication("user", "pass");
-
+ UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication(
+ "user", "pass");
+
assertEquals("user", auth.getUsername());
assertEquals("pass", auth.getPassword());
}
public void testConstructorNullUsername() {
- UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication(null, "pass");
-
+ UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication(
+ null, "pass");
+
assertNull(auth.getUsername());
assertEquals("pass", auth.getPassword());
}
-
+
public void testConstructorNullPassword() {
- UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication("user", null);
-
+ UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication(
+ "user", null);
+
assertEquals("user", auth.getUsername());
assertNull(auth.getPassword());
}
-
+
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/WritePermissionTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/WritePermissionTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/WritePermissionTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/WritePermissionTest.java Sun Aug 17 12:52:42 2008
@@ -15,31 +15,33 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.usermanager;
-
-
import junit.framework.TestCase;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class WritePermissionTest extends TestCase {
-
public void testRootDir() throws Exception {
WritePermission permission = new WritePermission("/");
-
- assertNotNull(permission.authorize(new WriteRequest("/")));
+
+ assertNotNull(permission.authorize(new WriteRequest("/")));
}
-
-
+
public void testDirs() throws Exception {
WritePermission permission = new WritePermission("/bar");
-
- assertNull(permission.authorize(new WriteRequest("/foo")));
- assertNull(permission.authorize(new WriteRequest("/foo/bar")));
- assertNotNull(permission.authorize(new WriteRequest("/bar")));
- assertNotNull(permission.authorize(new WriteRequest("/bar/foo")));
+
+ assertNull(permission.authorize(new WriteRequest("/foo")));
+ assertNull(permission.authorize(new WriteRequest("/foo/bar")));
+ assertNotNull(permission.authorize(new WriteRequest("/bar")));
+ assertNotNull(permission.authorize(new WriteRequest("/bar/foo")));
}
}
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/BasePropertiesTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/BasePropertiesTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/BasePropertiesTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/BasePropertiesTest.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.util;
@@ -31,6 +31,12 @@
import org.apache.ftpserver.ftplet.FtpException;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class BasePropertiesTest extends TestCase {
public void testGetBoolean() throws FtpException {
@@ -43,7 +49,7 @@
props.setProperty("bool6", "False");
props.setProperty("bool7", "foo");
props.setProperty("bool8", "");
-
+
assertEquals(true, props.getBoolean("bool1"));
assertEquals(true, props.getBoolean("bool2"));
assertEquals(true, props.getBoolean("bool3"));
@@ -52,59 +58,58 @@
assertEquals(false, props.getBoolean("bool6"));
assertEquals(false, props.getBoolean("bool7"));
assertEquals(false, props.getBoolean("bool8"));
-
+
// Unknown key
- try{
+ try {
props.getBoolean("foo");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
-
+
// default values
assertEquals(true, props.getBoolean("foo", true));
assertEquals(false, props.getBoolean("foo", false));
assertEquals(true, props.getBoolean("bool1", false));
assertEquals(false, props.getBoolean("bool4", true));
}
-
+
public void testSetBoolean() throws FtpException {
BaseProperties props = new BaseProperties();
props.setProperty("b1", true);
-
+
assertEquals(true, props.getBoolean("b1"));
assertEquals("true", props.getProperty("b1"));
- assertEquals("true", props.getString("b1"));
+ assertEquals("true", props.getString("b1"));
}
public void testGetString() throws FtpException {
BaseProperties props = new BaseProperties();
props.setProperty("s1", "bar");
-
+
assertEquals("bar", props.getString("s1"));
-
- // Unknown value
- try{
+ // Unknown value
+ try {
props.getString("foo");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
-
+
// default values
assertEquals("bar", props.getString("s1", "baz"));
assertEquals("baz", props.getString("foo", "baz"));
}
-
+
public void testSetString() throws FtpException {
BaseProperties props = new BaseProperties();
props.setProperty("s1", "bar");
-
+
assertEquals("bar", props.getProperty("s1"));
- assertEquals("bar", props.getString("s1"));
+ assertEquals("bar", props.getString("s1"));
}
-
+
public void testGetInteger() throws FtpException {
BaseProperties props = new BaseProperties();
props.setProperty("int1", "1");
@@ -113,43 +118,43 @@
props.setProperty("int4", "foo");
props.setProperty("int5", "");
props.setProperty("int6", "99999999999999999");
-
+
assertEquals(1, props.getInteger("int1"));
assertEquals(123, props.getInteger("int2"));
-
- try{
+
+ try {
props.getInteger("int3");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
- try{
+ try {
props.getInteger("int4");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
- try{
+ try {
props.getInteger("int5");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
- try{
+ try {
props.getInteger("int6");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
- // Unknown value
- try{
+ // Unknown value
+ try {
props.getInteger("foo");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
-
+
// default values
assertEquals(1, props.getInteger("int1", 7));
assertEquals(7, props.getInteger("int3", 7));
@@ -158,16 +163,16 @@
assertEquals(7, props.getInteger("int6", 7));
assertEquals(7, props.getInteger("foo", 7));
}
-
+
public void testSetInteger() throws FtpException {
BaseProperties props = new BaseProperties();
props.setProperty("i1", 1);
-
+
assertEquals(1, props.getInteger("i1"));
assertEquals("1", props.getProperty("i1"));
- assertEquals("1", props.getString("i1"));
+ assertEquals("1", props.getString("i1"));
}
-
+
public void testGetDouble() throws FtpException {
BaseProperties props = new BaseProperties();
props.setProperty("d1", "1");
@@ -175,37 +180,37 @@
props.setProperty("d3", "1,23");
props.setProperty("d4", "foo");
props.setProperty("d5", "");
-
+
assertEquals(1D, props.getDouble("d1"), 0.1);
assertEquals(1.23D, props.getDouble("d2"), 0.1);
-
- try{
+
+ try {
props.getDouble("d3");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
- try{
+ try {
props.getDouble("d4");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
- try{
+ try {
props.getDouble("d5");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
-
- // Unknown value
- try{
+
+ // Unknown value
+ try {
props.getDouble("foo");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
-
+
// default values
assertEquals(1, props.getDouble("d1", 7), 0.1);
assertEquals(7, props.getDouble("d3", 7), 0.1);
@@ -213,16 +218,16 @@
assertEquals(7, props.getDouble("d5", 7), 0.1);
assertEquals(7, props.getDouble("foo", 7), 0.1);
}
-
+
public void testSetDouble() throws FtpException {
BaseProperties props = new BaseProperties();
props.setProperty("d1", 1.23);
-
+
assertEquals(1.23, props.getDouble("d1"), 0.1);
assertEquals("1.23", props.getProperty("d1"));
- assertEquals("1.23", props.getString("d1"));
+ assertEquals("1.23", props.getString("d1"));
}
-
+
public void testGetLong() throws FtpException {
BaseProperties props = new BaseProperties();
props.setProperty("l1", "1");
@@ -231,38 +236,38 @@
props.setProperty("l4", "foo");
props.setProperty("l5", "");
props.setProperty("l6", "99999999999999999");
-
+
assertEquals(1, props.getLong("l1"));
assertEquals(123, props.getLong("l2"));
assertEquals(99999999999999999L, props.getLong("l6"));
-
- try{
+
+ try {
props.getLong("l3");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
- try{
+ try {
props.getLong("l4");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
- try{
+ try {
props.getLong("l5");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
- // Unknown value
- try{
+ // Unknown value
+ try {
props.getLong("foo");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
-
+
// default values
assertEquals(1, props.getLong("l1", 7));
assertEquals(7, props.getLong("l3", 7));
@@ -274,118 +279,115 @@
public void testSetLong() throws FtpException {
BaseProperties props = new BaseProperties();
props.setProperty("l1", 1L);
-
+
assertEquals(1, props.getLong("l1"));
assertEquals("1", props.getProperty("l1"));
- assertEquals("1", props.getString("l1"));
+ assertEquals("1", props.getString("l1"));
}
-
+
public void testGetClass() throws FtpException {
BaseProperties props = new BaseProperties();
props.setProperty("c1", "java.lang.String");
props.setProperty("c2", "foo");
-
assertEquals(String.class, props.getClass("c1"));
-
- try{
+
+ try {
props.getClass("c2");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
- // Unknown value
- try{
+ // Unknown value
+ try {
props.getClass("foo");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
-
+
// default values
assertEquals(String.class, props.getClass("c1", Integer.class));
assertEquals(Integer.class, props.getClass("c2", Integer.class));
assertEquals(Integer.class, props.getClass("foo", Integer.class));
}
-
+
public void testSetClass() throws FtpException {
BaseProperties props = new BaseProperties();
props.setProperty("c1", String.class);
-
+
assertEquals(String.class, props.getClass("c1"));
assertEquals("java.lang.String", props.getProperty("c1"));
- assertEquals("java.lang.String", props.getString("c1"));
+ assertEquals("java.lang.String", props.getString("c1"));
}
-
+
public void testGetDate() throws FtpException {
Date d1 = new Date();
Date d2 = new Date(100);
DateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSzzz");
-
+
BaseProperties props = new BaseProperties();
props.setProperty("d1", format.format(d1));
props.setProperty("d2", "foo");
-
assertEquals(d1, props.getDate("d1", format));
-
- try{
+
+ try {
props.getDate("d2", format);
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
- // Unknown value
- try{
+ // Unknown value
+ try {
props.getDate("foo", format);
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
-
+
// default values
assertEquals(d1, props.getDate("d1", format, d2));
assertEquals(d2, props.getDate("d2", format, d2));
assertEquals(d2, props.getDate("foo", format, d2));
}
-
+
public void testSetDate() throws FtpException {
Date d = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSzzz");
-
+
BaseProperties props = new BaseProperties();
props.setProperty("d1", d, format);
-
+
assertEquals(d, props.getDate("d1", format));
assertEquals(format.format(d), props.getProperty("d1"));
- assertEquals(format.format(d), props.getString("d1"));
+ assertEquals(format.format(d), props.getString("d1"));
}
-
+
public void testGetDateFormat() throws FtpException {
SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMddHHmmssSSSzzz");
SimpleDateFormat format2 = new SimpleDateFormat("yyyy");
-
+
BaseProperties props = new BaseProperties();
props.setProperty("d1", "yyyyMMddHHmmssSSSzzz");
props.setProperty("d2", "foo");
-
assertEquals(format1, props.getDateFormat("d1"));
-
- try{
+
+ try {
props.getDateFormat("d2");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
- // Unknown value
- try{
+ // Unknown value
+ try {
props.getDateFormat("foo");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
@@ -394,33 +396,32 @@
assertEquals(format2, props.getDateFormat("d2", format2));
assertEquals(format2, props.getDateFormat("foo", format2));
}
-
+
public void testSetDateFormat() throws FtpException {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSSzzz");
-
+
BaseProperties props = new BaseProperties();
props.setProperty("f1", format);
-
+
assertEquals(format, props.getDateFormat("f1"));
assertEquals("yyyyMMddHHmmssSSSzzz", props.getProperty("f1"));
- assertEquals("yyyyMMddHHmmssSSSzzz", props.getString("f1"));
+ assertEquals("yyyyMMddHHmmssSSSzzz", props.getString("f1"));
}
-
+
public void testGetFile() throws FtpException {
File file1 = new File("test-tmp/test1.txt").getAbsoluteFile();
File file2 = new File("test-tmp/test2.txt").getAbsoluteFile();
-
+
BaseProperties props = new BaseProperties();
props.setProperty("f1", file1.getAbsolutePath());
-
assertEquals(file1, props.getFile("f1"));
- // Unknown value
- try{
+ // Unknown value
+ try {
props.getFile("foo");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
@@ -428,90 +429,87 @@
assertEquals(file1, props.getFile("f1", file2));
assertEquals(file2, props.getFile("foo", file2));
}
-
+
public void testSetFile() throws FtpException {
File file = new File("test-tmp/test1.txt").getAbsoluteFile();
-
+
BaseProperties props = new BaseProperties();
props.setProperty("f1", file);
-
+
assertEquals(file, props.getFile("f1"));
assertEquals(file.getAbsolutePath(), props.getProperty("f1"));
- assertEquals(file.getAbsolutePath(), props.getString("f1"));
+ assertEquals(file.getAbsolutePath(), props.getString("f1"));
}
public void testGetInetAddress() throws FtpException, UnknownHostException {
InetAddress a1 = InetAddress.getByName("1.2.3.4");
InetAddress a2 = InetAddress.getByName("localhost");
InetAddress a3 = InetAddress.getByName("1.2.3.5");
-
+
BaseProperties props = new BaseProperties();
props.setProperty("a1", "1.2.3.4");
props.setProperty("a2", "localhost");
props.setProperty("a4", "1.2.3.4.5");
-
-
+
assertEquals(a1, props.getInetAddress("a1"));
assertEquals(a2, props.getInetAddress("a2"));
- // Unknown value
- try{
+ // Unknown value
+ try {
props.getInetAddress("foo");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
// Incorrect host name
- try{
+ try {
props.getInetAddress("a4");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
-
+
// default values
assertEquals(a1, props.getInetAddress("a1", a3));
assertEquals(a3, props.getInetAddress("foo", a3));
}
-
+
public void testGetTimeZone() throws FtpException {
TimeZone tz1 = TimeZone.getTimeZone("PST");
TimeZone tz2 = TimeZone.getTimeZone("GMT-8:00");
TimeZone tz3 = TimeZone.getTimeZone("foo");
-
+
BaseProperties props = new BaseProperties();
props.setProperty("tz1", "PST");
props.setProperty("tz2", "GMT-8:00");
props.setProperty("tz3", "foo");
-
assertEquals(tz1, props.getTimeZone("tz1"));
assertEquals(tz2, props.getTimeZone("tz2"));
assertEquals(tz3, props.getTimeZone("tz3"));
- // Unknown value
- try{
+ // Unknown value
+ try {
props.getTimeZone("foo");
fail("Must throw FtpException");
- } catch(FtpException e) {
+ } catch (FtpException e) {
// ok
}
-
// default values
assertEquals(tz1, props.getTimeZone("tz1", tz2));
assertEquals(tz2, props.getTimeZone("foo", tz2));
}
-
+
public void testSetTimeZone() throws FtpException {
TimeZone tz1 = TimeZone.getTimeZone("PST");
-
+
BaseProperties props = new BaseProperties();
props.setProperty("tz1", tz1);
-
+
assertEquals(tz1, props.getTimeZone("tz1"));
assertEquals("PST", props.getProperty("tz1"));
- assertEquals("PST", props.getString("tz1"));
+ assertEquals("PST", props.getString("tz1"));
}
}
\ No newline at end of file
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/EncryptUtilsTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/EncryptUtilsTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/EncryptUtilsTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/EncryptUtilsTest.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.util;
@@ -23,13 +23,21 @@
import org.apache.ftpserver.ftplet.FtpException;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class EncryptUtilsTest extends TestCase {
public void testEncryptMd5() throws FtpException {
- assertEquals("21232F297A57A5A743894A0E4A801FC3", EncryptUtils.encryptMD5("admin"));
+ assertEquals("21232F297A57A5A743894A0E4A801FC3", EncryptUtils
+ .encryptMD5("admin"));
}
public void testEncryptSha() throws FtpException {
- assertEquals("D033E22AE348AEB5660FC2140AEC35850C4DA997", EncryptUtils.encryptSHA("admin"));
+ assertEquals("D033E22AE348AEB5660FC2140AEC35850C4DA997", EncryptUtils
+ .encryptSHA("admin"));
}
}
\ No newline at end of file
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/RegularExprTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/RegularExprTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/RegularExprTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/RegularExprTest.java Sun Aug 17 12:52:42 2008
@@ -15,12 +15,18 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.util;
import junit.framework.TestCase;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class RegularExprTest extends TestCase {
public void testMatchText() {
@@ -30,7 +36,7 @@
assertFalse(expr.isMatch("xfoo"));
assertFalse(expr.isMatch("foox"));
}
-
+
public void testMatchingTrailingWhitespace() {
RegularExpr expr = new RegularExpr("foo");
assertFalse(expr.isMatch("foo "));
@@ -44,7 +50,7 @@
assertFalse(expr.isMatch("\nfoo"));
assertFalse(expr.isMatch("\tfoo"));
}
-
+
public void testMatchStar() {
RegularExpr expr = new RegularExpr("*");
assertTrue(expr.isMatch("foo"));
@@ -62,7 +68,7 @@
assertTrue(expr.isMatch("\nfoo"));
assertFalse(expr.isMatch("bar"));
}
-
+
public void testMatchTextThenStar() {
RegularExpr expr = new RegularExpr("foo*");
assertTrue(expr.isMatch("foo"));
@@ -82,7 +88,7 @@
assertTrue(expr.isMatch("\nfoo"));
assertFalse(expr.isMatch("bar"));
}
-
+
public void testMatchStarThenQuestionMark() {
RegularExpr expr = new RegularExpr("foo*?bar");
assertFalse(expr.isMatch("foobar"));
@@ -133,7 +139,7 @@
assertFalse(expr.isMatch("foocbar"));
assertFalse(expr.isMatch("fooabbar"));
}
-
+
/**
* Star is allowed as a choice character
*/
Modified: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/SocketAddressEncoderTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/SocketAddressEncoderTest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/SocketAddressEncoderTest.java (original)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/util/SocketAddressEncoderTest.java Sun Aug 17 12:52:42 2008
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.util;
@@ -23,35 +23,41 @@
import junit.framework.TestCase;
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
public class SocketAddressEncoderTest extends TestCase {
public void testEncodeLowPort() {
InetSocketAddress address = new InetSocketAddress("localhost", 21);
-
+
assertEquals("127,0,0,1,0,21", SocketAddressEncoder.encode(address));
}
public void testEncodeHighPort() {
InetSocketAddress address = new InetSocketAddress("localhost", 21123);
-
+
assertEquals("127,0,0,1,82,131", SocketAddressEncoder.encode(address));
}
public void testEncodeIpNumber() {
InetSocketAddress address = new InetSocketAddress("1.2.3.4", 21);
-
+
assertEquals("1,2,3,4,0,21", SocketAddressEncoder.encode(address));
}
-
+
public void testDecodeLowPort() throws Exception {
InetSocketAddress address = new InetSocketAddress("1.2.3.4", 21);
-
+
assertEquals(address, SocketAddressEncoder.decode("1,2,3,4,0,21"));
}
-
+
public void testDecodeHighPort() throws Exception {
InetSocketAddress address = new InetSocketAddress("1.2.3.4", 21123);
-
+
assertEquals(address, SocketAddressEncoder.decode("1,2,3,4,82,131"));
}
@@ -59,9 +65,9 @@
try {
SocketAddressEncoder.decode("1,2,3,4,82");
fail("Must throw IllegalInetAddressException");
- } catch(IllegalInetAddressException e) {
+ } catch (IllegalInetAddressException e) {
// OK
- } catch(Exception e) {
+ } catch (Exception e) {
fail("Must throw IllegalInetAddressException");
}
}
@@ -70,9 +76,9 @@
try {
SocketAddressEncoder.decode("1,2,3,4,82,1,2");
fail("Must throw IllegalInetAddressException");
- } catch(IllegalInetAddressException e) {
+ } catch (IllegalInetAddressException e) {
// OK
- } catch(Exception e) {
+ } catch (Exception e) {
fail("Must throw IllegalInetAddressException");
}
}
@@ -81,20 +87,20 @@
try {
SocketAddressEncoder.decode("1,2,3,4,820,2");
fail("Must throw IllegalPortException");
- } catch(IllegalPortException e) {
+ } catch (IllegalPortException e) {
// OK
- } catch(Exception e) {
+ } catch (Exception e) {
fail("Must throw IllegalPortException");
}
}
-
+
public void testDecodeIPTokenNotANumber() {
try {
SocketAddressEncoder.decode("foo,2,3,4,5,6");
fail("Must throw IllegalInetAddressException");
- } catch(IllegalInetAddressException e) {
+ } catch (IllegalInetAddressException e) {
// OK
- } catch(Exception e) {
+ } catch (Exception e) {
fail("Must throw IllegalInetAddressException");
}
}
@@ -103,9 +109,9 @@
try {
SocketAddressEncoder.decode("1,2,3,4,foo,6");
fail("Must throw IllegalPortException");
- } catch(IllegalPortException e) {
+ } catch (IllegalPortException e) {
// OK
- } catch(Exception e) {
+ } catch (Exception e) {
fail("Must throw IllegalPortException");
}
}
Modified: mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Authentication.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Authentication.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Authentication.java (original)
+++ mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Authentication.java Sun Aug 17 12:52:42 2008
@@ -15,13 +15,16 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.ftplet;
/**
- * Represents a type of authentication request, typically
- * anonymous or a username and password combination
+ * Represents a type of authentication request, typically anonymous or a
+ * username and password combination
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public interface Authentication {
Modified: mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/AuthenticationFailedException.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/AuthenticationFailedException.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/AuthenticationFailedException.java (original)
+++ mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/AuthenticationFailedException.java Sun Aug 17 12:52:42 2008
@@ -15,12 +15,15 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.ftplet;
/**
* Thrown if an authentication request fails
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public class AuthenticationFailedException extends FtpException {
private static final long serialVersionUID = -1328383839915898987L;
@@ -33,29 +36,33 @@
}
/**
- * Constructs a <code>AuthenticationFailedException</code> object with a message.
+ * Constructs a <code>AuthenticationFailedException</code> object with a
+ * message.
*
- * @param msg a description of the exception
+ * @param msg
+ * a description of the exception
*/
public AuthenticationFailedException(String msg) {
super(msg);
}
/**
- * Constructs a <code>AuthenticationFailedException</code> object with a
+ * Constructs a <code>AuthenticationFailedException</code> object with a
* <code>Throwable</code> cause.
*
- * @param th the original cause
+ * @param th
+ * the original cause
*/
public AuthenticationFailedException(Throwable th) {
super(th);
}
/**
- * Constructs a <code>AuthenticationFailedException</code> object with a
+ * Constructs a <code>AuthenticationFailedException</code> object with a
* <code>Throwable</code> cause.
*
- * @param th the original cause
+ * @param th
+ * the original cause
*/
public AuthenticationFailedException(String msg, Throwable th) {
super(msg);
Modified: mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Authority.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Authority.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Authority.java (original)
+++ mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/Authority.java Sun Aug 17 12:52:42 2008
@@ -15,29 +15,37 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.ftplet;
/**
- * Interface for an authority granted to the user, typical
- * example is write access or the number of concurrent logins
+ * Interface for an authority granted to the user, typical example is write
+ * access or the number of concurrent logins
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public interface Authority {
-
+
/**
* Indicates weather this Authority can authorize a certain request
- * @param request The request to authorize
+ *
+ * @param request
+ * The request to authorize
* @return True if the request can be authorized by this Authority
*/
boolean canAuthorize(AuthorizationRequest request);
-
+
/**
- * Authorize an {@link AuthorizationRequest}.
- * @param request The {@link AuthorizationRequest}
- * @return True if the request is authorized, false otherwise
- * If the request can not be authorized (as checked by {@link #canAuthorize(AuthorizationRequest)}
- * by this Authority, false is returned.
+ * Authorize an {@link AuthorizationRequest}.
+ *
+ * @param request
+ * The {@link AuthorizationRequest}
+ * @return True if the request is authorized, false otherwise If the request
+ * can not be authorized (as checked by
+ * {@link #canAuthorize(AuthorizationRequest)} by this Authority,
+ * false is returned.
*/
AuthorizationRequest authorize(AuthorizationRequest request);
}
Modified: mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/AuthorizationRequest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/AuthorizationRequest.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/AuthorizationRequest.java (original)
+++ mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/AuthorizationRequest.java Sun Aug 17 12:52:42 2008
@@ -15,14 +15,16 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.ftplet;
/**
- * A request for authorization for a specific task, for example
- * write access.
+ * A request for authorization for a specific task, for example write access.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public interface AuthorizationRequest {
-
+
}
Modified: mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataConnection.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataConnection.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataConnection.java (original)
+++ mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataConnection.java Sun Aug 17 12:52:42 2008
@@ -23,12 +23,19 @@
import java.io.InputStream;
import java.io.OutputStream;
+/**
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ */
public interface DataConnection {
/**
* Transfer data from the client (e.g. STOR).
- * @param out The {@link OutputStream} containing the destination
- * of the data from the client.
+ *
+ * @param out
+ * The {@link OutputStream} containing the destination of the
+ * data from the client.
* @return The length of the transferred data
* @throws IOException
*/
@@ -36,7 +43,9 @@
/**
* Transfer data to the client (e.g. RETR).
- * @param in Data to be transfered to the client
+ *
+ * @param in
+ * Data to be transfered to the client
* @return The length of the transferred data
* @throws IOException
*/
@@ -44,9 +53,11 @@
/**
* Transfer a string to the client, e.g. during LIST
- * @param str The string to transfer
+ *
+ * @param str
+ * The string to transfer
* @throws IOException
*/
void transferToClient(String str) throws IOException;
-
+
}
\ No newline at end of file
Modified: mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataConnectionFactory.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataConnectionFactory.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataConnectionFactory.java (original)
+++ mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataConnectionFactory.java Sun Aug 17 12:52:42 2008
@@ -19,12 +19,16 @@
package org.apache.ftpserver.ftplet;
-
+/**
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
+ */
public interface DataConnectionFactory {
-
/**
* Open an active data connection
+ *
* @return The open data connection
* @throws Exception
*/
@@ -33,11 +37,12 @@
/**
* Indicates whether the data socket created by this factory will be secure
* that is, running over SSL/TLS.
+ *
* @return true if the data socket will be secured
*/
boolean isSecure();
-
+
/**
* Close data socket.
*/
Modified: mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataType.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataType.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataType.java (original)
+++ mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DataType.java Sun Aug 17 12:52:42 2008
@@ -15,12 +15,15 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.ftplet;
/**
* Type safe enum for describing the data type
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public class DataType {
@@ -28,23 +31,23 @@
* Binary data type
*/
public static final DataType BINARY = new DataType("I");
-
+
/**
* ASCII data type
*/
public static final DataType ASCII = new DataType("A");
-
+
/**
- * Parses the argument value from the TYPE command into
- * the type safe class
+ * Parses the argument value from the TYPE command into the type safe class
*
- * @param argument The argument value from the TYPE command.
- * Not case sensitive
+ * @param argument
+ * The argument value from the TYPE command. Not case sensitive
* @return The appropriate data type
- * @throws IllegalArgumentException If the data type is unknown
+ * @throws IllegalArgumentException
+ * If the data type is unknown
*/
public static DataType parseArgument(char argument) {
- switch(argument) {
+ switch (argument) {
case 'A':
case 'a':
return ASCII;
@@ -55,9 +58,9 @@
throw new IllegalArgumentException("Unknown data type: " + argument);
}
}
-
+
private String type;
-
+
/**
* Private constructor.
*/
@@ -70,5 +73,5 @@
*/
public String toString() {
return type;
- }
+ }
}
Modified: mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DefaultFtpReply.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DefaultFtpReply.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DefaultFtpReply.java (original)
+++ mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DefaultFtpReply.java Sun Aug 17 12:52:42 2008
@@ -15,19 +15,24 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.ftplet;
-
/**
* FTP reply object.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
public class DefaultFtpReply implements FtpReply {
-
+
private int code;
+
private String message;
- private final static String CRLF = "\r\n";
+
+ private final static String CRLF = "\r\n";
+
/**
* @param code
* @param message
@@ -39,37 +44,41 @@
public DefaultFtpReply(final int code, final String[] message) {
this.code = code;
-
+
StringBuffer sb = new StringBuffer();
- for(int i = 0; i<message.length; i++) {
+ for (int i = 0; i < message.length; i++) {
sb.append(message[i]);
sb.append('\n');
}
this.message = sb.toString();
}
+
/**
* @return the code
*/
public int getCode() {
return code;
}
+
/**
* @return the message
*/
public String getMessage() {
return message;
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#toString()
*/
public String toString() {
int code = getCode();
String notNullMessage = getMessage();
- if(notNullMessage == null) {
+ if (notNullMessage == null) {
notNullMessage = "";
}
-
+
StringBuffer sb = new StringBuffer();
// no newline
@@ -80,25 +89,25 @@
sb.append(CRLF);
} else {
String[] lines = notNullMessage.split("\n");
-
+
sb.append(code);
sb.append("-");
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
-
- if(i + 1 == lines.length) {
+
+ if (i + 1 == lines.length) {
sb.append(code);
sb.append(" ");
}
-
+
sb.append(line);
sb.append(CRLF);
}
-
+
}
-
+
return sb.toString();
}
-
+
}
Modified: mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DefaultFtplet.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DefaultFtplet.java?rev=686637&r1=686636&r2=686637&view=diff
==============================================================================
--- mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DefaultFtplet.java (original)
+++ mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/DefaultFtplet.java Sun Aug 17 12:52:42 2008
@@ -15,106 +15,182 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- */
+ */
package org.apache.ftpserver.ftplet;
import java.io.IOException;
/**
- * Default ftplet implementation. All the callback method returns null.
- * It is just an empty implementation. You can derive your ftplet implementation
- * from this class.
+ * Default ftplet implementation. All the callback method returns null. It is
+ * just an empty implementation. You can derive your ftplet implementation from
+ * this class.
+ *
+ * @author The Apache MINA Project (dev@mina.apache.org)
+ * @version $Rev$, $Date$
*/
-public
-class DefaultFtplet implements Ftplet {
+public class DefaultFtplet implements Ftplet {
+
+ public void init(FtpletContext ftpletContext) throws FtpException {
+ }
- public void init(FtpletContext ftpletContext) throws FtpException {}
- public void destroy() {}
+ public void destroy() {
+ }
- public FtpletEnum onConnect(FtpSession session) throws FtpException, IOException {return null;}
- public FtpletEnum onDisconnect(FtpSession session) throws FtpException, IOException {return null;}
+ public FtpletEnum onConnect(FtpSession session) throws FtpException,
+ IOException {
+ return null;
+ }
- public FtpletEnum beforeCommand(FtpSession session, FtpRequest request) throws FtpException, IOException {
+ public FtpletEnum onDisconnect(FtpSession session) throws FtpException,
+ IOException {
+ return null;
+ }
+
+ public FtpletEnum beforeCommand(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
String command = request.getCommand().toUpperCase();
- if("DELE".equals(command)) {
+ if ("DELE".equals(command)) {
return onDeleteStart(session, request);
- } else if("STOR".equals(command)) {
+ } else if ("STOR".equals(command)) {
return onUploadStart(session, request);
- } else if("RETR".equals(command)) {
+ } else if ("RETR".equals(command)) {
return onDownloadStart(session, request);
- } else if("RMD".equals(command)) {
+ } else if ("RMD".equals(command)) {
return onRmdirStart(session, request);
- } else if("MKD".equals(command)) {
+ } else if ("MKD".equals(command)) {
return onMkdirStart(session, request);
- } else if("APPE".equals(command)) {
+ } else if ("APPE".equals(command)) {
return onAppendStart(session, request);
- } else if("STOU".equals(command)) {
+ } else if ("STOU".equals(command)) {
return onUploadUniqueStart(session, request);
- } else if("RNTO".equals(command)) {
+ } else if ("RNTO".equals(command)) {
return onRenameStart(session, request);
} else {
// TODO should we call a catch all?
return null;
- }
+ }
}
-
- public FtpletEnum afterCommand(FtpSession session, FtpRequest request) throws FtpException, IOException {
-
+
+ public FtpletEnum afterCommand(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+
String command = request.getCommand().toUpperCase();
- if("PASS".equals(command)) {
+ if ("PASS".equals(command)) {
return onLogin(session, request);
- } else if("DELE".equals(command)) {
+ } else if ("DELE".equals(command)) {
return onDeleteEnd(session, request);
- } else if("STOR".equals(command)) {
+ } else if ("STOR".equals(command)) {
return onUploadEnd(session, request);
- } else if("RETR".equals(command)) {
+ } else if ("RETR".equals(command)) {
return onDownloadEnd(session, request);
- } else if("RMD".equals(command)) {
+ } else if ("RMD".equals(command)) {
return onRmdirEnd(session, request);
- } else if("MKD".equals(command)) {
+ } else if ("MKD".equals(command)) {
return onMkdirEnd(session, request);
- } else if("APPE".equals(command)) {
+ } else if ("APPE".equals(command)) {
return onAppendEnd(session, request);
- } else if("STOU".equals(command)) {
+ } else if ("STOU".equals(command)) {
return onUploadUniqueEnd(session, request);
- } else if("RNTO".equals(command)) {
+ } else if ("RNTO".equals(command)) {
return onRenameEnd(session, request);
- } else if("SITE".equals(command)) {
+ } else if ("SITE".equals(command)) {
return onSite(session, request);
} else {
// TODO should we call a catch all?
return null;
- }
+ }
+ }
+
+ public FtpletEnum onLogin(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onDeleteStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onUploadStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onUploadEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onDownloadStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onDownloadEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onRmdirStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onMkdirStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onAppendStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
}
- public FtpletEnum onLogin(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
-
- public FtpletEnum onDeleteStart(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
- public FtpletEnum onDeleteEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
-
- public FtpletEnum onUploadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
- public FtpletEnum onUploadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
-
- public FtpletEnum onDownloadStart(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
- public FtpletEnum onDownloadEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
-
- public FtpletEnum onRmdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
- public FtpletEnum onRmdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
-
- public FtpletEnum onMkdirStart(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
- public FtpletEnum onMkdirEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
-
- public FtpletEnum onAppendStart(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
- public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
-
- public FtpletEnum onUploadUniqueStart(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
- public FtpletEnum onUploadUniqueEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
-
- public FtpletEnum onRenameStart(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
- public FtpletEnum onRenameEnd(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
-
- public FtpletEnum onSite(FtpSession session, FtpRequest request) throws FtpException, IOException {return null;}
+ public FtpletEnum onAppendEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onUploadUniqueStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onUploadUniqueEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onRenameStart(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onRenameEnd(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
+
+ public FtpletEnum onSite(FtpSession session, FtpRequest request)
+ throws FtpException, IOException {
+ return null;
+ }
}
\ No newline at end of file