/// <summary>
        /// Constructor with proxy credentials provided
        /// </summary>
        /// <param name="request">The request being sent to the server</param>
        /// <param name="proxyCredentials">Proxy credentials</param>
        /// <exception cref="System.ArgumentNullException">Thrown when any of the reference arguments are null</exception>
        public CloudFilesRequest(HttpWebRequest request, ProxyCredentials proxyCredentials)
        {
            if (request == null) throw new ArgumentNullException();

            _httpWebRequest = request;
            _proxyCredentials = proxyCredentials;
        }
        /// <summary>
        /// Constructor with proxy credentials provided
        /// </summary>
        /// <param name="request">The request being sent to the server</param>
        /// <param name="proxyCredentials">Proxy credentials</param>
        /// <exception cref="System.ArgumentNullException">Thrown when any of the reference arguments are null</exception>
        public CloudFilesRequest(IRequest request, ProxyCredentials proxyCredentials)
        {
            if (request == null) throw new ArgumentNullException();

            this.request = request;
            this.proxyCredentials = proxyCredentials;
        }
 public CryptoManager(string apiKey, ProxyCredentials credentials) : this(apiKey)
 {
     if (credentials != null)
     {
         _client.Proxy = MakeProxy(credentials);
     }
 }
 private IWebProxy MakeProxy(ProxyCredentials credentials)
 {
     return(new WebProxy($"{credentials.Host}:{credentials.Port}")
     {
         UseDefaultCredentials = false,
         Credentials = new NetworkCredential(credentials.Username, credentials.Password, credentials.Domain)
     });
 }
        /// <summary>
        /// Constructor with proxy credentials provided
        /// </summary>
        /// <param name="request">The request being sent to the server</param>
        /// <param name="proxyCredentials">Proxy credentials</param>
        /// <exception cref="System.ArgumentNullException">Thrown when any of the reference arguments are null</exception>
        public CloudFilesRequest(HttpWebRequest request, ProxyCredentials proxyCredentials)
        {
            if (request == null)
            {
                throw new ArgumentNullException();
            }

            this._httpWebRequest   = request;
            this._proxyCredentials = proxyCredentials;
        }
Exemple #6
0
        public void Setup()
        {
            proxyCredentials = new ProxyCredentials(Constants.PROXY_ADDRESS, Constants.PROXY_USERNAME, Constants.PROXY_PASSWORD, Constants.PROXY_DOMAIN);

            userCreds = new UserCredentials(
                Constants.CREDENTIALS_USER_NAME,
                Constants.CREDENTIALS_PASSWORD,
                proxyCredentials
                );
        }
Exemple #7
0
 public Proxy(ProxyType proxyType, string host, int port, ProxyCredentials proxyCreds)
 {
     ProxyType     = proxyType;
     Host          = host;
     Port          = port;
     ProxyCreds    = proxyCreds;
     ProxyState    = ProxyState.Online;
     NetworkType   = NetworkType.Datacenter;
     AddressFamily = AddressFamily.InterNetwork;
     IsStaticIP    = true;
 }
Exemple #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CloudFilesRequest"/> class with proxy creditials provided.
        /// </summary>
        /// <param name="request">The request being sent to the server</param>
        /// <param name="proxyCredentials">Proxy credentials</param>
        /// <exception cref="System.ArgumentNullException">Thrown when any of the reference arguments are null</exception>
        public CloudFilesRequest(HttpWebRequest request, ProxyCredentials proxyCredentials)
        {
            if (request == null)
            {
                throw new ArgumentNullException();
            }

            _httpWebRequest   = request;
            _proxyCredentials = proxyCredentials;
            if (request.Headers == null)
            {
                request.Headers = new WebHeaderCollection();
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CloudFilesRequest"/> class with proxy creditials provided.
        /// </summary>
        /// <param name="request">The request being sent to the server</param>
        /// <param name="proxyCredentials">Proxy credentials</param>
        /// <exception cref="System.ArgumentNullException">Thrown when any of the reference arguments are null</exception>
        public CloudFilesRequest(HttpWebRequest request, ProxyCredentials proxyCredentials)
        {
            if (request == null)
            {
                throw new ArgumentNullException();
            }

            _httpWebRequest = request;
            _proxyCredentials = proxyCredentials;
            if(request.Headers == null)
            {
                request.Headers = new WebHeaderCollection();
            }
        }
Exemple #10
0
        public void SetUp()
        {
            authUrl = new Uri(Constants.AUTH_URL);

            proxyCredentials = new ProxyCredentials(Constants.PROXY_ADDRESS, Constants.PROXY_USERNAME, Constants.PROXY_PASSWORD, Constants.PROXY_DOMAIN);

            userCreds = new UserCredentials(
                authUrl,
                Constants.CREDENTIALS_USER_NAME,
                Constants.CREDENTIALS_PASSWORD,
                Constants.CREDENTIALS_CLOUD_VERSION,
                Constants.CREDENTIALS_ACCOUNT_NAME,
                proxyCredentials
                );
        }
Exemple #11
0
        //=====================================================================

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="configuration">The current configuration element</param>
        public AjaxDocConfigDlg(XElement configuration)
        {
            InitializeComponent();

            this.chkUseProxyServer_CheckedChanged(this, null);

            chkUseDefaultCredentials.IsChecked = chkUseProxyDefCreds.IsChecked = true;

            this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));

            // Load the current settings
            if (!configuration.IsEmpty)
            {
                var node = configuration.Element("ajaxDoc");

                if (node != null)
                {
                    txtAjaxDocUrl.Text           = node.Attribute("url").Value;
                    txtProjectName.Text          = node.Attribute("project").Value;
                    chkRegenerateFiles.IsChecked = (bool)node.Attribute("regenerate");
                }

                var userCreds = UserCredentials.FromXml(configuration);

                chkUseDefaultCredentials.IsChecked = userCreds.UseDefaultCredentials;
                txtUserName.Text = userCreds.UserName;
                txtPassword.Text = userCreds.Password;

                var proxyCreds = ProxyCredentials.FromXml(configuration);

                chkUseProxyServer.IsChecked = proxyCreds.UseProxyServer;
                txtProxyServer.Text         = proxyCreds.ProxyServer?.OriginalString;

                chkUseProxyDefCreds.IsChecked = proxyCreds.Credentials.UseDefaultCredentials;
                txtProxyUserName.Text         = proxyCreds.Credentials.UserName;
                txtProxyPassword.Text         = proxyCreds.Credentials.Password;
            }
        }
Exemple #12
0
 public ICloudFilesRequest Create(Uri uri, ProxyCredentials creds)
 {
     return(new CloudFilesRequest((HttpWebRequest)WebRequest.Create(uri), creds));
 }
 public ICloudFilesResponse Submit(IAddToWebRequest requesttype, string authtoken, ProxyCredentials credentials)
 {
     return commonSubmit(requesttype, ()=> _requestfactory.Create(requesttype.CreateUri(),credentials),authtoken );
 }
Exemple #14
0
 public ICloudFilesResponse Submit(IAddToWebRequest requesttype, string authtoken, ProxyCredentials credentials)
 {
     return(commonSubmit(requesttype, () => _requestfactory.Create(requesttype.CreateUri(), credentials), authtoken));
 }
        /// <summary>
        /// Validate the control values and, if valid, create and return a new
        /// deployment location settings object.
        /// </summary>
        /// <returns>The deployment location settings if they are valid or
        /// null if they are not valid.</returns>
        public DeploymentLocation CreateDeploymentLocation()
        {
            DeploymentLocation location = null;
            bool isValid = true;

            foreach (var c in new[] { txtTargetLocation, txtUserName, txtPassword, txtProxyServer, txtProxyUserName,
                                      txtProxyPassword })
            {
                c.Text = c.Text.Trim();
                c.SetValidationState(true, null);
            }

            if (txtTargetLocation.Text.Length == 0 || !Uri.TryCreate(txtTargetLocation.Text,
                                                                     UriKind.RelativeOrAbsolute, out Uri targetUri))
            {
                targetUri = null;
            }

            if (txtTargetLocation.Text.Length != 0 && targetUri == null)
            {
                txtTargetLocation.SetValidationState(false, "The target location does not appear to be valid");
                isValid = false;
            }

            if (!chkUseDefaultCredentials.IsChecked.Value)
            {
                if (txtUserName.Text.Length == 0)
                {
                    txtUserName.SetValidationState(false, "A user name is required if not using default credentials");
                    isValid = false;
                }

                if (txtPassword.Text.Length == 0)
                {
                    txtPassword.SetValidationState(false, "A password is required if not using default credentials");
                    isValid = false;
                }
            }

            if (!Uri.TryCreate(txtProxyServer.Text, UriKind.RelativeOrAbsolute, out Uri proxyServer))
            {
                proxyServer = null;
            }

            if (chkUseProxyServer.IsChecked.Value)
            {
                if (txtProxyServer.Text.Length == 0)
                {
                    txtProxyServer.SetValidationState(false, "A proxy server is required if one is used");
                    isValid = false;
                }
                else
                {
                    if (proxyServer == null)
                    {
                        txtProxyServer.SetValidationState(false, "The proxy server name does not appear to be valid");
                        isValid = false;
                    }
                }

                if (!chkUseProxyDefCreds.IsChecked.Value)
                {
                    if (txtProxyUserName.Text.Length == 0)
                    {
                        txtProxyUserName.SetValidationState(false, "A user name is required if not using " +
                                                            "default credentials");
                        isValid = false;
                    }

                    if (txtProxyPassword.Text.Length == 0)
                    {
                        txtProxyPassword.SetValidationState(false, "A password is required if not using default " +
                                                            "credentials");
                        isValid = false;
                    }
                }
            }

            if (isValid)
            {
                var userCreds = new UserCredentials(chkUseDefaultCredentials.IsChecked.Value, txtUserName.Text,
                                                    txtPassword.Text);
                var proxyCreds = new ProxyCredentials(chkUseProxyServer.IsChecked.Value, proxyServer,
                                                      new UserCredentials(chkUseProxyDefCreds.IsChecked.Value, txtProxyUserName.Text,
                                                                          txtProxyPassword.Text));
                location = new DeploymentLocation(targetUri, userCreds, proxyCreds);
            }

            return(location);
        }
Exemple #16
0
 public ICloudFilesRequest Create(Uri uri, ProxyCredentials creds)
 {
     throw new NotImplementedException();
 }
Exemple #17
0
        /// <summary>
        /// Validate the configuration and save it
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            bool isValid = true;

            foreach (var c in new[] { txtAjaxDocUrl, txtProjectName, txtUserName, txtPassword, txtProxyServer,
                                      txtProxyUserName, txtProxyPassword })
            {
                c.Text = c.Text.Trim();
                c.SetValidationState(true, null);
            }

            if (txtAjaxDocUrl.Text.Length == 0)
            {
                txtAjaxDocUrl.SetValidationState(false, "An AjaxDoc URL is required");
                isValid = false;
            }
            else
            {
                if (!Uri.TryCreate(txtAjaxDocUrl.Text, UriKind.RelativeOrAbsolute, out _))
                {
                    txtAjaxDocUrl.SetValidationState(false, "The AjaxDoc URL does not appear to be valid");
                    isValid = false;
                }
            }

            if (txtProjectName.Text.Length == 0)
            {
                txtProjectName.SetValidationState(false, "A project filename is required");
                isValid = false;
            }

            if (!chkUseDefaultCredentials.IsChecked.Value)
            {
                if (txtUserName.Text.Length == 0)
                {
                    txtUserName.SetValidationState(false, "A user name is required if not using default credentials");
                    isValid = false;
                }

                if (txtPassword.Text.Length == 0)
                {
                    txtPassword.SetValidationState(false, "A password is required if not using default credentials");
                    isValid = false;
                }
            }

            if (Uri.TryCreate(txtProxyServer.Text, UriKind.RelativeOrAbsolute, out Uri proxyServer))
            {
                proxyServer = null;
            }

            if (chkUseProxyServer.IsChecked.Value)
            {
                if (txtProxyServer.Text.Length == 0)
                {
                    txtProxyServer.SetValidationState(false, "A proxy server is required if one is used");
                    isValid = false;
                }
                else
                {
                    if (proxyServer == null)
                    {
                        txtProxyServer.SetValidationState(false, "The proxy server name does not appear to be valid");
                        isValid = false;
                    }
                }

                if (!chkUseProxyDefCreds.IsChecked.Value)
                {
                    if (txtProxyUserName.Text.Length == 0)
                    {
                        txtProxyUserName.SetValidationState(false, "A user name is required if not using " +
                                                            "default credentials");
                        isValid = false;
                    }

                    if (txtProxyPassword.Text.Length == 0)
                    {
                        txtProxyPassword.SetValidationState(false, "A password is required if not using default " +
                                                            "credentials");
                        isValid = false;
                    }
                }
            }

            if (!isValid)
            {
                return;
            }

            var userCreds = new UserCredentials(chkUseDefaultCredentials.IsChecked.Value, txtUserName.Text,
                                                txtPassword.Text);
            var proxyCreds = new ProxyCredentials(chkUseProxyServer.IsChecked.Value, proxyServer,
                                                  new UserCredentials(chkUseProxyDefCreds.IsChecked.Value, txtProxyUserName.Text, txtProxyPassword.Text));

            configuration.RemoveNodes();

            configuration.Add(
                new XElement("ajaxDoc",
                             new XAttribute("url", txtAjaxDocUrl.Text),
                             new XAttribute("project", txtProjectName.Text),
                             new XAttribute("regenerate", chkRegenerateFiles.IsChecked.Value)),
                userCreds.ToXml(),
                proxyCreds.ToXml());

            this.DialogResult = true;
            this.Close();
        }
Exemple #18
0
 public Proxy(string host, int port, ProxyCredentials proxyCreds) : this(ProxyType.Http, host, port, proxyCreds)
 {
 }
 public ICloudFilesRequest Create(Uri uri, ProxyCredentials creds)
 {
     return new CloudFilesRequest((HttpWebRequest) WebRequest.Create(uri), creds);
 }