public Task <ActionResult> Index(string slug) { IApplication application = _applicationService.GetApplication(slug); if (application == null) { return(HttpNotFoundAsync()); } ICredentials credentials = _credentialProvider.GetCredentials(); RemoteDeploymentManager deploymentManager = application.GetDeploymentManager(credentials); // TODO: Do this in parallel return(deploymentManager.GetResultsAsync().Then(results => { return application.GetRepositoryInfo(credentials).Then(repositoryInfo => { var appViewModel = new ApplicationViewModel(application); appViewModel.RepositoryInfo = repositoryInfo; appViewModel.Deployments = results.ToList(); ViewBag.slug = slug; ViewBag.appName = appViewModel.Name; return (ActionResult)View(appViewModel); }); })); }
public async Task <ActionResult> Index(string slug) { IApplication application = _applicationService.GetApplication(slug); if (application == null) { return(HttpNotFound()); } ICredentials credentials = _credentialProvider.GetCredentials(); RemoteDeploymentManager deploymentManager = application.GetDeploymentManager(credentials); Task <IEnumerable <DeployResult> > deployResults = deploymentManager.GetResultsAsync(); Task <RepositoryInfo> repositoryInfo = application.GetRepositoryInfo(credentials); await Task.WhenAll(deployResults, repositoryInfo); var appViewModel = new ApplicationViewModel(application, _settingsResolver) { RepositoryInfo = repositoryInfo.Result, Deployments = deployResults.Result.ToList() }; ViewBag.slug = slug; ViewBag.appName = appViewModel.Name; return(View(appViewModel)); }
public Task <ISettings> GetSettings(string siteName) { IApplication application = _applicationService.GetApplication(siteName); ICredentials credentials = _credentialProvider.GetCredentials(); RemoteDeploymentSettingsManager settingsManager = application.GetSettingsManager(credentials); return(settingsManager.GetValues().Then(values => (ISettings) new Settings { KuduSettings = values })); }
public ISettings GetSettings(string siteName) { IApplication application = _applicationService.GetApplication(siteName); ICredentials credentials = _credentialProvider.GetCredentials(); RemoteDeploymentSettingsManager settingsManager = application.GetSettingsManager(credentials); return(new Settings { AppSettings = Convert(settingsManager.GetAppSettings()), ConnectionStrings = Convert(settingsManager.GetConnectionStrings()) }); }
public async Task <ActionResult> Trace(string slug) { IApplication application = _applicationService.GetApplication(slug); if (application == null) { return(HttpNotFound()); } ICredentials credentials = _credentialProvider.GetCredentials(); var document = await application.DownloadTrace(credentials); return(View(document)); }
protected RemoteDeploymentSettingsManager GetSettingsManager(string siteName) { IApplication application = _applicationService.GetApplication(siteName); ICredentials credentials = _credentialProvider.GetCredentials(); RemoteDeploymentSettingsManager settingsManager = application.GetSettingsManager(credentials); return(settingsManager); }
public Task AddApplication(string name) { if (GetApplications().Any(x => x == name)) { throw new SiteExistsException(); } return(_siteManager.CreateSiteAsync(name, credentials: _credentialProvider.GetCredentials())); }
public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, bool retrying) { if (Credentials.ContainsKey(uri)) { return(Credentials[uri]); } return(provider.GetCredentials(uri, proxy, credentialType, retrying)); }
public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, bool retrying) { if (credentialType != CredentialType.ProxyCredentials) { return(wrapped.GetCredentials(uri, proxy, credentialType, retrying)); } var proxyUri = proxy.GetProxy(uri); if (proxyUri == null) { return(null); } if (!retrying) { var cached = CredentialStore.Instance.GetCredentials(proxyUri); if (cached != null) { return(cached); } } lock (locker) { if (!retrying) { var cached = CredentialStore.Instance.GetCredentials(proxyUri); if (cached != null) { return(cached); } } var creds = wrapped.GetCredentials(uri, proxy, credentialType, retrying); if (creds != null) { CredentialStore.Instance.Add(proxyUri, creds); } return(creds); } }
public SiteConfiguration(IApplication application, ICredentialProvider credentialProvider) { ServiceUrl = application.ServiceUrl; SiteUrl = application.SiteUrl; Name = application.Name; // This is to work around a SignalR bug where the hub is still created // even if IDisconnect isn't implemented if (String.IsNullOrEmpty(ServiceUrl)) { return; } SiteConfiguration config; if (_cache.TryGetValue(ServiceUrl, out config)) { Repository = config.Repository; ProjectSystem = config.ProjectSystem; DevProjectSystem = config.DevProjectSystem; DeploymentManager = config.DeploymentManager; CommandExecutor = config.CommandExecutor; DevCommandExecutor = config.DevCommandExecutor; } else { var repository = new RemoteRepository(ServiceUrl + "scm"); repository.Credentials = credentialProvider.GetCredentials(); Repository = repository; var projectSystem = new RemoteProjectSystem(ServiceUrl + "live/files"); projectSystem.Credentials = credentialProvider.GetCredentials(); ProjectSystem = projectSystem; var devProjectSystem = new RemoteProjectSystem(ServiceUrl + "dev/files"); devProjectSystem.Credentials = credentialProvider.GetCredentials(); DevProjectSystem = devProjectSystem; SubscribeToEvents(credentialProvider); _cache[ServiceUrl] = this; } }
public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, bool retrying) { NetworkCredential credentials; // If we are retrying, the stored credentials must be invalid. if (!retrying && (credentialType == CredentialType.RequestCredentials) && TryGetCredentials(uri, out credentials)) { _logger.Log(MessageLevel.Info, NuGetResources.SettingsCredentials_UsingSavedCredentials, credentials.UserName); return(credentials); } return(_credentialProvider.GetCredentials(uri, proxy, credentialType, retrying)); }
public static Authorization GetAuthorization(ICredentialProvider credentialProvider) { Credentials.Credentials credentials = credentialProvider.GetCredentials(); var authService = new AuthorizationService(credentials.Username, credentials.Password) { UserAgent = Program.UserAgent, AgentVersion = Program.AgentVersion }; return(GetAuthorization(authService)); }
public static Authorization GetAuthorization(ICredentialProvider credentialProvider) { Credentials.Credentials credentials = credentialProvider.GetCredentials(); var authService = new AuthorizationService(credentials.Username, credentials.Password) { UserAgent = Program.UserAgent, AgentVersion = Program.AgentVersion }; return GetAuthorization(authService); }
public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, bool retrying) { if (!retrying && mySource.HasCredentials) { return(Credentials); } if (myNext != null) { return(myNext.GetCredentials(uri, proxy, credentialType, retrying)); } return(null); }
public Task <ActionResult> Details(string slug) { IApplication application = _applicationService.GetApplication(slug); if (application == null) { return(HttpNotFoundAsync()); } ICredentials credentials = _credentialProvider.GetCredentials(); return(application.GetRepositoryInfo(credentials).Then(repositoryInfo => { var appViewModel = new ApplicationViewModel(application); appViewModel.RepositoryInfo = repositoryInfo; ViewBag.slug = slug; ViewBag.tab = "settings"; ViewBag.appName = appViewModel.Name; return (ActionResult)View(appViewModel); })); }
private void AssertAuth(ICredentialProvider provider, string username = null, string password = null, string url = "http://jetbrains.com") { var value = provider.GetCredentials(new Uri(url), new Mock <IWebProxy>().Object, CredentialType.RequestCredentials, false) as NetworkCredential; if (username == null) { Assert.Null(value); } else { Assert.NotNull(value); Assert.AreEqual(username, value.UserName); Assert.AreEqual(password, value.Password); } }
private async Task <ActionResult> GetApplicationView(string tab, string viewName, string slug) { var application = _applicationService.GetApplication(slug); ICredentials credentials = _credentialProvider.GetCredentials(); var repositoryInfo = await application.GetRepositoryInfo(credentials); var appViewModel = new ApplicationViewModel(application, _settingsResolver); appViewModel.RepositoryInfo = repositoryInfo; ViewBag.slug = slug; ViewBag.tab = tab; ViewBag.appName = appViewModel.Name; ViewBag.siteBinding = String.Empty; ModelState.Clear(); return(View(viewName, appViewModel)); }
public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, bool retrying) { if (!retrying) { var matches = mySources .Where(x => x.Key(uri)) .Select(x => x.Value.GetCredentials(uri, proxy, credentialType, false)) .FirstOrDefault(x => x != null); if (matches != null) { return(matches); } } if (myNext != null) { return(myNext.GetCredentials(uri, proxy, credentialType, retrying)); } return(null); }
public ICredentials GetCredentials(Uri uri, IWebProxy proxy, CredentialType credentialType, bool retrying) { if (!retrying) { var requestUrl = uri.AbsoluteUri; if (!requestUrl.EndsWith("/")) { requestUrl += "/"; } var source = mySources.FirstOrDefault(x => requestUrl.StartsWith(x.Source, StringComparison.OrdinalIgnoreCase)); if (source != null) { return(new NetworkCredential(source.Username, source.Password)); } } if (myNext != null) { return(myNext.GetCredentials(uri, proxy, credentialType, retrying)); } return(null); }
/// <summary> /// Keeps sending requests until a response code that doesn't require authentication happens or if /// the request requires authentication and the user has stopped trying to enter them (i.e. they hit cancel when they are prompted). /// </summary> internal static WebResponse GetResponse(Func<WebRequest> createRequest, Action<WebRequest> prepareRequest, IProxyCache proxyCache, ICredentialCache credentialCache, ICredentialProvider credentialProvider) { HttpStatusCode? previousStatusCode = null; string authType = null; bool continueIfFailed = true; while (true) { // Create the request WebRequest request = createRequest(); request.Proxy = proxyCache.GetProxy(request.RequestUri); if (request.Proxy != null && request.Proxy.Credentials == null) { request.Proxy.Credentials = CredentialCache.DefaultCredentials; } if (previousStatusCode == null) { // Try to use the cached credentials (if any, for the first request) request.Credentials = credentialCache.GetCredentials(request.RequestUri); if (request.Credentials == null) { // If there are no cached credentials, use the default ones request.UseDefaultCredentials = true; } } else if (previousStatusCode == HttpStatusCode.ProxyAuthenticationRequired) { request.Proxy.Credentials = credentialProvider.GetCredentials(request, CredentialType.ProxyCredentials); continueIfFailed = request.Proxy.Credentials != null; } else if (previousStatusCode == HttpStatusCode.Unauthorized) { request.Credentials = credentialProvider.GetCredentials(request, CredentialType.RequestCredentials); continueIfFailed = request.Credentials != null; } try { ICredentials credentials = request.Credentials; // KeepAlive is required for NTLM and Kerberos authentication. // REVIEW: The WWW-Authenticate header is tricky to parse so a Equals might not be correct if (!String.Equals(authType, "NTLM", StringComparison.OrdinalIgnoreCase) && !String.Equals(authType, "Kerberos", StringComparison.OrdinalIgnoreCase)) { // This is to work around the "The underlying connection was closed: An unexpected error occurred on a receive." // exception. var httpRequest = (HttpWebRequest)request; httpRequest.KeepAlive = false; httpRequest.ProtocolVersion = HttpVersion.Version10; } // Prepare the request, we do something like write to the request stream // which needs to happen last before the request goes out prepareRequest(request); // Wrap the credentials in a CredentialCache in case there is a redirect // and credentials need to be kept around. request.Credentials = request.Credentials.AsCredentialCache(request.RequestUri); WebResponse response = request.GetResponse(); // Cache the proxy and credentials proxyCache.Add(request.Proxy); credentialCache.Add(request.RequestUri, credentials); credentialCache.Add(response.ResponseUri, credentials); return response; } catch (WebException ex) { IHttpWebResponse response = GetResponse(ex.Response); if (response == null && ex.Status != WebExceptionStatus.SecureChannelFailure) { // No response, something went wrong so just rethrow throw; } // Special case https connections that might require authentication if (ex.Status == WebExceptionStatus.SecureChannelFailure) { if (continueIfFailed) { // Act like we got a 401 so that we prompt for credentials on the next request previousStatusCode = HttpStatusCode.Unauthorized; continue; } throw; } // If we were trying to authenticate the proxy or the request and succeeded, cache the result. if (previousStatusCode == HttpStatusCode.ProxyAuthenticationRequired && response.StatusCode != HttpStatusCode.ProxyAuthenticationRequired) { proxyCache.Add(request.Proxy); } else if (previousStatusCode == HttpStatusCode.Unauthorized && response.StatusCode != HttpStatusCode.Unauthorized) { credentialCache.Add(request.RequestUri, request.Credentials); credentialCache.Add(response.ResponseUri, request.Credentials); } if (!IsAuthenticationResponse(response) || !continueIfFailed) { throw; } using (response) { previousStatusCode = response.StatusCode; authType = response.AuthType; } } } }
private async Task <CalendarModel> InternalGetCalendar(string id, DateTime start, DateTime end) { start = start.Date; end = end.Date; var credentials = credentialProvider.GetCredentials(id); if (credentials == null) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, "")); } var calendarModel = new CalendarModel { Owner = id, }; switch (credentials.Type) { case "EWS": var ewsService = new ExchangeService { Credentials = new WebCredentials(credentials.Username, credentials.Password, credentials.Domain), Url = new Uri(credentials.ServiceUrl) }; var week = ewsService.FindAppointments(WellKnownFolderName.Calendar, new CalendarView(start, end.AddDays(1))); calendarModel.Appointments = week.Select(a => new AppointmentModel { Subject = a.Subject, StartTime = a.Start.ToUniversalTime(), EndTime = a.End.ToUniversalTime(), Duration = a.Duration, IsPrivate = a.Sensitivity == Sensitivity.Private || a.Sensitivity == Sensitivity.Confidential }); break; case "ICS": var cache = calendarCache.GetCalendar(id); if (cache != null) { var icsServiceResponse = await icsService.GetIcsContent(credentials.ServiceUrl, cache.ETag); if (icsServiceResponse.NotModified) { calendarModel.Appointments = cache.CalendarModel.Appointments; } else { calendarModel.Appointments = icsServiceResponse.Appointments; calendarCache.PutCalendar(id, new CalendarCacheEntry(id) { CalendarModel = calendarModel, ETag = icsServiceResponse.ETag }); } } else { var icsResponse = await icsService.GetIcsContent(credentials.ServiceUrl, string.Empty); calendarModel.Appointments = icsResponse.Appointments; calendarCache.PutCalendar(id, new CalendarCacheEntry(id) { CalendarModel = calendarModel, ETag = icsResponse.ETag }); } break; default: throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "")); } // Now only return the appointments in the requested range return(new CalendarModel { Owner = calendarModel.Owner, Appointments = calendarModel.Appointments .Where(a => a != null && a.StartTime.Date >= start && a.StartTime.Date <= end) .OrderBy(a => a.StartTime) }); }
private IWebProxy GetProxyInternal(Uri uri) { WebProxy result = null; WebProxy systemProxy = GetSystemProxy(uri); if (_proxyCache.ContainsKey(systemProxy.Address)) { return(_proxyCache[systemProxy.Address]); } // Try and see if we have credentials saved for the system proxy first so that we can // validate and see if we should use them. if (_credentialProvider.HasCredentials(systemProxy.Address)) { WebProxy savedCredentialsProxy = GetSystemProxy(uri); savedCredentialsProxy.Credentials = _credentialProvider.GetCredentials(systemProxy.Address).FirstOrDefault(); if (IsProxyValid(savedCredentialsProxy, uri)) { result = savedCredentialsProxy; } } // If we did not find any saved credentials then let's try to use Default Credentials which is // used for Integrated Authentication if (null == result) { WebProxy integratedAuthProxy = GetSystemProxy(uri); integratedAuthProxy.Credentials = _credentialProvider.DefaultCredentials; if (IsProxyValid(integratedAuthProxy, uri)) { result = integratedAuthProxy; } } // If we did not succeed in getting a proxy by this time then let's try and prompt the user for // credentials and do that until we have succeeded. if (null == result) { WebProxy noCredentialsProxy = GetSystemProxy(uri); bool validCredentials = false; bool retryCredentials = false; ICredentials basicCredentials = null; while (!validCredentials) { // Get credentials for the proxy address and not the target url // because we'll end up prompting the user for a proxy for each different // package due to the packages having different urls. basicCredentials = _credentialProvider.PromptUserForCredentials(systemProxy.Address, retryCredentials); // If the provider returned credentials that are null that means the user cancelled the prompt // and we want to stop at this point and return nothing. if (null == basicCredentials) { result = null; retryCredentials = false; break; } noCredentialsProxy.Credentials = basicCredentials; if (IsProxyValid(noCredentialsProxy, uri)) { validCredentials = true; } else { retryCredentials = true; validCredentials = false; } } result = noCredentialsProxy; } Debug.Assert(null != result, "Proxy should not be null here."); if (null != result) { _proxyCache.Add(systemProxy.Address, result); } return(result); }
internal static WebResponse GetResponse(Func <WebRequest> createRequest, Action <WebRequest> prepareRequest, IProxyCache proxyCache, ICredentialCache credentialCache, ICredentialProvider credentialProvider) { HttpWebRequest previousRequest = null; IHttpWebResponse previousResponse = null; HttpStatusCode? previousStatusCode = null; bool usingSTSAuth = false; bool continueIfFailed = true; int proxyCredentialsRetryCount = 0; int credentialsRetryCount = 0; while (true) { // Create the request var request = (HttpWebRequest)createRequest(); request.Proxy = proxyCache.GetProxy(request.RequestUri); if (request.Proxy != null && request.Proxy.Credentials == null) { request.Proxy.Credentials = CredentialCache.DefaultCredentials; } if (previousResponse == null || ShouldKeepAliveBeUsedInRequest(previousRequest, previousResponse)) { // Try to use the cached credentials (if any, for the first request) request.Credentials = credentialCache.GetCredentials(request.RequestUri); // If there are no cached credentials, use the default ones if (request.Credentials == null) { request.UseDefaultCredentials = true; } } else if (previousStatusCode == HttpStatusCode.ProxyAuthenticationRequired) { request.Proxy.Credentials = credentialProvider.GetCredentials(request, CredentialType.ProxyCredentials, retrying: proxyCredentialsRetryCount > 0); continueIfFailed = request.Proxy.Credentials != null; proxyCredentialsRetryCount++; } else if ((previousStatusCode == HttpStatusCode.Unauthorized) && !usingSTSAuth) { // If we are using STS, the auth's being performed by a request header. We do not need to ask the user for credentials at this point. request.Credentials = credentialProvider.GetCredentials(request, CredentialType.RequestCredentials, retrying: credentialsRetryCount > 0); continueIfFailed = request.Credentials != null; credentialsRetryCount++; } try { ICredentials credentials = request.Credentials; SetKeepAliveHeaders(request, previousResponse); if (usingSTSAuth) { // Add request headers if the server requires STS based auth. STSAuthHelper.PrepareSTSRequest(request); } // Prepare the request, we do something like write to the request stream // which needs to happen last before the request goes out prepareRequest(request); // Wrap the credentials in a CredentialCache in case there is a redirect // and credentials need to be kept around. request.Credentials = request.Credentials.AsCredentialCache(request.RequestUri); WebResponse response = request.GetResponse(); // Cache the proxy and credentials proxyCache.Add(request.Proxy); credentialCache.Add(request.RequestUri, credentials); credentialCache.Add(response.ResponseUri, credentials); return(response); } catch (WebException ex) { using (IHttpWebResponse response = GetResponse(ex.Response)) { if (response == null && ex.Status != WebExceptionStatus.SecureChannelFailure) { // No response, something went wrong so just rethrow throw; } // Special case https connections that might require authentication if (ex.Status == WebExceptionStatus.SecureChannelFailure) { if (continueIfFailed) { // Act like we got a 401 so that we prompt for credentials on the next request previousStatusCode = HttpStatusCode.Unauthorized; continue; } throw; } // If we were trying to authenticate the proxy or the request and succeeded, cache the result. if (previousStatusCode == HttpStatusCode.ProxyAuthenticationRequired && response.StatusCode != HttpStatusCode.ProxyAuthenticationRequired) { proxyCache.Add(request.Proxy); } else if (previousStatusCode == HttpStatusCode.Unauthorized && response.StatusCode != HttpStatusCode.Unauthorized) { credentialCache.Add(request.RequestUri, request.Credentials); credentialCache.Add(response.ResponseUri, request.Credentials); } usingSTSAuth = STSAuthHelper.TryRetrieveSTSToken(request.RequestUri, response); if (!IsAuthenticationResponse(response) || !continueIfFailed) { throw; } previousRequest = request; previousResponse = response; previousStatusCode = previousResponse.StatusCode; } } } }
public static bool HasCredentials(this ICredentialProvider provider, Uri uri) { ICredentials[] credentials = provider.GetCredentials(uri); return(credentials != null && credentials.Count() > 0); }
internal static ICredentials GetCredentials(this ICredentialProvider provider, WebRequest request, CredentialType credentialType, bool retrying = false) { return(provider.GetCredentials(request.RequestUri, request.Proxy, credentialType, retrying)); }
public async Task <ISpinCredentials> GetCredentials() { return(await m_provider.GetCredentials()); }
/// <summary> /// Keeps sending requests until a response code that doesn't require authentication happens or if /// the request requires authentication and the user has stopped trying to enter them (i.e. they hit cancel when they are prompted). /// </summary> internal static WebResponse GetResponse(Func<WebRequest> createRequest, Action<WebRequest> prepareRequest, IProxyCache proxyCache, ICredentialCache credentialCache, ICredentialProvider credentialProvider) { IHttpWebResponse previousResponse = null; HttpStatusCode? previousStatusCode = null; bool usingSTSAuth = false; bool continueIfFailed = true; int proxyCredentialsRetryCount = 0; int credentialsRetryCount = 0; while (true) { // Create the request var request = (HttpWebRequest)createRequest(); request.Proxy = proxyCache.GetProxy(request.RequestUri); if (request.Proxy != null && request.Proxy.Credentials == null) { request.Proxy.Credentials = CredentialCache.DefaultCredentials; } if (previousResponse == null) { // Try to use the cached credentials (if any, for the first request) request.Credentials = credentialCache.GetCredentials(request.RequestUri); // If there are no cached credentials, use the default ones if (request.Credentials == null) { request.UseDefaultCredentials = true; } } else if (previousStatusCode == HttpStatusCode.ProxyAuthenticationRequired) { request.Proxy.Credentials = credentialProvider.GetCredentials(request, CredentialType.ProxyCredentials, retrying: proxyCredentialsRetryCount > 0); continueIfFailed = request.Proxy.Credentials != null; proxyCredentialsRetryCount++; } else if ((previousStatusCode == HttpStatusCode.Unauthorized) && !usingSTSAuth) { // If we are using STS, the auth's being performed by a request header. We do not need to ask the user for credentials at this point. request.Credentials = credentialProvider.GetCredentials(request, CredentialType.RequestCredentials, retrying: credentialsRetryCount > 0); continueIfFailed = request.Credentials != null; credentialsRetryCount++; } try { ICredentials credentials = request.Credentials; SetKeepAliveHeaders(request, previousResponse); if (usingSTSAuth) { // Add request headers if the server requires STS based auth. STSAuthHelper.PrepareSTSRequest(request); } // Prepare the request, we do something like write to the request stream // which needs to happen last before the request goes out prepareRequest(request); // Wrap the credentials in a CredentialCache in case there is a redirect // and credentials need to be kept around. request.Credentials = request.Credentials.AsCredentialCache(request.RequestUri); WebResponse response = request.GetResponse(); // Cache the proxy and credentials proxyCache.Add(request.Proxy); credentialCache.Add(request.RequestUri, credentials); credentialCache.Add(response.ResponseUri, credentials); return response; } catch (WebException ex) { using (IHttpWebResponse response = GetResponse(ex.Response)) { if (response == null && ex.Status != WebExceptionStatus.SecureChannelFailure) { // No response, something went wrong so just rethrow throw; } // Special case https connections that might require authentication if (ex.Status == WebExceptionStatus.SecureChannelFailure) { if (continueIfFailed) { // Act like we got a 401 so that we prompt for credentials on the next request previousStatusCode = HttpStatusCode.Unauthorized; continue; } throw; } // If we were trying to authenticate the proxy or the request and succeeded, cache the result. if (previousStatusCode == HttpStatusCode.ProxyAuthenticationRequired && response.StatusCode != HttpStatusCode.ProxyAuthenticationRequired) { proxyCache.Add(request.Proxy); } else if (previousStatusCode == HttpStatusCode.Unauthorized && response.StatusCode != HttpStatusCode.Unauthorized) { credentialCache.Add(request.RequestUri, request.Credentials); credentialCache.Add(response.ResponseUri, request.Credentials); } usingSTSAuth = STSAuthHelper.TryRetrieveSTSToken(request.RequestUri, response); if (!IsAuthenticationResponse(response) || !continueIfFailed) { throw; } previousResponse = response; previousStatusCode = previousResponse.StatusCode; } } } }
private void SubscribeToEvents(ICredentialProvider credentialProvider) { var deploymentManager = new RemoteDeploymentManager(ServiceUrl + "deploy"); deploymentManager.Credentials = credentialProvider.GetCredentials(); DeploymentManager = deploymentManager; DeploymentManager.StatusChanged += OnDeploymentStatusChanged; var commandExecutor = new RemoteCommandExecutor(ServiceUrl + "live/command"); commandExecutor.Credentials = credentialProvider.GetCredentials(); CommandExecutor = commandExecutor; CommandExecutor.CommandEvent += OnCommandEvent; var devCommandExecutor = new RemoteCommandExecutor(ServiceUrl + "dev/command"); devCommandExecutor.Credentials = credentialProvider.GetCredentials(); DevCommandExecutor = devCommandExecutor; DevCommandExecutor.CommandEvent += OnCommandEvent; //try //{ // // Start the connections // deploymentManager.Start(); // commandExecutor.Start(); // devCommandExecutor.Start(); //} //catch(Exception ex) //{ // Debug.WriteLine("Failed to subcribe for updates => " + ex.Message); //} }