What is the idea behind IIdentity and IPrincipal in .NET

前端 未结 4 1505
清歌不尽
清歌不尽 2021-01-30 16:23

So, what is the purpose for existence of both IIdentity and IPrincipal, and not some IIdentityMergedWithPrincipal? When is it not enough t

4条回答
  •  北恋
    北恋 (楼主)
    2021-01-30 17:12

    public class HBPrincipal : IPrincipal
    {
         private HBIdentity _identity;
    
         public HBPrincipal(HBIdentity identity)
        {
            _identity = identity;
        }
    
        public IIdentity Identity
        {
            get
            {
                return _identity;
            }
        }
    
        public bool IsInRole(string role)
        {
            // TODO implement roles
            return false;
        }
    }
    

提交回复
热议问题