/
IdentityRoleClaim.cs
54 lines (47 loc) · 1.81 KB
/
IdentityRoleClaim.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Security.Claims;
namespace Microsoft.AspNetCore.Identity
{
/// <summary>
/// Represents a claim that is granted to all users within a role.
/// </summary>
/// <typeparam name="TKey">The type of the primary key of the role associated with this claim.</typeparam>
public class IdentityRoleClaim<TKey> where TKey : IEquatable<TKey>
{
/// <summary>
/// Gets or sets the identifier for this role claim.
/// </summary>
public virtual int Id { get; set; }
/// <summary>
/// Gets or sets the of the primary key of the role associated with this claim.
/// </summary>
public virtual TKey RoleId { get; set; }
/// <summary>
/// Gets or sets the claim type for this claim.
/// </summary>
public virtual string ClaimType { get; set; }
/// <summary>
/// Gets or sets the claim value for this claim.
/// </summary>
public virtual string ClaimValue { get; set; }
/// <summary>
/// Constructs a new claim with the type and value.
/// </summary>
/// <returns>The <see cref="Claim"/> that was produced.</returns>
public virtual Claim ToClaim()
{
return new Claim(ClaimType, ClaimValue);
}
/// <summary>
/// Initializes by copying ClaimType and ClaimValue from the other claim.
/// </summary>
/// <param name="other">The claim to initialize from.</param>
public virtual void InitializeFromClaim(Claim other)
{
ClaimType = other?.Type;
ClaimValue = other?.Value;
}
}
}