Fix to support HTTP Auth as a WebSocket client

This commit is contained in:
sta 2013-06-10 17:49:44 +09:00
parent 9ebab427bf
commit 7499b6de74
51 changed files with 1391 additions and 14 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.

View File

@ -0,0 +1,205 @@
#region License
/*
* AuthenticationChallenge.cs
*
* The MIT License
*
* Copyright (c) 2013 sta.blockhead
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#endregion
using System;
using System.Text;
namespace WebSocketSharp {
internal class AuthenticationChallenge {
#region Private Fields
private string _algorithm;
private string _domain;
private string _nonce;
private string _opaque;
private string _qop;
private string _realm;
private string _scheme;
private string _stale;
#endregion
#region Private Constructors
private AuthenticationChallenge()
{
}
#endregion
#region Public Properties
public string Algorithm {
get {
return _algorithm ?? String.Empty;
}
private set {
_algorithm = value;
}
}
public string Domain {
get {
return _domain ?? String.Empty;
}
private set {
_domain = value;
}
}
public string Nonce {
get {
return _nonce ?? String.Empty;
}
private set {
_nonce = value;
}
}
public string Opaque {
get {
return _opaque ?? String.Empty;
}
private set {
_opaque = value;
}
}
public string Qop {
get {
return _qop ?? String.Empty;
}
private set {
_qop = value;
}
}
public string Realm {
get {
return _realm ?? String.Empty;
}
private set {
_realm = value;
}
}
public string Scheme {
get {
return _scheme ?? String.Empty;
}
private set {
_scheme = value;
}
}
public string Stale {
get {
return _stale ?? String.Empty;
}
private set {
_stale = value;
}
}
#endregion
#region Public Methods
public static AuthenticationChallenge Parse(string challenge)
{
var authChallenge = new AuthenticationChallenge();
if (challenge.StartsWith("basic", StringComparison.OrdinalIgnoreCase))
{
authChallenge.Scheme = "Basic";
authChallenge.Realm = challenge.Substring(6).GetValueInternal("=").Trim('"');
return authChallenge;
}
foreach (var p in challenge.SplitHeaderValue(','))
{
var param = p.Trim();
if (param.StartsWith("digest", StringComparison.OrdinalIgnoreCase))
{
authChallenge.Scheme = "Digest";
authChallenge.Realm = param.Substring(7).GetValueInternal("=").Trim('"');
continue;
}
var value = param.GetValueInternal("=").Trim('"');
if (param.StartsWith("domain", StringComparison.OrdinalIgnoreCase))
{
authChallenge.Domain = value;
continue;
}
if (param.StartsWith("nonce", StringComparison.OrdinalIgnoreCase))
{
authChallenge.Nonce = value;
continue;
}
if (param.StartsWith("opaque", StringComparison.OrdinalIgnoreCase))
{
authChallenge.Opaque = value;
continue;
}
if (param.StartsWith("stale", StringComparison.OrdinalIgnoreCase))
{
authChallenge.Stale = value;
continue;
}
if (param.StartsWith("algorithm", StringComparison.OrdinalIgnoreCase))
{
authChallenge.Algorithm = value;
continue;
}
if (param.StartsWith("qop", StringComparison.OrdinalIgnoreCase))
authChallenge.Qop = value;
}
return authChallenge;
}
#endregion
}
}

View File

@ -0,0 +1,328 @@
#region License
/*
* AuthenticationResponse.cs
*
* The MIT License
*
* Copyright (c) 2013 sta.blockhead
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#endregion
using System;
using System.Security.Cryptography;
using System.Text;
namespace WebSocketSharp {
internal class AuthenticationResponse {
#region Private Fields
private string _algorithm;
private string _cnonce;
private string _method;
private string _nc;
private string _nonce;
private string _opaque;
private string _password;
private string _qop;
private string _realm;
private string _response;
private string _scheme;
private string _uri;
private string _userName;
#endregion
#region Private Constructors
private AuthenticationResponse()
{
}
#endregion
#region Public Constructors
public AuthenticationResponse(WsCredential credential)
{
_userName = credential.UserName;
_password = credential.Password;
_scheme = "Basic";
}
public AuthenticationResponse(WsCredential credential, AuthenticationChallenge challenge)
{
_userName = credential.UserName;
_password = credential.Password;
_scheme = challenge.Scheme;
_realm = challenge.Realm;
if (_scheme == "Digest")
initForDigest(credential, challenge);
}
#endregion
#region Public Properties
public string Algorithm {
get {
return _algorithm ?? String.Empty;
}
private set {
_algorithm = value;
}
}
public string Cnonce {
get {
return _cnonce ?? String.Empty;
}
private set {
_cnonce = value;
}
}
public string Nc {
get {
return _nc ?? String.Empty;
}
private set {
_nc = value;
}
}
public string Nonce {
get {
return _nonce ?? String.Empty;
}
private set {
_nonce = value;
}
}
public string Opaque {
get {
return _opaque ?? String.Empty;
}
private set {
_opaque = value;
}
}
public string Qop {
get {
return _qop ?? String.Empty;
}
private set {
_qop = value;
}
}
public string Realm {
get {
return _realm ?? String.Empty;
}
private set {
_realm = value;
}
}
public string Response {
get {
return _response ?? String.Empty;
}
private set {
_response = value;
}
}
public string Scheme {
get {
return _scheme ?? String.Empty;
}
private set {
_scheme = value;
}
}
public string Uri {
get {
return _uri ?? String.Empty;
}
private set {
_uri = value;
}
}
public string UserName {
get {
return _userName ?? String.Empty;
}
private set {
_userName = value;
}
}
#endregion
#region Private Methods
private string a1()
{
var result = String.Format("{0}:{1}:{2}", _userName, _realm, _password);
return _algorithm != null && _algorithm.ToLower() == "md5-sess"
? String.Format("{0}:{1}:{2}", hash(result), _nonce, _cnonce)
: result;
}
private string a2()
{
return String.Format("{0}:{1}", _method, _uri);
}
private static string createNonceValue()
{
var src = new byte[16];
var rand = new Random();
rand.NextBytes(src);
var nonce = new StringBuilder(32);
foreach (var b in src)
nonce.Append(b.ToString("x2"));
return nonce.ToString();
}
private string createRequestDigest()
{
if (Qop == "auth")
{
var data = String.Format("{0}:{1}:{2}:{3}:{4}",
_nonce, _nc, _cnonce, _qop, hash(a2()));
return kd(hash(a1()), data);
}
return kd(hash(a1()), String.Format("{0}:{1}", _nonce, hash(a2())));
}
private static string hash(string value)
{
var md5 = MD5.Create();
var src = Encoding.UTF8.GetBytes(value);
var hashed = md5.ComputeHash(src);
var result = new StringBuilder(64);
foreach (var b in hashed)
result.Append(b.ToString("x2"));
return result.ToString();
}
private void initForDigest(WsCredential credential, AuthenticationChallenge challenge)
{
_nonce = challenge.Nonce;
_method = "GET";
_uri = credential.Domain;
_algorithm = challenge.Algorithm;
_opaque = challenge.Opaque;
foreach (var qop in challenge.Qop.Split(','))
{
if (qop.Trim().ToLower() == "auth")
{
_qop = "auth";
_nc = "00000001";
break;
}
}
_cnonce = createNonceValue();
_response = createRequestDigest();
}
private static string kd(string secret, string data)
{
var concatenated = String.Format("{0}:{1}", secret, data);
return hash(concatenated);
}
private string toBasicCredentials()
{
var userPass = String.Format("{0}:{1}", _userName, _password);
var base64UserPass = Convert.ToBase64String(Encoding.UTF8.GetBytes(userPass));
return "Basic " + base64UserPass;
}
private string toDigestCredentials()
{
var digestResponse = new StringBuilder(64);
digestResponse.AppendFormat("username={0}", _userName.Quote());
digestResponse.AppendFormat(", realm={0}", _realm.Quote());
digestResponse.AppendFormat(", nonce={0}", _nonce.Quote());
digestResponse.AppendFormat(", uri={0}", _uri.Quote());
digestResponse.AppendFormat(", response={0}", _response.Quote());
if (!_algorithm.IsNullOrEmpty())
digestResponse.AppendFormat(", algorithm={0}", _algorithm);
if (!_opaque.IsNullOrEmpty())
digestResponse.AppendFormat(", opaque={0}", _opaque.Quote());
if (!_qop.IsNullOrEmpty())
digestResponse.AppendFormat(", qop={0}", _qop);
if (!_nc.IsNullOrEmpty())
digestResponse.AppendFormat(", nc={0}", _nc);
if (!_qop.IsNullOrEmpty())
digestResponse.AppendFormat(", cnonce={0}", _cnonce.Quote());
return "Digest " + digestResponse.ToString();
}
#endregion
#region Public Methods
public static AuthenticationResponse Parse(string response)
{
throw new NotImplementedException();
}
public override string ToString()
{
return _scheme == "Basic"
? toBasicCredentials()
: toDigestCredentials();
}
#endregion
}
}

View File

@ -183,6 +183,12 @@ namespace WebSocketSharp {
AddHeader("Cookie", header.ToString());
}
public void SetAuthorization(AuthenticationResponse response)
{
var credentials = response.ToString();
AddHeader("Authorization", credentials);
}
public override string ToString()
{
var buffer = new StringBuilder(64);

View File

@ -55,12 +55,26 @@ namespace WebSocketSharp {
#region Public Properties
public AuthenticationChallenge AuthChallenge {
get {
return ContainsHeader("WWW-Authenticate")
? AuthenticationChallenge.Parse(Headers["WWW-Authenticate"])
: null;
}
}
public CookieCollection Cookies {
get {
return Headers.GetCookies(true);
}
}
public bool IsUnauthorized {
get {
return StatusCode == "401";
}
}
public bool IsWebSocketResponse {
get {
return ProtocolVersion < HttpVersion.Version11

View File

@ -71,12 +71,14 @@ namespace WebSocketSharp {
private CookieCollection _cookies;
private CompressionMethod _compression;
private WebSocketContext _context;
private WsCredential _credentials;
private string _extensions;
private AutoResetEvent _exitReceiving;
private object _forClose;
private object _forFrame;
private object _forSend;
private string _origin;
private bool _preAuth;
private string _protocol;
private string _protocols;
private volatile WsState _readyState;
@ -99,6 +101,7 @@ namespace WebSocketSharp {
_forFrame = new object();
_forSend = new object();
_origin = String.Empty;
_preAuth = false;
_protocol = String.Empty;
_readyState = WsState.CONNECTING;
}
@ -261,6 +264,18 @@ namespace WebSocketSharp {
}
}
/// <summary>
/// Gets the credentials for HTTP authentication (Basic/Digest).
/// </summary>
/// <value>
/// A <see cref="WsCredential"/> that contains the credentials for HTTP authentication.
/// </value>
public WsCredential Credentials {
get {
return _credentials;
}
}
/// <summary>
/// Gets the WebSocket extensions selected by the server.
/// </summary>
@ -675,6 +690,9 @@ namespace WebSocketSharp {
req.AddHeader("Sec-WebSocket-Version", _version);
if (_preAuth && _credentials != null)
req.SetAuthorization(new AuthenticationResponse(_credentials));
if (_cookies.Count > 0)
req.SetCookies(_cookies);
@ -718,8 +736,7 @@ namespace WebSocketSharp {
private bool doHandshake()
{
init();
sendRequestHandshake();
return processResponseHandshake();
return processResponseHandshake(sendRequestHandshake());
}
private static CompressionMethod getCompressionMethod(string value)
@ -1091,21 +1108,25 @@ namespace WebSocketSharp {
}
// As client
private bool processResponseHandshake()
private bool processResponseHandshake(ResponseHandshake response)
{
var res = receiveResponseHandshake();
if (!isValidResponseHandshake(res))
var error = response.IsUnauthorized
? String.Format("An HTTP {0} authorization is required.", response.AuthChallenge.Scheme)
: !isValidResponseHandshake(response)
? "Invalid response to this WebSocket connection request."
: String.Empty;
if (error.Length > 0)
{
var msg = "Invalid response to this WebSocket connection request.";
onError(msg);
Close(CloseStatusCode.ABNORMAL, msg);
onError(error);
Close(CloseStatusCode.ABNORMAL, error);
return false;
}
processResponseProtocol(res.Headers["Sec-WebSocket-Protocol"]);
processResponseExtensions(res.Headers["Sec-WebSocket-Extensions"]);
processResponseCookies(res.Cookies);
processResponseProtocol(response.Headers["Sec-WebSocket-Protocol"]);
processResponseExtensions(response.Headers["Sec-WebSocket-Extensions"]);
processResponseCookies(response.Cookies);
return true;
}
@ -1275,10 +1296,25 @@ namespace WebSocketSharp {
}
// As client
private void sendRequestHandshake()
private ResponseHandshake sendRequestHandshake()
{
var req = createRequestHandshake();
send(req);
var res = sendRequestHandshake(req);
if (!_preAuth && res.IsUnauthorized && _credentials != null)
{
var challenge = res.AuthChallenge;
req.SetAuthorization(new AuthenticationResponse(_credentials, challenge));
res = sendRequestHandshake(req);
}
return res;
}
// As client
private ResponseHandshake sendRequestHandshake(RequestHandshake request)
{
send(request);
return receiveResponseHandshake();
}
// As server
@ -1623,6 +1659,48 @@ namespace WebSocketSharp {
}
}
/// <summary>
/// Sets the credentials for HTTP authentication (Basic/Digest).
/// </summary>
/// <param name="userName">
/// A <see cref="string"/> that contains a user name associated with the credentials.
/// </param>
/// <param name="password">
/// A <see cref="string"/> that contains a password for <paramref name="userName"/> associated with the credentials.
/// </param>
/// <param name="preAuth">
/// <c>true</c> if sends the credentials as a Basic authorization with the first request handshake;
/// otherwise, <c>false</c>.
/// </param>
public void SetCredentials(string userName, string password, bool preAuth)
{
if (isOpened(true))
return;
if (userName == null)
{
_credentials = null;
_preAuth = false;
return;
}
var error = userName.Length > 0 && (userName.Contains(':') || !userName.IsText())
? "'userName' contains an invalid character."
: !password.IsNullOrEmpty() && !password.IsText()
? "'password' contains an invalid character."
: String.Empty;
if (error.Length > 0)
{
onError(error);
return;
}
_credentials = new WsCredential(userName, password, _uri.PathAndQuery);
_preAuth = preAuth;
}
#endregion
}
}

View File

@ -0,0 +1,119 @@
#region License
/*
* WsCredential.cs
*
* The MIT License
*
* Copyright (c) 2013 sta.blockhead
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#endregion
using System;
namespace WebSocketSharp {
/// <summary>
/// Provides the credentials for HTTP authentication (Basic/Digest).
/// </summary>
public class WsCredential {
#region Private Fields
string _domain;
string _password;
string _userName;
#endregion
#region Internal Constructors
internal WsCredential()
{
}
internal WsCredential(string userName, string password)
: this(userName, password, null)
{
}
internal WsCredential(string userName, string password, string domain)
{
_userName = userName;
_password = password;
_domain = domain;
}
#endregion
#region Public Properties
/// <summary>
/// Gets the name of the user domain associated with the credentials.
/// </summary>
/// <value>
/// A <see cref="string"/> that contains the name of the user domain associated with the credentials.
/// Currently, returns the request uri of a WebSocket opening handshake.
/// </value>
public string Domain {
get {
return _domain ?? String.Empty;
}
internal set {
_domain = value;
}
}
/// <summary>
/// Gets the password for the user name associated with the credentials.
/// </summary>
/// <value>
/// A <see cref="string"/> that contains the password for the user name associated with the credentials.
/// </value>
public string Password {
get {
return _password ?? String.Empty;
}
internal set {
_password = value;
}
}
/// <summary>
/// Gets the user name associated with the credentials.
/// </summary>
/// <value>
/// A <see cref="string"/> that contains the user name associated with the credentials.
/// </value>
public string UserName {
get {
return _userName ?? String.Empty;
}
internal set {
_userName = value;
}
}
#endregion
}
}

View File

@ -902,6 +902,14 @@
over the collection of cookies.
</value>
</member>
<member name="P:WebSocketSharp.WebSocket.Credentials">
<summary>
Gets the credentials for HTTP authentication (Basic/Digest).
</summary>
<value>
A <see cref="T:WebSocketSharp.WsCredential" /> that contains the credentials for HTTP authentication.
</value>
</member>
<member name="P:WebSocketSharp.WebSocket.Extensions">
<summary>
Gets the WebSocket extensions selected by the server.
@ -1122,6 +1130,21 @@
A <see cref="T:WebSocketSharp.Net.Cookie" /> that contains an HTTP Cookie to set.
</param>
</member>
<member name="M:WebSocketSharp.WebSocket.SetCredentials(System.String,System.String,System.Boolean)">
<summary>
Sets the credentials for HTTP authentication (Basic/Digest).
</summary>
<param name="userName">
A <see cref="T:System.String" /> that contains a user name associated with the credentials.
</param>
<param name="password">
A <see cref="T:System.String" /> that contains a password for <paramref name="userName" /> associated with the credentials.
</param>
<param name="preAuth">
<c>true</c> if sends the credentials as a Basic authorization with the first request handshake;
otherwise, <c>false</c>.
</param>
</member>
<member name="T:WebSocketSharp.Server.WebSocketServer">
<summary>
Provides the functions of the server that receives the WebSocket connection requests.
@ -5214,5 +5237,35 @@
One of the <see cref="T:WebSocketSharp.CloseStatusCode" /> values that indicates the cause of the exception.
</value>
</member>
<member name="T:WebSocketSharp.WsCredential">
<summary>
Provides the credentials for HTTP authentication (Basic/Digest).
</summary>
</member>
<member name="P:WebSocketSharp.WsCredential.Domain">
<summary>
Gets the name of the user domain associated with the credentials.
</summary>
<value>
A <see cref="T:System.String" /> that contains the name of the user domain associated with the credentials.
Currently, returns the request uri of a WebSocket opening handshake.
</value>
</member>
<member name="P:WebSocketSharp.WsCredential.Password">
<summary>
Gets the password for the user name associated with the credentials.
</summary>
<value>
A <see cref="T:System.String" /> that contains the password for the user name associated with the credentials.
</value>
</member>
<member name="P:WebSocketSharp.WsCredential.UserName">
<summary>
Gets the user name associated with the credentials.
</summary>
<value>
A <see cref="T:System.String" /> that contains the user name associated with the credentials.
</value>
</member>
</members>
</doc>

View File

@ -299,6 +299,20 @@
<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Collections.Generic.IEnumerable`1">IEnumerable&lt;WebSocketSharp.Net.Cookie&gt;</a>
</i>.
Gets the cookies used in the WebSocket opening handshake.
</td>
</tr>
<tr valign="top">
<td>[read-only]<div></div></td>
<td>
<b>
<a href="#P:WebSocketSharp.WebSocket.Credentials">Credentials</a>
</b>
</td>
<td>
<i>
<a href="../WebSocketSharp/WsCredential.html">WsCredential</a>
</i>.
Gets the credentials for HTTP authentication (Basic/Digest).
</td>
</tr>
<tr valign="top">
@ -603,6 +617,18 @@
<a href="#M:WebSocketSharp.WebSocket.SetCookie(WebSocketSharp.Net.Cookie)">SetCookie</a>
</b>(<a href="../WebSocketSharp.Net/Cookie.html">WebSocketSharp.Net.Cookie</a>)<blockquote>
Sets a <a href="../WebSocketSharp.Net/Cookie.html">WebSocketSharp.Net.Cookie</a> used in the WebSocket opening handshake.
</blockquote></td>
</tr>
<tr valign="top">
<td>
<div>
</div>
</td>
<td colspan="2">
<b>
<a href="#M:WebSocketSharp.WebSocket.SetCredentials(System.String,System.String,System.Boolean)">SetCredentials</a>
</b>(<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a>, <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a>, <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a>)<blockquote>
Sets the credentials for HTTP authentication (Basic/Digest).
</blockquote></td>
</tr>
</table>
@ -1017,6 +1043,26 @@
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<hr size="1" />
</blockquote>
<h3 id="P:WebSocketSharp.WebSocket.Credentials">Credentials Property</h3>
<blockquote id="P:WebSocketSharp.WebSocket.Credentials:member">
<p class="Summary">
Gets the credentials for HTTP authentication (Basic/Digest).
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="../WebSocketSharp/WsCredential.html">WsCredential</a> <b>Credentials</b> { get; }</div>
<h4 class="Subsection">Value</h4>
<blockquote class="SubsectionBox" id="P:WebSocketSharp.WebSocket.Credentials:Value">
A <a href="../WebSocketSharp/WsCredential.html">WebSocketSharp.WsCredential</a> that contains the credentials for HTTP authentication.
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="P:WebSocketSharp.WebSocket.Credentials:Remarks">
<span class="NotEntered">Documentation for this section has not yet been entered.</span>
</div>
<h2 class="Section">Requirements</h2>
<div class="SectionBox" id="P:WebSocketSharp.WebSocket.Credentials:Version Information">
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<hr size="1" />
</blockquote>
<h3 id="M:WebSocketSharp.WebSocket.Dispose">Dispose Method</h3>
<blockquote id="M:WebSocketSharp.WebSocket.Dispose:member">
<p class="Summary">
@ -1484,6 +1530,46 @@
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<hr size="1" />
</blockquote>
<h3 id="M:WebSocketSharp.WebSocket.SetCredentials(System.String,System.String,System.Boolean)">SetCredentials Method</h3>
<blockquote id="M:WebSocketSharp.WebSocket.SetCredentials(System.String,System.String,System.Boolean):member">
<p class="Summary">
Sets the credentials for HTTP authentication (Basic/Digest).
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Void">void</a> <b>SetCredentials</b> (<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> userName, <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> password, <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Boolean">bool</a> preAuth)</div>
<h4 class="Subsection">Parameters</h4>
<blockquote class="SubsectionBox" id="M:WebSocketSharp.WebSocket.SetCredentials(System.String,System.String,System.Boolean):Parameters">
<dl>
<dt>
<i>userName</i>
</dt>
<dd>
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains a user name associated with the credentials.
</dd>
<dt>
<i>password</i>
</dt>
<dd>
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains a password for <i>userName</i> associated with the credentials.
</dd>
<dt>
<i>preAuth</i>
</dt>
<dd>
<tt>true</tt> if sends the credentials as a Basic authorization with the first request handshake;
otherwise, <tt>false</tt>.
</dd>
</dl>
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="M:WebSocketSharp.WebSocket.SetCredentials(System.String,System.String,System.Boolean):Remarks">
<span class="NotEntered">Documentation for this section has not yet been entered.</span>
</div>
<h2 class="Section">Requirements</h2>
<div class="SectionBox" id="M:WebSocketSharp.WebSocket.SetCredentials(System.String,System.String,System.Boolean):Version Information">
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<hr size="1" />
</blockquote>
<h3 id="P:WebSocketSharp.WebSocket.Url">Url Property</h3>
<blockquote id="P:WebSocketSharp.WebSocket.Url:member">
<p class="Summary">

View File

@ -0,0 +1,351 @@
<html>
<head>
<title>WebSocketSharp.WsCredential</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
a { text-decoration: none }
div.SideBar {
padding-left: 1em;
padding-right: 1em;
right: 0;
float: right;
border: thin solid black;
background-color: #f2f2f2;
}
.CollectionTitle { font-weight: bold }
.PageTitle { font-size: 150%; font-weight: bold }
.Summary { }
.Signature { }
.Remarks { }
.Members { }
.Copyright { }
.Section { font-size: 125%; font-weight: bold }
p.Summary {
margin-left: 1em;
}
.SectionBox { margin-left: 2em }
.NamespaceName { font-size: 105%; font-weight: bold }
.NamespaceSumary { }
.MemberName { font-size: 115%; font-weight: bold; margin-top: 1em }
.Subsection { font-size: 105%; font-weight: bold }
.SubsectionBox { margin-left: 2em; margin-bottom: 1em }
.CodeExampleTable { background-color: #f5f5dd; border: thin solid black; padding: .25em; }
.TypesListing {
border-collapse: collapse;
}
td {
vertical-align: top;
}
th {
text-align: left;
}
.TypesListing td {
margin: 0px;
padding: .25em;
border: solid gray 1px;
}
.TypesListing th {
margin: 0px;
padding: .25em;
background-color: #f2f2f2;
border: solid gray 1px;
}
div.Footer {
border-top: 1px solid gray;
margin-top: 1.5em;
padding-top: 0.6em;
text-align: center;
color: gray;
}
span.NotEntered /* Documentation for this section has not yet been entered */ {
font-style: italic;
color: red;
}
div.Header {
background: #B0C4DE;
border: double;
border-color: white;
border-width: 7px;
padding: 0.5em;
}
div.Header * {
font-size: smaller;
}
div.Note {
}
i.ParamRef {
}
i.subtitle {
}
ul.TypeMembersIndex {
text-align: left;
background: #F8F8F8;
}
ul.TypeMembersIndex li {
display: inline;
margin: 0.5em;
}
table.HeaderTable {
}
table.SignatureTable {
}
table.Documentation, table.Enumeration, table.TypeDocumentation {
border-collapse: collapse;
width: 100%;
}
table.Documentation tr th, table.TypeMembers tr th, table.Enumeration tr th, table.TypeDocumentation tr th {
background: whitesmoke;
padding: 0.8em;
border: 1px solid gray;
text-align: left;
vertical-align: bottom;
}
table.Documentation tr td, table.TypeMembers tr td, table.Enumeration tr td, table.TypeDocumentation tr td {
padding: 0.5em;
border: 1px solid gray;
text-align: left;
vertical-align: top;
}
table.TypeMembers {
border: 1px solid #C0C0C0;
width: 100%;
}
table.TypeMembers tr td {
background: #F8F8F8;
border: white;
}
table.Documentation {
}
table.TypeMembers {
}
div.CodeExample {
width: 100%;
border: 1px solid #DDDDDD;
background-color: #F8F8F8;
}
div.CodeExample p {
margin: 0.5em;
border-bottom: 1px solid #DDDDDD;
}
div.CodeExample div {
margin: 0.5em;
}
h4 {
margin-bottom: 0;
}
div.Signature {
border: 1px solid #C0C0C0;
background: #F2F2F2;
padding: 1em;
}
</style>
<script type="text/JavaScript">
function toggle_display (block) {
var w = document.getElementById (block);
var t = document.getElementById (block + ":toggle");
if (w.style.display == "none") {
w.style.display = "block";
t.innerHTML = "⊟";
} else {
w.style.display = "none";
t.innerHTML = "⊞";
}
}
</script>
</head>
<body>
<div class="CollectionTitle">
<a href="../index.html">websocket-sharp</a> : <a href="index.html">WebSocketSharp Namespace</a></div>
<div class="SideBar">
<p>
<a href="#T:WebSocketSharp.WsCredential">Overview</a>
</p>
<p>
<a href="#T:WebSocketSharp.WsCredential:Signature">Signature</a>
</p>
<p>
<a href="#T:WebSocketSharp.WsCredential:Docs">Remarks</a>
</p>
<p>
<a href="#Members">Members</a>
</p>
<p>
<a href="#T:WebSocketSharp.WsCredential:Members">Member Details</a>
</p>
</div>
<h1 class="PageTitle" id="T:WebSocketSharp.WsCredential">WsCredential Class</h1>
<p class="Summary" id="T:WebSocketSharp.WsCredential:Summary">
Provides the credentials for HTTP authentication (Basic/Digest).
</p>
<div id="T:WebSocketSharp.WsCredential:Signature">
<h2>Syntax</h2>
<div class="Signature">public class <b>WsCredential</b></div>
</div>
<div class="Remarks" id="T:WebSocketSharp.WsCredential:Docs">
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="T:WebSocketSharp.WsCredential:Docs:Remarks">
<span class="NotEntered">Documentation for this section has not yet been entered.</span>
</div>
<h2 class="Section">Requirements</h2>
<div class="SectionBox" id="T:WebSocketSharp.WsCredential:Docs:Version Information">
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<h2 class="Section" id="Members">Members</h2>
<div class="SectionBox" id="_Members">
<p>
See Also: Inherited members from
<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.Object">object</a>.
</p>
<h2 class="Section">Public Properties</h2>
<div class="SectionBox" id="Public Properties">
<div class="SubsectionBox">
<table class="TypeMembers">
<tr valign="top">
<td>[read-only]<div></div></td>
<td>
<b>
<a href="#P:WebSocketSharp.WsCredential.Domain">Domain</a>
</b>
</td>
<td>
<i>
<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a>
</i>.
Gets the name of the user domain associated with the credentials.
</td>
</tr>
<tr valign="top">
<td>[read-only]<div></div></td>
<td>
<b>
<a href="#P:WebSocketSharp.WsCredential.Password">Password</a>
</b>
</td>
<td>
<i>
<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a>
</i>.
Gets the password for the user name associated with the credentials.
</td>
</tr>
<tr valign="top">
<td>[read-only]<div></div></td>
<td>
<b>
<a href="#P:WebSocketSharp.WsCredential.UserName">UserName</a>
</b>
</td>
<td>
<i>
<a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a>
</i>.
Gets the user name associated with the credentials.
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="Members" id="T:WebSocketSharp.WsCredential:Members">
<h2 class="Section" id="MemberDetails">Member Details</h2>
<div class="SectionBox" id="_MemberDetails">
<h3 id="P:WebSocketSharp.WsCredential.Domain">Domain Property</h3>
<blockquote id="P:WebSocketSharp.WsCredential.Domain:member">
<p class="Summary">
Gets the name of the user domain associated with the credentials.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> <b>Domain</b> { get; }</div>
<h4 class="Subsection">Value</h4>
<blockquote class="SubsectionBox" id="P:WebSocketSharp.WsCredential.Domain:Value">
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains the name of the user domain associated with the credentials.
Currently, returns the request uri of a WebSocket opening handshake.
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="P:WebSocketSharp.WsCredential.Domain:Remarks">
<span class="NotEntered">Documentation for this section has not yet been entered.</span>
</div>
<h2 class="Section">Requirements</h2>
<div class="SectionBox" id="P:WebSocketSharp.WsCredential.Domain:Version Information">
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<hr size="1" />
</blockquote>
<h3 id="P:WebSocketSharp.WsCredential.Password">Password Property</h3>
<blockquote id="P:WebSocketSharp.WsCredential.Password:member">
<p class="Summary">
Gets the password for the user name associated with the credentials.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> <b>Password</b> { get; }</div>
<h4 class="Subsection">Value</h4>
<blockquote class="SubsectionBox" id="P:WebSocketSharp.WsCredential.Password:Value">
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains the password for the user name associated with the credentials.
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="P:WebSocketSharp.WsCredential.Password:Remarks">
<span class="NotEntered">Documentation for this section has not yet been entered.</span>
</div>
<h2 class="Section">Requirements</h2>
<div class="SectionBox" id="P:WebSocketSharp.WsCredential.Password:Version Information">
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<hr size="1" />
</blockquote>
<h3 id="P:WebSocketSharp.WsCredential.UserName">UserName Property</h3>
<blockquote id="P:WebSocketSharp.WsCredential.UserName:member">
<p class="Summary">
Gets the user name associated with the credentials.
</p>
<h2>Syntax</h2>
<div class="Signature">public <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> <b>UserName</b> { get; }</div>
<h4 class="Subsection">Value</h4>
<blockquote class="SubsectionBox" id="P:WebSocketSharp.WsCredential.UserName:Value">
A <a href="http://www.go-mono.com/docs/monodoc.ashx?link=T:System.String">string</a> that contains the user name associated with the credentials.
</blockquote>
<h2 class="Section">Remarks</h2>
<div class="SectionBox" id="P:WebSocketSharp.WsCredential.UserName:Remarks">
<span class="NotEntered">Documentation for this section has not yet been entered.</span>
</div>
<h2 class="Section">Requirements</h2>
<div class="SectionBox" id="P:WebSocketSharp.WsCredential.UserName:Version Information">
<b>Namespace: </b>WebSocketSharp<br /><b>Assembly: </b>websocket-sharp (in websocket-sharp.dll)</div>
<hr size="1" />
</blockquote>
</div>
</div>
<hr size="1" />
<div class="Copyright">
</div>
</body>
</html>

View File

@ -282,6 +282,14 @@
Represents the exception that occurred when attempting to perform an operation on the WebSocket connection.
</td>
</tr>
<tr valign="top">
<td>
<a href="./WsCredential.html">WsCredential</a>
</td>
<td>
Provides the credentials for HTTP authentication (Basic/Digest).
</td>
</tr>
<tr valign="top">
<td>
<a href="./WsState.html">WsState</a>

View File

@ -284,6 +284,14 @@
Represents the exception that occurred when attempting to perform an operation on the WebSocket connection.
</td>
</tr>
<tr valign="top">
<td>
<a href="WebSocketSharp/WsCredential.html">WsCredential</a>
</td>
<td>
Provides the credentials for HTTP authentication (Basic/Digest).
</td>
</tr>
<tr valign="top">
<td>
<a href="WebSocketSharp/WsState.html">WsState</a>

View File

@ -272,6 +272,23 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Credentials">
<MemberSignature Language="C#" Value="public WebSocketSharp.WsCredential Credentials { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class WebSocketSharp.WsCredential Credentials" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>WebSocketSharp.WsCredential</ReturnType>
</ReturnValue>
<Docs>
<summary>
Gets the credentials for HTTP authentication (Basic/Digest).
</summary>
<value>
A <see cref="T:WebSocketSharp.WsCredential" /> that contains the credentials for HTTP authentication.
</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Dispose">
<MemberSignature Language="C#" Value="public void Dispose ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void Dispose() cil managed" />
@ -651,6 +668,35 @@
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="SetCredentials">
<MemberSignature Language="C#" Value="public void SetCredentials (string userName, string password, bool preAuth);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void SetCredentials(string userName, string password, bool preAuth) cil managed" />
<MemberType>Method</MemberType>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="userName" Type="System.String" />
<Parameter Name="password" Type="System.String" />
<Parameter Name="preAuth" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="userName">
A <see cref="T:System.String" /> that contains a user name associated with the credentials.
</param>
<param name="password">
A <see cref="T:System.String" /> that contains a password for <paramref name="userName" /> associated with the credentials.
</param>
<param name="preAuth">
<c>true</c> if sends the credentials as a Basic authorization with the first request handshake;
otherwise, <c>false</c>.
</param>
<summary>
Sets the credentials for HTTP authentication (Basic/Digest).
</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Url">
<MemberSignature Language="C#" Value="public Uri Url { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Uri Url" />

View File

@ -0,0 +1,71 @@
<Type Name="WsCredential" FullName="WebSocketSharp.WsCredential">
<TypeSignature Language="C#" Value="public class WsCredential" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit WsCredential extends System.Object" />
<AssemblyInfo>
<AssemblyName>websocket-sharp</AssemblyName>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>
Provides the credentials for HTTP authentication (Basic/Digest).
</summary>
<remarks>To be added.</remarks>
</Docs>
<Members>
<Member MemberName="Domain">
<MemberSignature Language="C#" Value="public string Domain { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Domain" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>
Gets the name of the user domain associated with the credentials.
</summary>
<value>
A <see cref="T:System.String" /> that contains the name of the user domain associated with the credentials.
Currently, returns the request uri of a WebSocket opening handshake.
</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Password">
<MemberSignature Language="C#" Value="public string Password { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Password" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>
Gets the password for the user name associated with the credentials.
</summary>
<value>
A <see cref="T:System.String" /> that contains the password for the user name associated with the credentials.
</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="UserName">
<MemberSignature Language="C#" Value="public string UserName { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string UserName" />
<MemberType>Property</MemberType>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>
Gets the user name associated with the credentials.
</summary>
<value>
A <see cref="T:System.String" /> that contains the user name associated with the credentials.
</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>

View File

@ -1,6 +1,6 @@
<Overview>
<Assemblies>
<Assembly Name="websocket-sharp" Version="1.0.2.2226">
<Assembly Name="websocket-sharp" Version="1.0.2.31647">
<AssemblyPublicKey>[00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 11 00 00 00 29 17 fb 89 fe c3 91 f7 2b cb 8b e2 61 d2 3f 05 93 6d 65 a8 9e 63 72 a6 f5 d5 2c f2 9d 20 fa 0b c0 70 6a f6 88 7e 8b 90 3f 39 f5 76 c8 48 e0 bb 7b b2 7b ed d3 10 a7 1a 0f 70 98 0f 7f f4 4b 53 09 d2 a5 ef 36 c3 56 b4 aa f0 91 72 63 25 07 89 e0 93 3e 3f 2e f2 b9 73 0e 12 15 5d 43 56 c3 f4 70 a5 89 fe f7 f6 ac 3e 77 c2 d8 d0 84 91 f4 0c d1 f3 8e dc c3 c3 b8 38 3d 0c bf 17 de 20 78 c1 ]</AssemblyPublicKey>
<Attributes>
<Attribute>
@ -44,6 +44,7 @@
<Type Name="Opcode" Kind="Enumeration" />
<Type Name="WebSocket" Kind="Class" />
<Type Name="WebSocketException" Kind="Class" />
<Type Name="WsCredential" Kind="Class" />
<Type Name="WsState" Kind="Enumeration" />
</Namespace>
<Namespace Name="WebSocketSharp.Net">

View File

@ -123,6 +123,9 @@
<Compile Include="Net\HttpHeaderInfo.cs" />
<Compile Include="CompressionMethod.cs" />
<Compile Include="WebSocketException.cs" />
<Compile Include="AuthenticationChallenge.cs" />
<Compile Include="AuthenticationResponse.cs" />
<Compile Include="WsCredential.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>