29 using System.Collections.Generic;
30 using System.Collections.Specialized;
32 using System.Reflection;
43 public string Name {
get {
return "BasicHttp"; } }
45 private string m_Username, m_Password;
46 private string m_CredentialsB64;
50 public string Credentials
52 get {
return m_CredentialsB64; }
58 m_Username = Util.GetConfigVarFromSections<
string>(config,
"HttpAuthUsername",
new string[] {
"Network", section }, string.Empty);
59 m_Password = Util.GetConfigVarFromSections<
string>(config,
"HttpAuthPassword",
new string[] {
"Network", section }, string.Empty);
60 string str = m_Username +
":" + m_Password;
61 byte[] encData_byte = Util.UTF8.GetBytes(str);
63 m_CredentialsB64 = Convert.ToBase64String(encData_byte);
70 headers[
"Authorization"] =
"Basic " + m_CredentialsB64;
75 string recovered = Util.Base64ToString(data);
76 if (!String.IsNullOrEmpty(recovered))
78 string[] parts = recovered.Split(
new char[] {
':' });
79 if (parts.Length >= 2)
81 return m_Username.Equals(parts[0]) && m_Password.Equals(parts[1]);
92 string value = requestHeaders.Get(
"Authorization");
96 if (value.StartsWith(
"Basic "))
98 value = value.Replace(
"Basic ", string.Empty);
101 statusCode = HttpStatusCode.OK;
107 d(
"WWW-Authenticate",
"Basic realm = \"Asset Server\"");
109 statusCode = HttpStatusCode.Unauthorized;
bool Authenticate(NameValueCollection requestHeaders, AddHeaderDelegate d, out HttpStatusCode statusCode)
BasicHttpAuthentication(IConfigSource config, string section)
bool Authenticate(string data)
void AddAuthorization(NameValueCollection headers)
Interactive OpenSim region server
delegate void AddHeaderDelegate(string key, string value)