public void ReadXml( XmlDictionaryReader reader )
        {
            if ( reader == null )
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull( "reader" );
            }

            reader.MoveToContent();
            if ( !reader.IsStartElement( XmlEncryptionConstants.Elements.EncryptionMethod, XmlEncryptionConstants.Namespace ) )
            {
                return;
            }

            _algorithm = reader.GetAttribute( XmlEncryptionConstants.Attributes.Algorithm, null );

            if ( !reader.IsEmptyElement )
            {
                //
                // Trace unread missing element
                //

                string xml = reader.ReadOuterXml();
                if ( DiagnosticUtility.ShouldTraceWarning )
                {
                    TraceUtility.TraceString( System.Diagnostics.TraceEventType.Warning, SR.GetString( SR.ID8024, reader.Name, reader.NamespaceURI, xml ) );
                }
            }
            else
            {
                //
                // Read to the next element
                //
                reader.Read();
            }
        }
Пример #2
0
        public virtual void ReadXml( XmlDictionaryReader reader )
        {
            if ( reader == null )
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull( "reader" );
            }

            reader.MoveToContent();
            if ( reader.IsStartElement( XD.XmlSignatureDictionary.KeyInfo.Value, XD.XmlSignatureDictionary.Namespace.Value ) )
            {
                // <KeyInfo>
                reader.ReadStartElement();

                while ( reader.IsStartElement() )
                {
                    // <RetrievalMethod>
                    if ( reader.IsStartElement( XmlSignatureConstants.Elements.RetrievalMethod, XD.XmlSignatureDictionary.Namespace.Value ) )
                    {
                        string method = reader.GetAttribute( XD.XmlSignatureDictionary.URI.Value );
                        if ( !string.IsNullOrEmpty( method ) )
                        {
                            _retrieval = method;
                        }
                        reader.Skip();
                    }
                    // check if internal serializer can handle clause
                    else if ( _keyInfoSerializer.CanReadKeyIdentifierClause( reader ) )
                    {
                        _ski.Add( _keyInfoSerializer.ReadKeyIdentifierClause( reader ) );
                    }
                    // trace we skipped over an element
                    else if ( reader.IsStartElement() )
                    {
                        string xml = reader.ReadOuterXml();

                        if ( DiagnosticUtility.ShouldTraceWarning )
                        {
                            TraceUtility.TraceString( System.Diagnostics.TraceEventType.Warning, SR.GetString( SR.ID8023, reader.Name, reader.NamespaceURI, xml ) );
                        }
                    }
                    reader.MoveToContent();
                }

                reader.MoveToContent();
                reader.ReadEndElement();
            }
        }
Пример #3
0
 public virtual void ReadXml(XmlDictionaryReader reader)
 {
     if (reader == null)
     {
         throw DiagnosticUtil.ExceptionUtil.ThrowHelperArgumentNull("reader");
     }
     reader.MoveToContent();
     if (reader.IsStartElement("KeyInfo", "http://www.w3.org/2000/09/xmldsig#"))
     {
         reader.ReadStartElement();
         while (reader.IsStartElement())
         {
             if (reader.IsStartElement("RetrievalMethod", "http://www.w3.org/2000/09/xmldsig#"))
             {
                 string attribute = reader.GetAttribute("URI");
                 if (!string.IsNullOrEmpty(attribute))
                 {
                     this._retrieval = attribute;
                 }
                 reader.Skip();
             }
             else if (this._keyInfoSerializer.CanReadKeyIdentifierClause(reader))
             {
                 this._ski.Add(this._keyInfoSerializer.ReadKeyIdentifierClause(reader));
             }
             else if (reader.IsStartElement())
             {
                 string str2 = reader.ReadOuterXml();
                 //if (DiagnosticUtil.TraceUtil.ShouldTrace(TraceEventType.Warning))
                 //{
                 //    DiagnosticUtil.TraceUtil.TraceString(TraceEventType.Warning, SR.GetString("ID8023", new object[] { reader.Name, reader.NamespaceURI, str2 }), new object[0]);
                 //}
             }
             reader.MoveToContent();
         }
         reader.MoveToContent();
         reader.ReadEndElement();
     }
 }
        public override void ReadExtensions( XmlDictionaryReader reader )
        {
            reader.MoveToContent();
            if ( reader.IsStartElement( XmlEncryptionConstants.Elements.ReferenceList, XmlEncryptionConstants.Namespace ) )
            {
                reader.ReadStartElement();

                // could have data or key references.  these are the only two possible elements sec 3.6 xml enc.
                // 3.6 The ReferenceList Element specifies there is a choice. Once one is chosen, it is fixed.
                if ( reader.IsStartElement( XmlEncryptionConstants.Elements.DataReference, XmlEncryptionConstants.Namespace ) )
                {
                    while ( reader.IsStartElement() )
                    {
                        if ( reader.IsStartElement( XmlEncryptionConstants.Elements.DataReference, XmlEncryptionConstants.Namespace ) )
                        {
                            string dataRef = reader.GetAttribute( XmlEncryptionConstants.Attributes.Uri );
                            if ( !string.IsNullOrEmpty( dataRef ) )
                            {
                                _dataReferences.Add( dataRef );
                            }
                            reader.Skip();
                        }
                        else if ( reader.IsStartElement( XmlEncryptionConstants.Elements.KeyReference, XmlEncryptionConstants.Namespace ) )
                        {
                            throw DiagnosticUtility.ThrowHelperXml( reader, SR.GetString( SR.ID4189 ) );
                        }
                        else
                        {
                            string xml = reader.ReadOuterXml();
                            if ( DiagnosticUtility.ShouldTraceWarning )
                            {
                                TraceUtility.TraceString( System.Diagnostics.TraceEventType.Warning, SR.GetString( SR.ID8024, reader.Name, reader.NamespaceURI, xml ) );
                            }
                        }
                    }
                }
                else if ( reader.IsStartElement( XmlEncryptionConstants.Elements.KeyReference, XmlEncryptionConstants.Namespace ) )
                {
                    while ( reader.IsStartElement() )
                    {
                        if ( reader.IsStartElement( XmlEncryptionConstants.Elements.KeyReference, XmlEncryptionConstants.Namespace ) )
                        {
                            string keyRef = reader.GetAttribute( XmlEncryptionConstants.Attributes.Uri );
                            if ( !string.IsNullOrEmpty( keyRef ) )
                            {
                                _keyReferences.Add( keyRef );
                            }
                            reader.Skip();
                        }
                        else if ( reader.IsStartElement( XmlEncryptionConstants.Elements.DataReference, XmlEncryptionConstants.Namespace ) )
                        {
                            throw DiagnosticUtility.ThrowHelperXml( reader, SR.GetString( SR.ID4190 ) );
                        }
                        else
                        {
                            string xml = reader.ReadOuterXml();
                            if ( DiagnosticUtility.ShouldTraceWarning )
                            {
                                TraceUtility.TraceString( System.Diagnostics.TraceEventType.Warning, SR.GetString( SR.ID8024, reader.Name, reader.NamespaceURI, xml ) );
                            }
                        }
                    }
                }
                else
                {
                    // there must be at least one reference.
                    throw DiagnosticUtility.ThrowHelperXml( reader, SR.GetString( SR.ID4191 ) );
                }

                reader.MoveToContent();
                if ( reader.IsStartElement( XmlEncryptionConstants.Elements.CarriedKeyName, XmlEncryptionConstants.Namespace ) )
                {
                    reader.ReadStartElement();
                    _carriedName = reader.ReadString();
                    reader.ReadEndElement();
                }

                // </ReferenceList>
                reader.ReadEndElement();
            }
        }
Пример #5
0
		public void SetMetadataReader (XmlDictionaryReader reader)
		{
			if (reader == null)
				metadata = null;
			else {
				reader.MoveToContent ();
				metadata = reader.ReadOuterXml ();
			}
		}
Пример #6
0
		public void SetExtensionReader (XmlDictionaryReader reader)
		{
			if (reader == null)
				extension = null;
			else {
				reader.MoveToContent ();
				extension = reader.ReadOuterXml ();
			}
		}
        private static Exception CreateExceptionOnFault(XmlDictionaryReader faultBody)
        {
            var document = XDocument.Parse(faultBody.ReadOuterXml());
            var details = document.Descendants("detail").First();

            var type = details.Elements("ExceptionType").FirstOrDefault();
            var message = details.Elements("ExceptionMessage").FirstOrDefault();
            var info = details.Elements("ExceptionInfo").FirstOrDefault();

            return new SoapException(string.Format(
                "{0}\n\r{1}\n\r{2}",
                message != null ? message.Value : "Not included message.",
                type != null ? type.Value : "Not included exception type.",
                info != null ? info.Value : "Not included detailed information."), XmlQualifiedName.Empty);
        }
Пример #8
0
 public override string ReadOuterXml()
 {
     return(reader.ReadOuterXml());
 }