private AccountPassword GetCredentialsFromRequest()
{
if (WebOperationContext.Current != null)
{
foreach (object header in HttpContext.Current.Request.Headers)
{
if (header.ToString() == "Authorization")
{
string headerItem = HttpContext.Current.Request.Headers[header.ToString()];
if (headerItem.StartsWith("Basic "))
{
string cred = Encoding.UTF8.GetString(Convert.FromBase64String(headerItem.Substring("Basic ".Length)));
string[] parts = cred.Split(':');
return new AccountPassword(parts[0], parts[1]);
}
}
}
}
throw new AuthenticationException();
}