yavsc/src/OAuth.AspNet.Token/MonoDataProtectionProvider.cs

38 lines
900 B
C#
Raw Normal View History

2016-05-17 18:22:18 +02:00
using System;
using System.IO;
2016-05-17 18:22:18 +02:00
using Microsoft.AspNet.DataProtection;
2016-05-17 18:22:18 +02:00
public class MonoDataProtectionProvider : IDataProtectionProvider
{
2016-05-17 18:22:18 +02:00
private readonly string appName;
public MonoDataProtectionProvider()
: this(Guid.NewGuid().ToString())
{ }
public MonoDataProtectionProvider(DirectoryInfo dataProtectionDirInfo)
: this(Guid.NewGuid().ToString())
{
}
2016-05-17 18:22:18 +02:00
public MonoDataProtectionProvider(string appName)
{
if (appName == null) { throw new ArgumentNullException("appName"); }
this.appName = appName;
2016-05-17 18:22:18 +02:00
}
public IDataProtector Create(params string[] purposes)
{
if (purposes == null) { throw new ArgumentNullException("profile"); }
2016-05-17 18:22:18 +02:00
return new MonoDataProtector(appName, purposes);
2016-05-17 18:22:18 +02:00
}
public IDataProtector CreateProtector(string purpose)
{
return Create(new string[] { purpose });
2016-05-17 18:22:18 +02:00
}
}