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