2020-03-24 20:30:03 +01:00
|
|
|
using System.Security.Claims;
|
|
|
|
|
|
2020-03-24 23:09:29 +01:00
|
|
|
namespace zero.Core.Entities
|
2020-03-24 20:30:03 +01:00
|
|
|
{
|
2020-04-03 18:03:36 +02:00
|
|
|
public class UserClaim : IUserClaim
|
2020-03-24 20:30:03 +01:00
|
|
|
{
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public string Type { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public string Value { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
public Claim ToClaim() => new Claim(Type, Value);
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2020-04-03 18:03:36 +02:00
|
|
|
public UserClaim FromClaim(Claim other)
|
2020-03-24 20:30:03 +01:00
|
|
|
{
|
|
|
|
|
Type = other?.Type;
|
|
|
|
|
Value = other?.Value;
|
2020-03-25 00:04:33 +01:00
|
|
|
return this;
|
2020-03-24 20:30:03 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-03 18:03:36 +02:00
|
|
|
public interface IUserClaim
|
2020-03-24 20:30:03 +01:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the claim type for this claim
|
|
|
|
|
/// </summary>
|
|
|
|
|
string Type { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the claim value for this claim
|
|
|
|
|
/// </summary>
|
|
|
|
|
string Value { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs a new claim with the type and value
|
|
|
|
|
/// </summary>
|
2020-04-03 18:03:36 +02:00
|
|
|
UserClaim FromClaim(Claim other);
|
2020-03-24 20:30:03 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Initializes by copying ClaimType and ClaimValue from the other claim
|
|
|
|
|
/// </summary>
|
|
|
|
|
Claim ToClaim();
|
|
|
|
|
}
|
|
|
|
|
}
|