void ModuleManager::DoSafeUnload(Module* mod) { // First, notify all modules that a module is about to be unloaded, so in case // they pass execution to the soon to be unloaded module, it will happen now, // i.e. before we unregister the services of the module being unloaded FOREACH_MOD(OnUnloadModule, (mod)); std::map<std::string, Module*>::iterator modfind = Modules.find(mod->ModuleSourceFile); std::vector<reference<ExtensionItem> > items; ServerInstance->Extensions.BeginUnregister(modfind->second, items); /* Give the module a chance to tidy out all its metadata */ const chan_hash& chans = ServerInstance->GetChans(); for (chan_hash::const_iterator c = chans.begin(); c != chans.end(); ) { Channel* chan = c->second; ++c; mod->OnCleanup(TYPE_CHANNEL, chan); chan->doUnhookExtensions(items); const Channel::MemberMap& users = chan->GetUsers(); for (Channel::MemberMap::const_iterator mi = users.begin(); mi != users.end(); ++mi) mi->second->doUnhookExtensions(items); } const user_hash& users = ServerInstance->Users->GetUsers(); for (user_hash::const_iterator u = users.begin(); u != users.end(); ) { User* user = u->second; // The module may quit the user (e.g. SSL mod unloading) and that will remove it from the container ++u; mod->OnCleanup(TYPE_USER, user); user->doUnhookExtensions(items); } const ModeParser::ModeHandlerMap& usermodes = ServerInstance->Modes->GetModes(MODETYPE_USER); for (ModeParser::ModeHandlerMap::const_iterator i = usermodes.begin(); i != usermodes.end(); ) { ModeHandler* mh = i->second; ++i; if (mh->creator == mod) this->DelService(*mh); } const ModeParser::ModeHandlerMap& chanmodes = ServerInstance->Modes->GetModes(MODETYPE_CHANNEL); for (ModeParser::ModeHandlerMap::const_iterator i = chanmodes.begin(); i != chanmodes.end(); ) { ModeHandler* mh = i->second; ++i; if (mh->creator == mod) this->DelService(*mh); } for(std::multimap<std::string, ServiceProvider*>::iterator i = DataProviders.begin(); i != DataProviders.end(); ) { std::multimap<std::string, ServiceProvider*>::iterator curr = i++; if (curr->second->creator == mod) DataProviders.erase(curr); } dynamic_reference_base::reset_all(); DetachAll(mod); Modules.erase(modfind); ServerInstance->GlobalCulls.AddItem(mod); ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Module %s unloaded",mod->ModuleSourceFile.c_str()); ServerInstance->ISupport.Build(); }
int main() { // Declarations char choice = '0'; BinarySearchTree<User,string> UserTree; User temp, maximum, minimum; User* ptr; string username, password, firstName, lastName; // Read in from file ifstream infile("users.txt"); while (infile >> temp) { UserTree.insert(temp); } infile.close(); // Menu while(choice != 'Q') { cout << "Enter the corresponding number for what you want to do:" << endl << "1: Attempt to log in" << endl << "2: Register a new user" << endl << "3: Delete an existing user" << endl << "4: View total number of users" << endl << "5: View min and max username" << endl << "6: View tree height" << endl << "Q: Quit the program" << endl; cin >> choice; switch(choice) { case '1': // Authenticate User cout << endl << "Log in:" << endl << " Username: "******" Password: "******"Invalid username/password combination." << endl; } else if (ptr->authenticate(password)){ cout << endl << "Welcome " << ptr->getFirstName() << ", " << ptr->getLastName() << "." << endl << endl << endl; } else { cout << endl << "Invalid username/password combination." << endl << endl << endl; } break; case '2': // Register User cout << endl << "Enter the unique username of the user you want to create: "; cin >> username; if (!UserTree.search(username)) { cout << " Password: "******" First Name: "; cin >> firstName; cout << " Last Name: "; cin >> lastName; User newuser(username, password, firstName, lastName); UserTree.insert(newuser); cout << endl << "User successfully created!" << endl << endl << endl; } else { cout << endl << "User already exists!" << endl << endl << endl; } break; case '3': cout << endl << "Enter the user name of the user you want to remove:"; cin >> username; if (UserTree.remove(username)) { cout << endl << username << " was successfully removed!" << endl << endl << endl; } else { cout << endl << "No such user exists." << endl << endl << endl; } break; case '4': cout << endl << " There are " << UserTree.size() << " users in this tree." << endl; break; case '5': maximum = UserTree.max(); minimum = UserTree.min(); cout << endl << " Minimum Username: "******" Maximum Username: "******"The User Tree is " << UserTree.height() << " users in height." << endl << endl << endl; break; }
void output_User(const User& u) { string str(u.getUsername() + " " + u.getUsername() + " " + u.getFirstName() + " " + u.getLastName()); outfile << str << endl; }
void menu(int choice, bool &goBackToFirstMenu, UserList &dataList) { while(choice != 1 && choice != 2 && choice != 3 && choice != 4) //if user enters something other than 1,2,3 { cout << "Please enter a correct number." << endl; cin >> choice; } if(choice == 1) { checkUsername(dataList); } else if(choice == 2) { bool checkIfExists; User newuser; cout << "Hi! You are about to create a new user." << endl; cout << endl; cout << "What is the user's name?" << endl; string newName; getline(cin, newName); getline(cin, newName); newuser.setName(newName); cout << "Make a username for yourself! (Remember, no spaces in usernames)" << endl; string newUserName; cin >> newUserName; newuser.setUsername(newUserName); checkIfExists = dataList.checkIfSame(newUserName); while(checkIfExists == true) { cout << "Try entering another username" << endl; string enterNewName; cin >> enterNewName; newuser.setUsername(enterNewName); checkIfExists = dataList.checkIfSame(enterNewName); } //cout << endl; cout << "Make your own password! (remember, no spaces!)" << endl; string newPassword; cin >> newPassword; cout << "For security purposes, please enter your password again." << endl; string checkNewPassword; cin >> checkNewPassword; while(newPassword != checkNewPassword) { cout << "Please enter your password again!" << endl; cin >> checkNewPassword; } newuser.setPassword(newPassword); //cout << endl; cout << "Now for the third element, please type which university you go to!" << endl; string newUniversity; getline(cin,newUniversity); getline(cin,newUniversity); cout << endl; newuser.setUniversity(newUniversity); cout << "Your university is " << newUniversity << "!" << endl; cout << endl; dataList.addUser(newuser); User addANewUser; string university = "USC"; string password = "******"; string username = "******"; string comment = "COMMENT"; string comment1 = "HEY WHATS UP"; string randomizing; for(int i = 0; i < 10000; i++) { randomizing = generatingRandom(); addANewUser.setUsername(randomizing); addANewUser.setPassword(password); addANewUser.setUniversity(university); //addANewUser.addPostAutomatic(username, comment); addANewUser.addPostAutomatic(username, comment1); //dataList.addUser(addANewUser); //addANewUser. for(int j = 0; j < 100; j++) { //addANewUser.addFriends() } //dataList.writeFile(); } }
void RceQueryCheckAndLockAccountIfPossibleHandle::handle_selfload(Event* e) { int64 uid = e->uid(); GameDataHandler* pUserManager = eh_->getDataHandler(); if(!pUserManager) { return; } User *pUser = pUserManager->getUser(uid); if ( !pUser) { return; } Player* pPlayer = pUser->GetPlayer(); if ( !pPlayer || !pPlayer->CanUse()) { return ; } RceQueryCheckAndLockAccountIfPossible* req = e->mutable_ce_rcequerycheckandlockaccountifpossible(); if( !req ) { return; } RseQueryCheckAndLockAccountIfPossible *pRsp = e->mutable_se_rsequerycheckandlockaccountifpossible(); pRsp->set_lockapplied(req->applylock()); pRsp->set_lockrequested(1); pRsp->set_locktype(0); pRsp->set_locksuccess(1); string text; pRsp->SerializeToString(&text); eh_->sendDataToUser(pUser->fd(), S2C_RseQueryCheckAndLockAccountIfPossible, text); return; DB_Planet *pDBPlanet = pPlayer->GetPlanet(pPlayer->GetCurPlanetId()); if(!pDBPlanet){ pRsp->set_locksuccess(0); pRsp->set_locktype(7); string text; pRsp->SerializeToString(&text); eh_->sendDataToUser(pUser->fd(), S2C_RseQueryCheckAndLockAccountIfPossible, text); return; } /*for(int i = 0; i < req->hangarsunitsinfo_size(); i++){ HangarsUnitsInfo *pMsgUnit = req->mutable_hangarsunitsinfo(i); if(pMsgUnit){ for (int k = 0; k < pDBPlanet->hangars_size(); k++){ DB_Hangar *pDBUnit = pDBPlanet->hangars(k); if(pDBUnit && pDBUnit->sid() == pMsgUnit->sid()){ } } } }*/ int64 TID; safe_atoll(req->targetaccountid(), TID); LoadStatus state = LOAD_INVALID; User *pTUser = pUserManager->getUser(TID, &state, true); if (pTUser == NULL) { if (state == LOAD_WAITING) { eh_->postBackEvent(e); } else if (state == LOAD_MISS) { e->mutable_forwardinfo()->set_uid(TID); e->set_state(Status_Normal_To_World); eh_->sendEventToWorld(e); } return; } else { if(0 == req->applylock()){ if(pTUser->Online()){ pRsp->set_locksuccess(0); pRsp->set_locktype(1); string text; pRsp->SerializeToString(&text); eh_->sendDataToUser(pUser->fd(), S2C_RseQueryCheckAndLockAccountIfPossible, text); return; }else if(pTUser->GetLastAttackedTime()){ pRsp->set_locksuccess(0); pRsp->set_locktype(2); string text; pRsp->SerializeToString(&text); eh_->sendDataToUser(pUser->fd(), S2C_RseQueryCheckAndLockAccountIfPossible, text); return; } }else{ int nPlanetId = req->planetid(); Player *pTPlayer = pUser->GetPlayer(); } } }
void ChatClient::slotReadAllYouMessageNotify(int dialog) { User *us = userlist->userByDialog(dialog); us->setWroteMessage(0); }
void ChatClient::slotNotifyOnOff(quint16 userId, bool stat) { User *us = userlist->userById(userId); us->setOnline(stat); userlist->updateStatus(us); }
Status CmdAuthenticate::_authenticateCR(const UserName& user, const BSONObj& cmdObj) { if (user == internalSecurity.user->getName() && serverGlobalParams.clusterAuthMode.load() == ServerGlobalParams::ClusterAuthMode_x509) { return Status(ErrorCodes::AuthenticationFailed, "Mechanism x509 is required for internal cluster authentication"); } if (_isCRAuthDisabled) { // SERVER-8461, MONGODB-CR must be enabled for authenticating the internal user, so that // cluster members may communicate with each other. if (user != internalSecurity.user->getName()) { return Status(ErrorCodes::BadValue, _nonceAuthenticationDisabledMessage); } } string key = cmdObj.getStringField("key"); string received_nonce = cmdObj.getStringField("nonce"); if( user.getUser().empty() || key.empty() || received_nonce.empty() ) { sleepmillis(10); return Status(ErrorCodes::ProtocolError, "field missing/wrong type in received authenticate command"); } stringstream digestBuilder; { ClientBasic *client = ClientBasic::getCurrent(); boost::scoped_ptr<AuthenticationSession> session; client->swapAuthenticationSession(session); if (!session || session->getType() != AuthenticationSession::SESSION_TYPE_MONGO) { sleepmillis(30); return Status(ErrorCodes::ProtocolError, "No pending nonce"); } else { nonce64 nonce = static_cast<MongoAuthenticationSession*>(session.get())->getNonce(); digestBuilder << hex << nonce; if (digestBuilder.str() != received_nonce) { sleepmillis(30); return Status(ErrorCodes::AuthenticationFailed, "Received wrong nonce."); } } } User* userObj; Status status = getGlobalAuthorizationManager()->acquireUser(user, &userObj); if (!status.isOK()) { // Failure to find the privilege document indicates no-such-user, a fact that we do not // wish to reveal to the client. So, we return AuthenticationFailed rather than passing // through the returned status. return Status(ErrorCodes::AuthenticationFailed, status.toString()); } string pwd = userObj->getCredentials().password; getGlobalAuthorizationManager()->releaseUser(userObj); md5digest d; { digestBuilder << user.getUser() << pwd; string done = digestBuilder.str(); md5_state_t st; md5_init(&st); md5_append(&st, (const md5_byte_t *) done.c_str(), done.size()); md5_finish(&st, d); } string computed = digestToString( d ); if ( key != computed ) { return Status(ErrorCodes::AuthenticationFailed, "key mismatch"); } AuthorizationSession* authorizationSession = ClientBasic::getCurrent()->getAuthorizationSession(); status = authorizationSession->addAndAuthorizeUser(user); if (!status.isOK()) { return status; } return Status::OK(); }