コード例 #1
0
        //Return the IAM and extravalue claims value
        private string _ExtractClaims(string pJwt, string pJwtIamName, string pExtraValuePath, bool isRecusive = false)
        {
            JwtSecurityTokenHandler handler = new JwtSecurityTokenHandler();
            JwtSecurityToken        token   = handler.ReadJwtToken(pJwt);

            bool   getExtraValue = !string.IsNullOrEmpty(pExtraValuePath);
            string fetchNeed     = null;

            string ret = string.Empty;

            foreach (Claim claim in token.Claims)
            {
                // Check if is fetch needed
                if (claim.Type == CNST_FETCH_NEED)
                {
                    fetchNeed = claim.Value;
                }

                // Get IAM
                if (claim.Type == pJwtIamName)
                {
                    ret = claim.Value;
                }

                // Get Extra Nodes
                if (getExtraValue && claim.Type == pExtraValuePath)
                {
                    if (ExtraNode == null)
                    {
                        ExtraNode = new HashSet <string>();
                    }
                    if (!ExtraNode.Contains(claim.Value))
                    {
                        ExtraNode.Add(claim.Value);
                    }
                }

                // Get User Email
                if (claim.Type == "https://travelgatex.com/member_id")
                {
                    UserEmail = claim.Value;
                }
            }

            if (!isRecusive && fetchNeed == "true")
            {
                string newBearer = _GetFullBearer(pJwt);
                ret = _ExtractClaims(newBearer, pJwtIamName, pExtraValuePath, true);
            }


            return(ret);
        }
コード例 #2
0
 //Constructor
 public ExtraNode()
 {
     this.data  = null;
     this.next  = null;
     this.check = false;
 }