public UserType CreateUser(UserEntity userEntity, Address address, bool useUserLoginInfo = true) { if (userEntity == null) { throw new ArgumentNullException("userEntity"); } // this workaround is necessary because although C# generics allow a default constructor constraint on a type, they do not allow // constraints for parameterized constructors. var user = (UserType)Activator.CreateInstance(typeof(UserType), userEntity.UserId); user.Address = address; user.DateOfBirth = userEntity.Dob; user.Email = !string.IsNullOrEmpty(userEntity.Email1) ? new Email(userEntity.Email1) : new Email(string.Empty, string.Empty); user.AlternateEmail = !string.IsNullOrEmpty(userEntity.Email2) ? new Email(userEntity.Email2) : new Email(string.Empty, string.Empty); user.HomePhoneNumber = _phoneNumberFactory.CreatePhoneNumber(userEntity.PhoneHome, PhoneNumberType.Home); user.MobilePhoneNumber = _phoneNumberFactory.CreatePhoneNumber(userEntity.PhoneCell, PhoneNumberType.Mobile); user.Name = new Name(userEntity.FirstName, userEntity.MiddleName, userEntity.LastName); user.OfficePhoneNumber = _phoneNumberFactory.CreatePhoneNumber(userEntity.PhoneOffice, PhoneNumberType.Office); user.PhoneOfficeExtension = userEntity.PhoneOfficeExtension; if (useUserLoginInfo) { user.UserLogin = _userLoginFactory.CreateUserLogin(userEntity.UserLogin); } if (userEntity.DefaultRoleId != null) { user.DefaultRole = (Roles)userEntity.DefaultRoleId.Value; } user.DataRecorderMetaData = new DataRecorderMetaData { DateCreated = userEntity.DateCreated, DateModified = userEntity.DateModified }; user.Ssn = !string.IsNullOrEmpty(userEntity.Ssn) ? _cryptographyService.Decrypt(userEntity.Ssn) : string.Empty; return(user); }
protected void ibtnContinue_Click(object sender, ImageClickEventArgs e) { if (ViewState["IsLock"] != null) { if (ViewState["IsLock"].ToString().Equals("false")) { if (dtQues == null) { dtQues = (DataTable)ViewState["Ques"]; } CryptographyService cryptographyService = new PasswordCryptographyService(); string answer = cryptographyService.Decrypt(dtQues.Rows[0]["Answer"].ToString()); var objUser = new UserDAL(); objUser.SaveClient(IpAddress(), "UserId"); if (!answer.ToLower().Equals(txtAnswer.Text.ToLower())) { divError.Visible = true; divError.InnerText = "Answer of Security question is not correct."; } else { if (Request.QueryString["Action"] != null) { if (Request.QueryString["Action"] == "Password") { Response.RedirectUser("./ResetPasswordStep3.aspx?Action=Password"); } else if (Request.QueryString["Action"] == "Username") { Response.RedirectUser("./ResetPasswordStep3.aspx?Action=CustomerId"); } } } } } }
public void Decrypt() { var password = _passwordCryptographyService.Decrypt(EncryptedPassword); var customerKey = _passwordCryptographyService.Decrypt(EncryptedCustomerKey); }