📄 sipcauthorizationheader.cs
字号:
namespace Imps.Base.Sipc
{
using System;
public class SipcAuthorizationHeader : SipcHeader
{
private string _algorithm;
private string _cNonce;
private string _method;
private string _response;
public SipcAuthorizationHeader() : base("A")
{
this._method = string.Empty;
this._algorithm = string.Empty;
this._response = string.Empty;
this._cNonce = string.Empty;
}
public SipcAuthorizationHeader(string value) : base("A", value)
{
this._method = string.Empty;
this._algorithm = string.Empty;
this._response = string.Empty;
this._cNonce = string.Empty;
}
public SipcAuthorizationHeader(string method, string algorithm, string response, string cnonce) : this(method, algorithm, response, cnonce, null)
{
}
public SipcAuthorizationHeader(string method, string algorithm, string response, string cnonce, string salt) : base("A")
{
this._method = string.Empty;
this._algorithm = string.Empty;
this._response = string.Empty;
this._cNonce = string.Empty;
this._method = method;
this._response = response;
this._cNonce = cnonce;
this._algorithm = algorithm;
base.Value = string.Format("{0} algorithm=\"{1}\",response=\"{2}\",cnonce=\"{3}\"", new object[] { method, algorithm, response, cnonce });
if (!string.IsNullOrEmpty(salt))
{
base.Value = base.Value + ",salt=\"" + salt + "\"";
}
}
public override void Parse(string value)
{
base.Value = value;
int length = value.IndexOf(" ");
if (length >= 0)
{
this._method = value.Substring(0, length).Trim();
foreach (string text in value.Substring(length + 1).Split(new char[] { ',' }))
{
string[] textArray2 = text.Trim().Split(new char[] { '=' });
if (textArray2.Length > 1)
{
if (textArray2[0].ToLower() == "response")
{
this._response = textArray2[1].Trim().Trim(new char[] { '"' });
}
else if (textArray2[0].ToLower() == "cnonce")
{
this._cNonce = textArray2[1].Trim().Trim(new char[] { '"' });
}
}
}
}
}
public override string ToString()
{
return string.Format("{0}: {1}", "A", base.Value);
}
public string Algorithm
{
get
{
return this._algorithm;
}
set
{
this._algorithm = (value == null) ? string.Empty : value.Trim();
}
}
public string CNonce
{
get
{
return this._cNonce;
}
set
{
this._cNonce = (value == null) ? string.Empty : value;
}
}
public string Method
{
get
{
return this._method;
}
set
{
this._method = (value == null) ? string.Empty : value.Trim();
}
}
public string Response
{
get
{
return this._response;
}
set
{
this._response = (value == null) ? string.Empty : value.Trim();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -