mirror of https://github.com/abpframework/abp.git
3 changed files with 66 additions and 64 deletions
@ -0,0 +1,57 @@ |
|||||
|
using System; |
||||
|
using System.Security.Claims; |
||||
|
using JetBrains.Annotations; |
||||
|
using Volo.Abp.Domain.Entities; |
||||
|
|
||||
|
namespace Volo.Abp.Identity |
||||
|
{ |
||||
|
public abstract class IdentityClaim : Entity<Guid> |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Gets or sets the claim type for this claim.
|
||||
|
/// </summary>
|
||||
|
public virtual string ClaimType { get; protected set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the claim value for this claim.
|
||||
|
/// </summary>
|
||||
|
public virtual string ClaimValue { get; protected set; } |
||||
|
|
||||
|
protected IdentityClaim() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected internal IdentityClaim(Guid id, [NotNull] Claim claim) |
||||
|
: this(id, claim.Type, claim.Value) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected internal IdentityClaim(Guid id, [NotNull] string claimType, string claimValue) |
||||
|
{ |
||||
|
Check.NotNull(claimType, nameof(claimType)); |
||||
|
|
||||
|
Id = id; |
||||
|
ClaimType = claimType; |
||||
|
ClaimValue = claimValue; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Creates a Claim instance from this entity.
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
public virtual Claim ToClaim() |
||||
|
{ |
||||
|
return new Claim(ClaimType, ClaimValue); |
||||
|
} |
||||
|
|
||||
|
public virtual void SetClaim([NotNull] Claim claim) |
||||
|
{ |
||||
|
Check.NotNull(claim, nameof(claim)); |
||||
|
|
||||
|
ClaimType = claim.Type; |
||||
|
ClaimValue = claim.Value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,58 +1,34 @@ |
|||||
using System; |
using System; |
||||
using System.Security.Claims; |
using System.Security.Claims; |
||||
using JetBrains.Annotations; |
using JetBrains.Annotations; |
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace Volo.Abp.Identity |
namespace Volo.Abp.Identity |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Represents a claim that is granted to all users within a role.
|
/// Represents a claim that is granted to all users within a role.
|
||||
/// </summary>
|
/// </summary>
|
||||
public class IdentityRoleClaim : Entity<Guid> |
public class IdentityRoleClaim : IdentityClaim |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Gets or sets the of the primary key of the role associated with this claim.
|
/// Gets or sets the of the primary key of the role associated with this claim.
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual Guid RoleId { get; protected set; } |
public virtual Guid RoleId { get; protected set; } |
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets or sets the claim type for this claim.
|
|
||||
/// </summary>
|
|
||||
public virtual string ClaimType { get; protected set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets or sets the claim value for this claim.
|
|
||||
/// </summary>
|
|
||||
public virtual string ClaimValue { get; protected set; } |
|
||||
|
|
||||
protected IdentityRoleClaim() |
protected IdentityRoleClaim() |
||||
{ |
{ |
||||
|
|
||||
} |
} |
||||
|
|
||||
protected internal IdentityRoleClaim(Guid id, Guid roleId, [NotNull] Claim claim) |
protected internal IdentityRoleClaim(Guid id, Guid roleId, [NotNull] Claim claim) |
||||
: this(id, roleId, claim.Type, claim.Value) |
: base(id, claim) |
||||
{ |
{ |
||||
|
RoleId = roleId; |
||||
} |
} |
||||
|
|
||||
protected internal IdentityRoleClaim(Guid id, Guid roleId, [NotNull] string claimType, string claimValue) |
protected internal IdentityRoleClaim(Guid id, Guid roleId, [NotNull] string claimType, string claimValue) |
||||
|
: base(id, claimType, claimValue) |
||||
{ |
{ |
||||
Check.NotNull(claimType, nameof(claimType)); |
|
||||
|
|
||||
Id = id; |
|
||||
RoleId = roleId; |
RoleId = roleId; |
||||
ClaimType = claimType; |
|
||||
ClaimValue = claimValue; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Constructs a new claim with the type and value.
|
|
||||
/// </summary>
|
|
||||
/// <returns></returns>
|
|
||||
public virtual Claim ToClaim() |
|
||||
{ |
|
||||
return new Claim(ClaimType, ClaimValue); |
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -1,66 +1,35 @@ |
|||||
using System; |
using System; |
||||
using System.Security.Claims; |
using System.Security.Claims; |
||||
using JetBrains.Annotations; |
using JetBrains.Annotations; |
||||
using Volo.Abp.Domain.Entities; |
|
||||
|
|
||||
namespace Volo.Abp.Identity |
namespace Volo.Abp.Identity |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Represents a claim that a user possesses.
|
/// Represents a claim that a user possesses.
|
||||
/// </summary>
|
/// </summary>
|
||||
public class IdentityUserClaim : Entity<Guid> |
public class IdentityUserClaim : IdentityClaim |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Gets or sets the primary key of the user associated with this claim.
|
/// Gets or sets the primary key of the user associated with this claim.
|
||||
/// </summary>
|
/// </summary>
|
||||
public virtual Guid UserId { get; protected set; } |
public virtual Guid UserId { get; protected set; } |
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets or sets the claim type for this claim.
|
|
||||
/// </summary>
|
|
||||
public virtual string ClaimType { get; protected set; } |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets or sets the claim value for this claim.
|
|
||||
/// </summary>
|
|
||||
public virtual string ClaimValue { get; protected set; } |
|
||||
|
|
||||
protected IdentityUserClaim() |
protected IdentityUserClaim() |
||||
{ |
{ |
||||
|
|
||||
} |
} |
||||
|
|
||||
protected internal IdentityUserClaim(Guid id, Guid userId, [NotNull] Claim claim) |
protected internal IdentityUserClaim(Guid id, Guid userId, [NotNull] Claim claim) |
||||
: this(id, userId, claim.Type, claim.Value) |
: base(id, claim) |
||||
{ |
{ |
||||
|
UserId = userId; |
||||
|
|
||||
} |
} |
||||
|
|
||||
protected internal IdentityUserClaim(Guid id, Guid userId, [NotNull] string claimType, string claimValue) |
protected internal IdentityUserClaim(Guid id, Guid userId, [NotNull] string claimType, string claimValue) |
||||
|
: base(id, claimType, claimValue) |
||||
{ |
{ |
||||
Check.NotNull(claimType, nameof(claimType)); |
|
||||
|
|
||||
Id = id; |
|
||||
UserId = userId; |
UserId = userId; |
||||
ClaimType = claimType; |
|
||||
ClaimValue = claimValue; |
|
||||
} |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Creates a Claim instance from this entity.
|
|
||||
/// </summary>
|
|
||||
/// <returns></returns>
|
|
||||
public virtual Claim ToClaim() |
|
||||
{ |
|
||||
return new Claim(ClaimType, ClaimValue); |
|
||||
} |
|
||||
|
|
||||
public void SetClaim([NotNull] Claim claim) |
|
||||
{ |
|
||||
Check.NotNull(claim, nameof(claim)); |
|
||||
|
|
||||
ClaimType = claim.Type; |
|
||||
ClaimValue = claim.Value; |
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
Loading…
Reference in new issue