Пример #1
0
CCommandParser* CCommandParser::NewLC(MConnectionDataCallbacks& aObserver)
    {
    CCommandParser* self = new (ELeave) CCommandParser(aObserver);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }
Пример #2
0
	void getNewPasswordFromCmdLine(std::string &rPassword, std::istream &rInput, std::ostream &rOutput, CCommandParser const &rCommandParser)
	{
		bool IsPasswordValid = false;

		if (rCommandParser.isNotInteractive())
		{
			throw ExInputError("No password given in not-interactive mode. Please use interactive mode or specify all passwords on command line.", 1);
		}

		while (!IsPasswordValid)
		{
			std::string Password1;
			std::string Password2;

			getPasswordFromCmdLine(Password1, std::string("Enter new Password:"******"Enter Password again:"), rInput, rOutput, rCommandParser);

			if (Password1 == Password2)
			{
				rPassword = Password1;
				IsPasswordValid = true;

				rCommandParser.resetPassword(Password1);
				rCommandParser.resetPassword(Password2);
			}
			else
			{
				rOutput << "[ERROR] First and second password was not the same. Please type again!" << std::endl;
			}
		}

		return;
	}
Пример #3
0
CCommandParser* CCommandParser::NewL(CConsoleBase& aConsl)
//
// Create and connect client with leaving
//
    {
    CCommandParser* p = new (ELeave) CCommandParser(aConsl);
    CleanupStack::PushL(p);
    p->ConstructL();
    CleanupStack::Pop(p);
    return p;
    }
Пример #4
0
	bool testPasswordStrength(std::string &rPassword, mySafeCore::ImySafeCore * pMySafeCore, std::istream &rInput, std::ostream &rOutput, CCommandParser const &rCommandParser)
	{
		bool IsPasswordStrong = false;

		int Strength = pMySafeCore->getPasswordStrength(rPassword, "");

	  if (Strength < 75)
		{
			IsPasswordStrong = false;
		  rOutput << "[WARNING] Password strength is: " << getStrengthString(Strength).c_str() << " (" << Strength << "%)" << std::endl;

			if (rCommandParser.isNotInteractive())
			{
				throw ExInputError("Used password is too weak in not-interactive mode. Please specify a stronger password.", 1);
			}

			if (askUser(rInput, rOutput, rCommandParser, std::string("Do you want to chose another password?")) == true)
			{
				rPassword = "";
			}
			else
			{
				IsPasswordStrong = true;
			}
		}
		else
		{
			IsPasswordStrong = true;

			if (!rCommandParser.isSilent())
			{
			  rOutput << "Password strength is: " << getStrengthString(Strength).c_str() << std::endl;
			}
		}

		return IsPasswordStrong;
	}
Пример #5
0
  void getPasswordFromCmdLine(std::string &rPassword, std::string const &rQuestion, std::istream &rInput, std::ostream &rOutput, CCommandParser const &rCommandParser)
  {
		if (rCommandParser.isNotInteractive())
		{
			throw ExInputError("No password given in not-interactive mode. Please use interactive mode or specify all passwords on command line.", 1);
		}

		rOutput << rQuestion << std::endl;
		{
			Tools::CDisableTerminalEcho EchoOff;
			std::getline(rInput, rPassword);
		}

  	return;
  }