/// <summary> /// Get role entity from principal. /// </summary> /// <typeparam name="TUser">Type of user.</typeparam> /// <param name="principal">Principal.</param> /// <returns></returns> public static TUser GetUser <TUser>(this IPrincipal principal) where TUser : class, IRoleEntity { ALEXFWPrincipal cp = principal as ALEXFWPrincipal; return(GetUser <TUser>(cp)); }
/// <summary> /// Determines whether the current principal belongs to the specified role. /// </summary> /// <param name="principal">ALEXFW principal.</param> /// <param name="role">Role.</param> /// <returns></returns> public static bool IsInRole(this IPrincipal principal, object role) { ALEXFWPrincipal item = principal as ALEXFWPrincipal; if (item == null) { throw new NotSupportedException("Only support with ALEXFW principal."); } return(item.IsInRole(role)); }
/// <summary> /// Get role entity from principal. /// </summary> /// <typeparam name="TUser">Type of user.</typeparam> /// <param name="principal">Principal.</param> /// <returns></returns> public static TUser GetUser <TUser>(this ALEXFWPrincipal principal) where TUser : class, IRoleEntity { if (principal == null) { return(null); } TUser roleEntity = principal.RoleEntity as TUser; return(roleEntity); }
internal ALEXFWIdentity(ALEXFWPrincipal principal) { _Principal = principal; }