コード例 #1
0
        private Dictionary <string, string> GetSecurityHeaders()
        {
            var result = new Dictionary <string, string>(1);

            if (_securityProxy.GetAccessToken().IsNotNullOrWhiteSpace())
            {
                result[Constants.ACCESS_TOKEN] = _securityProxy.GetAccessToken();
            }

            return(result);
        }
コード例 #2
0
        private void InjectSecurityInfo(HttpRequestMessage requestMessage, Dictionary <string, string> paramValues)
        {
            if (!string.IsNullOrWhiteSpace(_securityProxy.GetAccessToken()))
            {
                if (!paramValues.ContainsKey(ConstValue.ACCESS_TOKEN))
                {
                    paramValues.Add(ConstValue.ACCESS_TOKEN, _securityProxy.GetAccessToken());
                }
            }

            if (!string.IsNullOrWhiteSpace(_namespaceId) && paramValues != null && !paramValues.ContainsKey("tenant"))
            {
                requestMessage.Headers.TryAddWithoutValidation("tenant", _namespaceId);
            }
        }
コード例 #3
0
        private void InjectSecurityInfo(Dictionary <string, string> paramters)
        {
            if (!string.IsNullOrWhiteSpace(_securityProxy.GetAccessToken()))
            {
                paramters[Constants.ACCESS_TOKEN] = _securityProxy.GetAccessToken();
            }

            paramters["app"] = AppDomain.CurrentDomain.FriendlyName;
            if (string.IsNullOrWhiteSpace(_options.AccessKey) &&
                string.IsNullOrWhiteSpace(_options.SecretKey))
            {
                return;
            }

            string signData = string.IsNullOrWhiteSpace(paramters["serviceName"])
                ? DateTimeOffset.Now.ToUnixTimeSeconds().ToString() + "@@" + paramters["serviceName"]
                : DateTimeOffset.Now.ToUnixTimeSeconds().ToString();

            string signature = Utilities.HashUtil.GetHMACSHA1(signData, _options.SecretKey);

            paramters["signature"] = signature;
            paramters["data"]      = signData;
            paramters["ak"]        = _options.AccessKey;
        }
コード例 #4
0
        private void InjectSecurityInfo(Dictionary <string, string> paramters)
        {
            if (!string.IsNullOrWhiteSpace(_securityProxy.GetAccessToken()))
            {
                paramters[Constants.ACCESS_TOKEN] = _securityProxy.GetAccessToken();
            }

            paramters[CommonParams.APP_FILED] = AppDomain.CurrentDomain.FriendlyName;
            if (string.IsNullOrWhiteSpace(_options.AccessKey) ||
                string.IsNullOrWhiteSpace(_options.SecretKey))
            {
                return;
            }

            string signData = !string.IsNullOrWhiteSpace(paramters[CommonParams.SERVICE_NAME_PARAM])
                ? DateTimeOffset.Now.ToUnixTimeSeconds().ToString() + CommonParams.SEPARATOR + paramters[CommonParams.SERVICE_NAME_PARAM]
                : DateTimeOffset.Now.ToUnixTimeSeconds().ToString();

            string signature = HashUtil.GetHMACSHA1(signData, _options.SecretKey);

            paramters[CommonParams.SIGNATURE_FILED] = signature;
            paramters[CommonParams.DATA_FILED]      = signData;
            paramters[CommonParams.AK_FILED]        = _options.AccessKey;
        }