コード例 #1
0
        public override ClaimsPrincipal ValidateToken(string token, TokenValidationParameters validationParameters, out SecurityToken validatedToken)
        {
            ClaimsPrincipal principal       = base.ValidateToken(token, validationParameters, out validatedToken);
            var             parsedToken     = base.ReadJwtToken(token);
            TicketIdentity  identity        = TicketIdentity.ToIdentity(principal.Identity as ClaimsIdentity);
            TicketPrincipal TicketPrincipal = new TicketPrincipal(identity);

            return(TicketPrincipal);
        }
コード例 #2
0
 private ClaimsIdentity GetIdentity(IUser user)
 {
     if (user != null)
     {
         TicketIdentity myIdentity = new TicketIdentity(new GenericIdentity(user.Email), new List <Claim>(), "Standard", "name", "role", user);
         return(myIdentity);
     }
     else
     {
         return(null);
     }
 }
コード例 #3
0
        public static TicketIdentity ToIdentity(ClaimsIdentity identity)
        {
            TicketIdentity myIdentity = new TicketIdentity(identity, identity.Claims, identity.AuthenticationType, identity.NameClaimType, identity.RoleClaimType);

            return(myIdentity);
        }
コード例 #4
0
 public TicketPrincipal(TicketIdentity identity) : base()
 {
     this._identity     = identity;
     identity.Principal = this;
     this.AddIdentity(identity);
 }