refactorisation : separation du code serveur d'authentification
This commit is contained in:
parent
f8eef31fb3
commit
b462350d72
57 changed files with 5452 additions and 108 deletions
43
OAuth.AspNet.AuthServer/AuthenticationTokenCreateContext.cs
Normal file
43
OAuth.AspNet.AuthServer/AuthenticationTokenCreateContext.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Authentication;
|
||||
using System;
|
||||
|
||||
namespace OAuth.AspNet.AuthServer
|
||||
{
|
||||
|
||||
public class AuthenticationTokenCreateContext : BaseContext
|
||||
{
|
||||
private readonly ISecureDataFormat<AuthenticationTicket> _secureDataFormat;
|
||||
|
||||
public AuthenticationTokenCreateContext(HttpContext context, ISecureDataFormat<AuthenticationTicket> secureDataFormat, AuthenticationTicket ticket) : base(context)
|
||||
{
|
||||
if (secureDataFormat == null)
|
||||
throw new ArgumentNullException(nameof(secureDataFormat));
|
||||
|
||||
if (ticket == null)
|
||||
throw new ArgumentNullException(nameof(ticket));
|
||||
|
||||
_secureDataFormat = secureDataFormat;
|
||||
|
||||
Ticket = ticket;
|
||||
}
|
||||
|
||||
public string Token { get; protected set; }
|
||||
|
||||
public AuthenticationTicket Ticket { get; protected set; }
|
||||
|
||||
public string SerializeTicket()
|
||||
{
|
||||
return _secureDataFormat.Protect(Ticket);
|
||||
}
|
||||
|
||||
public void SetToken(string tokenValue)
|
||||
{
|
||||
if (tokenValue == null)
|
||||
throw new ArgumentNullException(nameof(tokenValue));
|
||||
|
||||
Token = tokenValue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue