Author: ngn
Date: Wed Dec 10 13:38:25 2008
New Revision: 725447
URL: http://svn.apache.org/viewvc?rev=725447&view=rev
Log:
Adding example for managing users using the API
Added:
mina/ftpserver/trunk/core/src/examples/java/org/apache/ftpserver/examples/ManagingUsers.java
Added:
mina/ftpserver/trunk/core/src/examples/java/org/apache/ftpserver/examples/ManagingUsers.java
URL:
http://svn.apache.org/viewvc/mina/ftpserver/trunk/core/src/examples/java/org/apache/ftpserver/examples/ManagingUsers.java?rev=725447&view=auto
==============================================================================
---
mina/ftpserver/trunk/core/src/examples/java/org/apache/ftpserver/examples/ManagingUsers.java
(added)
+++
mina/ftpserver/trunk/core/src/examples/java/org/apache/ftpserver/examples/ManagingUsers.java
Wed Dec 10 13:38:25 2008
@@ -0,0 +1,45 @@
+package org.apache.ftpserver.examples;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+
+import org.apache.ftpserver.ftplet.User;
+import org.apache.ftpserver.ftplet.UserManager;
+import org.apache.ftpserver.usermanager.PropertiesUserManagerFactory;
+import org.apache.ftpserver.usermanager.SaltedPasswordEncryptor;
+import org.apache.ftpserver.usermanager.impl.BaseUser;
+
+public class ManagingUsers {
+
+ public static void main(String[] args) throws Exception {
+ PropertiesUserManagerFactory userManagerFactory = new
PropertiesUserManagerFactory();
+ userManagerFactory.setFile(new File("myusers.properties"));
+ userManagerFactory.setPasswordEncryptor(new SaltedPasswordEncryptor());
+ UserManager um = userManagerFactory.createUserManager();
+
+ BaseUser user = new BaseUser();
+ user.setName("myNewUser");
+ user.setPassword("secret");
+ user.setHomeDirectory("ftproot");
+
+ um.save(user);
+ }
+}