public WebClientFactory(Uri serviceBusAddress, NetworkCredential credential)
 {
     _serviceBusAddress = serviceBusAddress;
     _tokenProvider = new WebTokenProvider(serviceBusAddress, credential);
     _requestFactory = new WebRequestFactory(_tokenProvider);
     _uriCreator = new UriCreator(serviceBusAddress);
 }
 public WebQueueValidator(Uri managementUri, IWebTokenProvider tokenProvider, IWebClient webClient)
 {
     _managementUri = managementUri;
     _webClient = webClient;
     _requestFactory = new WebRequestFactory(tokenProvider);
     _uriCreator = new UriCreator(managementUri);
 }
 public ServiceBusClient(Uri address, IWebTokenProvider tokenManager, IWebClient webClient)
 {
     _address = address;
     _tokenManager = tokenManager;
     _webClient = webClient;
     _webRequestFactory = new WebRequestFactory(tokenManager);
     _serializer = new MessageSerializer();
 }
Exemple #4
0
        public TopicApiTests()
        {
            Uri serviceBusUri = ServiceBusHelper.GetLocalHttpsEndpoint();
            _uriCreator = new UriCreator(serviceBusUri);
            _webClient =  new WebClientWrapper();
            _requestFactory = ServiceBusHelper.GetWebRequestFactory();

            string topicName = Guid.NewGuid().ToString();
            _topicUri = _uriCreator.GenerateTopicUri(topicName);
        }
        private WebToken RequestOAuthToken(string userName, string userPassword)
        {
            const string ClientPasswordFormat =
                "grant_type=authorization_code&client_id={0}&client_secret={1}&scope={2}";

            Uri requestUri = GenerateTokenRequestUri("OAuth");
            string requestContent = string.Format(CultureInfo.InvariantCulture,
                ClientPasswordFormat, HttpUtility.UrlEncode(userName),
                HttpUtility.UrlEncode(userPassword),
                HttpUtility.UrlEncode(_stsAddress.AbsoluteUri));
            byte[] data = Encoding.UTF8.GetBytes(requestContent);

            var requestFactory = new WebRequestFactory(this);
            HttpWebRequest request = requestFactory.CreateTokenWebRequest(requestUri, data, false);

            WebToken token = RequestToken(request);
            return token;
        }
        private WebToken RequestWindowsToken()
        {
            Uri requestUri = GenerateTokenRequestUri("Windows");
            string requestContent = string.Format("scope={0}", HttpUtility.UrlEncode(_stsAddress.AbsoluteUri));
            byte[] data = Encoding.UTF8.GetBytes(requestContent);

            var requestFactory = new WebRequestFactory(this);
            HttpWebRequest request = requestFactory.CreateTokenWebRequest(requestUri, data, true);

            WebToken token = RequestToken(request);
            return token;
        }
 public static WebRequestFactory GetWebRequestFactoryWithCredentials(NetworkCredential credential)
 {
     var tokenProvider = GetTokenProviderWithCredentials(credential);
     var factory = new WebRequestFactory(tokenProvider);
     return factory;
 }