Esempio n. 1
0
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            string password1 = txtPassword.Text;
            string password2 = txtConferma.Text;

            if (password1 != password2)
            {
                MessageBox.Show(this, "Digitare la stessa parola sia nel campo 'password' che nel campo 'conferma password'");
                this.DialogResult = DialogResult.None;
                return;
            }
            if (password1.Length == 0)
            {
                MessageBox.Show(this, "La password deve essere composta da almeno 1 carattere");
                this.DialogResult = DialogResult.None;
                return;
            }
            byte[] password = Easy_DataAccess.CryptString(password1.PadRight(31));
            string errore;

            byte[]          nuovoAlfa1;
            Easy_DataAccess newConn = Conn.getDepartmentConnection(idDbDepartment, password, out errore, out nuovoAlfa1);

            if (errore != null)
            {
                MessageBox.Show(this, "La password inserita non è valida per operare sul dipartimento " + idDbDepartment + "\r\n." + errore);
                this.DialogResult = DialogResult.None;
                return;
            }
            this.DialogResult = DialogResult.OK;
        }
Esempio n. 2
0
//		private string getNuovoAlfa1(string passwordDipart) {
//			byte[] alfa = mainConn.sha256UserPassword();
//			byte[] g1 = DataAccess.CryptString(passwordDipart.PadRight(31));
//			byte[] alfa1 = xor(alfa, g1);
//			return QueryCreator.ByteArrayToString(alfa1);
//		}

        public void MetaData_BeforePost()
        {
            DataRow rDepartment = HelpForm.GetLastSelected(DS.dbdepartment);

            if (rDepartment == null)
            {
                return;
            }
            string passwordDipart = rDepartment["!password"] as string;

            textBox1.Text = passwordDipart;

            string       userAmmin    = (string)Meta.Conn.GetSys("user");
            MetaData     metaDBAccess = MetaData.GetMetaData(this, "dbaccess");
            MetaData     metaDBUser   = MetaData.GetMetaData(this, "dbuser");
            UTF8Encoding encoding     = new UTF8Encoding();

            string    filtroUtente = "(login="******")";
            DataTable tUtenti      = DataAccess.RUN_SELECT(mainConn, "dbuser", null, null, filtroUtente, null, null, true);

            DataRow[] rUtenti = tUtenti.Select(filtroUtente);
            if (rUtenti.Length == 0)
            {
                MetaData.SetDefault(DS.dbuser, "login", userAmmin);
                metaDBUser.Get_New_Row(null, DS.dbuser);
            }

            string filtroAccesso = filtroUtente + " and (iddbdepartment="
                                   + QueryCreator.quotedstrvalue(rDepartment["iddbdepartment"], true) + ")";

            DataAccess.RUN_SELECT_INTO_TABLE(mainConn, DS.dbaccess, null, filtroAccesso, null, true);
            MetaData.SetDefault(DS.dbaccess, "login", userAmmin);

            string iddbdepartment = (string)rDepartment["iddbdepartment"];
            string errore;

            byte[] g1 = mainConn.getDepartmentPassword(iddbdepartment, out errore);
            if (g1 == null)
            {
                metaDBAccess.Get_New_Row(rDepartment, DS.dbaccess);
                g1 = Easy_DataAccess.CryptString(passwordDipart.PadRight(31));
            }
            DataRow[] righeAccesso = rDepartment.GetChildRows("dbdepartmentdbaccess");
            foreach (DataRow rAccess in righeAccesso)
            {
                byte[] alfa  = mainConn.sha256UserPassword();
                byte[] alfa1 = xor(alfa, g1);
                rAccess["alpha1"] = QueryCreator.ByteArrayToString(alfa1);
            }
        }