Exemplo n.º 1
0
        public static MolecularIdentity ToIdentity(ClaimsIdentity identity)
        {
            MolecularIdentity myIdentity = new MolecularIdentity(identity, identity.Claims, identity.AuthenticationType, identity.NameClaimType, identity.RoleClaimType);

            //(myIdentity.User as IdentityUser).SetIdentiyFromClaims(identity);
            return(myIdentity);
        }
        public override ClaimsPrincipal ValidateToken(string token, TokenValidationParameters validationParameters, out SecurityToken validatedToken)
        {
            ClaimsPrincipal    principal          = base.ValidateToken(token, validationParameters, out validatedToken);
            var                parsedToken        = base.ReadJwtToken(token);
            MolecularIdentity  identity           = MolecularIdentity.ToIdentity(principal.Identity as ClaimsIdentity);
            MolecularPrincipal molecularPrincipal = new MolecularPrincipal(identity);

            return(molecularPrincipal);
        }
Exemplo n.º 3
0
 private ClaimsIdentity GetIdentity(IUser user)
 {
     if (user != null)
     {
         MolecularIdentity myIdentity = new MolecularIdentity(new GenericIdentity(user.Email), new List <Claim>(), "Standard", "name", "role", user);
         return(myIdentity);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 4
0
 public MolecularPrincipal(MolecularIdentity identity) : base()
 {
     this._identity     = identity;
     identity.Principal = this;
     this.AddIdentity(identity);
 }