1 karl 1.5 //%2003////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.5 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
|
7 mike 1.2 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 kumpf 1.4 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
12 mike 1.2 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
|
15 kumpf 1.4 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
16 mike 1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
18 kumpf 1.4 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
21 mike 1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
|
24 kumpf 1.4 //==============================================================================
|
25 mike 1.2 //
26 // Author: Sushma Fernandes, Hewlett Packard Company (sushma_fernandes@hp.com)
27 //
28 // Modified By:
29 //
30 //%////////////////////////////////////////////////////////////////////////////
31
32
33 ///////////////////////////////////////////////////////////////////////////////
34 //
35 // This file implements the functionality required to manage password file.
36 //
37 ///////////////////////////////////////////////////////////////////////////////
38
39 #ifndef Pegasus_UserFileHandler_h
40 #define Pegasus_UserFileHandler_h
41
42 #include <cctype>
43 #include <fstream>
44
45 #include <Pegasus/Common/Config.h>
|
46 kumpf 1.3 #include <Pegasus/Common/IPC.h>
|
47 mike 1.2
48 #include <Pegasus/Security/UserManager/PasswordFile.h>
49 #include <Pegasus/Security/UserManager/Linkage.h>
50
51 PEGASUS_NAMESPACE_BEGIN
52
53 /**
54 This class implements the functionality required to manage password file.
55 */
56
57 class PEGASUS_USERMANAGER_LINKAGE UserFileHandler
58 {
59
60 private:
61
62 //
|
63 kumpf 1.3 // Contains the property name for password filepath
|
64 mike 1.2 //
|
65 kumpf 1.3 static const String _PROPERTY_NAME_PASSWORD_FILEPATH;
|
66 mike 1.2
67 //
68 // Contains the salt string for password encryption
69 //
70 static const unsigned char _SALT_STRING[];
71
72 //
|
73 kumpf 1.3 // Denotes the types of update operations
74 //
75 enum UpdateOperations
76 {
77 ADD_USER,
78 MODIFY_USER,
79 REMOVE_USER
80 };
81
82 //
83 // Contains the mutex timeout value
84 //
85 static const Uint32 _MUTEX_TIMEOUT;
|
86 mike 1.2
87 //
88 // Flag to indicate whether password file exists
89 Boolean _passwordFileExists;
90
91 //
92 // Password cache
93 //
94 PasswordTable _passwordTable;
95
96 //
97 // Instance of the PasswordFile
98 //
|
99 kumpf 1.3 PasswordFile* _passwordFile;
100
101 //
102 // Mutex variable for consistent Password File and cache updates
103 //
104 Mutex* _mutex;
|
105 mike 1.2
106 /**
107 generate random salt key for password encryption
108
109 @param salt A array of 3 characters
110 */
111 void _GetSalt (char* salt);
112
|
113 kumpf 1.3 /**
114 Update the password hash table and write to password file
115 */
116 void _Update(
117 char operation,
118 const String& userName,
119 const String& password = String::EMPTY);
120
121
|
122 mike 1.2 protected:
123
124 /**
125 Load the user information from the password file.
126
127 @exception PasswordFileSyntaxError if password file contains a syntax error.
128 @exception CannotRenameFile if password file cannot be renamed.
129 */
130 void _loadAllUsers ();
131
132 public:
133
134 /** Constructor. */
135 UserFileHandler();
136
137 /** Destructor. */
138 ~UserFileHandler();
|
139 kumpf 1.3
|
140 mike 1.2
141 /**
142 Add user entry to file
143
144 @param userName The name of the user to add.
145 @param password The password for the user.
146
147 @exception FileNotReadable if unable to read password file
148 @exception DuplicateUser if the user is already exists
149 @exception PasswordCacheError if there is an error processing
150 password hashtable
151 @exception CannotRenameFile if password file cannot be renamed.
152 */
153 void addUserEntry(const String& userName, const String& passWord);
154
155 /**
156 Modify user entry in file
157
158 @param userName The name of the user to modify.
159 @param password User's old password.
160 @param newPassword User's new password.
161 mike 1.2
162 @exception InvalidUser if the user does not exist.
163 @exception PasswordMismatch if the specified password does not match
164 user's current password.
165 @exception PasswordCacheError if there is an error processing
166 password hashtable
167 @exception CannotRenameFile if password file cannot be renamed.
168
169 */
170 void modifyUserEntry(
171 const String& userName,
172 const String& password,
173 const String& newPassword );
174
175 /**
176 Remove user entry from file
177
178 @param userName The name of the user to add.
179
180 @exception FileNotReadable if unable to read password file
181 @exception InvalidUser if the user is does not exist
182 mike 1.2 @exception PasswordCacheError if there is an error processing
183 password hashtable
184 @exception CannotRenameFile if password file cannot be renamed.
185 */
186 void removeUserEntry(const String& userName);
187
188
189 /**
190 Get a list of all the user names.
191
192 @param userNames List containing all the user names.
193
194 @exception FileNotReadable if unable to read password file
195 */
196 void getAllUserNames(Array<String>& userNames);
197
198 /**
199 Verify user exists in the cimserver password file
200
201 @param userName Name of the user to be verified
202 @return true if the user exists, else false
203 mike 1.2
204 @exception FileNotReadable if unable to read password file
205 */
206 Boolean verifyCIMUser(const String& userName);
207
208 /**
209 Verify user's password matches specified password
210
211 @param userName Name of the user to be verified
212 @param password password to be verified
213 @return true if the user's password matches existing password, else false
214
215 @exception FileNotReadable if unable to read password file
216 @exception InvalidUser if the specified user does not exist
217 */
218 Boolean verifyCIMUserPassword(
219 const String& userName,
220 const String& password );
221 };
222
223 PEGASUS_NAMESPACE_END
224 mike 1.2
225 #endif /* Pegasus_UserFileHandler_h */
226
|