예제 #1
0
        private IEnumerable <ClaimsIdentity> CreateClaims()
        {
            ThrowOnNotValid();

            foreach (XmlElement assertionNode in AllAssertionElementNodes)
            {
                using (var reader = new XmlNodeReader(assertionNode))
                {
                    MorePublicSaml2SecurityTokenHandler handler = MorePublicSaml2SecurityTokenHandler.DefaultInstance;

                    var token = (Saml2SecurityToken)MorePublicSaml2SecurityTokenHandler.DefaultInstance.ReadToken(reader);
                    handler.DetectReplayedToken(token);

                    var validateAudience = token.Assertion.Conditions.AudienceRestrictions.Count > 0;

                    handler.ValidateConditions(token.Assertion.Conditions, validateAudience);

                    yield return(handler.CreateClaims(token));
                }
            }
        }
예제 #2
0
        private IEnumerable <ClaimsIdentity> CreateClaims()
        {
            ThrowOnNotValid();

            foreach (XmlElement assertionNode in xmlDocument.DocumentElement.ChildNodes.Cast <XmlElement>()
                     .Where(xe => xe.LocalName == "Assertion" && xe.NamespaceURI == Saml2Namespaces.Saml2Name))
            {
                using (var reader = new XmlNodeReader(assertionNode))
                {
                    MorePublicSaml2SecurityTokenHandler handler = MorePublicSaml2SecurityTokenHandler.DefaultInstance;

                    var token = (Saml2SecurityToken)MorePublicSaml2SecurityTokenHandler.DefaultInstance.ReadToken(reader);
                    handler.DetectReplayedToken(token);

                    var validateAudience = token.Assertion.Conditions.AudienceRestrictions.Count > 0;

                    handler.ValidateConditions(token.Assertion.Conditions, validateAudience);

                    yield return(handler.CreateClaims(token));
                }
            }
        }