Beispiel #1
0
        private static string BuildAuthorizationHeader(IReadOnlyDictionary <string, string> parameters,
                                                       string appSecret, string secretId, string activityKind)
        {
            // check if the secret exists and it's not empty
            if (string.IsNullOrEmpty(appSecret) || parameters == null)
            {
                return(null);
            }

            var signatureDetails = GetSignature(parameters, activityKind, appSecret);

            string algorithm = ALG_SHA256;
            string signature = AdjustConfig.String2Sha256Func(signatureDetails[CLEAR_SIGNATURE]);

            signature = signature.ToLower();
            string fields = signatureDetails[FIELDS];

            string secretIdHeader  = $"{SECRET_ID}=\"{secretId}\"";
            string signatureHeader = $"{SIGNATURE}=\"{signature}\"";
            string algorithmHeader = $"{ALGORITHM}=\"{algorithm}\"";
            string fieldsHeader    = $"{HEADERS}=\"{fields}\"";

            string authorizationHeader = $"Signature {secretIdHeader},{signatureHeader},{algorithmHeader},{fieldsHeader}";

            Logger.Verbose($"authorizationHeader: {authorizationHeader}");

            return(authorizationHeader);
        }