Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public static AttributeStatementType Load(XElement AttributeStatementElement)
        {
            var ct = new AttributeStatementType();

            foreach (var e in AttributeStatementElement.Elements())
            {
                switch (e.Name.LocalName)
                {
                case "Attribute": ct.Add(AttributeType.Load(e)); break;
                    //case "EncryptedAttribute": ct.Add( EncryptedElementType.Load(e)); break;
                }
            }
            return(ct);
        }