Esempio n. 1
0
        public void CopyManifestInformation(IRepositoryProxy otherRepository)
        {
            // Clone the manifest and all of its information
            Manifest dummyManifest = new Manifest(otherRepository.Manifest);

            // Remove the files before we send it over because all we care about is the info
            dummyManifest.RootDirectory.Files.Clear();
            dummyManifest.RootDirectory.Subdirectories.Clear();

            Uri requestUri = new Uri(BaseUri.ToString());

            HttpWebRequest request =
                (HttpWebRequest)WebRequest.Create(requestUri);

            request.Method  = "SETMANIFESTINFO";
            request.Timeout = RequestTimeout;
            request.AllowWriteStreamBuffering = false;

            MemoryStream memStream = new MemoryStream();

            dummyManifest.WriteManifestStream(memStream);

            memStream.Seek(0, SeekOrigin.Begin);
            request.ContentLength = memStream.Length;

            StreamUtilities.CopyStream(memStream, request.GetRequestStream());
            request.GetRequestStream().Close();

            HttpWebResponse response =
                (HttpWebResponse)request.GetResponse();

            response.Close();
        }
        protected virtual Uri GetConnectionUrl(Symbol publisherId)
        {
            var url = BaseUri.ToString();

            if (url.StartsWith("http://"))
            {
                url = "ws://" + url.Substring(7);
            }
            else if (url.StartsWith("https://"))
            {
                url = "wss://" + url.Substring(8);
            }
            if (url.EndsWith("/"))
            {
                url = url.Substring(0, url.Length - 1);
            }
            url += RequestPath;
            var uriBuilder = new UriBuilder(url);
            var queryTail  =
                $"{PublisherIdQueryParameterName}={publisherId.Value}" +
                $"&{ClientIdQueryParameterName}={ClientId.Value}";

            if (!string.IsNullOrEmpty(uriBuilder.Query))
            {
                uriBuilder.Query += "&" + queryTail;
            }
            else
            {
                uriBuilder.Query = queryTail;
            }
            return(uriBuilder.Uri);
        }
Esempio n. 3
0
 public void Save()
 {
     Log.Debug("Saving settings...");
     Properties.Settings.Default.threadfix_url = BaseUri.ToString();
     Properties.Settings.Default.apikey        = ApiKey;
     Properties.Settings.Default.Save();
 }
        public void TestCreateUriField()
        {
            var decorator       = new VersionInformationServiceDecorator();
            var codeMemberField = decorator.CreateUriField(CreateService());

            Assert.AreEqual(VersionInformationServiceDecorator.BaseUriName, codeMemberField.Name);
            Assert.AreEqual(BaseUri.ToString(), GetReturnPrimitiveValue(codeMemberField));
        }
Esempio n. 5
0
        protected override void OnContentChanged(object oldContent, object newContent)
        {
            BaseUriPath = BaseUri != null?BaseUri.ToString() : string.Empty;

            FrameContent = newContent;
            FrameContentChanged(oldContent, newContent);
            base.OnContentChanged(oldContent, newContent);
        }
        public void TestCreateUriField()
        {
            var decorator       = new BaseClientServiceAbstractPropertiesDecorator();
            var codeMemberField = decorator.CreateUriProperty(CreateService());

            Assert.AreEqual("BaseUri", codeMemberField.Name);
            Assert.AreEqual(BaseUri.ToString(), GetReturnPrimitiveValue(codeMemberField));
        }
Esempio n. 7
0
        public (string headerName, string headerValue) ToString(ICspNonceService nonceService)
        {
            string headerName;

            if (ReportOnly)
            {
                headerName = "Content-Security-Policy-Report-Only";
            }
            else
            {
                headerName = "Content-Security-Policy";
            }
            var values = new List <string>
            {
                Default.ToString(nonceService),
                Script.ToString(nonceService),
                Style.ToString(nonceService),
#pragma warning disable CS0618 // Type or member is obsolete
                Child.ToString(nonceService),
#pragma warning restore CS0618 // Type or member is obsolete
                Connect.ToString(nonceService),
                Manifest.ToString(nonceService),
                Font.ToString(nonceService),
                FormAction.ToString(nonceService),
                Img.ToString(nonceService),
                Media.ToString(nonceService),
                Object.ToString(nonceService),
                FrameAncestors.ToString(),
                PluginTypes.ToString(),
                Frame.ToString(nonceService),
                Worker.ToString(nonceService),
                Prefetch.ToString(nonceService),
                BaseUri.ToString(nonceService),
                RequireSri.ToString()
            };

            if (BlockAllMixedContent)
            {
                values.Insert(0, "block-all-mixed-content");
            }
            if (UpgradeInsecureRequests)
            {
                values.Insert(0, "upgrade-insecure-requests");
            }
            if (EnableSandbox)
            {
                values.Add(Sandbox.ToString());
            }
            if (ReportUri != null)
            {
                values.Add("report-uri " + ReportUri);
            }

            string headerValue = string.Join(";", values.Where(s => s.Length > 0));

            return(headerName, headerValue);
        }
Esempio n. 8
0
        public void Start()
        {
            _webApp = WebApp.Start(BaseUri.ToString(), app => app.Use <ProxyMiddleware>(Expect));

            _initialProxy       = WebRequest.DefaultWebProxy;
            _initialCachePolicy = WebRequest.DefaultCachePolicy;

            WebRequest.DefaultCachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
            WebRequest.DefaultWebProxy    = new WebProxy(BaseUri, false)
            {
                UseDefaultCredentials = true,
                BypassList            = new string[] {},
                Credentials           = CredentialCache.DefaultCredentials,
            };
        }
Esempio n. 9
0
        protected Uri MakeRemoteUri(ManifestFileInfo remoteFile)
        {
            String manifestPath =
                Manifest.MakeStandardPathString(remoteFile);

            // Remove the leading '.' from the relative path
            String uriPathString =
                manifestPath.Substring(1, manifestPath.Length - 1);

            String escapedUriPathString = System.Uri.EscapeDataString(uriPathString);

            Uri uri = new Uri(BaseUri.ToString() + escapedUriPathString);

            return(uri);
        }
        public Uri BuildUri()
        {
            var uri     = new StringBuilder();
            var baseUri = BaseUri.ToString();

            uri.AppendFormat("{0}", baseUri.EndsWith("/") ? baseUri : baseUri + "/");
            uri.AppendFormat("{0}", Resource.StartsWith("/") ? Resource.Substring(1) : Resource);

            if (Parameters.Any())
            {
                var data = EncodeParameters(uri.ToString(), Parameters);
                uri.Append(data);
            }

            return(new Uri(uri.ToString()));
        }
Esempio n. 11
0
        private Uri BuildRequestPath()
        {
            if (Paths == null || Paths.Count == 0)
            {
                return(BaseUri);
            }

            // append paths
            var basePath = BaseUri.ToString();

            basePath = AppendSlash(basePath);

            var paths    = string.Join("/", Paths);
            var fullPath = basePath + paths;

            var requestPath = new Uri(fullPath, UriKind.Absolute);

            return(requestPath);
        }
Esempio n. 12
0
        public virtual HttpRequest Build(string path)
        {
            if (BaseUri.ToString().EndsWith("/"))
            {
                path = path.TrimStart('/');
            }

            var request = new HttpRequest(BaseUri + path)
            {
                SuppressHttpError = SupressHttpError,
                NetworkCredential = NetworkCredential
            };

            if (PostProcess != null)
            {
                PostProcess(request);
            }

            return(request);
        }
Esempio n. 13
0
        protected List <XAttribute> GetXAttributes()
        {
            var attributes = new List <XAttribute>();

            if (!string.IsNullOrWhiteSpace(Lang))
            {
                attributes.Add(new XAttribute("lang", Lang));
            }

            if (BaseUri != null)
            {
                attributes.Add(new XAttribute("baseUri", BaseUri.ToString()));
            }

            if (Branding.HasValue)
            {
                attributes.Add(new XAttribute("branding", Branding.Value.ToString().FirstLetterToLower()));
            }

            if (AddImageQuery.HasValue)
            {
                attributes.Add(new XAttribute("addImageQuery", AddImageQuery.Value));
            }

            if (!string.IsNullOrWhiteSpace(ContentId))
            {
                attributes.Add(new XAttribute("contentId", ContentId));
            }

            if (!string.IsNullOrWhiteSpace(DisplayName))
            {
                attributes.Add(new XAttribute("displayName", DisplayName));
            }

            return(attributes);
        }
Esempio n. 14
0
        void initializeView()
        {
            if (!ArcGISOnlineEnvironment.ArcGISOnline.IsInitialized) // Wait for AGOL environment initialization
            {
                EventHandler <EventArgs> onInitialized = null;
                onInitialized = (o, e) =>
                {
                    ArcGISOnlineEnvironment.ArcGISOnline.Initialized -= onInitialized;
                    initializeView();
                };
                ArcGISOnlineEnvironment.ArcGISOnline.Initialized += onInitialized;
            }
            else
            {
                WindowManager manager = View != null && View.WindowManager != null ? View.WindowManager : null;

                string portalUrl = BaseUri.Scheme == "http" ? ViewerApplication.ArcGISOnlineSharing :
                                   ViewerApplication.ArcGISOnlineSecure;

                // TODO: Investigate difference between ViewerApplication.ArcGISOnlineProxy and ViewerApplication.Proxy
                ArcGISPortal portal = new ArcGISPortal()
                {
                    Url   = portalUrl,
                    Token = ArcGISOnlineEnvironment.ArcGISOnline.User != null
                        ? ArcGISOnlineEnvironment.ArcGISOnline.User.Token : null,
                    ProxyUrl = ViewerApplication.ArcGISOnlineProxy
                };

                View = new View(ApplicationServices, manager)
                {
                    IsEditMode          = IsEditMode,
                    BaseUrl             = BaseUri.ToString(),
                    ApplicationColorSet = ApplicationColorSet,
                    LayoutProvider      = new LayoutFileProvider()
                    {
                        LayoutFileContents = layoutFileContents,
                    },
                    Portal = portal
                };
                if (!string.IsNullOrWhiteSpace(ConfigurationStoreFilePath))
                {
                    View.ConfigurationStoreProvider = new ViewerConfigurationStoreProvider(ViewerApplication.GeometryService, ViewerApplication.BingMapsAppId, ViewerApplication.PortalAppId);
                }
                View.ProxyUrl = View.DefaultProxyUrl = ViewerApplication.Proxy;
                layoutResourceDictionaries = new List <ResourceDictionary>();
                foreach (string layoutResourceDictionaryFileContent in layoutResourceDictionaryFileContents)
                {
                    if (!string.IsNullOrWhiteSpace(layoutResourceDictionaryFileContent))
                    {
                        ResourceDictionary resourceDict = XamlReader.Load(layoutResourceDictionaryFileContent) as ResourceDictionary;
                        if (resourceDict != null)
                        {
                            Application.Current.Resources.MergedDictionaries.Add(resourceDict);
                            layoutResourceDictionaries.Add(resourceDict);
                        }
                    }
                }
                View.LayoutResourceDictionaries = layoutResourceDictionaries;

                if (!string.IsNullOrWhiteSpace(ThemeFilePath))
                {
                    View.ThemeProvider = new ThemeProvider()
                    {
                        ThemeFileUrl = ThemeFilePath,
                    };
                }

                if (!string.IsNullOrWhiteSpace(ConnectionsFileFilePath))
                {
                    View.ConnectionsProvider = new FileConnectionsProvider()
                    {
                        ConfigurationFile = new DataFile()
                        {
                            IsUrl = true, Path = ConnectionsFileFilePath
                        }
                    };
                }

                if (!string.IsNullOrWhiteSpace(MapConfigurationFilePath))
                {
                    FileConfigurationProvider fileConfigurationProvider = ConfigurationProvider ?? new FileConfigurationProvider();
                    fileConfigurationProvider.ConfigurationFile = new DataFile()
                    {
                        IsUrl = true, Path = MapConfigurationFilePath
                    };
                    View.ConfigurationProvider = fileConfigurationProvider;
                }

                if (!string.IsNullOrWhiteSpace(SymbolConfigurationFilePath))
                {
                    View.SymbolConfigProvider = new FileSymbolConfigProvider()
                    {
                        ConfigFileUrl = SymbolConfigurationFilePath,
                        ClassBreaksColorGradientsConfigFileUrl = ClassBreaksColorGradientsConfigFileUrl,
                        HeatMapColorGradientsConfigFileUrl     = HeatMapColorGradientsConfigFileUrl,
                        SymbolFolderParentUrl = SymbolFolderParentUrl,
                        UniqueValueColorGradientsConfigFileUrl = UniqueValueColorGradientsConfigFileUrl,
                    };
                }

                View.ExtensionsDataManager = new ExtensionsDataManager()
                {
                    ExtensionsConfigData = new ExtensionsConfigData(controlsXmlFileContents)
                };
                View.ExtensionBehaviors = getBehaviors(behaviorsXmlFileContents);

                View.ExtensionLoadFailed += new EventHandler <ExceptionEventArgs>(View_ExtensionLoadFailed);

                View.ConfigurationLoaded += new EventHandler(View_ConfigurationLoaded);

                this.Content = View;

                OnViewInitialized(new ViewEventArgs()
                {
                    View = View
                });
            }
        }
Esempio n. 15
0
        void ProcessRequest()
        {
            try
            {
                var requestUri = new StringBuilder();
                requestUri.AppendFormat("{0}{1}{2}/{3}",
                                        BaseUri,
                                        (BaseUri.ToString().EndsWith("/")) ? string.Empty : "/",
                                        Uri.EscapeUriString(ScopeName),
                                        _wrapper.CacheRequest.RequestType.ToString());

                string prefix = "?";

                // Add the scope params if any
                foreach (KeyValuePair <string, string> kvp in _scopeParameters)
                {
                    requestUri.AppendFormat("{0}{1}={2}", prefix, Uri.EscapeUriString(kvp.Key), Uri.EscapeUriString(kvp.Value));
                    if (prefix.Equals("?"))
                    {
                        prefix = "&";
                    }
                }

                // Create the WebRequest
                var webRequest = new NSMutableUrlRequest(new NSUrl(requestUri.ToString()));
                if (_credentials != null)
                {
                    NetworkCredential credential     = _credentials.GetCredential(BaseUri, "Basic");
                    string            svcCredentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(credential.UserName + ":" + credential.Password));
                    webRequest["Authorization"] = "Basic " + svcCredentials;

                    webRequest["configname"]    = _behaviors.ConfigName;
                    webRequest["configversion"] = _behaviors.ConfigVersion;

                    webRequest["coreversion"] = _behaviors.CoreVersion.ToString();
                }
                else
                {
                    throw new Exception("Credentials is null");
                }

                foreach (var item in _behaviors.DeviceInfo)
                {
                    webRequest[item.Key] = item.Value;
                }

                webRequest.HttpMethod         = "POST";
                webRequest["Accept"]          = ApplicationContext.Current.Settings.BitMobileFormatterDisabled ? "application/atom+xml" : "application/bitmobile";
                webRequest["Content-Type"]    = ApplicationContext.Current.Settings.BitMobileFormatterDisabled ? "application/atom+xml" : "application/bitmobile";
                webRequest["Accept-Encoding"] = "gzip, deflate";
                webRequest.TimeoutInterval    = Timeout;

                webRequest.Body = CreateRequestBody();

                _wrapper.WebRequest = webRequest;

                if (_wrapper.CacheRequest.RequestType == CacheRequestType.UploadChanges)
                {
                    lock (_lockObject)
                    {
                        _currentTask = CreateUploadSession().CreateDownloadTask(webRequest);
                        _currentTask.Resume();
                    }
                }
                else
                {
                    lock (_lockObject)
                    {
                        _currentTask = CreateDownloadSession().CreateDownloadTask(webRequest);
                        _currentTask.Resume();
                    }
                }
            }
            catch (Exception e)
            {
                if (ExceptionUtility.IsFatal(e))
                {
                    throw;
                }

                _wrapper.Error = e;

                _workerManager.CompleteWorkRequest(_wrapper.WorkerRequest, _wrapper);
            }
        }
Esempio n. 16
0
 /// <summary>
 /// Сохранить конфигурацию.
 /// </summary>
 /// <param name="container">Контейнер.</param>
 protected override void SaveConfiguration(ApplicationDataContainer container)
 {
     container.Values["baseUri"] = BaseUri?.ToString() ?? "https://2ch.hk/";
 }
Esempio n. 17
0
 public void Start()
 {
     _webApp = WebApp.Start(BaseUri.ToString(), app => app.Use <ProxyMiddleware>(Expect, _capturedRequests));
 }
 /// <summary>
 /// Returns a <see cref="System.String" /> that represents this instance.
 /// </summary>
 /// <returns>
 /// A <see cref="System.String" /> that represents this instance.
 /// </returns>
 public override string ToString()
 {
     return(BaseUri.ToString());
 }
Esempio n. 19
0
 public void Start()
 {
     _webApp            = WebApp.Start(BaseUri.ToString(), app => app.Use <ProxyMiddleware>(Expect, _capturedRequests));
     Client             = new HttpClient();
     Client.BaseAddress = BaseUri;
 }
Esempio n. 20
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            var sb = new StringBuilder();

            sb.AppendLine(string.Format("Level : {0}", Level));
            sb.AppendLine(string.Format("Strategy : {0}", Strategy));
            sb.AppendLine(string.Format("IsOk : {0}", Ok));
            sb.AppendLine(string.Format("SchemaError : {0}", SchemaError));
            sb.AppendLine(string.Format("BaseUri : '{0}'", BaseUri == null ? "NULL" : BaseUri.ToString()));
            foreach (var trustedHost in TrustedHosts)
            {
                sb.AppendLine("Trust : '" + trustedHost + "'");
            }
            if (0 != Errors.Count)
            {
                foreach (var desc in Errors)
                {
                    sb.AppendLine(desc.ToString());
                }
            }
            return(sb.ToString());
        }
Esempio n. 21
0
 public string ToString(CoapEndpointStringFormat format)
 {
     return(BaseUri.ToString());
 }