public IPrincipal GetPrincipal(User user)
        {
            var identity = new UserIdentity(user, Constants.SchemeTypes.Basic);

            identity.AddClaim(new Claim(ClaimTypes.Name, user.Fullname));
            identity.AddClaim(new Claim(ClaimTypes.Role, Constants.RoleNames.Standard));

            return new ClaimsPrincipal(identity);
        }
        public bool SetPrincipal(User user)
        {
            IPrincipal principal = GetPrincipal(user);
            if (principal == null)
            {
                Console.WriteLine("System could not create principal for user {0}", user.Username);
                return false;
            }

            Thread.CurrentPrincipal = principal;
            if (HttpContext.Current != null)
            {
                HttpContext.Current.User = principal;
            }

            return true;
        }
 public UserIdentity(User user, string type) : base(user.Username,type)
 {
     User = user;
 }