// This API is a helper method to create auth header based on client request. // Uri is split into resourceType/resourceId - // For feed/post/put requests, resourceId = parentId, // For point get requests, resourceId = last segment in URI public static string GenerateKeyAuthorizationSignature(string verb, Uri uri, INameValueCollection headers, IComputeHash stringHMACSHA256Helper, string clientVersion = "") { if (string.IsNullOrEmpty(verb)) { throw new ArgumentException(RMResources.StringArgumentNullOrEmpty, nameof(verb)); } if (uri == null) { throw new ArgumentNullException(nameof(uri)); } if (stringHMACSHA256Helper == null) { throw new ArgumentNullException(nameof(stringHMACSHA256Helper)); } if (headers == null) { throw new ArgumentNullException(nameof(headers)); } string resourceType = string.Empty; string resourceIdValue = string.Empty; bool isNameBased = false; AuthorizationHelper.GetResourceTypeAndIdOrFullName(uri, out isNameBased, out resourceType, out resourceIdValue, clientVersion); string authToken = AuthorizationHelper.GenerateKeyAuthorizationSignature(verb, resourceIdValue, resourceType, headers, stringHMACSHA256Helper, out ArrayOwner arrayOwner); using (arrayOwner) { return(authToken); } }
// This API is a helper method to create auth header based on client request. // Uri is split into resourceType/resourceId - // For feed/post/put requests, resourceId = parentId, // For point get requests, resourceId = last segment in URI public static string GenerateKeyAuthorizationSignature(string verb, Uri uri, INameValueCollection headers, IComputeHash stringHMACSHA256Helper, string clientVersion = "") { if (string.IsNullOrEmpty(verb)) { throw new ArgumentException(RMResources.StringArgumentNullOrEmpty, "verb"); } if (uri == null) { throw new ArgumentNullException("uri"); } if (stringHMACSHA256Helper == null) { throw new ArgumentNullException("stringHMACSHA256Helper"); } if (headers == null) { throw new ArgumentNullException("headers"); } string resourceType = string.Empty; string resourceIdValue = string.Empty; bool isNameBased = false; AuthorizationHelper.GetResourceTypeAndIdOrFullName(uri, out isNameBased, out resourceType, out resourceIdValue, clientVersion); string payload; return(AuthorizationHelper.GenerateKeyAuthorizationSignature(verb, resourceIdValue, resourceType, headers, stringHMACSHA256Helper, out payload)); }