Basic验证的Domain处理

王朝other·作者佚名  2006-11-30
窄屏简体版  字體: |||超大  

Basic验证的Domain处理

Email:zfive5@yahoo.com.cn

Author:zfive5(zhaozi)

发觉自己对网络编程真是有些末名的潜力,过去编写basic代理认证时,往往乎略Domain,最近发现Domain在basic的编码中也有体现!

如果有域值的需要这样的:

"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);

源码之下,确实可以解决一些疑问。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航