files tree made better.
This commit is contained in:
parent
ffbf032480
commit
ccc91bbf19
1630 changed files with 18209 additions and 41860 deletions
72
src/OAuth.AspNet.AuthServer/AuthenticationTokenProvider.cs
Normal file
72
src/OAuth.AspNet.AuthServer/AuthenticationTokenProvider.cs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OAuth.AspNet.AuthServer
|
||||
{
|
||||
|
||||
public class AuthenticationTokenProvider : IAuthenticationTokenProvider
|
||||
{
|
||||
public Action<AuthenticationTokenCreateContext> OnCreate { get; set; }
|
||||
public Func<AuthenticationTokenCreateContext, Task> OnCreateAsync { get; set; }
|
||||
public Action<AuthenticationTokenReceiveContext> OnReceive { get; set; }
|
||||
public Func<AuthenticationTokenReceiveContext, Task> OnReceiveAsync { get; set; }
|
||||
|
||||
public virtual void Create(AuthenticationTokenCreateContext context)
|
||||
{
|
||||
if (OnCreateAsync != null && OnCreate == null)
|
||||
{
|
||||
throw new InvalidOperationException("Authentication token did not provide an OnCreate method.");
|
||||
}
|
||||
if (OnCreate != null)
|
||||
{
|
||||
OnCreate.Invoke(context);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task CreateAsync(AuthenticationTokenCreateContext context)
|
||||
{
|
||||
if (OnCreateAsync != null && OnCreate == null)
|
||||
{
|
||||
throw new InvalidOperationException("Authentication token did not provide an OnCreate method.");
|
||||
}
|
||||
if (OnCreateAsync != null)
|
||||
{
|
||||
await OnCreateAsync.Invoke(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
Create(context);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Receive(AuthenticationTokenReceiveContext context)
|
||||
{
|
||||
if (OnReceiveAsync != null && OnReceive == null)
|
||||
{
|
||||
throw new InvalidOperationException("Authentication token did not provide an OnReceive method.");
|
||||
}
|
||||
|
||||
if (OnReceive != null)
|
||||
{
|
||||
OnReceive.Invoke(context);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
|
||||
{
|
||||
if (OnReceiveAsync != null && OnReceive == null)
|
||||
{
|
||||
throw new InvalidOperationException("Authentication token did not provide an OnReceive method.");
|
||||
}
|
||||
if (OnReceiveAsync != null)
|
||||
{
|
||||
await OnReceiveAsync.Invoke(context);
|
||||
}
|
||||
else
|
||||
{
|
||||
Receive(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue