[Modify] Polish it

This commit is contained in:
sta 2016-05-12 17:13:55 +09:00
parent 67b262dac2
commit b2c5f954ba

View File

@ -554,10 +554,19 @@ namespace WebSocketSharp.Net
AuthenticationSchemes scheme, AuthenticationSchemes scheme,
string realm, string realm,
string method, string method,
Func<IIdentity, NetworkCredential> credentialsFinder) Func<IIdentity, NetworkCredential> credentialsFinder
)
{ {
if (response == null || if (response == null)
!response.StartsWith (scheme.ToString (), StringComparison.OrdinalIgnoreCase)) return null;
if (!(scheme == AuthenticationSchemes.Basic || scheme == AuthenticationSchemes.Digest))
return null;
if (!response.StartsWith (scheme.ToString (), StringComparison.OrdinalIgnoreCase))
return null;
if (credentialsFinder == null)
return null; return null;
var res = AuthenticationResponse.Parse (response); var res = AuthenticationResponse.Parse (response);
@ -578,15 +587,19 @@ namespace WebSocketSharp.Net
if (cred == null) if (cred == null)
return null; return null;
var valid = scheme == AuthenticationSchemes.Basic if (scheme == AuthenticationSchemes.Basic
? ((HttpBasicIdentity) id).Password == cred.Password && ((HttpBasicIdentity) id).Password != cred.Password
: scheme == AuthenticationSchemes.Digest ) {
? ((HttpDigestIdentity) id).IsValid (cred.Password, realm, method, null) return null;
: false; }
return valid if (scheme == AuthenticationSchemes.Digest
? new GenericPrincipal (id, cred.Roles) && !((HttpDigestIdentity) id).IsValid (cred.Password, realm, method, null)
: null; ) {
return null;
}
return new GenericPrincipal (id, cred.Roles);
} }
internal static Encoding GetEncoding (string contentType) internal static Encoding GetEncoding (string contentType)