Пример #1
0
int Console::Run(int argc,char* argv[])
{
	CreateDirectories();
	bool isUser=false;
	string cmd;
	if (PasswordManager::ValidatePassword())
	{
		pair<bool, tVecStr> valPass=ValidatePassword();
		if(valPass.first)
			isUser=true;
		else
			IntrudersManager::writeIntruder(valPass.second);
	}
	else
	{
		/*PEDIR PASS Y CREAR TODAS LAS ESTRUCTURAS*/
		Message pass;
		bool isOk=Console::InsertNewPassword(pass);
		if(isOk){
			FileSystem::CreateStruture(pass);
			isUser=true;
			pass.Delete();
		}
	}
	if (isUser)
	{
		ShowInitialMessage();
		if (IntrudersManager::ExistNewIntruder() )
		{
			Console::ShowIntruderMessage();
		}
		UpdatesImage();
		while(!CommandFactory::IsQuitCommand(cmd))
		{
			ReadCommand(cmd);
			Command* command = CommandFactory::CreateCommand(cmd);
			if(command != NULL)
			{
				command->Run(cmd);
				delete command;
			}
		}
		Destroy();
	}
	return 0;
}
Пример #2
0
void PSPasswordDlg::OnOK() 
{
	UpdateData();

	BOOL bValid = ValidatePassword();
	if (bValid)
	{
		EndDialog(IDOK);
	}
	else 
	{
		m_nRetries++;
		if (m_nRetries == 3)
		{
			m_nRetries = 0;
			MessageBox(L"Thank you for trying. Good Bye!", L"Diplo", MB_ICONEXCLAMATION);
			EndDialog(IDCANCEL);
		}
		else 
			MessageBox(L"Invalid Password", L"Diplo", MB_ICONEXCLAMATION);
	}
}
   std::shared_ptr<const Account>
   PasswordValidator::ValidatePassword(const String &sUsername, const String &sPassword)
   {
      std::shared_ptr<Account> pEmpty;

      // Apply domain name aliases to this domain name.
      std::shared_ptr<DomainAliases> pDA = ObjectCache::Instance()->GetDomainAliases();
      String sAccountAddress = pDA->ApplyAliasesOnAddress(sUsername);

      // Apply default domain
      sAccountAddress = DefaultDomain::ApplyDefaultDomain(sAccountAddress);

      std::shared_ptr<const Account> pAccount = CacheContainer::Instance()->GetAccount(sAccountAddress);
      
      if (!pAccount)
         return pEmpty;

      if (!pAccount->GetActive())
         return pEmpty;

      // Check that the domain is active as well.
      
      String sDomain = StringParser::ExtractDomain(sAccountAddress);
      std::shared_ptr<const Domain> pDomain = CacheContainer::Instance()->GetDomain(sDomain);

      if (!pDomain)
         return pEmpty;

      if (!pDomain->GetIsActive())
         return pEmpty;

      if (!ValidatePassword(pAccount, sPassword))
         return pEmpty;



      return pAccount;
   }
Пример #4
0
std::shared_ptr<const Account>
PasswordValidator::ValidatePassword(const String &sMasqname, const String &sUsername, const String &sPassword)
{
    std::shared_ptr<Account> pEmpty;

    // Apply domain name aliases to this domain name.
    std::shared_ptr<DomainAliases> pDA = ObjectCache::Instance()->GetDomainAliases();
    String sAccountAddress = pDA->ApplyAliasesOnAddress(sUsername);

    // Apply default domain
    sAccountAddress = DefaultDomain::ApplyDefaultDomain(sAccountAddress);

    std::shared_ptr<const Account> pAccount = CacheContainer::Instance()->GetAccount(sAccountAddress);

    if (!pAccount)
        return pEmpty;

    if (!pAccount->GetActive())
        return pEmpty;

    // Check that the domain is active as well.

    String sDomain = StringParser::ExtractDomain(sAccountAddress);
    std::shared_ptr<const Domain> pDomain = CacheContainer::Instance()->GetDomain(sDomain);

    if (!pDomain)
        return pEmpty;

    if (!pDomain->GetIsActive())
        return pEmpty;

    if (!ValidatePassword(pAccount, sPassword))
        return pEmpty;

    if (sMasqname.GetLength() == 0)
        return pAccount;

    // if we get this far, we are authenticating against one username, but will actually login
    // as a second username (rfc-4616)

    // Apply domain name aliases to this domain name.
    pDA = ObjectCache::Instance()->GetDomainAliases();
    sAccountAddress = pDA->ApplyAliasesOnAddress(sMasqname);

    // Apply default domain
    sAccountAddress = DefaultDomain::ApplyDefaultDomain(sAccountAddress);

    pAccount = CacheContainer::Instance()->GetAccount(sAccountAddress);

    if (!pAccount)
        return pEmpty;

    if (!pAccount->GetActive())
        return pEmpty;

    // Check that the domain is active as well.

    sDomain = StringParser::ExtractDomain(sAccountAddress);
    pDomain = CacheContainer::Instance()->GetDomain(sDomain);

    if (!pDomain)
        return pEmpty;

    if (!pDomain->GetIsActive())
        return pEmpty;

    return pAccount;
}