From 797e1287e383683597595b072c343d6c051d6b68 Mon Sep 17 00:00:00 2001 From: Hisham Abdullah Bin Ateya Date: Thu, 11 Jun 2015 23:28:12 +0300 Subject: [PATCH] Using [NotNull] --- .../OAuthBearerAuthenticationOptions.cs | 9 ++------ .../OpenIdConnectAuthenticationHandler.cs | 4 ++-- .../OpenIdConnectAuthenticationOptions.cs | 21 ++++--------------- ...ertificateSubjectKeyIdentifierValidator.cs | 2 +- 4 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationOptions.cs index 8f632a7a53..7aa48deaa7 100644 --- a/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OAuthBearer/OAuthBearerAuthenticationOptions.cs @@ -5,8 +5,8 @@ using System; using System.Collections.Generic; using System.IdentityModel.Tokens; using System.Net.Http; -using Microsoft.IdentityModel.Protocols; using Microsoft.Framework.Internal; +using Microsoft.IdentityModel.Protocols; namespace Microsoft.AspNet.Authentication.OAuthBearer { @@ -140,14 +140,9 @@ namespace Microsoft.AspNet.Authentication.OAuthBearer { return _tokenValidationParameters; } - + [param: NotNull] set { - if (value == null) - { - throw new ArgumentNullException("TokenValidationParameters"); - } - _tokenValidationParameters = value; } } diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationHandler.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationHandler.cs index cc132e9bb0..7e97628e14 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationHandler.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationHandler.cs @@ -528,9 +528,9 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect /// The value of the cookie is: "N". private void WriteNonceCookie(string nonce) { - if (string.IsNullOrWhiteSpace(nonce)) + if (string.IsNullOrEmpty(nonce)) { - throw new ArgumentNullException("nonce"); + throw new ArgumentNullException(nameof(nonce)); } Response.Cookies.Append( diff --git a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationOptions.cs b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationOptions.cs index 9e4bfa55d7..8e78a5b09e 100644 --- a/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationOptions.cs +++ b/src/Microsoft.AspNet.Authentication.OpenIdConnect/OpenIdConnectAuthenticationOptions.cs @@ -8,8 +8,8 @@ using System.IdentityModel.Tokens; using System.Net.Http; using Microsoft.AspNet.Http; using Microsoft.AspNet.Http.Authentication; -using Microsoft.IdentityModel.Protocols; using Microsoft.Framework.Internal; +using Microsoft.IdentityModel.Protocols; namespace Microsoft.AspNet.Authentication.OpenIdConnect { @@ -252,13 +252,9 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect { return _stateDataFormat; } + [param: NotNull] set { - if (value == null) - { - throw new ArgumentNullException("value"); - } - _stateDataFormat = value; } } @@ -272,13 +268,9 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect { return _stringDataFormat; } + [param: NotNull] set { - if (value == null) - { - throw new ArgumentNullException("value"); - } - _stringDataFormat = value; } } @@ -315,14 +307,9 @@ namespace Microsoft.AspNet.Authentication.OpenIdConnect { return _tokenValidationParameters; } - + [param: NotNull] set { - if (value == null) - { - throw new ArgumentNullException("value"); - } - _tokenValidationParameters = value; } } diff --git a/src/Microsoft.AspNet.Authentication/CertificateSubjectKeyIdentifierValidator.cs b/src/Microsoft.AspNet.Authentication/CertificateSubjectKeyIdentifierValidator.cs index a4705a9546..ce13de2510 100644 --- a/src/Microsoft.AspNet.Authentication/CertificateSubjectKeyIdentifierValidator.cs +++ b/src/Microsoft.AspNet.Authentication/CertificateSubjectKeyIdentifierValidator.cs @@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Authentication if (_validSubjectKeyIdentifiers.Count == 0) { - throw new ArgumentOutOfRangeException(nameof(_validSubjectKeyIdentifiers)); + throw new ArgumentOutOfRangeException(nameof(validSubjectKeyIdentifiers)); } }