39 lines
900 B
C#
39 lines
900 B
C#
8 years ago
|
|
||
|
|
||
|
|
||
|
using System;
|
||
8 years ago
|
using System.IO;
|
||
8 years ago
|
using Microsoft.AspNet.DataProtection;
|
||
7 years ago
|
|
||
8 years ago
|
public class MonoDataProtectionProvider : IDataProtectionProvider
|
||
7 years ago
|
{
|
||
8 years ago
|
private readonly string appName;
|
||
|
|
||
|
public MonoDataProtectionProvider()
|
||
|
: this(Guid.NewGuid().ToString())
|
||
|
{ }
|
||
|
|
||
7 years ago
|
public MonoDataProtectionProvider(DirectoryInfo dataProtectionDirInfo)
|
||
8 years ago
|
: this(Guid.NewGuid().ToString())
|
||
|
{
|
||
7 years ago
|
|
||
8 years ago
|
}
|
||
8 years ago
|
public MonoDataProtectionProvider(string appName)
|
||
|
{
|
||
7 years ago
|
if (appName == null) { throw new ArgumentNullException("appName"); }
|
||
|
this.appName = appName;
|
||
8 years ago
|
}
|
||
|
|
||
|
public IDataProtector Create(params string[] purposes)
|
||
|
{
|
||
7 years ago
|
if (purposes == null) { throw new ArgumentNullException("profile"); }
|
||
8 years ago
|
|
||
7 years ago
|
return new MonoDataProtector(appName, purposes);
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
public IDataProtector CreateProtector(string purpose)
|
||
|
{
|
||
|
return Create(new string[] { purpose });
|
||
8 years ago
|
}
|
||
|
}
|