(file) Return to UserFileHandler.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Security / UserManager

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2