internal bool Authenticate()
{
var schm = _listener.SelectAuthenticationScheme(_request);
if (schm == AuthenticationSchemes.Anonymous)
{
return(true);
}
if (schm == AuthenticationSchemes.None)
{
_response.Close(HttpStatusCode.Forbidden);
return(false);
}
var realm = _listener.GetRealm();
var user =
HttpUtility.CreateUser(
_request.Headers["Authorization"],
schm,
realm,
_request.HttpMethod,
_listener.GetUserCredentialsFinder()
);
if (user == null || !user.Identity.IsAuthenticated)
{
_response.CloseWithAuthChallenge(new AuthenticationChallenge(schm, realm).ToString());
return(false);
}
_user = user;
return(true);
}