Пример #1
0
        public static AuthnStatementType Load(XElement AuthnStatementElement)
        {
            var ct = new AuthnStatementType();

            foreach (var a in AuthnStatementElement.Attributes())
            {
                switch (a.Name.LocalName)
                {
                case "AuthnInstant": ct.AuthnInstant = (DateTime)a; break;

                case "SessionIndex": ct.SessionIndex = (string)a; break;

                case "SessionNotOnOrAfter": ct.SessionNotOnOrAfter = (DateTime)a; break;
                }
            }

            foreach (var e in AuthnStatementElement.Elements())
            {
                switch (e.Name.LocalName)
                {
                //case "SubjectLocality": ct.SubjectLocality = SubjectLocalityType.Load(e); break;
                case "AuthnContext": ct.AuthnContext = AuthnContextType.Load(e); break;
                }
            }
            return(ct);
        }
Пример #2
0
        public static AssertionType Load(XElement AssertionElement)
        {
            var at = new AssertionType();

            foreach (var a in AssertionElement.Attributes())
            {
                switch (a.Name.LocalName)
                {
                case "Id": at.ID = a.Value; break;

                case "Version": at.Version = a.Value; break;

                case "IssueInstant": at.IssueInstant = (DateTime)a; break;
                }
            }

            foreach (var e in AssertionElement.Elements())
            {
                switch (e.Name.LocalName)
                {
                case "Issuer": at.Issuer = IssuerType.Load(e); break;

                case "Signature":
                {
                    XmlDocument doc = new XmlDocument();
                    using (var rd = e.CreateReader())
                    {
                        doc.Load(rd);
                    }
                    at.Signature = new Signature();
                    at.Signature.LoadXml(doc.DocumentElement);

                    if (at.Signature.Id == null && e.Attribute("Id") != null)
                    {
                        at.Signature.Id = e.Attribute("Id").Value;
                    }
                }
                break;

                case "Subject": at.Subject = SubjectType.Load(e); break;

                case "Conditions": at.Conditions = ConditionsType.Load(e); break;

                //case "Advice": at.Advice = AdviceType.Load(e); break;
                case "AuthnStatement": at.Statements.Add(AuthnStatementType.Load(e)); break;

                case "AttributeStatement": at.Statements.Add(AttributeStatementType.Load(e)); break;

                //case "AuthzDecisionStatement": at.Statements.Add(AuthzDecisionStatementType.Load(e)); break;
                case "Statement": at.Statements.Add(StatementType.Load(e)); break;
                }
            }
            return(at);
        }