/// <summary> /// Invoked by the REST client framework to add authentication information to an outgoing request /// </summary> /// <param name="request">The request to be updated with authentication information</param> public void Authenticate(HttpWebRequest request) { #if PORTABLE || WINDOWS_PHONE request.Headers[HttpRequestHeader.Authorization] = "SharedKey " + _accountId + ":" + RestClientHelper.GenerateSignature(request, SignatureType.SharedKey, _authKey); #else request.Headers.Add(HttpRequestHeader.Authorization, "SharedKey " + _accountId + ":" + RestClientHelper.GenerateSignature(request, SignatureType.SharedKey, _authKey)); #endif }
private static bool ValidateSignature(HttpRequestBase request, AccountDetails accessAccount, SignatureType sigType, string signature) { if (accessAccount != null) { if (signature.Equals(RestClientHelper.GenerateSignature(request, sigType, accessAccount.PrimaryKey)) || signature.Equals(RestClientHelper.GenerateSignature(request, sigType, accessAccount.SecondaryKey))) { return(true); } } return(false); }
/// <summary> /// Adds the required authentication and timestamp headers to the request /// </summary> /// <param name="request"></param> private void SignRequest(HttpWebRequest request) { request.Headers.Add(HttpRequestHeader.Authorization, "SharedKey " + _accountId + ":" + RestClientHelper.GenerateSignature(request, SignatureType.SharedKey, _key)); }