inline DirectoryEntry LocalServiceLocatorDataStore::MakeAccount(
     const std::string& name, const std::string& password,
     const DirectoryEntry& parent,
     const boost::posix_time::ptime& registrationTime) {
   bool accountExists;
   try {
     DirectoryEntry existingAccount = LoadAccount(name);
     accountExists = true;
   } catch(const ServiceLocatorDataStoreException&) {
     accountExists = false;
   }
   if(accountExists) {
     BOOST_THROW_EXCEPTION(ServiceLocatorDataStoreException(
       "An account with the specified name exists."));
   }
   DirectoryEntry newEntry(DirectoryEntry::Type::ACCOUNT, m_nextId, name);
   ++m_nextId;
   m_accounts.push_back(newEntry);
   m_passwords.insert(std::make_pair(newEntry,
     HashPassword(newEntry, password)));
   m_registrationTimes.insert(std::make_pair(newEntry, registrationTime));
   m_lastLoginTimes.insert(std::make_pair(newEntry,
     boost::posix_time::neg_infin));
   Associate(newEntry, parent);
   return newEntry;
 }
示例#2
0
/*!
\brief Reload all account
*/
void cAccounts::LoadAccounts( void )
{
	int b,c,ac;
	unsigned int account;
	char accnumb[264];
	char acc[264];
	char *t;
	lastusedacctnum = 0;
    char script1[1024];
    char script2[1024];

	FILE *F = fopen("config/accounts.adm", "rt");
	if (F==NULL) {
	#ifndef WIN32
		ConOut("************\nCan't load accounts. Can't continue.\n***********");
		ConOut("\nPress <return> to exit.");
		char str[80];
		fgets(str, 70, stdin);
	#else
		MessageBox(NULL, "Can't load accounts. Can't continue.", "Fatal Error - NoX-Wizard", MB_ICONHAND);
	#endif
		exit(1);
	}

	acctlist.clear();
	while (!feof(F))
	{
		readSplitted(F, script1, script2);
		if (feof(F)) break;
		if (!(strcmp(script1, "SECTION")))
		{
			c = strlen(script2);
			for (b=0; b<9; b++) acc[b]=script2[b];
			for (b=8; b<c; b++) accnumb[b-8]=script2[b];
			accnumb[b-8]=0; acc[8]=0;
			ac = strtol(accnumb, &t, 10);
			if (strlen(t)!=0) ac=-1;

			if (strcmp(acc,"ACCOUNT ") || ac < 0 )
			{
				ConOut("Error loading accounts, skipping invalid account entry!\n");

			} else {
			   account=ac;
			   LoadAccount(account, F);
			   if (account > lastusedacctnum)
				   lastusedacctnum = account;
			}
		}
	}
	fclose(F);
}
 inline DirectoryEntry LocalServiceLocatorDataStore::MakeDirectory(
     const std::string& name, const DirectoryEntry& parent) {
   bool accountExists;
   try {
     DirectoryEntry existingAccount = LoadAccount(name);
     accountExists = true;
   } catch(const ServiceLocatorDataStoreException&) {
     accountExists = false;
   }
   if(accountExists) {
     BOOST_THROW_EXCEPTION(ServiceLocatorDataStoreException(
       "An account with the specified name exists."));
   }
   DirectoryEntry newEntry(DirectoryEntry::Type::DIRECTORY, m_nextId, name);
   ++m_nextId;
   m_directories.push_back(newEntry);
   Associate(newEntry, parent);
   return newEntry;
 }
void cAccount::LoadAccounts( void )
{
	int b,c,ac, account,loopexit=0;
	char accnumb[64]; 		
	char acc[64];
	char *t;
	lastusedacctnum = 0;

	openscript("accounts.adm");
	acctlist.clear();
	do
	{
		read2();	
		if (!(strcmp((char*)script1, "SECTION")))
		{
			   
			c = strlen((char*)script2);
			for (b=0; b<9; b++) acc[b]=script2[b]; 
			for (b=8; b<c; b++) accnumb[b-8]=script2[b];
			accnumb[b-8]=0; acc[8]=0;		
			ac = strtol(accnumb, &t, 10);
			if (strlen(t)!=0) ac=-1;

			if (strcmp(acc,"ACCOUNT ") || ac < 0 )
			{
				clConsole.send("Error loading accounts, skipping invalid account entry!\n");

			} else {
			   account=ac;
			   LoadAccount(account);
			   if (account > lastusedacctnum)
				   lastusedacctnum = account;
			}
		}
	}
	while ( (strcmp((char*)script1, "EOF")) && (++loopexit < MAXLOOPS) );
	closescript();	
}