コード例 #1
0
ファイル: XRD.cs プロジェクト: AArnott/dotnetxri
        //throws UriFormatException, ParseException
        /**
        * This method populates the obj from DOM.  It does not keep a
        * copy of the DOM around.  Whitespace information is lost in this process.
        */
        public void fromDOM(XmlElement oElem)
        {
            reset();

            // get the id attribute
            if (oElem.hasAttributeNS(Tags.NS_XML, Tags.ATTR_ID_LOW))
                xmlID = oElem.getAttributeNS(Tags.NS_XML, Tags.ATTR_ID_LOW);

            if (oElem.hasAttributeNS(Tags.NS_XML, Tags.ATTR_IDREF))
                idRef = oElem.getAttributeNS(Tags.NS_XML, Tags.ATTR_IDREF);

            if (oElem.hasAttributeNS(null, Tags.ATTR_XRD_VERSION))
                version = oElem.getAttributeNS(null, Tags.ATTR_XRD_VERSION);

            for (XmlElement oChild = (XmlElement)oElem.FirstChild; oChild != null; oChild = (XmlElement)oChild.NextSibling) {

                string sChildName = oChild.LocalName ?? oChild.Name;

                if (sChildName.Equals(Tags.TAG_TYPE)) {
                    XRDType t = new XRDType();
                    t.fromXML(oChild);
                    types.Add(t);
                } else if (sChildName.Equals(Tags.TAG_QUERY)) {
                    Query q = new Query();
                    q.fromXML(oChild);
                    this.query = q;
                } else if (sChildName.Equals(Tags.TAG_STATUS)) {
                    Status s = new Status();
                    s.fromXML(oChild);
                    this.status = s;
                } else if (sChildName.Equals(Tags.TAG_SERVERSTATUS)) {
                    ServerStatus s = new ServerStatus();
                    s.fromXML(oChild);
                    this.serverStatus = s;
                } else if (sChildName.Equals(Tags.TAG_EXPIRES)) {
                    // only accept the first Expires element and make sure it
                    expires = new Expires(XmlConvert.ToDateTime(oChild.FirstChild.Value));
                } else if (sChildName.Equals(Tags.TAG_PROVIDERID)) {
                    ProviderID p = new ProviderID();
                    p.fromXML(oChild);
                    this.providerID = p;
                } else if (sChildName.Equals(Tags.TAG_LOCALID)) {
                    addLocalID(new LocalID(oChild));
                } else if (sChildName.Equals(Tags.TAG_EQUIVID)) {
                    equivIDs.Add(new EquivID(oChild));
                } else if (sChildName.Equals(Tags.TAG_CANONICALID)) {
                    canonicalIDs.Add(new CanonicalID(oChild));
                } else if (sChildName.Equals(Tags.TAG_CANONICALEQUIVID)) {
                    canonicalEquivID = new CanonicalEquivID();
                    canonicalEquivID.fromXML(oChild);
                } else if (sChildName.Equals(Tags.TAG_REDIRECT)) {
                    Redirect _ref = new Redirect(oChild);
                    addRedirect(_ref);
                } else if (sChildName.Equals(Tags.TAG_REF)) {
                    Ref _ref = new Ref(oChild);
                    addRef(_ref);
                } else if (sChildName.Equals(Tags.TAG_SERVICE)) {
                    addService(new Service(oChild));
                } else if (
                          (oChild.NamespaceURI != null) &&
                          oChild.NamespaceURI.Equals(Tags.NS_SAML) &&
                          (oChild.LocalName != null) &&
                          oChild.LocalName.Equals(Tags.TAG_ASSERTION)) {
                    samlAssertion = new Assertion(oChild);
                }
                    // Added this code to support extensions in Authority XmlElement
                  else {
                    ArrayList oVector =
                        (ArrayList)moOtherChildrenVectorsMap[sChildName];

                    if (oVector == null) {
                        oVector = new ArrayList();
                        moOtherChildrenVectorsMap[sChildName] = oVector;
                    }

                    oVector.Add(oChild.CloneNode(true));
                }
            }
        }
コード例 #2
0
ファイル: Assertion.cs プロジェクト: AArnott/dotnetxri
        /*
        ****************************************************************************
        * fromDOM()
        ****************************************************************************
        */
        /**
        *  This method populates the obj from DOM.  It does not keep a
        * copy of the DOM around.  Whitespace information is lost in this process.
        */
        public void fromDOM(XmlElement oElem)
        {
            reset();

            // get the id attribute
            if (oElem.hasAttributeNS(null, Tags.ATTR_ID_CAP))
            {
            msXmlID = oElem.getAttributeNS(null, Tags.ATTR_ID_CAP);
            }

            if (oElem.hasAttributeNS(null, Tags.ATTR_ISSUEINSTANT))
            {
            msIssueInstant = oElem.getAttributeNS(null, Tags.ATTR_ISSUEINSTANT);
            }

            for (
            XmlNode oChild = oElem.FirstChild; oChild != null;
            oChild = oChild.NextSibling)
            {
            if (oChild.LocalName.Equals(Tags.TAG_ISSUER))
            {
                // only accept the first XRIAuthority
                if (moIssuer == null)
                {
                    moIssuer = new NameID((XmlElement) oChild);
                }
            }
            else if (oChild.LocalName.Equals(Tags.TAG_SIGNATURE))
            {
                // only accept the first XRIAuthority
                if (moSignature == null)
                {
                    try
                    {
                        XmlDocument oDoc = new XmlDocument();
                        XmlElement oChildCopy =
                            (XmlElement) oDoc.ImportNode(oChild, true);
                        moSignature = new XMLSignature(oChildCopy, null);
                    }
                    catch (Exception oEx)
                    {
                        soLog.Warn(
                            "Caught exception while parsing Signature", oEx);
                    }
                }
            }
            else if (oChild.LocalName.Equals(Tags.TAG_SUBJECT))
            {
                // only accept the first XRIAuthority
                if (moSubject == null)
                {
                    moSubject = new Subject((XmlElement) oChild);
                }
            }
            else if (oChild.LocalName.Equals(Tags.TAG_CONDITIONS))
            {
                // only accept the first XRIAuthority
                if (moConditions == null)
                {
                    moConditions = new Conditions((XmlElement) oChild);
                }
            }
            else if (oChild.LocalName.Equals(Tags.TAG_ATTRIBUTESTATEMENT))
            {
                // only accept the first XRIAuthority
                if (moAttrStatement == null)
                {
                    moAttrStatement = new AttributeStatement((XmlElement) oChild);
                }
            }
            }
        }
コード例 #3
0
ファイル: Attribute.cs プロジェクト: AArnott/dotnetxri
        /*
        ****************************************************************************
        * fromDOM()
        ****************************************************************************
        */
        /**
        *  This method populates the XRD from DOM.  It does not keep a
        * copy of the DOM around.  Whitespace information is lost in this process.
        */
        public void fromDOM(XmlElement oElem)
        {
            reset();

            // get the id attribute
            if (oElem.hasAttributeNS(null, Tags.ATTR_NAME))
            {
            msName = oElem.getAttributeNS(null, Tags.ATTR_NAME);
            }

            for (
            XmlNode oChild = oElem.FirstChild; oChild != null;
            oChild = oChild.NextSibling)
            {
            if (oChild.LocalName.Equals(Tags.TAG_ATTRIBUTEVALUE))
            {
                // only accept the first  element and make sure it
                // is a text node
                if (
                    (msValue.Equals("")) && (oChild.FirstChild != null) &&
                    (oChild.FirstChild.NodeType == XmlNode.TEXT_NODE))
                {
                    msValue = oChild.FirstChild.getNodeValue();
                }
            }
            }
        }