Show / Hide Table of Contents

Class WMPrincipal

Abstract base class representing an entity to which access privileges can be granted.

Inheritance
object
WMPrincipal
WMOrganization
WMProxyPrincipal
WMUser
Implements
IDbEntity
IWMEntity
IPolicyAssignable
IWMAssetOwner
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Quantellia.WMServer.Auth
Assembly: WMServer.dll
Syntax
public abstract class WMPrincipal : IDbEntity, IWMEntity, IPolicyAssignable, IWMAssetOwner

Constructors

WMPrincipal()

Default constructor initializes ID with a new GUID.

Declaration
public WMPrincipal()

WMPrincipal(string)

Declaration
public WMPrincipal(string id)
Parameters
Type Name Description
string id

Properties

CreatedBy

ID of the user that created this entity.

Declaration
public string CreatedBy { get; set; }
Property Value
Type Description
string

CreatedDate

Date and time at which this entity was last updated.

Declaration
public DateTime CreatedDate { get; set; }
Property Value
Type Description
DateTime

ID

Declaration
public string ID { get; protected set; }
Property Value
Type Description
string

LastUpdatedBy

ID of the user that last updated this entity.

Declaration
public string LastUpdatedBy { get; set; }
Property Value
Type Description
string

LastUpdatedDate

Date and time at which this entity was last updated.

Declaration
public DateTime LastUpdatedDate { get; set; }
Property Value
Type Description
DateTime

LoginName

Name used as login credentials.

Declaration
public string LoginName { get; set; }
Property Value
Type Description
string

Name

Actual name of the principal

Declaration
public string Name { get; set; }
Property Value
Type Description
string

Password

Password used for authentication.

Declaration
public string Password { get; set; }
Property Value
Type Description
string

Permissions

List of Permissions assigned to this WMPrincipal

Declaration
public virtual List<Permission> Permissions { get; }
Property Value
Type Description
List<Permission>

Policies

List of Policy instances assigned to this WMPrincipal

Declaration
public virtual List<Policy> Policies { get; }
Property Value
Type Description
List<Policy>

Status

Declaration
public PrincipalStatus Status { get; set; }
Property Value
Type Description
PrincipalStatus

Methods

Authorized(string, string)

Determines if a user is allowed to access an entity with OwnerID and OwnerType. If the entity's type is WMUser, check against the user's ID. if the entity's type is WMOrganization, check that the user belongs to that organization.

Declaration
public bool Authorized(string entityID, string entityType)
Parameters
Type Name Description
string entityID

The OwnerID of the entity.

string entityType

The OwnerType of the entity.

Returns
Type Description
bool

Authorized(string, string, string, string)

Determines if a user is allowed to access an entity with OwnerID and OwnerType. If the entity's type is WMUser, check against the user's ID. if the entity's type is WMOrganization, check that the user belongs to that organization.

Declaration
public static bool Authorized(string userID, string userType, string entityID, string entityType)
Parameters
Type Name Description
string userID

The ID of the user.

string userType

The type of the user.

string entityID

The OwnerID of the entity.

string entityType

The OwnerType of the entity.

Returns
Type Description
bool

AuthorizedAsync(string, string)

Determines if a user is allowed to access an entity with OwnerID and OwnerType. If the entity's type is WMUser, check against the user's ID. if the entity's type is WMOrganization, check that the user belongs to that organization.

Declaration
public Task<bool> AuthorizedAsync(string entityID, string entityType)
Parameters
Type Name Description
string entityID

The OwnerID of the entity.

string entityType

The OwnerType of the entity.

Returns
Type Description
Task<bool>

AuthorizedAsync(string, string, string)

Determines if a user is allowed to access an entity with OwnerID and OwnerType. If the entity's type is WMUser, check against the user's ID. if the entity's type is WMOrganization, check that the user belongs to that organization.

Declaration
public static Task<bool> AuthorizedAsync(string userID, string entityID, string entityType)
Parameters
Type Name Description
string userID

The ID of the user.

string entityID

The OwnerID of the entity.

string entityType

The OwnerType of the entity.

Returns
Type Description
Task<bool>

EnsureAuthorizedAsync(WMAssetBase)

Throws an exception if the principal is not allowed to access the given asset.

Declaration
public Task EnsureAuthorizedAsync(WMAssetBase asset)
Parameters
Type Name Description
WMAssetBase asset

The asset.

Returns
Type Description
Task

EnsureAuthorizedAsync<T>(WMAssetBaseDTO<T>)

Throws an exception if the principal is not allowed to access the given asset.

Declaration
public Task EnsureAuthorizedAsync<T>(WMAssetBaseDTO<T> a_dto) where T : WMAssetBase, new()
Parameters
Type Name Description
WMAssetBaseDTO<T> a_dto

The asset DTO.

Returns
Type Description
Task
Type Parameters
Name Description
T

The model type of the DTO provided.

Get(string, string)

Static factory that gets the instance of a WMPrincipal sub-class depending on its type and ID.

Declaration
public static Task<WMPrincipal> Get(string typeName, string id)
Parameters
Type Name Description
string typeName
string id
Returns
Type Description
Task<WMPrincipal>

HashPassword(string, out string)

Declaration
public static string HashPassword(string password, out string salt)
Parameters
Type Name Description
string password
string salt
Returns
Type Description
string
Exceptions
Type Condition
ArgumentNullException

VerifyPassword(string, string, string)

Declaration
public static bool VerifyPassword(string password, string hash, string salt)
Parameters
Type Name Description
string password
string hash
string salt
Returns
Type Description
bool
Exceptions
Type Condition
ArgumentNullException

Implements

IDbEntity
IWMEntity
IPolicyAssignable
IWMAssetOwner
In this article
Back to top Copyright © 2025 Quantellia LLC.    Version 2.0.0 Revision 399     Last Updated 1/15/2025    DRAFT DOCUMENTATION. SUBJECT TO CHANGE