Esempio n. 1
0
 /// <summary>
 /// Check the Database to make sure user exists.
 /// </summary>
 /// <param name="user"></param>
 /// <param name="password"></param>
 /// <returns>True if exists, false if doesn't</returns>
 public bool AuthenticateUser(string encrypteduser, string encryptedpassword)
 {
     UserDB db = new UserDB();
     return db.userExists(encrypteduser, encryptedpassword);
 }
Esempio n. 2
0
 /// <summary>
 /// Get the role of the user from the db
 /// </summary>
 /// <param name="encrypteduser"></param>
 /// <param name="encryptedpassword"></param>
 /// <returns></returns>
 public string getRole(string encrypteduser, string encryptedpassword)
 {
     UserDB db = new UserDB();
     if (db.userExists(encrypteduser, encryptedpassword))
         return db.getRole(encrypteduser, encryptedpassword);
     return null;
 }
Esempio n. 3
0
 /// <summary>
 /// Ensure the user has the adminstrator role
 /// </summary>
 /// <param name="encrypeduser"></param>
 /// <param name="encryptedpassword"></param>
 /// <returns>True if user has admin role</returns>
 public bool AuthenticateAdminRole(string encrypteduser, string encryptedpassword)
 {
     UserDB db = new UserDB();
     //the encrypted role of the user == the encryption of "administrator" using the decryption of the stored encrypted key as the passphrase.
     return db.getRole(encrypteduser, encryptedpassword) == cryptographer.EncryptString("administrator", cryptographer.DecryptString(key.EncryptedKey(), sharedPrivateKey));
 }
Esempio n. 4
0
 private void AddUser_Load(object sender, EventArgs e)
 {
     db = new UserDB();
     crypter = new En_De_cryption();
     key = new Key();
 }