Modified HTTP auth for HttpListener class

This commit is contained in:
sta
2014-11-14 15:49:14 +09:00
parent b596c05179
commit 9c79e28f22
3 changed files with 54 additions and 59 deletions

View File

@@ -486,23 +486,6 @@ namespace WebSocketSharp.Server
_state = ServerState.Stop;
}
private bool authenticateRequest (AuthenticationSchemes scheme, HttpListenerContext context)
{
if (context.Request.IsAuthenticated)
return true;
if (scheme == AuthenticationSchemes.Basic)
context.Response.CloseWithAuthChallenge (
AuthenticationChallenge.CreateBasicChallenge (_listener.Realm).ToBasicString ());
else if (scheme == AuthenticationSchemes.Digest)
context.Response.CloseWithAuthChallenge (
AuthenticationChallenge.CreateDigestChallenge (_listener.Realm).ToDigestString ());
else
context.Response.Close (HttpStatusCode.Forbidden);
return false;
}
private string checkIfCertificateExists ()
{
if (!_secure)
@@ -570,11 +553,6 @@ namespace WebSocketSharp.Server
ThreadPool.QueueUserWorkItem (
state => {
try {
var schm = _listener.SelectAuthenticationScheme (ctx);
if (schm != AuthenticationSchemes.Anonymous &&
!authenticateRequest (schm, ctx))
return;
if (ctx.Request.IsUpgradeTo ("websocket")) {
processWebSocketRequest (ctx.AcceptWebSocket (null, _logger));
return;