@@ -59,14 +59,12 @@ public class TcpListenerWebSocketContext : WebSocketContext
5959 #region Internal Constructors
6060
6161 internal TcpListenerWebSocketContext (
62- TcpClient client , string protocol , X509Certificate cert , bool secure , Logger logger )
62+ TcpClient client , string protocol , bool secure , X509Certificate cert , Logger logger )
6363 {
6464 _client = client ;
6565 _secure = secure ;
66- _stream = WsStream . CreateServerStream ( client , cert , secure ) ;
67- _request = _stream . ReadHandshake < HandshakeRequest > (
68- HandshakeRequest . Parse , 90000 ) ;
69-
66+ _stream = WsStream . CreateServerStream ( client , secure , cert ) ;
67+ _request = _stream . ReadHandshake < HandshakeRequest > ( HandshakeRequest . Parse , 90000 ) ;
7068 _websocket = new WebSocket ( this , protocol , logger ) ;
7169 }
7270
@@ -326,8 +324,8 @@ private Uri createRequestUri ()
326324 var host = _request . Headers [ "Host" ] ;
327325 var rawUri = _request . RequestUri ;
328326 var path = rawUri . IsAbsoluteUri
329- ? rawUri . PathAndQuery
330- : HttpUtility . UrlDecode ( _request . RawUrl ) ;
327+ ? rawUri . PathAndQuery
328+ : HttpUtility . UrlDecode ( _request . RawUrl ) ;
331329
332330 return String . Format ( "{0}://{1}{2}" , scheme , host , path ) . ToUri ( ) ;
333331 }
@@ -356,37 +354,37 @@ internal void SendAuthChallenge (string challenge)
356354 }
357355
358356 internal void SetUser (
359- AuthenticationSchemes expectedScheme ,
357+ AuthenticationSchemes scheme ,
360358 string realm ,
361359 Func < IIdentity , NetworkCredential > credentialsFinder )
362360 {
363361 var authRes = _request . AuthResponse ;
364362 if ( authRes == null )
365363 return ;
366364
367- var identity = authRes . ToIdentity ( ) ;
368- if ( identity == null )
365+ var id = authRes . ToIdentity ( ) ;
366+ if ( id == null )
369367 return ;
370368
371- NetworkCredential credentials = null ;
369+ NetworkCredential cred = null ;
372370 try {
373- credentials = credentialsFinder ( identity ) ;
371+ cred = credentialsFinder ( id ) ;
374372 }
375373 catch {
376374 }
377375
378- if ( credentials == null )
376+ if ( cred == null )
379377 return ;
380378
381- var valid = expectedScheme == AuthenticationSchemes . Basic
382- ? ( ( HttpBasicIdentity ) identity ) . Password == credentials . Password
383- : expectedScheme == AuthenticationSchemes . Digest
384- ? ( ( HttpDigestIdentity ) identity ) . IsValid (
385- credentials . Password , realm , _request . HttpMethod , null )
386- : false ;
379+ var valid = scheme == AuthenticationSchemes . Basic
380+ ? ( ( HttpBasicIdentity ) id ) . Password == cred . Password
381+ : scheme == AuthenticationSchemes . Digest
382+ ? ( ( HttpDigestIdentity ) id ) . IsValid (
383+ cred . Password , realm , _request . HttpMethod , null )
384+ : false ;
387385
388386 if ( valid )
389- _user = new GenericPrincipal ( identity , credentials . Roles ) ;
387+ _user = new GenericPrincipal ( id , cred . Roles ) ;
390388 }
391389
392390 #endregion
0 commit comments