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/27 16:58:53 UTC
svn commit: r689495 [2/2] - in /mina/ftpserver/trunk:
core/src/main/java/org/apache/ftpserver/config/spring/
core/src/main/java/org/apache/ftpserver/filesystem/
core/src/main/java/org/apache/ftpserver/ftpletcontainer/
core/src/main/java/org/apache/ftps...
Added: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/ClearTextPasswordEncryptorTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/ClearTextPasswordEncryptorTest.java?rev=689495&view=auto
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/ClearTextPasswordEncryptorTest.java (added)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/ClearTextPasswordEncryptorTest.java Wed Aug 27 07:58:52 2008
@@ -0,0 +1,66 @@
+/*
+ * 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.ftpserver.usermanager;
+
+import junit.framework.TestCase;
+
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
+public class ClearTextPasswordEncryptorTest extends TestCase {
+
+ protected PasswordEncryptor createPasswordEncryptor() {
+ return new ClearTextPasswordEncryptor();
+ }
+
+ public void testMatches() {
+ PasswordEncryptor encryptor = createPasswordEncryptor();
+
+ assertTrue(encryptor.matches("foo", "foo"));
+
+ assertFalse(encryptor.matches("foo", "bar"));
+ }
+
+ public void testMatchesNullPasswordToCheck() {
+ PasswordEncryptor encryptor = createPasswordEncryptor();
+
+ try {
+ encryptor.matches(null, "bar");
+ fail("Must throw NullPointerException");
+ } catch (NullPointerException e) {
+ // OK
+ }
+ }
+
+ public void testMatchesNullStoredPassword() {
+ PasswordEncryptor encryptor = createPasswordEncryptor();
+
+ try {
+ encryptor.matches("foo", null);
+ fail("Must throw NullPointerException");
+ } catch (NullPointerException e) {
+ // OK
+ }
+ }
+
+}
Propchange: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/ClearTextPasswordEncryptorTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
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=689495&r1=689494&r2=689495&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 Wed Aug 27 07:58:52 2008
@@ -38,18 +38,20 @@
*/
public class DbUserManagerTest extends UserManagerTestTemplate {
- private static final File INIT_SQL_SCRIPT = new File(TestUtil.getBaseDir(),
- "src/test/resources/dbusermanagertest-hsql.sql");
-
private jdbcDataSource ds;
private Connection conn;
+ protected File getInitSqlScript() {
+ return new File(TestUtil.getBaseDir(),
+ "src/test/resources/dbusermanagertest-hsql.sql");
+ }
+
private void createDatabase() throws Exception {
conn = ds.getConnection();
conn.setAutoCommit(true);
- String ddl = IoUtils.readFully(new FileReader(INIT_SQL_SCRIPT));
+ String ddl = IoUtils.readFully(new FileReader(getInitSqlScript()));
Statement stm = conn.createStatement();
stm.execute(ddl);
@@ -70,7 +72,7 @@
manager
.setSqlUserSelectAll("SELECT userid FROM FTP_USER ORDER BY userid");
manager
- .setSqlUserAuthenticate("SELECT userid FROM FTP_USER WHERE userid='{userid}' AND userpassword='{userpassword}'");
+ .setSqlUserAuthenticate("SELECT userid, userpassword FROM FTP_USER WHERE userid='{userid}'");
manager
.setSqlUserAdmin("SELECT userid FROM FTP_USER WHERE userid='{userid}' AND userid='admin'");
Added: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/Md5PasswordEncryptorTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/Md5PasswordEncryptorTest.java?rev=689495&view=auto
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/Md5PasswordEncryptorTest.java (added)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/Md5PasswordEncryptorTest.java Wed Aug 27 07:58:52 2008
@@ -0,0 +1,46 @@
+/*
+ * 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.ftpserver.usermanager;
+
+
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
+public class Md5PasswordEncryptorTest extends ClearTextPasswordEncryptorTest {
+
+ @Override
+ protected PasswordEncryptor createPasswordEncryptor() {
+ return new Md5PasswordEncryptor();
+ }
+
+ public void testMatches() {
+ PasswordEncryptor encryptor = createPasswordEncryptor();
+
+ assertTrue(encryptor.matches("foo", "ACBD18DB4CC2F85CEDEF654FCCC4A4D8"));
+
+ // check lower case
+ assertTrue(encryptor.matches("foo", "acbd18DB4CC2F85CEDEF654FCCC4A4D8"));
+
+ assertFalse(encryptor.matches("foo", "bar"));
+ }
+}
Propchange: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/Md5PasswordEncryptorTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
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=689495&r1=689494&r2=689495&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 Wed Aug 27 07:58:52 2008
@@ -66,8 +66,8 @@
protected UserManager createUserManager() throws FtpException {
PropertiesUserManager um = new PropertiesUserManager();
- um.setPropFile(USERS_FILE);
- um.setEncryptPasswords(false);
+ um.setFile(USERS_FILE);
+ um.setPasswordEncryptor(new ClearTextPasswordEncryptor());
um.configure();
return um;
Added: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/SaltedPasswordEncryptorTest.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/SaltedPasswordEncryptorTest.java?rev=689495&view=auto
==============================================================================
--- mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/SaltedPasswordEncryptorTest.java (added)
+++ mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/SaltedPasswordEncryptorTest.java Wed Aug 27 07:58:52 2008
@@ -0,0 +1,46 @@
+/*
+ * 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.ftpserver.usermanager;
+
+
+/**
+*
+* @author The Apache MINA Project (dev@mina.apache.org)
+* @version $Rev$, $Date$
+*
+*/
+public class SaltedPasswordEncryptorTest extends ClearTextPasswordEncryptorTest {
+
+ @Override
+ protected PasswordEncryptor createPasswordEncryptor() {
+ return new SaltedPasswordEncryptor();
+ }
+
+ public void testMatches() {
+ PasswordEncryptor encryptor = createPasswordEncryptor();
+
+ assertTrue(encryptor.matches("foo", "71288966:F7B097C7BB2D02B8C2ACCE8A17284715"));
+
+ // check lower case
+ assertTrue(encryptor.matches("foo", "71288966:f7b097C7BB2D02B8C2ACCE8A17284715"));
+
+ assertFalse(encryptor.matches("foo", "bar:bar"));
+ }
+}
Propchange: mina/ftpserver/trunk/core/src/test/java/org/apache/ftpserver/usermanager/SaltedPasswordEncryptorTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: mina/ftpserver/trunk/core/src/test/resources/dbusermanagertest-cleartext-hsql.sql
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/resources/dbusermanagertest-cleartext-hsql.sql?rev=689495&view=auto
==============================================================================
--- mina/ftpserver/trunk/core/src/test/resources/dbusermanagertest-cleartext-hsql.sql (added)
+++ mina/ftpserver/trunk/core/src/test/resources/dbusermanagertest-cleartext-hsql.sql Wed Aug 27 07:58:52 2008
@@ -0,0 +1,42 @@
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied. See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+
+CREATE TABLE FTP_USER (
+ userid VARCHAR(64) NOT NULL PRIMARY KEY,
+ userpassword VARCHAR(64),
+ homedirectory VARCHAR(128) NOT NULL,
+ enableflag BOOLEAN DEFAULT TRUE,
+ writepermission BOOLEAN DEFAULT FALSE,
+ idletime INT DEFAULT 0,
+ uploadrate INT DEFAULT 0,
+ downloadrate INT DEFAULT 0,
+ maxloginnumber INT DEFAULT 0,
+ maxloginperip INT DEFAULT 0
+);
+
+-- password="pw1"
+INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('user1', 'pw1', 'home');
+
+-- password="pw2"
+INSERT INTO FTP_USER VALUES ('user2', 'pw2', 'home', false, true, 2, 5, 1, 3, 4);
+
+-- password=""
+INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('user3', '', 'home');
+
+-- password="admin"
+INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('admin', 'admin', 'home');
+
Modified: mina/ftpserver/trunk/core/src/test/resources/dbusermanagertest-hsql.sql
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/test/resources/dbusermanagertest-hsql.sql?rev=689495&r1=689494&r2=689495&view=diff
==============================================================================
--- mina/ftpserver/trunk/core/src/test/resources/dbusermanagertest-hsql.sql (original)
+++ mina/ftpserver/trunk/core/src/test/resources/dbusermanagertest-hsql.sql Wed Aug 27 07:58:52 2008
@@ -28,8 +28,15 @@
maxloginperip INT DEFAULT 0
);
-INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('user1', 'pw1', 'home');
-INSERT INTO FTP_USER VALUES ('user2', 'pw2', 'home', false, true, 2, 5, 1, 3, 4);
-INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('user3', '', 'home');
-INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('admin', 'admin', 'home');
+-- password="pw1"
+INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('user1', '6E6FDF956D04289354DCF1619E28FE77', 'home');
+
+-- password="pw2"
+INSERT INTO FTP_USER VALUES ('user2', '6D5779B9B85BD4F11E44C9772E0DE602', 'home', false, true, 2, 5, 1, 3, 4);
+
+-- password=""
+INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('user3', 'D41D8CD98F00B204E9800998ECF8427E', 'home');
+
+-- password="admin"
+INSERT INTO FTP_USER (userid, userpassword, homedirectory) VALUES ('admin', '21232F297A57A5A743894A0E4A801FC3', 'home');
Modified: mina/ftpserver/trunk/ftplet-api/pom.xml
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api/pom.xml?rev=689495&r1=689494&r2=689495&view=diff
==============================================================================
--- mina/ftpserver/trunk/ftplet-api/pom.xml (original)
+++ mina/ftpserver/trunk/ftplet-api/pom.xml Wed Aug 27 07:58:52 2008
@@ -1,58 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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. -->
-
+ <!--
+ 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.
+ -->
<project>
- <parent>
- <artifactId>ftpserver-parent</artifactId>
- <groupId>org.apache.ftpserver</groupId>
- <version>1.0.0-M3-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.ftpserver</groupId>
- <artifactId>ftplet-api</artifactId>
- <name>Apache Ftplet API</name>
- <version>1.0.0-M3-SNAPSHOT</version>
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/mina/ftpserver/trunk/ftplet-api</connection>
- <developerConnection>scm:svn:https://svn.apache.org/repos/asf/mina/ftpserver/trunk/ftplet-api</developerConnection>
- <url>http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api</url>
- </scm>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <reporting>
- <plugins>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>jxr-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </reporting>
- <properties>
- <maven.compile.source>1.5</maven.compile.source>
- <maven.compile.target>1.5</maven.compile.target>
- </properties>
-</project>
+ <parent>
+ <artifactId>ftpserver-parent</artifactId>
+ <groupId>org.apache.ftpserver</groupId>
+ <version>1.0.0-M3-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.ftpserver</groupId>
+ <artifactId>ftplet-api</artifactId>
+ <packaging>bundle</packaging>
+ <name>Apache Ftplet API</name>
+ <description>
+ Ftplets are, similar to servlets, an API to plug into the request
+ lifecycle of FtpServer. Ftplets are called on session connect and disconnect
+ as well as before and after each command within a user session.
+ </description>
+ <version>1.0.0-M3-SNAPSHOT</version>
+ <url>http://mina.apache.org/ftpserver</url>
+ <scm>
+ <connection>
+ scm:svn:http://svn.apache.org/repos/asf/mina/ftpserver/trunk/ftplet-api
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.apache.org/repos/asf/mina/ftpserver/trunk/ftplet-api
+ </developerConnection>
+ <url>http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api
+ </url>
+ </scm>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.1</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName> ${artifactId}</Bundle-SymbolicName>
+ <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+ <Export-Package> org.apache.ftpserver.ftplet</Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jxr-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+ <properties>
+ <maven.compile.source>1.5</maven.compile.source>
+ <maven.compile.target>1.5</maven.compile.target>
+ </properties>
+</project>
\ No newline at end of file
Modified: mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/User.java
URL: http://svn.apache.org/viewvc/mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/User.java?rev=689495&r1=689494&r2=689495&view=diff
==============================================================================
--- mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/User.java (original)
+++ mina/ftpserver/trunk/ftplet-api/src/main/java/org/apache/ftpserver/ftplet/User.java Wed Aug 27 07:58:52 2008
@@ -33,7 +33,7 @@
String getName();
/**
- * Get password.
+ * Get password. Might return null if the user manager can not provide the password
*/
String getPassword();