You are viewing a plain text version of this content. The canonical link for it is here.
Posted to npanday-commits@incubator.apache.org by br...@apache.org on 2012/03/21 03:30:31 UTC
svn commit: r1303268 - in
/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp:
AddArtifactsForm.cs LoginForm.Designer.cs LoginForm.cs
NPandayImportProjectForm.cs
Author: brett
Date: Wed Mar 21 03:30:31 2012
New Revision: 1303268
URL: http://svn.apache.org/viewvc?rev=1303268&view=rev
Log:
[NPANDAY-552] POM generator should prompt for credentials to validate an SCM connection rather than warning that it might not be accessible
Modified:
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/AddArtifactsForm.cs
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/LoginForm.Designer.cs
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/LoginForm.cs
incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPandayImportProjectForm.cs
Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/AddArtifactsForm.cs
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/AddArtifactsForm.cs?rev=1303268&r1=1303267&r2=1303268&view=diff
==============================================================================
--- incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/AddArtifactsForm.cs (original)
+++ incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/AddArtifactsForm.cs Wed Mar 21 03:30:31 2012
@@ -245,7 +245,7 @@ namespace NPanday.VisualStudio.Addin
// ask for user credentials then try again
if (ex.Response != null && (ex.Response as HttpWebResponse).StatusCode == HttpStatusCode.Unauthorized)
{
- LoginForm dialog = new LoginForm();
+ LoginForm dialog = new LoginForm("Enter repository credentials:");
if (dialog.ShowDialog(this) == DialogResult.OK)
{
CredentialCache cache = new CredentialCache();
Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/LoginForm.Designer.cs
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/LoginForm.Designer.cs?rev=1303268&r1=1303267&r2=1303268&view=diff
==============================================================================
--- incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/LoginForm.Designer.cs (original)
+++ incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/LoginForm.Designer.cs Wed Mar 21 03:30:31 2012
@@ -54,11 +54,12 @@ namespace NPanday.VisualStudio.Addin
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtPassword = new System.Windows.Forms.TextBox();
+ this.message = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// btnOk
//
- this.btnOk.Location = new System.Drawing.Point(27, 88);
+ this.btnOk.Location = new System.Drawing.Point(29, 105);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new System.Drawing.Size(75, 23);
this.btnOk.TabIndex = 0;
@@ -69,7 +70,7 @@ namespace NPanday.VisualStudio.Addin
// btnCancel
//
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.btnCancel.Location = new System.Drawing.Point(108, 88);
+ this.btnCancel.Location = new System.Drawing.Point(110, 105);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 23);
this.btnCancel.TabIndex = 1;
@@ -79,7 +80,7 @@ namespace NPanday.VisualStudio.Addin
//
// txtUsername
//
- this.txtUsername.Location = new System.Drawing.Point(83, 23);
+ this.txtUsername.Location = new System.Drawing.Point(85, 40);
this.txtUsername.Name = "txtUsername";
this.txtUsername.Size = new System.Drawing.Size(100, 20);
this.txtUsername.TabIndex = 2;
@@ -87,7 +88,7 @@ namespace NPanday.VisualStudio.Addin
// label1
//
this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(22, 26);
+ this.label1.Location = new System.Drawing.Point(24, 43);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(55, 13);
this.label1.TabIndex = 3;
@@ -96,7 +97,7 @@ namespace NPanday.VisualStudio.Addin
// label2
//
this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(22, 52);
+ this.label2.Location = new System.Drawing.Point(24, 69);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 13);
this.label2.TabIndex = 4;
@@ -104,19 +105,29 @@ namespace NPanday.VisualStudio.Addin
//
// txtPassword
//
- this.txtPassword.Location = new System.Drawing.Point(83, 49);
+ this.txtPassword.Location = new System.Drawing.Point(85, 66);
this.txtPassword.Name = "txtPassword";
this.txtPassword.PasswordChar = '*';
this.txtPassword.Size = new System.Drawing.Size(100, 20);
this.txtPassword.TabIndex = 5;
//
+ // message
+ //
+ this.message.AutoSize = true;
+ this.message.Location = new System.Drawing.Point(12, 9);
+ this.message.Name = "message";
+ this.message.Size = new System.Drawing.Size(49, 13);
+ this.message.TabIndex = 6;
+ this.message.Text = "message";
+ //
// LoginForm
//
this.AcceptButton = this.btnOk;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
- this.ClientSize = new System.Drawing.Size(209, 126);
+ this.ClientSize = new System.Drawing.Size(214, 145);
+ this.Controls.Add(this.message);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
@@ -143,5 +154,6 @@ namespace NPanday.VisualStudio.Addin
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtPassword;
+ private System.Windows.Forms.Label message;
}
}
\ No newline at end of file
Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/LoginForm.cs
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/LoginForm.cs?rev=1303268&r1=1303267&r2=1303268&view=diff
==============================================================================
--- incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/LoginForm.cs (original)
+++ incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/LoginForm.cs Wed Mar 21 03:30:31 2012
@@ -30,9 +30,11 @@ namespace NPanday.VisualStudio.Addin
{
public partial class LoginForm : Form
{
- public LoginForm()
+ public LoginForm(string message)
{
InitializeComponent();
+
+ this.message.Text = message;
}
private string _username;
Modified: incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPandayImportProjectForm.cs
URL: http://svn.apache.org/viewvc/incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPandayImportProjectForm.cs?rev=1303268&r1=1303267&r2=1303268&view=diff
==============================================================================
--- incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPandayImportProjectForm.cs (original)
+++ incubator/npanday/trunk/dotnet/assemblies/NPanday.VisualStudio.Addin/src/main/csharp/NPandayImportProjectForm.cs Wed Mar 21 03:30:31 2012
@@ -29,6 +29,7 @@ using EnvDTE;
using EnvDTE80;
using log4net;
using Microsoft.Win32;
+using System.Net;
namespace NPanday.VisualStudio.Addin
{
@@ -329,11 +330,7 @@ namespace NPanday.VisualStudio.Addin
if (!urlValidator.IsMatch(scmTag))
throw new Exception(string.Format("SCM tag {0} is incorrect format", scmTag));
- System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(scmTag);
- request.Method = "GET";
- System.Net.WebResponse response = request.GetResponse();
- if (response.ResponseUri.AbsoluteUri.Contains("url=")) // verify if just forwarded to a external DNS server (e.g. openDNS.com)
- throw new Exception(string.Format("SCM tag {0} is not accessible", scmTag));
+ verifyRemoteAccess(scmTag, null);
}
}
catch
@@ -400,6 +397,40 @@ namespace NPanday.VisualStudio.Addin
}
+ private void verifyRemoteAccess(string url, CredentialCache credentials)
+ {
+ try
+ {
+ System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
+ if (credentials != null)
+ request.Credentials = credentials;
+ request.Method = "HEAD";
+ System.Net.WebResponse response = request.GetResponse();
+ if (response.ResponseUri.AbsoluteUri.Contains("url=")) // verify if just forwarded to a external DNS server (e.g. openDNS.com)
+ throw new Exception(string.Format("SCM tag {0} is not accessible", url));
+ }
+ catch (WebException ex)
+ {
+ // ask for user credentials then try again
+ if (ex.Response != null && (ex.Response as HttpWebResponse).StatusCode == HttpStatusCode.Unauthorized)
+ {
+ LoginForm dialog = new LoginForm("Enter SCM credentials:");
+ if (dialog.ShowDialog(this) == DialogResult.OK)
+ {
+ CredentialCache cache = new CredentialCache();
+ cache.Add(new Uri(url), "Basic", new NetworkCredential(dialog.Username, dialog.Password));
+ verifyRemoteAccess(url, cache);
+ }
+ else
+ throw new Exception("Sorry, but you are not authorized to access the specified URL.");
+ }
+ else
+ {
+ throw new Exception("Sorry, but you have entered an invalid URL.");
+ }
+ }
+ }
+
private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;