public virtual void ChangeAndPersistPassword(Context context, PasswordConfig secConfig, String currentPasswordText, String newPasswordText, String confirmedPasswordText) { if (newPasswordText != confirmedPasswordText) { throw new iSabayaException(Messages.Security.NewPasswordsNotConfirmed.Format(context.Configuration.DefaultLanguage.Code)); } if (this.PasswordMatch(currentPasswordText)) { Password newPassword = new Password(this, secConfig, newPasswordText); if (null != Configuration.CurrentConfiguration && PassPasswordHistoryCheck(secConfig.PasswordHistoryDepth, newPassword)) { Password previouswPassword = this.CurrentPassword; this.CurrentPassword = newPassword; context.Persist(previouswPassword); context.Persist(newPassword); } else { throw new iSabayaException(Messages.Security.FailPasswordHistory.Format(context.Configuration.DefaultLanguage.Code)); } } else { throw new iSabayaException(Messages.Security.CurrentPasswordIsNotValid.Format(context.Configuration.DefaultLanguage.Code)); } }
public virtual void ResetPassword(PasswordConfig secConfig, String newPasswordText) { Password newPassword = new Password(this, secConfig, newPasswordText); Password previousPassword = this.CurrentPassword; if (null != this.CurrentPassword) { this.CurrentPassword.EffectivePeriod.ExpiryDate = newPassword.EffectivePeriod.EffectiveDate; } this.CurrentPassword = newPassword; this.ConsecutiveFailedLoginCount = 0; }
public Password(User user, PasswordConfig pwdConfig, String plainPasswordText) { if (null == user) { throw new iSabayaException(Messages.SecurityUserPersonIsNull); } if (null != pwdConfig) { pwdConfig.ValidatePassword(plainPasswordText); } this.user = user; if (String.IsNullOrEmpty(this.Salt)) { this.encryptedPassword = Encrypt(user.LoginName + plainPasswordText); } else { this.encryptedPassword = Encrypt(user.LoginName + plainPasswordText); } }