Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1005 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
22 changed files with 633 additions and 33 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,46 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Gui |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Holds information needed when an async web discovery call has completed.
|
||||||
|
/// </summary>
|
||||||
|
public class AsyncDiscoveryState |
||||||
|
{ |
||||||
|
WebServiceDiscoveryClientProtocol protocol; |
||||||
|
Uri uri; |
||||||
|
DiscoveryNetworkCredential credential; |
||||||
|
|
||||||
|
public WebServiceDiscoveryClientProtocol Protocol { |
||||||
|
get { |
||||||
|
return protocol; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Uri Uri { |
||||||
|
get { |
||||||
|
return uri; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public DiscoveryNetworkCredential Credential { |
||||||
|
get { |
||||||
|
return credential; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public AsyncDiscoveryState(WebServiceDiscoveryClientProtocol protocol, Uri uri, DiscoveryNetworkCredential credential) |
||||||
|
{ |
||||||
|
this.protocol = protocol; |
||||||
|
this.uri = uri; |
||||||
|
this.credential = credential; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,43 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Net; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Gui |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Adds an authentication type to the standard NetworkCredential class.
|
||||||
|
/// </summary>
|
||||||
|
public class DiscoveryNetworkCredential : NetworkCredential |
||||||
|
{ |
||||||
|
public const string DefaultAuthenticationType = "Default"; |
||||||
|
|
||||||
|
string authenticationType = String.Empty; |
||||||
|
|
||||||
|
public DiscoveryNetworkCredential(string userName, string password, string domain, string authenticationType) : base(userName, password, domain) |
||||||
|
{ |
||||||
|
this.authenticationType = authenticationType; |
||||||
|
} |
||||||
|
|
||||||
|
public DiscoveryNetworkCredential(NetworkCredential credential, string authenticationType) : this(credential.UserName, credential.Password, credential.Domain, authenticationType) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public string AuthenticationType { |
||||||
|
get { |
||||||
|
return authenticationType; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsDefaultAuthenticationType { |
||||||
|
get { |
||||||
|
return String.Compare(authenticationType, DefaultAuthenticationType, true) == 0; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,72 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Net; |
||||||
|
using System.Text; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Gui |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Represents the WWW-Authenticate HTTP response header.
|
||||||
|
/// </summary>
|
||||||
|
public class HttpAuthenticationHeader |
||||||
|
{ |
||||||
|
string[] authenticationSchemes; |
||||||
|
|
||||||
|
public HttpAuthenticationHeader(WebHeaderCollection headers) |
||||||
|
{ |
||||||
|
authenticationSchemes = headers.GetValues("WWW-Authenticate"); |
||||||
|
} |
||||||
|
|
||||||
|
public override string ToString() |
||||||
|
{ |
||||||
|
if (HasAuthenticationSchemes) { |
||||||
|
StringBuilder schemes = new StringBuilder(); |
||||||
|
foreach (string scheme in authenticationSchemes) { |
||||||
|
schemes.Append("WWW-Authenticate: "); |
||||||
|
schemes.Append(scheme); |
||||||
|
schemes.Append("\r\n"); |
||||||
|
} |
||||||
|
return schemes.ToString(); |
||||||
|
} |
||||||
|
return String.Empty; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a comma separated list of authentication types.
|
||||||
|
/// </summary>
|
||||||
|
public string AuthenticationType { |
||||||
|
get { |
||||||
|
if (HasAuthenticationSchemes) { |
||||||
|
int schemesAdded = 0; |
||||||
|
StringBuilder authenticationType = new StringBuilder(); |
||||||
|
for (int i = 0; i < authenticationSchemes.Length; ++i) { |
||||||
|
string scheme = authenticationSchemes[i]; |
||||||
|
int index = scheme.IndexOf(' '); |
||||||
|
if (index > 0) { |
||||||
|
scheme = scheme.Substring(0, index); |
||||||
|
} |
||||||
|
if (schemesAdded > 0) { |
||||||
|
authenticationType.Append(","); |
||||||
|
} |
||||||
|
authenticationType.Append(scheme); |
||||||
|
schemesAdded++; |
||||||
|
} |
||||||
|
return authenticationType.ToString(); |
||||||
|
} |
||||||
|
return String.Empty; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
bool HasAuthenticationSchemes { |
||||||
|
get { |
||||||
|
return authenticationSchemes != null && authenticationSchemes.Length > 0; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,219 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using ICSharpCode.Core; |
||||||
|
using System; |
||||||
|
using System.Drawing; |
||||||
|
using System.Net; |
||||||
|
using System.Windows.Forms; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Gui |
||||||
|
{ |
||||||
|
public class UserCredentialsDialog : System.Windows.Forms.Form |
||||||
|
{ |
||||||
|
string authenticationType = String.Empty; |
||||||
|
|
||||||
|
public UserCredentialsDialog(string url, string authenticationType) |
||||||
|
{ |
||||||
|
InitializeComponent(); |
||||||
|
this.url.Text = url; |
||||||
|
this.authenticationType = authenticationType; |
||||||
|
AddStringResources(); |
||||||
|
} |
||||||
|
|
||||||
|
public DiscoveryNetworkCredential Credential { |
||||||
|
get { |
||||||
|
return new DiscoveryNetworkCredential(userTextBox.Text, passwordTextBox.Text, domainTextBox.Text, authenticationType); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
#region Windows Forms Designer generated code
|
||||||
|
/// <summary>
|
||||||
|
/// This method is required for Windows Forms designer support.
|
||||||
|
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||||
|
/// not be able to load this method if it was changed manually.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent() |
||||||
|
{ |
||||||
|
this.urlLabel = new System.Windows.Forms.Label(); |
||||||
|
this.userNameLabel = new System.Windows.Forms.Label(); |
||||||
|
this.passwordLabel = new System.Windows.Forms.Label(); |
||||||
|
this.domainLabel = new System.Windows.Forms.Label(); |
||||||
|
this.userTextBox = new System.Windows.Forms.TextBox(); |
||||||
|
this.passwordTextBox = new System.Windows.Forms.TextBox(); |
||||||
|
this.domainTextBox = new System.Windows.Forms.TextBox(); |
||||||
|
this.url = new System.Windows.Forms.Label(); |
||||||
|
this.okButton = new System.Windows.Forms.Button(); |
||||||
|
this.cancelButton = new System.Windows.Forms.Button(); |
||||||
|
this.infoLabel = new System.Windows.Forms.Label(); |
||||||
|
this.SuspendLayout(); |
||||||
|
//
|
||||||
|
// urlLabel
|
||||||
|
//
|
||||||
|
this.urlLabel.Location = new System.Drawing.Point(10, 59); |
||||||
|
this.urlLabel.Name = "urlLabel"; |
||||||
|
this.urlLabel.Size = new System.Drawing.Size(91, 23); |
||||||
|
this.urlLabel.TabIndex = 0; |
||||||
|
this.urlLabel.Text = "Url:"; |
||||||
|
this.urlLabel.UseCompatibleTextRendering = true; |
||||||
|
//
|
||||||
|
// userNameLabel
|
||||||
|
//
|
||||||
|
this.userNameLabel.Location = new System.Drawing.Point(10, 88); |
||||||
|
this.userNameLabel.Name = "userNameLabel"; |
||||||
|
this.userNameLabel.Size = new System.Drawing.Size(91, 23); |
||||||
|
this.userNameLabel.TabIndex = 1; |
||||||
|
this.userNameLabel.Text = "&User name:"; |
||||||
|
this.userNameLabel.UseCompatibleTextRendering = true; |
||||||
|
//
|
||||||
|
// passwordLabel
|
||||||
|
//
|
||||||
|
this.passwordLabel.Location = new System.Drawing.Point(10, 115); |
||||||
|
this.passwordLabel.Name = "passwordLabel"; |
||||||
|
this.passwordLabel.Size = new System.Drawing.Size(91, 23); |
||||||
|
this.passwordLabel.TabIndex = 3; |
||||||
|
this.passwordLabel.Text = "&Password:"; |
||||||
|
this.passwordLabel.UseCompatibleTextRendering = true; |
||||||
|
//
|
||||||
|
// domainLabel
|
||||||
|
//
|
||||||
|
this.domainLabel.Location = new System.Drawing.Point(10, 142); |
||||||
|
this.domainLabel.Name = "domainLabel"; |
||||||
|
this.domainLabel.Size = new System.Drawing.Size(91, 23); |
||||||
|
this.domainLabel.TabIndex = 5; |
||||||
|
this.domainLabel.Text = "&Domain:"; |
||||||
|
this.domainLabel.UseCompatibleTextRendering = true; |
||||||
|
//
|
||||||
|
// userTextBox
|
||||||
|
//
|
||||||
|
this.userTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.userTextBox.Location = new System.Drawing.Point(93, 85); |
||||||
|
this.userTextBox.Name = "userTextBox"; |
||||||
|
this.userTextBox.Size = new System.Drawing.Size(187, 21); |
||||||
|
this.userTextBox.TabIndex = 2; |
||||||
|
//
|
||||||
|
// passwordTextBox
|
||||||
|
//
|
||||||
|
this.passwordTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.passwordTextBox.Location = new System.Drawing.Point(93, 112); |
||||||
|
this.passwordTextBox.Name = "passwordTextBox"; |
||||||
|
this.passwordTextBox.PasswordChar = '*'; |
||||||
|
this.passwordTextBox.Size = new System.Drawing.Size(187, 21); |
||||||
|
this.passwordTextBox.TabIndex = 4; |
||||||
|
//
|
||||||
|
// domainTextBox
|
||||||
|
//
|
||||||
|
this.domainTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.domainTextBox.Location = new System.Drawing.Point(93, 139); |
||||||
|
this.domainTextBox.Name = "domainTextBox"; |
||||||
|
this.domainTextBox.Size = new System.Drawing.Size(187, 21); |
||||||
|
this.domainTextBox.TabIndex = 6; |
||||||
|
//
|
||||||
|
// url
|
||||||
|
//
|
||||||
|
this.url.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.url.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; |
||||||
|
this.url.Location = new System.Drawing.Point(93, 57); |
||||||
|
this.url.Name = "url"; |
||||||
|
this.url.Size = new System.Drawing.Size(187, 21); |
||||||
|
this.url.TabIndex = 9; |
||||||
|
this.url.UseCompatibleTextRendering = true; |
||||||
|
//
|
||||||
|
// okButton
|
||||||
|
//
|
||||||
|
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; |
||||||
|
this.okButton.Location = new System.Drawing.Point(146, 166); |
||||||
|
this.okButton.Name = "okButton"; |
||||||
|
this.okButton.Size = new System.Drawing.Size(64, 26); |
||||||
|
this.okButton.TabIndex = 7; |
||||||
|
this.okButton.Text = "OK"; |
||||||
|
this.okButton.UseCompatibleTextRendering = true; |
||||||
|
this.okButton.UseVisualStyleBackColor = true; |
||||||
|
//
|
||||||
|
// cancelButton
|
||||||
|
//
|
||||||
|
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel; |
||||||
|
this.cancelButton.Location = new System.Drawing.Point(216, 166); |
||||||
|
this.cancelButton.Name = "cancelButton"; |
||||||
|
this.cancelButton.Size = new System.Drawing.Size(64, 26); |
||||||
|
this.cancelButton.TabIndex = 8; |
||||||
|
this.cancelButton.Text = "Cancel"; |
||||||
|
this.cancelButton.UseCompatibleTextRendering = true; |
||||||
|
this.cancelButton.UseVisualStyleBackColor = true; |
||||||
|
//
|
||||||
|
// infoLabel
|
||||||
|
//
|
||||||
|
this.infoLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.infoLabel.Location = new System.Drawing.Point(12, 9); |
||||||
|
this.infoLabel.Name = "infoLabel"; |
||||||
|
this.infoLabel.Size = new System.Drawing.Size(267, 48); |
||||||
|
this.infoLabel.TabIndex = 10; |
||||||
|
this.infoLabel.Text = "Please supply the credentials to access the specified url."; |
||||||
|
this.infoLabel.UseCompatibleTextRendering = true; |
||||||
|
//
|
||||||
|
// UserCredentialsDialog
|
||||||
|
//
|
||||||
|
this.AcceptButton = this.okButton; |
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
||||||
|
this.CancelButton = this.cancelButton; |
||||||
|
this.ClientSize = new System.Drawing.Size(292, 202); |
||||||
|
this.Controls.Add(this.infoLabel); |
||||||
|
this.Controls.Add(this.cancelButton); |
||||||
|
this.Controls.Add(this.okButton); |
||||||
|
this.Controls.Add(this.url); |
||||||
|
this.Controls.Add(this.domainTextBox); |
||||||
|
this.Controls.Add(this.passwordTextBox); |
||||||
|
this.Controls.Add(this.userTextBox); |
||||||
|
this.Controls.Add(this.domainLabel); |
||||||
|
this.Controls.Add(this.passwordLabel); |
||||||
|
this.Controls.Add(this.userNameLabel); |
||||||
|
this.Controls.Add(this.urlLabel); |
||||||
|
this.MaximizeBox = false; |
||||||
|
this.MinimizeBox = false; |
||||||
|
this.MinimumSize = new System.Drawing.Size(300, 236); |
||||||
|
this.Name = "UserCredentialsDialog"; |
||||||
|
this.ShowIcon = false; |
||||||
|
this.ShowInTaskbar = false; |
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; |
||||||
|
this.Text = "Discovery Credential"; |
||||||
|
this.ResumeLayout(false); |
||||||
|
this.PerformLayout(); |
||||||
|
} |
||||||
|
private System.Windows.Forms.Label infoLabel; |
||||||
|
private System.Windows.Forms.TextBox passwordTextBox; |
||||||
|
private System.Windows.Forms.Label userNameLabel; |
||||||
|
private System.Windows.Forms.Button cancelButton; |
||||||
|
private System.Windows.Forms.Button okButton; |
||||||
|
private System.Windows.Forms.Label url; |
||||||
|
private System.Windows.Forms.TextBox domainTextBox; |
||||||
|
private System.Windows.Forms.TextBox userTextBox; |
||||||
|
private System.Windows.Forms.Label domainLabel; |
||||||
|
private System.Windows.Forms.Label passwordLabel; |
||||||
|
private System.Windows.Forms.Label urlLabel; |
||||||
|
#endregion
|
||||||
|
|
||||||
|
void AddStringResources() |
||||||
|
{ |
||||||
|
Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.Dialogs.UserCredentialsDialog.DialogTitle}"); |
||||||
|
infoLabel.Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.Dialogs.UserCredentialsDialog.InformationLabel}"); |
||||||
|
urlLabel.Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.Dialogs.UserCredentialsDialog.UrlLabel}"); |
||||||
|
userNameLabel.Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.Dialogs.UserCredentialsDialog.UserNameLabel}"); |
||||||
|
passwordLabel.Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.Dialogs.UserCredentialsDialog.PasswordLabel}"); |
||||||
|
domainLabel.Text = StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.Dialogs.UserCredentialsDialog.DomainLabel}"); |
||||||
|
cancelButton.Text = StringParser.Parse("${res:Global.CancelButtonText}"); |
||||||
|
okButton.Text = StringParser.Parse("${res:Global.OKButtonText}"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,50 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Net; |
||||||
|
using System.Web.Services.Discovery; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Gui |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Custom DiscoveryClientProtocol that determines whether user authentication
|
||||||
|
/// is required.
|
||||||
|
/// </summary>
|
||||||
|
public class WebServiceDiscoveryClientProtocol : DiscoveryClientProtocol |
||||||
|
{ |
||||||
|
HttpWebResponse lastResponseReceived; |
||||||
|
|
||||||
|
public WebServiceDiscoveryClientProtocol() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public HttpAuthenticationHeader GetAuthenticationHeader() |
||||||
|
{ |
||||||
|
if (lastResponseReceived != null) { |
||||||
|
return new HttpAuthenticationHeader(lastResponseReceived.Headers); |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsAuthenticationRequired { |
||||||
|
get { |
||||||
|
if (lastResponseReceived != null) { |
||||||
|
return lastResponseReceived.StatusCode == HttpStatusCode.Unauthorized; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
protected override WebResponse GetWebResponse(WebRequest request) |
||||||
|
{ |
||||||
|
lastResponseReceived = null; |
||||||
|
lastResponseReceived = base.GetWebResponse(request) as HttpWebResponse; |
||||||
|
return lastResponseReceived; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,81 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
using NUnit.Framework; |
||||||
|
using System; |
||||||
|
using System.Net; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Tests.WebReferences |
||||||
|
{ |
||||||
|
[TestFixture] |
||||||
|
public class HttpAuthenticationHeaderTests |
||||||
|
{ |
||||||
|
[Test] |
||||||
|
public void IsBasicAuthentication() |
||||||
|
{ |
||||||
|
WebHeaderCollection headers = new WebHeaderCollection(); |
||||||
|
headers.Add(HttpResponseHeader.WwwAuthenticate, "Basic realm='localhost'"); |
||||||
|
HttpAuthenticationHeader authenticationHeader = new HttpAuthenticationHeader(headers); |
||||||
|
|
||||||
|
Assert.AreEqual("Basic", authenticationHeader.AuthenticationType); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void NoHeadersAdded() |
||||||
|
{ |
||||||
|
WebHeaderCollection headers = new WebHeaderCollection(); |
||||||
|
HttpAuthenticationHeader authenticationHeader = new HttpAuthenticationHeader(headers); |
||||||
|
|
||||||
|
Assert.AreEqual(String.Empty, authenticationHeader.AuthenticationType); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void NonStandardAuthenticationHeaderAdded() |
||||||
|
{ |
||||||
|
WebHeaderCollection headers = new WebHeaderCollection(); |
||||||
|
headers.Add(HttpResponseHeader.WwwAuthenticate, "Foo"); |
||||||
|
HttpAuthenticationHeader authenticationHeader = new HttpAuthenticationHeader(headers); |
||||||
|
|
||||||
|
Assert.AreEqual("Foo", authenticationHeader.AuthenticationType); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void IsWindowsAuthentication() |
||||||
|
{ |
||||||
|
WebHeaderCollection headers = new WebHeaderCollection(); |
||||||
|
headers.Add(HttpResponseHeader.WwwAuthenticate, "Negotiate"); |
||||||
|
headers.Add(HttpResponseHeader.WwwAuthenticate, "NTLM"); |
||||||
|
HttpAuthenticationHeader authenticationHeader = new HttpAuthenticationHeader(headers); |
||||||
|
|
||||||
|
Assert.AreEqual("Negotiate,NTLM", authenticationHeader.AuthenticationType); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void ManyAuthenticationSchemesAdded() |
||||||
|
{ |
||||||
|
WebHeaderCollection headers = new WebHeaderCollection(); |
||||||
|
headers.Add(HttpResponseHeader.WwwAuthenticate, "Negotiate"); |
||||||
|
headers.Add(HttpResponseHeader.WwwAuthenticate, "NTLM"); |
||||||
|
headers.Add(HttpResponseHeader.WwwAuthenticate, "Basic realm='test'"); |
||||||
|
HttpAuthenticationHeader authenticationHeader = new HttpAuthenticationHeader(headers); |
||||||
|
|
||||||
|
Assert.AreEqual("Negotiate,NTLM,Basic", authenticationHeader.AuthenticationType); |
||||||
|
} |
||||||
|
|
||||||
|
[Test] |
||||||
|
public void DigestAuthenticationSchemeAdded() |
||||||
|
{ |
||||||
|
WebHeaderCollection headers = new WebHeaderCollection(); |
||||||
|
headers.Add(HttpResponseHeader.WwwAuthenticate, "Digest realm='test'"); |
||||||
|
headers.Add(HttpResponseHeader.WwwAuthenticate, "NTLM"); |
||||||
|
HttpAuthenticationHeader authenticationHeader = new HttpAuthenticationHeader(headers); |
||||||
|
|
||||||
|
Assert.AreEqual("Digest,NTLM", authenticationHeader.AuthenticationType); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Binary file not shown.
Loading…
Reference in new issue