Basic验证的Domain处理

 
Basic验证的Domain处理
 
Email:zfive5@yahoo.com.cn
Author:zfive5(zhaozi)
 
发觉自己对网络编程真是有些末名的潜力,过去编写basic代理认证时,往往乎略Domain,最近发现Domainbasic的编码中也有体现!
 
如果有域值的需要这样的:
 
"Proxy-Authorization:Basic"+" "+Base64(Domain+“/"+UserName+":"+Password)
 
"WWW-Authorization:Basic"+" "+Base64(Domain+“/"+UserName+":"+Password)
 
如果没有域值:
 
"Proxy-Authorization:Basic"+" "+Base64(UserName+":"+Password)
 
"WWW-Authorization:Basic"+" "+Base64(UserName+":"+Password)
 
 
.NET下的Reflector反编译的代码
 
NetworkCredential credential1 = credentials.GetCredential(httpWebRequest.ChallengedUri, BasicClient.Signature);
if (credential1 == null)
{
    return null;
}
 
string text1 = credential1.UserName;
string text2 = credential1.Domain;
if (ValidationHelper.IsBlankString(text1))
{
    return null;
}
 
string text3 = (!ValidationHelper.IsBlankString(text2) ? (text2 + @"/") : "") + text1 + ":" + credential1.Password;
byte[] buffer1 = BasicClient.EncodingRightGetBytes(text3);
string text4 = "Basic " + Convert.ToBase64String(buffer1);
return new Authorization(text4);
 
源码之下,确实可以解决一些疑问。
 
 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值