//public byte[] GenerateUserExcelBySearchCriteria(UserSearchCriteriaDTO searchCriteria, PagingInformation pageInfo)
        //{

        //    //For excel export, we need to export all records.
        //    //So set the pageindex and pagesize to -1
        //    pageInfo.StartIndex = -1;
        //    pageInfo.PageSize = -1;

        //    var list = GetUserBySearchCriteria(searchCriteria, pageInfo);

        //    //Get excel export list
        //    var excelList = mapper.Map<IList<BusinessRuleExportExcelModel>>(list);

        //    return excelList.ToExcelContent();

        //}

        public bool RedirectUseToken(string username, string password, string timestamp, out string conciergeID)
        {
            conciergeID = string.Empty;
            if (string.IsNullOrEmpty(username) ||
                string.IsNullOrEmpty(password) ||
                string.IsNullOrEmpty(timestamp))
            {
                return(false);
            }

            var decrypted_username  = string.Empty;
            var decrypted_password  = string.Empty;
            var decrypted_timestamp = string.Empty;

            using (var decrypter = new TripleDESEncryption(appConfig.TripleDESEncryptionKey))
            {
                try
                {
                    decrypted_username  = decrypter.Decrypt(username);
                    decrypted_password  = decrypter.Decrypt(password);
                    decrypted_timestamp = decrypter.Decrypt(timestamp);
                }
                catch (FormatException fe)
                {
                    return(false);
                }
                catch (Exception e)
                {
                    return(false);
                }
            }

            DateTime datetime = DateTime.Parse(decrypted_timestamp);

            if (DateTime.Compare(datetime.AddDays(20), DateTime.Now) < 0)
            {
                return(false);
            }
            //Encode the password user input
            var encodedPassword = SimpleTextEncodeHelper.EncodeText(decrypted_password);
            var userid          = decrypted_username;
            //Retrieve user information from concierge login table
            var user = conciergeLoginloginRepo.Get(x => x.ConciergeID == userid && x.password == encodedPassword);

            if (user != null)
            {
                conciergeID = user.ConciergeID;
                return(true);
            }

            return(false);
        }
 public string DecryptPasswordResetToken(string token)
 {
     using (var decrypter = new TripleDESEncryption(appConfig.TripleDESEncryptionKey))
     {
         token = System.Web.HttpUtility.UrlDecode(decrypter.Decrypt(token));
     }
     return(token);
 }
Beispiel #3
0
 private void btnDecrypt_Click(object sender, EventArgs e)
 {
     if (tbIV.Text.Length != 8)
     {
         WarningNotice.IVLength(8);
         return;
     }
     try
     {
         tbToText.Text = TripleDESEncryption.Decrypt(tbFromText.Text, tbPassword.Text, tbIV.Text);
     }
     catch (Exception)
     {
         WarningNotice.WrongKey();
     }
 }
Beispiel #4
0
        private void btnFileSave2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbPath.Text))
            {
                WarningNotice.InputString();
                return;
            }
            if (!File.Exists(tbPath.Text))
            {
                WarningNotice.NotFound();
                return;
            }
            if (tbIV.Text.Length != 8)
            {
                WarningNotice.IVLength(8);
                return;
            }
            if (DialogResult.OK == sfdFile.ShowDialog())
            {
                FileInfo file   = new FileInfo(tbPath.Text);
                FileInfo result = new FileInfo(sfdFile.FileName);
                fileSize = file.Length;

                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        ControlEnable(this.Controls, false);
                        TripleDESEncryption.Decrypt(file, result, tbPassword.Text, tbIV.Text);
                        this.Invoke(new Action(() => WarningNotice.Save()));
                    }
                    catch (Exception)
                    {
                        WarningNotice.WrongKey();
                    }
                    finally
                    {
                        ControlEnable(this.Controls, true);
                    }
                });
            }
            sfdFile.FileName = "";
        }
        public bool LoginUseToken(string token, out LoginTokenDTO loginToken)
        {
            loginToken = new LoginTokenDTO();

            if (string.IsNullOrEmpty(token))
            {
                return(false);
            }

            var decryptedString = string.Empty;

            using (var decrypter = new TripleDESEncryption(appConfig.TripleDESEncryptionKey))
            {
                decryptedString = decrypter.Decrypt(token);
            }

            var paramsFromUrl = StringHelper.SplitString(decryptedString, "&")
                                .Select(p => { var m = p.Split('='); return(new { key = m[0], value = m[1] }); })
                                .ToDictionary(x => x.key, x => x.value);

            //Encode the password user input
            var encodedPassword = SimpleTextEncodeHelper.EncodeText(paramsFromUrl["pwd"]);
            var username        = paramsFromUrl["uid"];
            //Retrieve user information from concierge login table
            var user = conciergeLoginloginRepo.Get(x => x.ConciergeID == username && x.password == encodedPassword);

            if (user != null)
            {
                string arrivalDate, status;
                paramsFromUrl.TryGetValue("arrivaldate", out arrivalDate);
                paramsFromUrl.TryGetValue("status", out status);

                //Set Info
                loginToken.UserName    = user.ConciergeID;
                loginToken.ArrivalDate = arrivalDate;
                loginToken.Status      = status;

                return(true);
            }

            return(false);
        }