KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > outdated > UserManager


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.outdated;
7
8 import java.util.*;
9
10 import com.raptus.owxv3.*;
11
12 /**
13  * The UserManager provides methods to add, remove, update users. When the
14  * <multiuser> flag is set, a webmaster can add or remove user. Otherwise
15  * existing users can just be changed.
16  *
17  * <hr>
18  * <table width="100%" border="0">
19  * <tr>
20  * <td width="24%"><b>Filename</b></td><td width="76%">UserMgr.java</td>
21  * </tr>
22  * <tr>
23  * <td width="24%"><b>Author</b></td><td width="76%">Guy Z�rcher (gzuercher@raptus.com)</td>
24  * </tr>
25  * <tr>
26  * <td width="24%"><b>Date</b></td><td width="76%">15th of April 2001</td>
27  * </tr>
28  * </table>
29  * <hr>
30  * <table width="100%" border="0">
31  * <tr>
32  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
33  * </tr>
34  * </table>
35  * <hr>
36  */

37 public class UserManager extends Object JavaDoc
38 {
39     /**
40      * contains the user id's for all known users
41      */

42     protected HashSet allusers = null;
43
44     /**
45      * if set access to addUser() and removeUser() is granted.
46      */

47     protected boolean multiuser = false;
48
49     /**
50      * read's in all user related informations
51      */

52     public UserManager()
53     {
54         XMLConfigManager cm = XMLConfigManager.getInstance();
55         //Configuration cfg = cm.getConfiguration();
56

57         String JavaDoc[] users = cm.getStringArrayByTree("virtualhost/users", "names");
58
59         if(users != null)
60         {
61             allusers = new HashSet();
62             for(int i = 0; i < users.length; i ++)
63                 allusers.add(users[i]);
64         }
65
66         //ADDEDBYJANCSI
67
// try
68
// {
69
// multiuser = cfg.getBooleanByKey(Constants.VIRTUALHOST_MULTIUSER);
70
// }
71
// catch(ParseException e) {
72
// LoggingManager.log("Cannot parse expression! (" +
73
// Constants.VIRTUALHOST_MULTIUSER + ")", this);
74
// }
75
multiuser = cm.getBooleanByTree("virtualhost","multiuser");
76     }
77
78     /**
79      * @return the number of users installed on this virtualhost
80      */

81     public int getUsersCount()
82     {
83         return allusers.size();
84     }
85
86     /**
87      * @return a enumerable list of user objects for this virtualhost
88      */

89     public Iterator getUsers()
90     {
91         return allusers.iterator();
92     }
93
94     /**
95      *
96      */

97     public boolean existUser(String JavaDoc username)
98     {
99         return allusers.contains(username);
100     }
101
102     /**
103      *
104      */

105     public User getUser(String JavaDoc username, String JavaDoc password)
106     {
107         if(!existUser(username))
108           return null;
109
110         User u = new User();
111         if(u.initialize(username, password))
112         {
113             LoggingManager.log("User " + username + " has been initialized", this);
114             return u;
115         }
116
117         return null;
118     }
119
120     /**
121      *
122      */

123     public boolean updateUser(String JavaDoc username, String JavaDoc password, User newuser)
124     {
125         // HERE TO DO: implement
126
return false;
127     }
128
129     /**
130      *
131      */

132     public boolean addUser(User u, String JavaDoc password, User webmaster)
133     {
134         if(!multiuser)
135             return false;
136
137         // HERE TO DO: implement
138
return false;
139     }
140
141     /**
142      *
143      */

144     public boolean removeUser(String JavaDoc username, String JavaDoc password, User webmaster)
145     {
146         if(!multiuser)
147             return false;
148
149         // HERE TO DO: implement
150
return false;
151     }
152
153 }
154
155 /* end class UserMgr */
156
Popular Tags