Esempio n. 1
0
PasswordDialog::PasswordDialog(QWidget *parent)
    : QDialog(parent),
      ui(new Ui::PasswordDialog),
      _password("")
{
    ui->setupUi(this);

    ui->labelIcon->setPixmap(QIcon(":/logo/128x128/logo.png").pixmap(128));

    QScopedPointer<SettingsPassword> settings(new SettingsPassword(this));
    ui->editUsername->setText(settings->username());
    if (!settings->password().isEmpty()) {
        _password = settings->password();
        ui->remember->setChecked(true);

        validatePassword();
    }

    if (globalNetwork) {
        connect(globalNetwork, SIGNAL(passwordError(int)), this, SLOT(validatePasswordError(int)));
        connect(globalNetwork, SIGNAL(passwordOk(QString)), this, SLOT(validatePasswordOk(QString)));
    }

    connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(validatePassword()));
}
Esempio n. 2
0
void login()
{
	double enteredPassword = 0;
	int attempt = 1;

	printf("\nPlease enter the administrator's password.\n");
	do
	{
		printf("Attempt number %d\n>", attempt);
		enteredPassword = 0;
		scanf("%lf", &enteredPassword);
		fflush(stdin);
		attempt++;
	} while (!(validatePassword(enteredPassword)) && (attempt <= 3));

	if (attempt > 3)
	{
		printf("You have used too many attempts\n");
		return;
	}
	isAdmin = 1;
	printf("You have successfully logged in.\n");
	adminOptions();

}
Esempio n. 3
0
LoginForm::LoginForm(QString title, QWidget *parent): QWidget(parent), ui(new Ui::LoginForm) {
	ui->setupUi(this);
	connect(ui->SignIn_pushButton, SIGNAL(clicked()), this, SIGNAL(finished()));
	connect(ui->UserName_lineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateUsername(QString)));
	connect(ui->Password_lineEdit, SIGNAL(textChanged(QString)), this, SLOT(validatePassword(QString)));
	setWindowTitle(title);
	username_valid = false;
	password_valid = false;
	ui->SignIn_pushButton->setEnabled(false);
	setWindowIcon(QIcon(":/acid_16.png"));
}
Esempio n. 4
0
void Options::setPassword(const String &oldPassword, const String &newPassword) { // static
  if(!validatePassword(oldPassword)) {
    throwException(_T("Forkert password"));
  }

  String newMD5Password;
  if(newPassword.length() == 0) {
    newMD5Password = EMPTYSTRING;
  } else {
    MD5Context md5;
    newMD5Password = md5.digest(newPassword);
  }
  getKey().setValue(_T("password"),newMD5Password);
}
Esempio n. 5
0
/* Both password and username are inserted into their respective map.	 */
void Authentication::newUser() {
    string temp;
    cout << "Please choose a username:  "******"Enter Password:  "******"\nRe-Enter Password:  ");

    m_password.insert(pair<int, string>(m_password.size(), password));
    writeFile();

    m_user = name;
}
Esempio n. 6
0
/* their password.							 */
void Authentication::changePassword(string name) {
    char ans;
    string password;
    do {
        cout << "Do you want to change your password (y/n):  ";
        cin >> ans;
    } while(ans != 'y' && ans != 'Y' && ans != 'n' && ans != 'N');

    if(ans == 'y' || ans == 'Y') {
        password = validatePassword("Enter New Password:  "******"\nRe-Enter New Password:  ");
        for(unsigned int i = 0; i < m_username.size(); i++) {
            if(m_username.at(i) == name)
                m_password.at(i) = password;
        }
        writeFile();
    }
}
Esempio n. 7
0
void InternalConnection::attach(thread_db* tdbb, const PathName& dbName,
		const MetaName& user, const string& pwd,
		const MetaName& role)
{
	fb_assert(!m_attachment);
	Database* dbb = tdbb->getDatabase();
	fb_assert(dbName.isEmpty() || dbName == dbb->dbb_database_name.c_str());

	// Don't wrap raised errors. This is needed for backward compatibility.
	setWrapErrors(false);

	Jrd::Attachment* attachment = tdbb->getAttachment();
	if ((user.isEmpty() || user == attachment->att_user->getUserName()) &&
		pwd.isEmpty() &&
		(role.isEmpty() || role == attachment->att_user->getSqlRole()))
	{
		m_isCurrent = true;
		m_attachment = attachment->getInterface();
	}
	else
	{
		m_isCurrent = false;
		m_dbName = dbb->dbb_database_name.c_str();
		generateDPB(tdbb, m_dpb, user, pwd, role);

		// Avoid change of m_dpb by validatePassword() below
		ClumpletWriter newDpb(m_dpb);
		validatePassword(tdbb, m_dbName, newDpb);

		FbLocalStatus status;
		{
			EngineCallbackGuard guard(tdbb, *this, FB_FUNCTION);
			RefPtr<JProvider> jInstance(JProvider::getInstance());
			jInstance->setDbCryptCallback(&status, tdbb->getAttachment()->att_crypt_callback);
			m_attachment.assignRefNoIncr(jInstance->attachDatabase(&status, m_dbName.c_str(),
				newDpb.getBufferLength(), newDpb.getBuffer()));
		}

		if (status->getState() & IStatus::STATE_ERRORS)
			raise(&status, tdbb, "JProvider::attach");
	}

	m_sqlDialect = (m_attachment->getHandle()->att_database->dbb_flags & DBB_DB_SQL_dialect_3) ?
					SQL_DIALECT_V6 : SQL_DIALECT_V5;
}