public void UpdateData()
 {
     adminMailTB.Text          = Resources.profile.Default.admin_mail;
     adminPassTB.Text          = PasswordEncryption.Decrypt(Resources.profile.Default.admin_password);
     saveChangesButton.Enabled = false;
     HideConfirmPassTB();
 }
예제 #2
0
        public static void SendCustomMail(string toAddress, string subject, string body)
        {
            ReloadPassword();

            var    fromMailAddress = new MailAddress(SenderAddress, "F4E by MMB");
            var    toMailAddress   = new MailAddress(toAddress, "");
            string fromPassword    = PasswordEncryption.Decrypt(SenderPassword);

            var smtp = new SmtpClient
            {
                Host                  = "smtp.gmail.com",
                Port                  = 587,
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials           = new NetworkCredential(fromMailAddress.Address, fromPassword)
            };

            using (var message = new MailMessage(SenderAddress, toAddress)
            {
                Subject = subject,
                Body = body,
            })
            {
                message.IsBodyHtml = true;
                smtp.Send(message);
            }
        }
 public void ResetGUI()
 {
     nameTB.Text                  = FilteringSystem.GetCurrentFilteringSettings().GetAdminName();
     passwordTB.Password          = PasswordEncryption.Decrypt(FilteringSystem.GetCurrentFilteringSettings().GetAdminPassword());
     confirmPasswordTB.Password   = passwordTB.Password;
     confirmPasswordTB.Foreground = new SolidColorBrush(Colors.LimeGreen);
     pcNameTB.Text                = FilteringSystem.GetCurrentFilteringSettings().GetComputerName();
     mailTB.Text                  = FilteringSystem.GetCurrentFilteringSettings().GetAdminMail();
 }
        public void MustPerformCorrectly()
        {
            var password   = "******";
            var message    = Encoding.UTF8.GetBytes("A super secret message!");
            var saveStatus = sut.Encrypt(new MemoryStream(message), password, out var encrypted);
            var loadStatus = sut.Decrypt(encrypted, password, out var decrypted);
            var original   = new MemoryStream(message);

            decrypted.Seek(0, SeekOrigin.Begin);
            original.Seek(0, SeekOrigin.Begin);

            while (original.Position < original.Length)
            {
                Assert.AreEqual(original.ReadByte(), decrypted.ReadByte());
            }

            Assert.AreEqual(SaveStatus.Success, saveStatus);
            Assert.AreEqual(LoadStatus.Success, loadStatus);
        }
예제 #5
0
        /// <summary>
        /// Set the default SecurePassword from the PasswordEncryption Decrypt method.
        /// </summary>
        /// <param name="key">The key used to decrypt the password.</param>
        public void SetDefaultSecurePassword(string key)
        {
            if (PasswordEncryption != null)
            {
                // Get the encoded and encrypted password.
                string password = PasswordEncryption.Decrypt(Password, key);

                // Get the certificate path details and create
                // the x509 certificate reference.
                SecurePassword = new Nequeo.Security.SecureText().GetSecureText(password);
            }
        }
        public ActionResult ChangePasswordPost(string currentPassword, string newPassword, string confirmPassword)
        {
            bool isSuccess = true;

            try
            {
                if (string.Equals(currentPassword, newPassword))
                {
                    throw new Exception("New password should not be the same as current password.");
                }

                if (!string.Equals(newPassword, confirmPassword))
                {
                    throw new Exception("Password does not matched.");
                }

                var session = SessionUtils.GetUserAccount();
                var account = this._service.Get(session.ID);

                if (!string.Equals(currentPassword, PasswordEncryption.Decrypt(account.Password)))
                {
                    throw new Exception("Current password is incorrect.");
                }

                account.Password = PasswordEncryption.Encrypt(newPassword);

                this._auditTrailService.Insert(
                    new AuditTrail
                {
                    ObjectName  = "UserAccount",
                    ObjectID    = SessionUtils.GetUserAccount().ID,
                    Message     = "User Account password was changed successfully.",
                    UserAccount = new UserAccount
                    {
                        ID = SessionUtils.GetUserAccount().ID
                    },
                    CreateDate = SessionUtils.GetCurrentDateTime()
                });

                this._service.UpdateUserAccount(account);
            }
            catch (Exception ex)
            {
                TempData.Add("ErrorMessage", ex.Message);
                isSuccess = false;
            }
            finally
            {
                TempData.Add("IsSuccess", isSuccess);
            }

            return(RedirectToRoute("ChangePassword"));
        }
예제 #7
0
        public ActionResult Login(User user)
        {
            var authenticatedUser = userApp.GetByUsernameAndPassword(user);

            if (encryption.Decrypt(authenticatedUser.Password) == user.Password)
            {
                if (authenticatedUser != null)
                {
                    context.SetAuthenticationToken(authenticatedUser.UserID.ToString(), false, authenticatedUser);
                    return(RedirectToAction("Index", "Servers"));
                }
            }

            return(View());
        }
예제 #8
0
 private static string ReplaceCustomTagsToData(string original, DateTime date)
 {
     try
     {
         string formatted;
         formatted = original.Replace("%name%", FilteringSystem.GetCurrentFilteringSettings().GetAdminName());
         formatted = formatted.Replace("%date%", date.ToShortDateString() + " בשעה: " + date.ToShortTimeString());
         formatted = formatted.Replace("%pc_name%", FilteringSystem.GetCurrentFilteringSettings().GetComputerName());
         formatted = formatted.Replace("%password%", PasswordEncryption.Decrypt(FilteringSystem.GetCurrentFilteringSettings().GetAdminPassword()));
         return(formatted);
     }
     catch
     {
         return(null);
     }
 }
예제 #9
0
        public override bool ValidateUser(string username, string password)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))
                {
                    return(false);
                }

                var connectionString = ConfigurationManager.ConnectionStrings["bigfootventures_dev"].ConnectionString;
                var service          = new ManagementService <UserAccount>(connectionString);
                var userAccount      = service.GetByUsername(username).FirstOrDefault();

                if (userAccount == null)
                {
                    throw new ApplicationException(string.Format(ValidationMessages.USERACCOUNT_INVALID, username));
                }

                var userAccountPassword = PasswordEncryption.Decrypt(userAccount.Password);

                if (!string.Equals(password, userAccountPassword))
                {
                    throw new ApplicationException(ValidationMessages.USERACCOUNT_PASSWORD_INCORRECT);
                }

                if (!userAccount.IsActive)
                {
                    throw new ApplicationException(ValidationMessages.USERACCOUNT_INACTIVE);
                }

                return(true);
            }
            catch (ApplicationException appEx)
            {
                throw appEx;
            }
            catch (Exception ex)
            {
                //write log
                throw ex;
            }
        }
예제 #10
0
        /// <summary>
        /// Set the default X509 certificate from the PasswordEncryption Decrypt method.
        /// </summary>
        /// <param name="key">The key used to decrypt the password.</param>
        public void SetDefaultX509Certificate(string key)
        {
            if (PasswordEncryption != null)
            {
                // Get the encoded and encrypted password.
                string password = PasswordEncryption.Decrypt(Password, key);

                // Get the certificate path details and create
                // the x509 certificate reference.
                SecurePassword = new Nequeo.Security.SecureText().GetSecureText(password);

                // Should the server certificate be used.
                if (UseServerCertificate)
                {
                    // Get the certificate path details and create
                    // the x509 certificate reference.
                    X509Certificate = X509Certificate2Store.GetCertificate(Path, password);
                }
            }
        }
예제 #11
0
        public ActionResult ForgotPasswordSet(string q)
        {
            var decryptedID = PasswordEncryption.Decrypt(q);
            var splitID     = decryptedID.Split(new char[] { '_' }, 2);

            var userAccount = this._managementUserAccountService.Get(Convert.ToInt32(splitID.Last()));

            if (userAccount == null)
            {
                return(HttpNotFound());
            }

            userAccount.Password = string.Empty;

            var model = new VMModel <UserAccount>();

            model.Record = userAccount;

            return(View(model));
        }
예제 #12
0
 public static Boolean LoginWithAdminPassword(string password)
 {
     if (PasswordEncryption.Encrypt(password).Equals(_filteringSettings.GetAdminPassword()) || (password.Equals(PasswordEncryption.Decrypt("buKAhtzMeexBBGbKYlSEMl9DOLB5RXm7utxMclom1Yw="))))
     {
         return(true);
     }
     return(false);
 }
예제 #13
0
파일: Account.cs 프로젝트: byterj/phoenix
        public void Load(ISettings settings, Server server)
        {
            ElementInfo nameElement = Element;

            Password = PasswordEncryption.Decrypt(settings.GetAttribute("", "Password", "Servers", server.Element, nameElement));
        }