org.apache.ftpserver.usermanager
Class DbUserManager

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.ftpserver.usermanager.AbstractUserManager
          extended byorg.apache.ftpserver.usermanager.DbUserManager
All Implemented Interfaces:
org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.logger.LogEnabled, UserManagerInterface

public class DbUserManager
extends AbstractUserManager

This is another database based user manager class. I have tested it using MySQL and Oracle database. The sql file is ftp-db.sql

Author:
Rana Bhattacharyya

Field Summary
 
Fields inherited from class org.apache.ftpserver.usermanager.AbstractUserManager
mConfig, mstAdminName
 
Fields inherited from interface org.apache.ftpserver.usermanager.UserManagerInterface
ROLE
 
Constructor Summary
DbUserManager()
          Instantiate user manager - default constructor.
 
Method Summary
 boolean authenticate(java.lang.String user, java.lang.String password)
          User authentication
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
          Set configuration - open database connection
 void delete(java.lang.String name)
          Delete user.
 void dispose()
          Close this user manager.
 boolean doesExist(java.lang.String name)
          User existance check
 java.util.List getAllUserNames()
          Get all user names from the database.
 User getUserByName(java.lang.String name)
          Get the user object.
 void save(User user)
          Save user.
 
Methods inherited from class org.apache.ftpserver.usermanager.AbstractUserManager
contextualize, getAdminName, getBaseDirectory, getConfig, initialize, reload
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbUserManager

public DbUserManager()
              throws java.lang.Exception
Instantiate user manager - default constructor.

Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration conf)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Set configuration - open database connection

Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Overrides:
configure in class AbstractUserManager
Throws:
org.apache.avalon.framework.configuration.ConfigurationException

delete

public void delete(java.lang.String name)
            throws java.sql.SQLException
Delete user. Delete the row from the table.

Throws:
java.sql.SQLException

save

public void save(User user)
          throws java.sql.SQLException
Save user. If new insert a new row, else update the existing row.

Throws:
java.sql.SQLException

getUserByName

public User getUserByName(java.lang.String name)
Get the user object. Fetch the row from the table.


doesExist

public boolean doesExist(java.lang.String name)
User existance check

Parameters:
name - user name

getAllUserNames

public java.util.List getAllUserNames()
Get all user names from the database.


authenticate

public boolean authenticate(java.lang.String user,
                            java.lang.String password)
User authentication


dispose

public void dispose()
Close this user manager. Close the database statements and connection.

Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable
Overrides:
dispose in class AbstractUserManager


Copyright © 2001-2007 Codehaus. All Rights Reserved.