public static void AddAuthorizationHeader(this WebClient request, SharedAccessSignatureTokenProvider tokenProvider, string address)
 {
     if (tokenProvider != null)
     {
         string messagingWebToken = tokenProvider.BuildSignature(address);
         request.Headers[HttpRequestHeader.Authorization] = messagingWebToken;
     }
 }
        public NamespaceManager CreateNamespaceManager()
        {
            NamespaceManager  namespaceManager;
            IEnumerable <Uri> endpointAddresses = KeyValueConfigurationManager.GetEndpointAddresses(this.connectionProperties["Endpoint"], this.connectionProperties["ManagementPort"]);
            string            str1  = this.connectionProperties["SharedAccessKeyName"];
            string            item2 = this.connectionProperties["SharedAccessKey"];

            SharedAccessSignatureTokenProvider tokenProvider = new SharedAccessSignatureTokenProvider(str1, item2, SharedAccessSignatureTokenProvider.DefaultTokenTimeout);

            namespaceManager = new NamespaceManager(endpointAddresses, tokenProvider);

            return(namespaceManager);
        }
Exemple #3
0
 public static void AddCommmonHeaders(this WebClient request, SharedAccessSignatureTokenProvider provider, string address, bool addContentType = true, bool addAnonHeader = false, bool addIfMatchheader = false)
 {
     if (addContentType)
     {
         request.AddContentType();
     }
     if (addAnonHeader)
     {
         request.Headers.Add("X-MS-ISANONYMOUSACCESSIBLE", "False");
     }
     if (addIfMatchheader)
     {
         request.Headers.Add("If-Match", "*");
     }
     request.SetUserAgentHeader();
     request.AddXProcessAtHeader();
     request.AddAuthorizationHeader(provider, address);
     request.AddTrackingIdHeader(Guid.NewGuid());
 }
Exemple #4
0
 internal NamespaceManager(IEnumerable <Uri> endpointAddresses, SharedAccessSignatureTokenProvider provider)
 {
     this.endpointAddresses = endpointAddresses;
     this.provider          = provider;
 }
Exemple #5
0
 public static void AddServiceBusSupplementaryAuthorizationHeader(this WebClient request, SharedAccessSignatureTokenProvider tokenProvider, string address)
 {
     if (tokenProvider != null)
     {
         string messagingWebToken = tokenProvider.BuildSignature(address); //tokenProvider.GetMessagingWebToken(namespaceAddress, request.RequestUri.AbsoluteUri, action, false, Constants.TokenRequestOperationTimeout);
         request.Headers["ServiceBusSupplementaryAuthorization"] = messagingWebToken;
     }
 }