From 4eff17c9b29d5535d7fa72653ad2e64ad4a8d263 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 12 Jan 2015 12:34:16 -0800 Subject: [PATCH] Cleanup DataProtectionTokenProvider --- .../DataProtectionTokenProvider.cs | 10 +++------- .../DataProtectionTokenProviderOptions.cs | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNet.Identity/DataProtectionTokenProvider.cs b/src/Microsoft.AspNet.Identity/DataProtectionTokenProvider.cs index b50ad1ecaa..988b569e32 100644 --- a/src/Microsoft.AspNet.Identity/DataProtectionTokenProvider.cs +++ b/src/Microsoft.AspNet.Identity/DataProtectionTokenProvider.cs @@ -25,15 +25,11 @@ namespace Microsoft.AspNet.Identity /// The configured . public DataProtectorTokenProvider(IDataProtectionProvider dataProtectionProvider, IOptions options) { - if (options == null || options.Options == null) - { - throw new ArgumentNullException(nameof(options)); - } if (dataProtectionProvider == null) { throw new ArgumentNullException(nameof(dataProtectionProvider)); } - Options = options.Options; + Options = options?.Options ?? new DataProtectionTokenProviderOptions(); // Use the Name as the purpose which should usually be distinct from others Protector = dataProtectionProvider.CreateProtector(Name ?? "DataProtectorTokenProvider"); } @@ -44,7 +40,7 @@ namespace Microsoft.AspNet.Identity /// /// The for this instance. /// - public DataProtectionTokenProviderOptions Options { get; private set; } + protected DataProtectionTokenProviderOptions Options { get; private set; } /// /// Gets the for this instance. @@ -52,7 +48,7 @@ namespace Microsoft.AspNet.Identity /// /// The for this instance. /// - public IDataProtector Protector { get; private set; } + protected IDataProtector Protector { get; private set; } /// /// Gets the name of this instance. diff --git a/src/Microsoft.AspNet.Identity/DataProtectionTokenProviderOptions.cs b/src/Microsoft.AspNet.Identity/DataProtectionTokenProviderOptions.cs index e7a6ab7170..57d589440a 100644 --- a/src/Microsoft.AspNet.Identity/DataProtectionTokenProviderOptions.cs +++ b/src/Microsoft.AspNet.Identity/DataProtectionTokenProviderOptions.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Identity /// /// The name of the . /// - public string Name { get; set; } = "DataProtection"; + public string Name { get; set; } = "DataProtectorTokenProvider"; /// /// Gets or sets the amount of time a generated token remains valid.