Exemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="deployTo">The deployment location</param>
 /// <param name="user">The user credentials, if any</param>
 /// <param name="proxy">The proxy credentials, if any</param>
 public DeploymentLocation(Uri deployTo, UserCredentials user,
                           ProxyCredentials proxy)
 {
     location   = deployTo;
     userCreds  = user ?? new UserCredentials();
     proxyCreds = proxy ?? new ProxyCredentials();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Create a deployment location instance from an XML element containing the settings
        /// </summary>
        /// <param name="configuration">The XML element from which to obtain the settings</param>
        /// <param name="id">The id of the element to load</param>
        /// <returns>A <see cref="DeploymentLocation"/> object containing the settings from the XPath navigator.</returns>
        /// <remarks>It should contain an element called <b>deploymentLocation</b> with two attributes (<b>id</b>
        /// with the specified ID value and <b>location</b>) and nested <b>userCredentials</b> and
        /// <b>proxyCredentials</b> elements.</remarks>
        public static DeploymentLocation FromXml(XElement configuration, string id)
        {
            DeploymentLocation depLoc = new DeploymentLocation();

            configuration = configuration?.XPathSelectElement("deploymentLocation[@id='" + id + "']");

            if (configuration != null)
            {
                string location = configuration.Attribute("location").Value;

                if (!String.IsNullOrWhiteSpace(location))
                {
                    depLoc.Location = new Uri(location, UriKind.RelativeOrAbsolute);
                }

                UserCredentials user = UserCredentials.FromXml(configuration);

                depLoc.UserCredentials.UseDefaultCredentials = user.UseDefaultCredentials;
                depLoc.UserCredentials.UserName = user.UserName;
                depLoc.UserCredentials.Password = user.Password;

                ProxyCredentials proxy = ProxyCredentials.FromXml(configuration);

                depLoc.ProxyCredentials.UseProxyServer = proxy.UseProxyServer;
                depLoc.ProxyCredentials.ProxyServer    = proxy.ProxyServer;
                depLoc.ProxyCredentials.Credentials.UseDefaultCredentials = proxy.Credentials.UseDefaultCredentials;
                depLoc.ProxyCredentials.Credentials.UserName = proxy.Credentials.UserName;
                depLoc.ProxyCredentials.Credentials.Password = proxy.Credentials.Password;
            }

            return(depLoc);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a proxy credentials instance from an XPath navigator
        /// containing the settings.
        /// </summary>
        /// <param name="navigator">The XPath navigator from which to
        /// obtain the settings.</param>
        /// <returns>A <see cref="ProxyCredentials"/> object containing the
        /// settings from the XPath navigator.</returns>
        /// <remarks>It should contain an element called <b>proxyCredentials</b>
        /// with two attributes (<b>useProxy</b> and <b>proxyServer</b>) and a
        /// nested <b>userCredentials</b> element.</remarks>
        public static ProxyCredentials FromXPathNavigator(
            XPathNavigator navigator)
        {
            ProxyCredentials credentials = new ProxyCredentials();
            UserCredentials  user;
            string           server;

            if (navigator != null)
            {
                navigator = navigator.SelectSingleNode("proxyCredentials");

                if (navigator != null)
                {
                    credentials.UseProxyServer = Convert.ToBoolean(
                        navigator.GetAttribute("useProxy", String.Empty),
                        CultureInfo.InvariantCulture);
                    server = navigator.GetAttribute("proxyServer",
                                                    String.Empty).Trim();

                    if (server.Length != 0)
                    {
                        credentials.ProxyServer = new Uri(server,
                                                          UriKind.RelativeOrAbsolute);
                    }

                    user = UserCredentials.FromXPathNavigator(navigator);
                    credentials.Credentials.UseDefaultCredentials =
                        user.UseDefaultCredentials;
                    credentials.Credentials.UserName = user.UserName;
                    credentials.Credentials.Password = user.Password;
                }
            }

            return(credentials);
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the build process
        /// </summary>
        /// <param name="buildProcess">A reference to the current build process</param>
        /// <param name="configuration">The configuration data that the plug-in should use to initialize itself</param>
        /// <exception cref="BuilderException">This is thrown if the plug-in configuration is not valid</exception>
        public void Initialize(BuildProcess buildProcess, XElement configuration)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            builder    = buildProcess ?? throw new ArgumentNullException(nameof(buildProcess));
            ajaxDocUrl = projectName = String.Empty;
            userCreds  = new UserCredentials();
            proxyCreds = new ProxyCredentials();

            var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
                typeof(HelpFileBuilderPlugInExportAttribute), false).First();

            builder.ReportProgress("{0} Version {1}\r\n{2}", metadata.Id, metadata.Version, metadata.Copyright);

            if (configuration.IsEmpty)
            {
                throw new BuilderException("ADP0001", "The AjaxDoc plug-in has not been configured yet");
            }

            var node = configuration.Element("ajaxDoc");

            if (node != null)
            {
                ajaxDocUrl      = node.Attribute("url").Value;
                projectName     = node.Attribute("project").Value;
                regenerateFiles = (bool)node.Attribute("regenerate");
            }

            userCreds  = UserCredentials.FromXml(configuration);
            proxyCreds = ProxyCredentials.FromXml(configuration);

            if (ajaxDocUrl.Length == 0 || projectName.Length == 0 || (!userCreds.UseDefaultCredentials &&
                                                                      (userCreds.UserName.Length == 0 || userCreds.Password.Length == 0)) ||
                (proxyCreds.UseProxyServer && (proxyCreds.ProxyServer == null ||
                                               (!proxyCreds.Credentials.UseDefaultCredentials && (proxyCreds.Credentials.UserName.Length == 0 ||
                                                                                                  proxyCreds.Credentials.Password.Length == 0)))))
            {
                throw new BuilderException("ADP0002", "The AjaxDoc plug-in has an invalid configuration");
            }

            if (ajaxDocUrl[ajaxDocUrl.Length - 1] != '/')
            {
                ajaxDocUrl += "/";
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the
        /// build process.
        /// </summary>
        /// <param name="buildProcess">A reference to the current build
        /// process.</param>
        /// <param name="configuration">The configuration data that the plug-in
        /// should use to initialize itself.</param>
        /// <exception cref="BuilderException">This is thrown if the plug-in
        /// configuration is not valid.</exception>
        public void Initialize(BuildProcess buildProcess,
                               XPathNavigator configuration)
        {
            XPathNavigator root, node;

            builder    = buildProcess;
            ajaxDocUrl = projectName = String.Empty;
            userCreds  = new UserCredentials();
            proxyCreds = new ProxyCredentials();

            builder.ReportProgress("{0} Version {1}\r\n{2}",
                                   this.Name, this.Version, this.Copyright);

            root = configuration.SelectSingleNode("configuration");

            if (root.IsEmptyElement)
            {
                throw new BuilderException("ADP0001", "The AjaxDoc plug-in " +
                                           "has not been configured yet");
            }

            node = root.SelectSingleNode("ajaxDoc");
            if (node != null)
            {
                ajaxDocUrl      = node.GetAttribute("url", String.Empty).Trim();
                projectName     = node.GetAttribute("project", String.Empty).Trim();
                regenerateFiles = Convert.ToBoolean(node.GetAttribute(
                                                        "regenerate", String.Empty), CultureInfo.InvariantCulture);
            }

            userCreds  = UserCredentials.FromXPathNavigator(root);
            proxyCreds = ProxyCredentials.FromXPathNavigator(root);

            if (ajaxDocUrl.Length == 0 || projectName.Length == 0 ||
                (!userCreds.UseDefaultCredentials &&
                 (userCreds.UserName.Length == 0 ||
                  userCreds.Password.Length == 0)) ||
                (proxyCreds.UseProxyServer &&
                 (proxyCreds.ProxyServer == null ||
                  (!proxyCreds.Credentials.UseDefaultCredentials &&
                   (proxyCreds.Credentials.UserName.Length == 0 ||
                    proxyCreds.Credentials.Password.Length == 0)))))
            {
                throw new BuilderException("ADP0002", "The AjaxDoc plug-in " +
                                           "has an invalid configuration");
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="currentConfig">The current XML configuration
        /// XML fragment</param>
        public AjaxDocConfigDlg(string currentConfig)
        {
            XPathNavigator   navigator, root, node;
            UserCredentials  userCreds;
            ProxyCredentials proxyCreds;

            InitializeComponent();

            lnkCodePlexSHFB.Links[0].LinkData    = "http://SHFB.CodePlex.com";
            lnkCodePlexAjaxDoc.Links[0].LinkData = "http://AjaxDoc.CodePlex.com";

            // Load the current settings
            config = new XmlDocument();
            config.LoadXml(currentConfig);
            navigator = config.CreateNavigator();

            root = navigator.SelectSingleNode("configuration");

            if (root.IsEmptyElement)
            {
                return;
            }

            node = root.SelectSingleNode("ajaxDoc");
            if (node != null)
            {
                txtAjaxDocUrl.Text         = node.GetAttribute("url", String.Empty);
                txtProjectName.Text        = node.GetAttribute("project", String.Empty);
                chkRegenerateFiles.Checked = Convert.ToBoolean(
                    node.GetAttribute("regenerate", String.Empty),
                    CultureInfo.InvariantCulture);
            }

            userCreds = UserCredentials.FromXPathNavigator(root);
            chkUseDefaultCredentials.Checked = userCreds.UseDefaultCredentials;
            txtUserName.Text = userCreds.UserName;
            txtPassword.Text = userCreds.Password;

            proxyCreds = ProxyCredentials.FromXPathNavigator(root);
            chkUseProxyServer.Checked = proxyCreds.UseProxyServer;
            txtProxyServer.Text       = (proxyCreds.ProxyServer == null) ? null :
                                        proxyCreds.ProxyServer.OriginalString;
            chkUseProxyDefCreds.Checked = proxyCreds.Credentials.UseDefaultCredentials;
            txtProxyUserName.Text       = proxyCreds.Credentials.UserName;
            txtProxyPassword.Text       = proxyCreds.Credentials.Password;
        }
Exemplo n.º 7
0
        //=====================================================================
        // Methods, etc.

        /// <summary>
        /// Constructor
        /// </summary>
        /// <overloads>There are two overloads for the constructor</overloads>
        public DeploymentLocation()
        {
            userCreds = new UserCredentials();
            proxyCreds = new ProxyCredentials();
        }
Exemplo n.º 8
0
        //=====================================================================
        // Methods, etc.

        /// <summary>
        /// Constructor
        /// </summary>
        /// <overloads>There are two overloads for the constructor</overloads>
        public DeploymentLocation()
        {
            userCreds  = new UserCredentials();
            proxyCreds = new ProxyCredentials();
        }
        /// <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;
            UserCredentials userCreds;
            ProxyCredentials proxyCreds;
            Uri targetUri = null, proxyUri = null;
            bool isValid = true;

            epErrors.Clear();

            txtTargetLocation.Text = txtTargetLocation.Text.Trim();
            txtUserName.Text = txtUserName.Text.Trim();
            txtPassword.Text = txtPassword.Text.Trim();
            txtProxyServer.Text = txtProxyServer.Text.Trim();
            txtProxyUserName.Text = txtProxyUserName.Text.Trim();
            txtProxyPassword.Text = txtProxyPassword.Text.Trim();

            if(txtTargetLocation.Text.Length != 0 && !Uri.TryCreate(
              txtTargetLocation.Text, UriKind.RelativeOrAbsolute, out targetUri))
            {
                epErrors.SetError(txtTargetLocation, "The target location " +
                    "does not appear to be valid");
                isValid = false;
            }

            if(!chkUseDefaultCredentials.Checked)
            {
                if(txtUserName.Text.Length == 0)
                {
                    epErrors.SetError(txtUserName, "A user name is required " +
                        "if not using default credentials");
                    isValid = false;
                }

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

            if(chkUseProxyServer.Checked)
            {
                if(txtProxyServer.Text.Length == 0)
                {
                    epErrors.SetError(txtProxyServer, "A proxy server is " +
                        "required if one is used");
                    isValid = false;
                }
                else
                {
                    Uri.TryCreate(txtProxyServer.Text, UriKind.RelativeOrAbsolute,
                        out proxyUri);

                    if(proxyUri == null)
                    {
                        epErrors.SetError(txtProxyServer, "The proxy server " +
                            "name does not appear to be valid");
                        isValid = false;
                    }
                }

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

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

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

            return location;
        }
        /// <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 valud or
        /// null if they are not valid.</returns>
        public DeploymentLocation CreateDeploymentLocation()
        {
            DeploymentLocation location = null;
            UserCredentials    userCreds;
            ProxyCredentials   proxyCreds;
            Uri  targetUri = null, proxyUri = null;
            bool isValid = true;

            epErrors.Clear();

            txtTargetLocation.Text = txtTargetLocation.Text.Trim();
            txtUserName.Text       = txtUserName.Text.Trim();
            txtPassword.Text       = txtPassword.Text.Trim();
            txtProxyServer.Text    = txtProxyServer.Text.Trim();
            txtProxyUserName.Text  = txtProxyUserName.Text.Trim();
            txtProxyPassword.Text  = txtProxyPassword.Text.Trim();

            if (txtTargetLocation.Text.Length != 0 && !Uri.TryCreate(
                    txtTargetLocation.Text, UriKind.RelativeOrAbsolute, out targetUri))
            {
                epErrors.SetError(txtTargetLocation, "The target location " +
                                  "does not appear to be valid");
                isValid = false;
            }

            if (!chkUseDefaultCredentials.Checked)
            {
                if (txtUserName.Text.Length == 0)
                {
                    epErrors.SetError(txtUserName, "A user name is required " +
                                      "if not using default credentials");
                    isValid = false;
                }

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

            if (chkUseProxyServer.Checked)
            {
                if (txtProxyServer.Text.Length == 0)
                {
                    epErrors.SetError(txtProxyServer, "A proxy server is " +
                                      "required if one is used");
                    isValid = false;
                }
                else
                {
                    Uri.TryCreate(txtProxyServer.Text, UriKind.RelativeOrAbsolute,
                                  out proxyUri);

                    if (proxyUri == null)
                    {
                        epErrors.SetError(txtProxyServer, "The proxy server " +
                                          "name does not appear to be valid");
                        isValid = false;
                    }
                }

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

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

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

            return(location);
        }
Exemplo n.º 11
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, EventArgs e)
        {
            XmlAttribute attr;
            XmlNode root, node;
            UserCredentials userCreds;
            ProxyCredentials proxyCreds;
            bool isValid = true;
            Uri ajaxDoc = null, proxyServer = null;

            txtAjaxDocUrl.Text = txtAjaxDocUrl.Text.Trim();
            txtProjectName.Text = txtProjectName.Text.Trim();
            txtUserName.Text = txtUserName.Text.Trim();
            txtPassword.Text = txtPassword.Text.Trim();
            txtProxyServer.Text = txtProxyServer.Text.Trim();
            txtProxyUserName.Text = txtProxyUserName.Text.Trim();
            txtProxyPassword.Text = txtProxyPassword.Text.Trim();
            epErrors.Clear();

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

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

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

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

            Uri.TryCreate(txtProxyServer.Text, UriKind.RelativeOrAbsolute, out proxyServer);

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

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

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

            if(!isValid)
                return;

            if(txtAjaxDocUrl.Text[txtAjaxDocUrl.Text.Length - 1] != '/')
                txtAjaxDocUrl.Text += "/";

            // Store the changes
            root = config.SelectSingleNode("configuration");

            node = root.SelectSingleNode("ajaxDoc");

            if(node == null)
            {
                node = config.CreateNode(XmlNodeType.Element, "ajaxDoc", null);
                root.AppendChild(node);

                attr = config.CreateAttribute("url");
                node.Attributes.Append(attr);
                attr = config.CreateAttribute("project");
                node.Attributes.Append(attr);
                attr = config.CreateAttribute("regenerate");
                node.Attributes.Append(attr);
            }

            node.Attributes["url"].Value = txtAjaxDocUrl.Text;
            node.Attributes["project"].Value = txtProjectName.Text;
            node.Attributes["regenerate"].Value = chkRegenerateFiles.Checked.ToString().ToLowerInvariant();

            userCreds = new UserCredentials(chkUseDefaultCredentials.Checked, txtUserName.Text, txtPassword.Text);
            userCreds.ToXml(config, root);

            proxyCreds = new ProxyCredentials(chkUseProxyServer.Checked, proxyServer,
                new UserCredentials(chkUseProxyDefCreds.Checked, txtProxyUserName.Text, txtProxyPassword.Text));
            proxyCreds.ToXml(config, root);

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="deployTo">The deployment location</param>
 /// <param name="user">The user credentials, if any</param>
 /// <param name="proxy">The proxy credentials, if any</param>
 public DeploymentLocation(Uri deployTo, UserCredentials user, ProxyCredentials proxy)
 {
     this.Location         = deployTo;
     this.UserCredentials  = user ?? new UserCredentials();
     this.ProxyCredentials = proxy ?? new ProxyCredentials();
 }
Exemplo n.º 13
0
        //=====================================================================
        // Methods, etc.

        /// <summary>
        /// Constructor
        /// </summary>
        /// <overloads>There are two overloads for the constructor</overloads>
        public DeploymentLocation()
        {
            this.UserCredentials  = new UserCredentials();
            this.ProxyCredentials = new ProxyCredentials();
        }
Exemplo n.º 14
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, EventArgs e)
        {
            XmlAttribute     attr;
            XmlNode          root, node;
            UserCredentials  userCreds;
            ProxyCredentials proxyCreds;
            bool             isValid = true;
            Uri ajaxDoc = null, proxyServer = null;

            txtAjaxDocUrl.Text    = txtAjaxDocUrl.Text.Trim();
            txtProjectName.Text   = txtProjectName.Text.Trim();
            txtUserName.Text      = txtUserName.Text.Trim();
            txtPassword.Text      = txtPassword.Text.Trim();
            txtProxyServer.Text   = txtProxyServer.Text.Trim();
            txtProxyUserName.Text = txtProxyUserName.Text.Trim();
            txtProxyPassword.Text = txtProxyPassword.Text.Trim();
            epErrors.Clear();

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

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

            if (!chkUseDefaultCredentials.Checked)
            {
                if (txtUserName.Text.Length == 0)
                {
                    epErrors.SetError(txtUserName, "A user name is " +
                                      "required if not using default credentials");
                    isValid = false;
                }

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

            Uri.TryCreate(txtProxyServer.Text, UriKind.RelativeOrAbsolute,
                          out proxyServer);

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

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

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

            if (!isValid)
            {
                return;
            }

            if (txtAjaxDocUrl.Text[txtAjaxDocUrl.Text.Length - 1] != '/')
            {
                txtAjaxDocUrl.Text += "/";
            }

            // Store the changes
            root = config.SelectSingleNode("configuration");

            node = root.SelectSingleNode("ajaxDoc");
            if (node == null)
            {
                node = config.CreateNode(XmlNodeType.Element,
                                         "ajaxDoc", null);
                root.AppendChild(node);

                attr = config.CreateAttribute("url");
                node.Attributes.Append(attr);
                attr = config.CreateAttribute("project");
                node.Attributes.Append(attr);
                attr = config.CreateAttribute("regenerate");
                node.Attributes.Append(attr);
            }

            node.Attributes["url"].Value        = txtAjaxDocUrl.Text;
            node.Attributes["project"].Value    = txtProjectName.Text;
            node.Attributes["regenerate"].Value =
                chkRegenerateFiles.Checked.ToString().ToLower(
                    CultureInfo.InvariantCulture);

            userCreds = new UserCredentials(chkUseDefaultCredentials.Checked,
                                            txtUserName.Text, txtPassword.Text);
            userCreds.ToXml(config, root);

            proxyCreds = new ProxyCredentials(chkUseProxyServer.Checked,
                                              proxyServer, new UserCredentials(chkUseProxyDefCreds.Checked,
                                                                               txtProxyUserName.Text, txtProxyPassword.Text));
            proxyCreds.ToXml(config, root);

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 15
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="deployTo">The deployment location</param>
 /// <param name="user">The user credentials, if any</param>
 /// <param name="proxy">The proxy credentials, if any</param>
 public DeploymentLocation(Uri deployTo, UserCredentials user,
     ProxyCredentials proxy)
 {
     location = deployTo;
     userCreds = user ?? new UserCredentials();
     proxyCreds = proxy ?? new ProxyCredentials();
 }
Exemplo n.º 16
0
        /// <summary>
        /// This method is used to initialize the plug-in at the start of the
        /// build process.
        /// </summary>
        /// <param name="buildProcess">A reference to the current build
        /// process.</param>
        /// <param name="configuration">The configuration data that the plug-in
        /// should use to initialize itself.</param>
        /// <exception cref="BuilderException">This is thrown if the plug-in
        /// configuration is not valid.</exception>
        public void Initialize(BuildProcess buildProcess,
          XPathNavigator configuration)
        {
            XPathNavigator root, node;

            builder = buildProcess;
            ajaxDocUrl = projectName = String.Empty;
            userCreds = new UserCredentials();
            proxyCreds = new ProxyCredentials();

            builder.ReportProgress("{0} Version {1}\r\n{2}",
                this.Name, this.Version, this.Copyright);

            root = configuration.SelectSingleNode("configuration");

            if(root.IsEmptyElement)
                throw new BuilderException("ADP0001", "The AjaxDoc plug-in " +
                    "has not been configured yet");

            node = root.SelectSingleNode("ajaxDoc");
            if(node != null)
            {
                ajaxDocUrl = node.GetAttribute("url", String.Empty).Trim();
                projectName = node.GetAttribute("project", String.Empty).Trim();
                regenerateFiles = Convert.ToBoolean(node.GetAttribute(
                    "regenerate", String.Empty), CultureInfo.InvariantCulture);
            }

            userCreds = UserCredentials.FromXPathNavigator(root);
            proxyCreds = ProxyCredentials.FromXPathNavigator(root);

            if(ajaxDocUrl.Length == 0 || projectName.Length == 0 ||
              (!userCreds.UseDefaultCredentials &&
              (userCreds.UserName.Length == 0 ||
              userCreds.Password.Length == 0)) ||
              (proxyCreds.UseProxyServer &&
              (proxyCreds.ProxyServer == null ||
              (!proxyCreds.Credentials.UseDefaultCredentials &&
              (proxyCreds.Credentials.UserName.Length == 0 ||
              proxyCreds.Credentials.Password.Length == 0)))))
                throw new BuilderException("ADP0002", "The AjaxDoc plug-in " +
                    "has an invalid configuration");
        }
Exemplo n.º 17
0
        /// <summary>
        /// Create a proxy credentials instance from an XPath navigator
        /// containing the settings.
        /// </summary>
        /// <param name="navigator">The XPath navigator from which to
        /// obtain the settings.</param>
        /// <returns>A <see cref="ProxyCredentials"/> object containing the
        /// settings from the XPath navigator.</returns>
        /// <remarks>It should contain an element called <b>proxyCredentials</b>
        /// with two attributes (<b>useProxy</b> and <b>proxyServer</b>) and a
        /// nested <b>userCredentials</b> element.</remarks>
        public static ProxyCredentials FromXPathNavigator(
          XPathNavigator navigator)
        {
            ProxyCredentials credentials = new ProxyCredentials();
            UserCredentials user;
            string server;

            if(navigator != null)
            {
                navigator = navigator.SelectSingleNode("proxyCredentials");

                if(navigator != null)
                {
                    credentials.UseProxyServer = Convert.ToBoolean(
                        navigator.GetAttribute("useProxy", String.Empty),
                        CultureInfo.InvariantCulture);
                    server = navigator.GetAttribute("proxyServer",
                        String.Empty).Trim();

                    if(server.Length != 0)
                        credentials.ProxyServer = new Uri(server,
                            UriKind.RelativeOrAbsolute);

                    user = UserCredentials.FromXPathNavigator(navigator);
                    credentials.Credentials.UseDefaultCredentials =
                        user.UseDefaultCredentials;
                    credentials.Credentials.UserName = user.UserName;
                    credentials.Credentials.Password = user.Password;
                }
            }

            return credentials;
        }