version 1.25.30.2, 2007/01/02 06:14:47
|
version 1.26, 2007/04/03 18:50:58
|
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Sushma Fernandes, Hewlett Packard Company (sushma_fernandes@hp.com) |
|
// |
|
// Modified By: Amit K Arora, IBM (amita@in.ibm.com) for Bug#1519 |
|
// Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for PEP#101 |
|
// Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for PEP#1791, Bug#3606 |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
| |
|
|
#include <Pegasus/Common/FileSystem.h> | #include <Pegasus/Common/FileSystem.h> |
#include <Pegasus/Common/Logger.h> | #include <Pegasus/Common/Logger.h> |
#include <Pegasus/Common/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
#include <Pegasus/Common/Executor.h> |
|
#if defined(PEGASUS_OS_OS400) | #if defined(PEGASUS_OS_OS400) |
#include "OS400ConvertChar.h" | #include "OS400ConvertChar.h" |
#endif | #endif |
|
|
{ | { |
if (FileSystem::exists(_passwordFile)) | if (FileSystem::exists(_passwordFile)) |
{ | { |
if (Executor::removeFile(_passwordFile.getCString()) != 0) |
if (! FileSystem::removeFile(_passwordFile)) |
{ | { |
throw CannotRemoveFile(_passwordFile); | throw CannotRemoveFile(_passwordFile); |
} | } |
|
|
Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, | Logger::put_l(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, |
"Security.UserManager.PasswordFile.TRYING_TO_BACKUP_FILE", | "Security.UserManager.PasswordFile.TRYING_TO_BACKUP_FILE", |
"Trying to use the backup file : $0.", _passwordBackupFile); | "Trying to use the backup file : $0.", _passwordBackupFile); |
if (Executor::renameFile( |
if (! FileSystem::renameFile(_passwordBackupFile, _passwordFile)) |
_passwordBackupFile.getCString(), _passwordFile.getCString()) != 0) |
|
{ | { |
//l10n | //l10n |
//Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, | //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
|
// | // |
// Get the userName | // Get the userName |
// | // |
String userName = String::EMPTY; |
String userName; |
| |
userName.append(*p++); | userName.append(*p++); |
| |
|
|
// | // |
// Get the password | // Get the password |
// | // |
String password = String::EMPTY; |
String password; |
| |
while (*p) | while (*p) |
{ | { |
|
|
{ | { |
if ( FileSystem::exists(_passwordFile)) | if ( FileSystem::exists(_passwordFile)) |
{ | { |
if (Executor::removeFile(_passwordFile.getCString()) != 0) |
if ( ! FileSystem::removeFile(_passwordFile)) |
{ | { |
//l10n | //l10n |
//Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, | //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, |
|
|
{ | { |
if ( FileSystem::exists(_passwordFile)) | if ( FileSystem::exists(_passwordFile)) |
{ | { |
if (Executor::renameFile(_passwordFile.getCString(), |
if ( ! FileSystem::renameFile(_passwordFile, _passwordBackupFile)) |
_passwordBackupFile.getCString()) != 0) |
|
{ | { |
//l10n | //l10n |
//Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, | //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, Logger::SEVERE, |
|
|
// | // |
// Open the password file for writing | // Open the password file for writing |
// | // |
|
#if defined(PEGASUS_OS_OS400) |
FILE* ofs = Executor::openFile(_passwordFile.getCString(), 'w'); |
ofstream ofs(_passwordFile.getCString(), PEGASUS_STD(_CCSID_T(1208))); |
|
#else |
|
ofstream ofs(_passwordFile.getCString()); |
|
#endif |
if (!ofs) | if (!ofs) |
{ | { |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
throw CannotOpenFile(getFileName()); | throw CannotOpenFile(getFileName()); |
} | } |
| |
|
ofs.clear(); |
|
|
// | // |
// Save user names and passwords to the new file | // Save user names and passwords to the new file |
// | // |
for (PasswordTable::Iterator i = passwordTable.start(); i; i++) | for (PasswordTable::Iterator i = passwordTable.start(); i; i++) |
{ | { |
CString key = i.key().getCString(); |
ofs << i.key() << ":" << i.value() << endl; |
CString value = i.value().getCString(); |
|
fprintf(ofs, "%s:%s\n", (const char*)key, (const char*)value); |
|
} | } |
| |
fclose(ofs); |
ofs.close(); |
| |
if ( FileSystem::exists(_passwordBackupFile)) | if ( FileSystem::exists(_passwordBackupFile)) |
{ | { |
if (Executor::removeFile(_passwordBackupFile.getCString()) != 0) |
if ( ! FileSystem::removeFile(_passwordBackupFile)) |
{ | { |
//l10n | //l10n |
//Logger::put(Logger::ERROR_LOG, System::CIMSERVER, | //Logger::put(Logger::ERROR_LOG, System::CIMSERVER, |