version 1.8.6.1, 2003/07/29 15:08:30
|
version 1.21.14.1, 2006/07/27 23:12:11
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// Author: Sushma Fernandes, Hewlett Packard Company (sushma_fernandes@hp.com) | // Author: Sushma Fernandes, Hewlett Packard Company (sushma_fernandes@hp.com) |
// | // |
// Modified By: | // Modified By: |
|
// Amit K Arora, IBM (amita@in.ibm.com) for PEP#101 |
|
// Josephine Eskaline Joyce (jojustin@in.ibm.com) for PEP#101 |
|
// Josephine Eskaline Joyce (jojustin@in.ibm.com) for Bug#2486 |
|
// David Dillard, VERITAS Software Corp. |
|
// (david.dillard@veritas.com) |
// | // |
//%//////////////////////////////////////////////////////////////////////////// | //%//////////////////////////////////////////////////////////////////////////// |
| |
|
|
/////////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////////// |
| |
#include <Pegasus/Common/FileSystem.h> | #include <Pegasus/Common/FileSystem.h> |
#include <Pegasus/Common/Destroyer.h> |
|
#include <Pegasus/Common/Logger.h> | #include <Pegasus/Common/Logger.h> |
#include <Pegasus/Common/System.h> | #include <Pegasus/Common/System.h> |
#include <Pegasus/Common/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
|
|
System::getCurrentTime( sec, milliSec ); | System::getCurrentTime( sec, milliSec ); |
| |
srand( (int) sec ); | srand( (int) sec ); |
|
#ifdef PEGASUS_PLATFORM_SOLARIS_SPARC |
|
Unit32 seed; |
|
randNum = rand_r(*seed); |
|
#else |
randNum = rand(); | randNum = rand(); |
|
#endif |
| |
// | // |
// Make sure the random number generated is between 0-63. | // Make sure the random number generated is between 0-63. |
|
|
randNum >>= 6; | randNum >>= 6; |
*salt++ = _SALT_STRING[ randNum & 0x3f ]; | *salt++ = _SALT_STRING[ randNum & 0x3f ]; |
| |
salt[2] = '\0'; |
*salt = '\0'; |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
|
|
// Get the PasswordFilePath property from the Config Manager. | // Get the PasswordFilePath property from the Config Manager. |
// | // |
String passwdFile; | String passwdFile; |
passwdFile = configManager->getCurrentValue( |
passwdFile = ConfigManager::getHomedPath( |
_PROPERTY_NAME_PASSWORD_FILEPATH); |
configManager->getCurrentValue(_PROPERTY_NAME_PASSWORD_FILEPATH)); |
| |
// | // |
// Construct a PasswordFile object. | // Construct a PasswordFile object. |
// | // |
_passwordFile = new PasswordFile(passwdFile); |
_passwordFile.reset(new PasswordFile(passwdFile)); |
| |
// | // |
// Load the user information in to the cache. | // Load the user information in to the cache. |
|
|
{ | { |
_loadAllUsers(); | _loadAllUsers(); |
} | } |
catch (Exception& e) |
catch (const Exception&) |
{ | { |
throw e; |
throw; |
} | } |
| |
// | // |
// Initialize the mutex, mutex lock needs to be held for any updates | // Initialize the mutex, mutex lock needs to be held for any updates |
// to the password cache and password file. | // to the password cache and password file. |
// | // |
_mutex = new Mutex; |
_mutex.reset(new Mutex); |
| |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
|
|
{ | { |
PEG_METHOD_ENTER(TRC_USER_MANAGER, "UserFileHandler::~UserFileHandler"); | PEG_METHOD_ENTER(TRC_USER_MANAGER, "UserFileHandler::~UserFileHandler"); |
| |
delete _passwordFile; |
|
delete _mutex; |
|
|
|
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
| |
|
|
_passwordTable.clear(); | _passwordTable.clear(); |
_passwordFile->load(_passwordTable); | _passwordFile->load(_passwordTable); |
} | } |
catch (CannotOpenFile cof) |
catch (CannotOpenFile&) |
{ | { |
_passwordTable.clear(); | _passwordTable.clear(); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw cof; |
throw; |
} | } |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
} | } |
|
|
| |
try | try |
{ | { |
_mutex->timed_lock(_MUTEX_TIMEOUT, pegasus_thread_self()); |
_mutex->timed_lock(_MUTEX_TIMEOUT, Threads::self()); |
} | } |
catch (TimeOut e) |
catch (TimeOut&) |
{ | { |
//l10n | //l10n |
//throw PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, | //throw PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, |
|
|
throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_FAILED, MessageLoaderParms("Security.UserManager.UserFileHandler.TIMEOUT", | throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_FAILED, MessageLoaderParms("Security.UserManager.UserFileHandler.TIMEOUT", |
"Timed out trying to perform requested operation.Please re-try the operation again.")); | "Timed out trying to perform requested operation.Please re-try the operation again.")); |
} | } |
catch (WaitFailed e) |
catch (WaitFailed&) |
{ | { |
//l10n | //l10n |
//throw PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, | //throw PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, |
|
|
throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_FAILED, MessageLoaderParms("Security.UserManager.UserFileHandler.TIMEOUT", | throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_FAILED, MessageLoaderParms("Security.UserManager.UserFileHandler.TIMEOUT", |
"Timed out trying to perform requested operation.Please re-try the operation again.")); | "Timed out trying to perform requested operation.Please re-try the operation again.")); |
} | } |
catch (Deadlock e) |
catch (Deadlock&) |
{ | { |
//l10n | //l10n |
//throw PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, | //throw PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, |
|
|
{ | { |
_passwordFile->save(_passwordTable); | _passwordFile->save(_passwordTable); |
} | } |
catch (CannotOpenFile& e) |
catch (const CannotOpenFile&) |
{ | { |
_mutex->unlock(); | _mutex->unlock(); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw e; |
throw; |
} | } |
catch (CannotRenameFile& e) |
catch (const CannotRenameFile&) |
{ | { |
// | // |
// reload password hash table from file | // reload password hash table from file |
|
|
| |
_mutex->unlock(); | _mutex->unlock(); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw e; |
throw; |
} | } |
_mutex->unlock(); | _mutex->unlock(); |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
|
|
throw PasswordMismatch(userName); | throw PasswordMismatch(userName); |
} | } |
} | } |
catch (Exception& e) |
catch (const Exception&) |
{ | { |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw e; |
throw; |
} | } |
| |
// encrypt new password | // encrypt new password |