// Copyright Epic Games, Inc. All Rights Reserved.
using System.Security.Claims;
namespace HordeServer.Users
{
///
/// Claim for a user
///
public interface IUserClaim
{
///
/// Name of the claim
///
public string Type { get; }
///
/// Value of the claim
///
public string Value { get; }
}
///
/// New claim document
///
public class UserClaim : IUserClaim
{
///
public string Type { get; set; }
///
public string Value { get; set; }
///
/// Constructor
///
///
///
public UserClaim(string type, string value)
{
Type = type;
Value = value;
}
///
/// Constructor
///
/// Claim to construct from
public UserClaim(IUserClaim other)
: this(other.Type, other.Value)
{
}
///
/// Constructs a UserClaim from a Claim object
///
/// Claim object
///
public static UserClaim FromClaim(Claim claim)
{
return new UserClaim(claim.Type, claim.Value);
}
///
/// Conversion operator from NET claims
///
///
public static implicit operator UserClaim(Claim claim) => FromClaim(claim);
}
}