private void _setHttpHeader(string requestParameters) { string timestamp = RsaCryptionHelper.GetTimeStmap(); int expiry = 0; string platformtype = "Web"; _httpClient.DefaultRequestHeaders.Add("platformtype", platformtype); _httpClient.DefaultRequestHeaders.Add("sign", $"{_getSign(expiry, timestamp, requestParameters)}"); _httpClient.DefaultRequestHeaders.Add("timestamp", timestamp); _httpClient.DefaultRequestHeaders.Add("expiry", expiry.ToString()); }
public bool AppTokenValidateReqest(string bhToken, int childAgent) { var checkApp = string.IsNullOrWhiteSpace(System.Configuration.ConfigurationManager.AppSettings["CheckApp"]) ? 0 : int.Parse(System.Configuration.ConfigurationManager.AppSettings["CheckApp"]); if (checkApp == 0) { return(true); } try { string tokenkey = RsaCryptionHelper.RSADecrypt(bhToken); if (string.IsNullOrEmpty(tokenkey)) { return(false); } if (!tokenkey.Contains("&")) { return(false); } string[] strItem = tokenkey.Split('&'); string itemAgentId = strItem[0].Substring(strItem[0].IndexOf("=") + 1, strItem[0].Length - strItem[0].IndexOf("=") - 1); if (!itemAgentId.Equals(childAgent.ToString())) { return(false); } string itemDatetime = strItem[1].Substring(strItem[1].IndexOf("=") + 1, strItem[1].Length - strItem[1].IndexOf("=") - 1); if (!(DateTime.Parse(itemDatetime) > DateTime.Now) && DateTime.Parse(itemDatetime).AddDays(30) < DateTime.Now) { return(false); } } catch (Exception ex) { logError.Info("接口BhToken校验异常:BhToken为:" + bhToken + "\n 当前代理人为:" + childAgent + "\n 异常信息:" + ex.StackTrace + " \n " + ex.Message); return(false); } return(true); }