public dynamic Verivication([FromUri] string DecryptText)
        {
            VerificationInfo info = new VerificationInfo();

            info = Decrypt(DecryptText);
            return(info);
        }
Esempio n. 2
0
        /// <summary>
        /// Queries the specified application identifier.
        /// </summary>
        /// <param name="appId">The application identifier.</param>
        /// <param name="orderId">The order identifier.</param>
        /// <param name="appSecret">The application secret.</param>
        /// <returns>the verification info.</returns>
        public VerificationInfo Query(string appId, string orderId, string appSecret)
        {
            const string QueryURL   = "http://api.miglass.mi.com/queryOrder?";
            string       parameters = "devAppId=" + appId;

            parameters += "&orderId=" + orderId;

            HMACSHA1 hmacSha1 = new HMACSHA1(Encoding.UTF8.GetBytes(appSecret));

            byte[] hashValue = hmacSha1.ComputeHash(Encoding.UTF8.GetBytes(parameters));
            parameters += "&signature=" + BitConverter.ToString(hashValue).Replace("-", string.Empty).ToLower();
            string finalUrl = QueryURL + parameters;

            Debug.Log("final url is " + finalUrl);

            WebRequest request = WebRequest.Create(finalUrl);

            request.Credentials = CredentialCache.DefaultCredentials;
            request.Method      = "GET";
            var response = request.GetResponse();

            Stream       dataStream         = response.GetResponseStream();
            StreamReader reader             = new StreamReader(dataStream);
            string       responseFromServer = reader.ReadToEnd();

            Debug.Log("response is: " + responseFromServer);
            reader.Close();

            response.Close();

            var queryResult = JsonUtility.FromJson <QueryResult>(responseFromServer);

            VerificationInfo result = new VerificationInfo();

            if (queryResult.code == 0)
            {
                result.Status = QueryStatus.Success;
                if (queryResult.data != null)
                {
                    result.PayedAmount = queryResult.data.buyerPayAmount;
                    result.IsPayed     = queryResult.data.paymentStatus.Equals("TRADE_SUCCESS");
                    if (queryResult.data.paymentType == "ALIPAY")
                    {
                        result.PayType = PayType.ALIPAY;
                    }
                    else
                    {
                        result.PayType = PayType.Unknown;
                    }
                }
            }
            else if (queryResult.code == 1353)
            {
                result.Status = QueryStatus.WrongParameter;
            }

            return(result);
        }
        public bool Remove(string email, string type)
        {
            if (!IsExist(email, type))
            {
                throw new Exception("试图删除不存在的邮箱验证码信息");
            }
            VerificationInfo info = VerifyInfos.FirstOrDefault(v => v.Email == email && v.Type == type);

            return(VerifyInfos.Remove(info));
        }
        public bool IsExist(string email, string type)
        {
            VerificationInfo info = VerifyInfos.FirstOrDefault(v => v.Email == email && v.Type == type);

            if (info == null)
            {
                return(false);
            }
            return(true);
        }
        public DateTime?GetCreateTime(string email, string type)
        {
            VerificationInfo info = VerifyInfos.FirstOrDefault(v => v.Email == email && v.Type == type);

            if (info == null)
            {
                return(null);
            }
            return(info.CreateTime);
        }
Esempio n. 6
0
            internal void WriteVerificationInfo(VerificationInfo info)
            {
                _writer.WriteU1((byte)info.Tag);

                switch (info)
                {
                case ObjectVariableInfo objectVariableInfo:
                    WriteVerificationInfo(objectVariableInfo);
                    break;

                case UninitializedVariableInfo uninitializedVariableInfo:
                    WriteVerificationInfo(uninitializedVariableInfo);
                    break;
                }
            }
Esempio n. 7
0
        private void VerifyClick(object sender, RoutedEventArgs e)
        {
            if (!int.TryParse(verification.Text, out int verificationCode))
            {
                statusMessage.Text       = "The code contains only numbers, enter the correct code";
                statusMessage.Visibility = Visibility.Visible;
                return;
            }

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(ConfigurationSettings.AppSettings["userManagementBaseUri"]);

                var verific = new VerificationInfo
                {
                    UserName = this.userName,
                    Code     = verificationCode
                };

                var verificJsonString = JsonConvert.SerializeObject(verific);

                var httpContent = new StringContent(verificJsonString, Encoding.UTF8, "application/json");

                var requestResult = client.PostAsync("/api/userverification", httpContent).Result;

                var content = requestResult.Content;

                var jsonContent = content.ReadAsStringAsync().Result;

                var status = JsonConvert.DeserializeObject <Status>(jsonContent);

                if (status.StatusCode != 1000)
                {
                    statusMessage.Text       = "Invalid activatoin code";
                    statusMessage.Visibility = Visibility.Visible;
                    return;
                }

                var login = new Login();

                login.Show();

                this.Close();

                return;
            }
        }
 public bool Update(string email, string code, string type)
 {
     if (!IsExist(email, type))
     {
         throw new Exception("试图更新不存在的邮箱验证码信息");
     }
     try
     {
         VerificationInfo info = VerifyInfos.FirstOrDefault(v => v.Email == email && v.Type == type);
         info.VerificationCode = code;
         info.CreateTime       = DateTime.Now;
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public Status Post([FromBody] VerificationInfo verification)
        {
            if (this.dataAccesLayer.CodeIsValid(verification))
            {
                this.dataAccesLayer.UpdateApproveValue(verification.UserName, true);

                return(new Status
                {
                    StatusCode = 1000,
                    IsOk = true,
                    Message = "You are verified."
                });
            }

            return(new Status
            {
                StatusCode = 2003,
                IsOk = false,
                Message = "You are no verified.Verification code is incorrect."
            });
        }
        private VerificationInfo Decrypt(string DecryptText)
        {
            VerificationInfo VerificationInfo = new VerificationInfo();

            try
            {
                string EncryptText   = "";
                string EncryptionKey = Helper.EncryptionKey;
                DecryptText = Regex.Replace(DecryptText, @"\s", "");
                byte[] cipherBytes = Convert.FromBase64String(DecryptText);
                using (Aes encryptor = Aes.Create())
                {
                    Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[]
                                                                    { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 }
                                                                    );
                    encryptor.Key = pdb.GetBytes(32);
                    encryptor.IV  = pdb.GetBytes(16);
                    using (MemoryStream ms = new MemoryStream())
                    {
                        using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
                        {
                            cs.Write(cipherBytes, 0, cipherBytes.Length);
                            cs.Close();
                        }
                        EncryptText = Encoding.Unicode.GetString(ms.ToArray());
                    }
                }
                String[] info = EncryptText.Split(',');

                if (info[0].Length > 0)
                {
                    VerificationInfo.UserName = info[0];
                }
                else
                {
                    VerificationInfo.UserName = "******";
                }

                if (info[1].Length > 0)
                {
                    VerificationInfo.Password = info[1];
                }
                else
                {
                    VerificationInfo.Password = "******";
                }

                if (info[2].Length > 0)
                {
                    VerificationInfo.Company = info[2];
                }
                else
                {
                    VerificationInfo.Company = "Invalid Parameter";
                }
                if (info[0].Length > 0 && info[1].Length > 0 && info[2].Length > 0)
                {
                    VerificationInfo.Result  = 1;
                    VerificationInfo.Message = "Text Derypted Successfully";
                }
                else
                {
                    VerificationInfo.Result  = -1;
                    VerificationInfo.Message = "Invalid Text";
                }
                return(VerificationInfo);
            }
            catch
            {
                VerificationInfo.UserName = "******";
                VerificationInfo.Password = "******";
                VerificationInfo.Company  = "Invalid Parameter";
                VerificationInfo.Result   = -1;
                VerificationInfo.Message  = "Invalid Text";
                return(VerificationInfo);
            }
        }