88 * The MIT License
99 *
1010 * Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
11- * Copyright (c) 2012-2013 sta.blockhead
11+ * Copyright (c) 2012-2014 sta.blockhead
1212 *
1313 * Permission is hereby granted, free of charge, to any person obtaining a copy
1414 * of this software and associated documentation files (the "Software"), to deal
3333#region Authors
3434/*
3535 * Authors:
36- * Gonzalo Paniagua Javier <[email protected] > 36+ * - Gonzalo Paniagua Javier <[email protected] > 3737 */
3838#endregion
3939
4040using System ;
41- using System . Collections . Specialized ;
42- using System . IO ;
4341using System . Security . Principal ;
44- using System . Text ;
4542using WebSocketSharp . Net . WebSockets ;
4643
4744namespace WebSocketSharp . Net
4845{
4946 /// <summary>
50- /// Provides access to the HTTP request and response information used by the
51- /// <see cref="HttpListener"/>.
47+ /// Provides a set of methods and properties used to access the HTTP request and response
48+ /// information used by the <see cref="HttpListener"/>.
5249 /// </summary>
5350 /// <remarks>
5451 /// The HttpListenerContext class cannot be inherited.
@@ -123,12 +120,10 @@ internal bool HaveError {
123120 #region Public Properties
124121
125122 /// <summary>
126- /// Gets the <see cref="HttpListenerRequest"/> that contains the HTTP
127- /// request information from a client.
123+ /// Gets the HTTP request information from a client.
128124 /// </summary>
129125 /// <value>
130- /// A <see cref="HttpListenerRequest"/> that contains the HTTP request
131- /// information.
126+ /// A <see cref="HttpListenerRequest"/> that represents the HTTP request.
132127 /// </value>
133128 public HttpListenerRequest Request {
134129 get {
@@ -137,13 +132,10 @@ public HttpListenerRequest Request {
137132 }
138133
139134 /// <summary>
140- /// Gets the <see cref="HttpListenerResponse"/> that contains the HTTP
141- /// response information to send to the client in response to the client's
142- /// request.
135+ /// Gets the HTTP response information used to send to the client.
143136 /// </summary>
144137 /// <value>
145- /// A <see cref="HttpListenerResponse"/> that contains the HTTP response
146- /// information.
138+ /// A <see cref="HttpListenerResponse"/> that represents the HTTP response to send.
147139 /// </value>
148140 public HttpListenerResponse Response {
149141 get {
@@ -152,11 +144,10 @@ public HttpListenerResponse Response {
152144 }
153145
154146 /// <summary>
155- /// Gets the client information (identity, authentication information, and
156- /// security roles).
147+ /// Gets the client information (identity, authentication, and security roles).
157148 /// </summary>
158149 /// <value>
159- /// A <see cref="IPrincipal"/> contains the client information.
150+ /// A <see cref="IPrincipal"/> that represents the client information.
160151 /// </value>
161152 public IPrincipal User {
162153 get {
@@ -169,53 +160,52 @@ public IPrincipal User {
169160 #region Internal Methods
170161
171162 internal void SetUser (
172- AuthenticationSchemes expectedScheme ,
163+ AuthenticationSchemes scheme ,
173164 string realm ,
174165 Func < IIdentity , NetworkCredential > credentialsFinder )
175166 {
176167 var authRes = AuthenticationResponse . Parse ( _request . Headers [ "Authorization" ] ) ;
177168 if ( authRes == null )
178169 return ;
179170
180- var identity = authRes . ToIdentity ( ) ;
181- if ( identity == null )
171+ var id = authRes . ToIdentity ( ) ;
172+ if ( id == null )
182173 return ;
183174
184- NetworkCredential credentials = null ;
175+ NetworkCredential cred = null ;
185176 try {
186- credentials = credentialsFinder ( identity ) ;
177+ cred = credentialsFinder ( id ) ;
187178 }
188179 catch {
189180 }
190181
191- if ( credentials == null )
182+ if ( cred == null )
192183 return ;
193184
194- var valid = expectedScheme == AuthenticationSchemes . Basic
195- ? ( ( HttpBasicIdentity ) identity ) . Password == credentials . Password
196- : expectedScheme == AuthenticationSchemes . Digest
197- ? ( ( HttpDigestIdentity ) identity ) . IsValid (
198- credentials . Password , realm , _request . HttpMethod , null )
199- : false ;
185+ var valid = scheme == AuthenticationSchemes . Basic
186+ ? ( ( HttpBasicIdentity ) id ) . Password == cred . Password
187+ : scheme == AuthenticationSchemes . Digest
188+ ? ( ( HttpDigestIdentity ) id ) . IsValid (
189+ cred . Password , realm , _request . HttpMethod , null )
190+ : false ;
200191
201192 if ( valid )
202- _user = new GenericPrincipal ( identity , credentials . Roles ) ;
193+ _user = new GenericPrincipal ( id , cred . Roles ) ;
203194 }
204195
205196 #endregion
206197
207- #region Public Method
198+ #region Public Methods
208199
209200 /// <summary>
210201 /// Accepts a WebSocket connection request.
211202 /// </summary>
212203 /// <returns>
213- /// A <see cref="HttpListenerWebSocketContext"/> that contains a WebSocket
214- /// connection request information .
204+ /// A <see cref="HttpListenerWebSocketContext"/> that represents the WebSocket connection
205+ /// request.
215206 /// </returns>
216207 /// <param name="logger">
217- /// A <see cref="Logger"/> that provides the logging functions used in the
218- /// WebSocket attempts.
208+ /// A <see cref="Logger"/> that provides the logging functions used in the WebSocket attempts.
219209 /// </param>
220210 public HttpListenerWebSocketContext AcceptWebSocket ( Logger logger )
221211 {
0 commit comments