2 interfaces inheriting from IDataProtector
Microsoft.AspNetCore.DataProtection (1)
IPersistedDataProtector.cs (1)
12public interface IPersistedDataProtector : IDataProtector
Microsoft.AspNetCore.DataProtection.Extensions (1)
ITimeLimitedDataProtector.cs (1)
18public interface ITimeLimitedDataProtector : IDataProtector
7 implementations of IDataProtector
Aspire.Dashboard.Tests (1)
LocalBrowserStorageTests.cs (1)
152private sealed class TestDataProtector : IDataProtector
Microsoft.AspNetCore.Authentication.Test (1)
CookieTests.cs (1)
1734private class NoOpDataProtector : IDataProtector
Microsoft.AspNetCore.Components.Endpoints.Tests (1)
RazorComponentResultTest.cs (1)
503class FakeDataProtector : IDataProtector
Microsoft.AspNetCore.Components.Server.Tests (1)
ProtectedBrowserStorageTest.cs (1)
311class TestDataProtector : IDataProtector
Microsoft.AspNetCore.DataProtection (1)
KeyManagement\KeyRingBasedDataProtector.cs (1)
20internal sealed unsafe class KeyRingBasedDataProtector : IDataProtector, IPersistedDataProtector
Microsoft.AspNetCore.DataProtection.Extensions (1)
DataProtectionAdvancedExtensions.cs (1)
99private sealed class TimeLimitedWrappingProtector : IDataProtector
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (1)
CookieTempDataProviderTest.cs (1)
425private class PassThroughDataProtector : IDataProtector
190 references to IDataProtector
Aspire.Dashboard.Tests (1)
LocalBrowserStorageTests.cs (1)
154public IDataProtector CreateProtector(string purpose)
CustomEncryptorSample (1)
Program.cs (1)
22var protector = services.GetDataProtector("SamplePurpose");
EntityFrameworkCoreSample (1)
Program.cs (1)
36var protector = services.GetDataProtector("sample-purpose");
Microsoft.AspNetCore.Antiforgery (1)
Internal\DefaultAntiforgeryTokenSerializer.cs (1)
15private readonly IDataProtector _cryptoSystem;
Microsoft.AspNetCore.Antiforgery.Test (1)
DefaultAntiforgeryTokenSerializerTest.cs (1)
141var mockCryptoSystem = new Mock<IDataProtector>();
Microsoft.AspNetCore.Authentication (9)
PropertiesDataFormat.cs (2)
17/// <param name="protector">The <see cref="IDataProtector"/>.</param> 18public PropertiesDataFormat(IDataProtector protector)
SecureDataFormat.cs (5)
15private readonly IDataProtector _protector; 21/// <param name="protector">The <see cref="IDataProtector"/>.</param> 22public SecureDataFormat(IDataSerializer<TData> serializer, IDataProtector protector) 39var protector = _protector; 71var protector = _protector;
TicketDataFormat.cs (2)
17/// <param name="protector">The <see cref="IDataProtector"/>.</param> 18public TicketDataFormat(IDataProtector protector)
Microsoft.AspNetCore.Authentication.Cookies (1)
PostConfigureCookieAuthenticationOptions.cs (1)
43var dataProtector = options.DataProtectionProvider.CreateProtector("Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationMiddleware", name, "v2");
Microsoft.AspNetCore.Authentication.OAuth (1)
OAuthPostConfigureOptions.cs (1)
46var dataProtector = options.DataProtectionProvider.CreateProtector(
Microsoft.AspNetCore.Authentication.OpenIdConnect (2)
OpenIdConnectPostConfigureOptions.cs (2)
47var dataProtector = options.DataProtectionProvider.CreateProtector( 54var dataProtector = options.DataProtectionProvider.CreateProtector(
Microsoft.AspNetCore.Authentication.Test (4)
CookieTests.cs (1)
1736public IDataProtector CreateProtector(string purpose)
SecureDataFormatTests.cs (3)
25var prototector = provider.CreateProtector("test"); 38var prototector = provider.CreateProtector("test"); 52var prototector = provider.CreateProtector("test");
Microsoft.AspNetCore.Authentication.Twitter (1)
TwitterPostConfigureOptions.cs (1)
39var dataProtector = options.DataProtectionProvider.CreateProtector(
Microsoft.AspNetCore.Authentication.WsFederation (1)
WsFederationPostConfigureOptions.cs (1)
47var dataProtector = options.DataProtectionProvider.CreateProtector(
Microsoft.AspNetCore.Components.Endpoints (1)
src\Shared\Components\ProtectedPrerenderComponentApplicationStore.cs (1)
11private IDataProtector _protector = default!; // Assigned in all constructor paths
Microsoft.AspNetCore.Components.Endpoints.Tests (2)
RazorComponentResultTest.cs (2)
500public IDataProtector CreateProtector(string purpose) 505public IDataProtector CreateProtector(string purpose) => this;
Microsoft.AspNetCore.Components.Server (8)
Circuits\CircuitIdFactory.cs (1)
21private readonly IDataProtector _protector;
Circuits\ServerComponentDeserializer.cs (1)
60private readonly IDataProtector _dataProtector;
ProtectedBrowserStorage\ProtectedBrowserStorage.cs (5)
19private readonly ConcurrentDictionary<string, IDataProtector> _cachedDataProtectorsByPurpose 20= new ConcurrentDictionary<string, IDataProtector>(StringComparer.Ordinal); 126var protector = GetOrCreateCachedProtector(purpose); 133var protector = GetOrCreateCachedProtector(purpose); 149private IDataProtector GetOrCreateCachedProtector(string purpose)
src\Shared\Components\ProtectedPrerenderComponentApplicationStore.cs (1)
11private IDataProtector _protector = default!; // Assigned in all constructor paths
Microsoft.AspNetCore.Components.Server.Tests (2)
ProtectedBrowserStorageTest.cs (2)
305public IDataProtector CreateProtector(string purpose) 320public IDataProtector CreateProtector(string purpose)
Microsoft.AspNetCore.DataProtection (4)
EphemeralDataProtectionProvider.cs (1)
67public IDataProtector CreateProtector(string purpose)
KeyManagement\KeyManagementOptions.cs (1)
36/// to <see cref="IDataProtector.Protect(byte[])"/> may fail. The system may end up
KeyManagement\KeyRingBasedDataProtectionProvider.cs (1)
22public IDataProtector CreateProtector(string purpose)
KeyManagement\KeyRingBasedDataProtector.cs (1)
60public IDataProtector CreateProtector(string purpose)
Microsoft.AspNetCore.DataProtection.Abstractions (26)
DataProtectionCommonExtensions.cs (21)
20/// Creates an <see cref="IDataProtector"/> given a list of purposes. 25/// <returns>An <see cref="IDataProtector"/> tied to the provided purpose chain.</returns> 31public static IDataProtector CreateProtector(this IDataProtectionProvider provider, IEnumerable<string> purposes) 44retVal = retVal.CreateProtector(purpose) ?? CryptoUtil.Fail<IDataProtector>("CreateProtector returned null."); 53Debug.Assert(retVal is IDataProtector); // CreateProtector is supposed to return an instance of this interface 54return (IDataProtector)retVal; 58/// Creates an <see cref="IDataProtector"/> given a list of purposes. 61/// <param name="purpose">The primary purpose used to create the <see cref="IDataProtector"/>.</param> 64/// <returns>An <see cref="IDataProtector"/> tied to the provided purpose chain.</returns> 70public static IDataProtector CreateProtector(this IDataProtectionProvider provider, string purpose, params string[] subPurposes) 79IDataProtector? protector = provider.CreateProtector(purpose); 84return protector ?? CryptoUtil.Fail<IDataProtector>("CreateProtector returned null."); 108/// Retrieves an <see cref="IDataProtector"/> from an <see cref="IServiceProvider"/> given a list of purposes. 114/// <returns>An <see cref="IDataProtector"/> tied to the provided purpose chain.</returns> 120public static IDataProtector GetDataProtector(this IServiceProvider services, IEnumerable<string> purposes) 129/// Retrieves an <see cref="IDataProtector"/> from an <see cref="IServiceProvider"/> given a list of purposes. 133/// <param name="purpose">The primary purpose used to create the <see cref="IDataProtector"/>.</param> 136/// <returns>An <see cref="IDataProtector"/> tied to the provided purpose chain.</returns> 142public static IDataProtector GetDataProtector(this IServiceProvider services, string purpose, params string[] subPurposes) 156public static string Protect(this IDataProtector protector, string plaintext) 183public static string Unprotect(this IDataProtector protector, string protectedData)
IDataProtectionProvider.cs (5)
7/// An interface that can be used to create <see cref="IDataProtector"/> instances. 12/// Creates an <see cref="IDataProtector"/> given a purpose. 15/// The purpose to be assigned to the newly-created <see cref="IDataProtector"/>. 20/// different <see cref="IDataProtector"/> instances created with two different <paramref name="purpose"/> 24IDataProtector CreateProtector(string purpose);
Microsoft.AspNetCore.DataProtection.Abstractions.Tests (48)
DataProtectionCommonExtensionsTests.cs (48)
24var mockProtector = new Mock<IDataProtector>(); 26var provider = mockProtector.Object; 41var mockProtector = new Mock<IDataProtector>(); 43var provider = mockProtector.Object; 56var finalExpectedProtector = new Mock<IDataProtector>().Object; 58var thirdMock = new Mock<IDataProtector>(); 60var secondMock = new Mock<IDataProtector>(); 62var firstMock = new Mock<IDataProtector>(); 66var retVal = firstMock.Object.CreateProtector((IEnumerable<string>)new string[] { "first", "second", "third" }); 76var finalExpectedProtector = new Mock<IDataProtector>().Object; 78var thirdMock = new Mock<IDataProtector>(); 80var secondMock = new Mock<IDataProtector>(); 82var firstMock = new Mock<IDataProtector>(); 86var retVal = firstMock.Object.CreateProtector("first", "second", "third"); 98var finalExpectedProtector = new Mock<IDataProtector>().Object; 99var firstMock = new Mock<IDataProtector>(); 103var retVal = firstMock.Object.CreateProtector("first", subPurposes); 143var mockProtector = new Mock<IDataProtector>(); 162var mockProtector = new Mock<IDataProtector>(); 179var finalExpectedProtector = new Mock<IDataProtector>().Object; 181var thirdMock = new Mock<IDataProtector>(); 183var secondMock = new Mock<IDataProtector>(); 185var firstMock = new Mock<IDataProtector>(); 193var retVal = services.GetDataProtector((IEnumerable<string>)new string[] { "first", "second", "third" }); 203var finalExpectedProtector = new Mock<IDataProtector>().Object; 205var thirdMock = new Mock<IDataProtector>(); 207var secondMock = new Mock<IDataProtector>(); 209var firstMock = new Mock<IDataProtector>(); 217var retVal = services.GetDataProtector("first", "second", "third"); 229var finalExpectedProtector = new Mock<IDataProtector>().Object; 230var firstMock = new Mock<IDataProtector>(); 237var retVal = services.GetDataProtector("first", subPurposes); 247Mock<IDataProtector> mockProtector = new Mock<IDataProtector>(); 261Mock<IDataProtector> mockProtector = new Mock<IDataProtector>(); 275Mock<IDataProtector> mockProtector = new Mock<IDataProtector>(); 288Mock<IDataProtector> mockProtector = new Mock<IDataProtector>(); 303Mock<IDataProtector> mockProtector = new Mock<IDataProtector>();
Microsoft.AspNetCore.DataProtection.Extensions (14)
DataProtectionAdvancedExtensions.cs (4)
65/// Converts an <see cref="IDataProtector"/> into an <see cref="ITimeLimitedDataProtector"/> 68/// <param name="protector">The <see cref="IDataProtector"/> to convert to a time-limited protector.</param> 70public static ITimeLimitedDataProtector ToTimeLimitedDataProtector(this IDataProtector protector) 109public IDataProtector CreateProtector(string purpose)
TimeLimitedDataProtector.cs (10)
14/// Wraps an existing <see cref="IDataProtector"/> and appends a purpose that allows 21private readonly IDataProtector _innerProtector; 22private IDataProtector? _innerProtectorWithTimeLimitedPurpose; // created on-demand 24public TimeLimitedDataProtector(IDataProtector innerProtector) 36private IDataProtector GetInnerProtectorWithTimeLimitedPurpose() 39var retVal = Volatile.Read(ref _innerProtectorWithTimeLimitedPurpose); 42var newValue = _innerProtector.CreateProtector(MyPurposeString); // we always append our purpose to the end of the chain 107IDataProtector IDataProtectionProvider.CreateProtector(string purpose) 114byte[] IDataProtector.Protect(byte[] plaintext) 122byte[] IDataProtector.Unprotect(byte[] protectedData)
Microsoft.AspNetCore.DataProtection.Extensions.Tests (20)
DataProtectionProviderTests.cs (11)
34var protector = DataProtectionProvider.Create(directory).CreateProtector("purpose"); 69var protector = provider.CreateProtector("Protector"); 100var protector = DataProtectionProvider.Create(directory, configure => 144var protector = DataProtectionProvider.Create(directory, certificate).CreateProtector("purpose"); 149var unprotector = DataProtectionProvider.Create(directory, o => o.UnprotectKeysWithAnyCertificate(certWithoutKey)).CreateProtector("purpose"); 195var protector = DataProtectionProvider.Create(directory, certWithKey).CreateProtector("purpose"); 198var keylessUnprotector = DataProtectionProvider.Create(directory).CreateProtector("purpose"); 201var unprotector = DataProtectionProvider.Create(directory, o => o.UnprotectKeysWithAnyCertificate(certInStore, certWithKey)).CreateProtector("purpose"); 228var protector = DataProtectionProvider.Create(directory, certificate).CreateProtector("purpose"); 257var protector = DataProtectionProvider.Create("Test", certificate).CreateProtector("purpose"); 297var protector = DataProtectionProvider
TimeLimitedDataProtectorTests.cs (9)
24var mockInnerProtector = new Mock<IDataProtector>(); 34var subProtector = timeLimitedProtector.CreateProtector("new purpose"); 47var mockInnerProtector = new Mock<IDataProtector>(); 57var subProtector = timeLimitedProtector.CreateProtector("new purpose"); 71var mockInnerProtector = new Mock<IDataProtector>(); 95var mockInnerProtector = new Mock<IDataProtector>(); 117var mockInnerProtector = new Mock<IDataProtector>(); 138var mockInnerProtector = new Mock<IDataProtector>(); 155var ephemeralProtector = new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("my purpose");
Microsoft.AspNetCore.DataProtection.Tests (23)
EphemeralDataProtectionProviderTests.cs (6)
16var dataProtector1 = new EphemeralDataProtectionProvider().CreateProtector("purpose"); 17var dataProtector2 = new EphemeralDataProtectionProvider(NullLoggerFactory.Instance).CreateProtector("purpose"); 34var dataProtector1 = dataProtectionProvider.CreateProtector("purpose"); 35var dataProtector2 = dataProtectionProvider.CreateProtector("different purpose"); 51var dataProtector1 = dataProtectionProvider.CreateProtector("purpose"); 52var dataProtector2 = dataProtectionProvider.CreateProtector("purpose"); // should be equivalent to the previous instance
KeyManagement\KeyRingBasedDataProtectorTests.cs (17)
24IDataProtector protector = new KeyRingBasedDataProtector( 59IDataProtector protector = new KeyRingBasedDataProtector( 97IDataProtector protector = new KeyRingBasedDataProtector( 114IDataProtector protector = new KeyRingBasedDataProtector( 129IDataProtector protector = new KeyRingBasedDataProtector( 143IDataProtector protector = new KeyRingBasedDataProtector( 161IDataProtector protector = new KeyRingBasedDataProtector( 179IDataProtector protector = new KeyRingBasedDataProtector( 213IDataProtector protector = new KeyRingBasedDataProtector( 266IDataProtector protector = new KeyRingBasedDataProtector( 302IDataProtector protector = new KeyRingBasedDataProtector( 337IDataProtector protector = new KeyRingBasedDataProtector( 400IDataProtector protector = new KeyRingBasedDataProtector( 440IDataProtector protector = new KeyRingBasedDataProtector( 486IDataProtector protector = new KeyRingBasedDataProtector( 536IDataProtector protector = new KeyRingBasedDataProtector( 608IDataProtector protector = new KeyRingBasedDataProtector(
Microsoft.AspNetCore.Identity (3)
DataProtectorTokenProvider.cs (3)
46/// Gets the <see cref="IDataProtector"/> for this instance. 49/// The <see cref="IDataProtector"/> for this instance. 51protected IDataProtector Protector { get; private set; }
Microsoft.AspNetCore.Mvc.TagHelpers.Test (3)
ComponentTagHelperTest.cs (1)
89x => x.CreateProtector(It.IsAny<string>()) == Mock.Of<IDataProtector>()))
PersistComponentStateTagHelperTest.cs (1)
30private static readonly IDataProtector _protector =
ProtectedPrerenderComponentApplicationStateTest.cs (1)
15private static readonly IDataProtector _protector = _provider.CreateProtector("Microsoft.AspNetCore.Components.Server.State");
Microsoft.AspNetCore.Mvc.ViewFeatures (1)
CookieTempDataProvider.cs (1)
25private readonly IDataProtector _dataProtector;
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (6)
CookieTempDataProviderTest.cs (6)
71var dataProtector = new Mock<IDataProtector>(MockBehavior.Strict); 389private CookieTempDataProvider GetProvider(IDataProtector dataProtector = null, CookieTempDataProviderOptions options = null) 412private readonly IDataProtector _dataProtector; 414public PassThroughDataProtectionProvider(IDataProtector dataProtector) 419public IDataProtector CreateProtector(string purpose) 431public IDataProtector CreateProtector(string purpose)
Microsoft.AspNetCore.Session (3)
CookieProtection.cs (2)
12internal static string Protect(IDataProtector protector, string data) 26internal static string Unprotect(IDataProtector protector, string? protectedText, ILogger logger)
SessionMiddleware.cs (1)
25private readonly IDataProtector _dataProtector;
NonDISample (1)
Program.cs (1)
27var protector = dataProtectionProvider.CreateProtector("Program.No-DI");
Redis (1)
Program.cs (1)
27var protector = services.GetDataProtector("sample-purpose");