FileDocCategorySizeDatePackage
HomesUserDatabase.javaAPI DocGlassfish v2 API4796Fri May 04 22:32:30 BST 2007org.apache.catalina.startup

HomesUserDatabase

public final class HomesUserDatabase extends Object implements UserDatabase
Concrete implementation of the UserDatabase interface considers all directories in a directory whose pathname is specified to our constructor to be "home" directories for those users.
author
Craig R. McClanahan
version
$Revision: 1.3 $ $Date: 2007/05/05 05:32:29 $

Fields Summary
private Hashtable
homes
The set of home directories for all defined users, keyed by username.
private UserConfig
userConfig
The UserConfig listener with which we are associated.
Constructors Summary
public HomesUserDatabase()
Initialize a new instance of this user database component.


        super();

    
Methods Summary
public java.lang.StringgetHome(java.lang.String user)
Return an absolute pathname to the home directory for the specified user.

param
user User for which a home directory should be retrieved


        return ((String) homes.get(user));

    
public UserConfiggetUserConfig()
Return the UserConfig listener with which we are associated.



    // ----------------------------------------------------------- Properties


                  
       

        return (this.userConfig);

    
public java.util.EnumerationgetUsers()
Return an enumeration of the usernames defined on this server.


        return (homes.keys());

    
private voidinit()
Initialize our set of users and home directories.


        String homeBase = userConfig.getHomeBase();
        File homeBaseDir = new File(homeBase);
        if (!homeBaseDir.exists() || !homeBaseDir.isDirectory())
            return;
        String homeBaseFiles[] = homeBaseDir.list();

        for (int i = 0; i < homeBaseFiles.length; i++) {
            File homeDir = new File(homeBaseDir, homeBaseFiles[i]);
            if (!homeDir.isDirectory() || !homeDir.canRead())
                continue;
            homes.put(homeBaseFiles[i], homeDir.toString());
        }


    
public voidsetUserConfig(UserConfig userConfig)
Set the UserConfig listener with which we are associated.

param
userConfig The new UserConfig listener


        this.userConfig = userConfig;
        init();