void ValidateMessageBody(ref System.ServiceModel.Channels.Message message, bool isRequest)
        {
            if (!message.IsFault)
            {
                XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();
                XmlReader bodyReader = message.GetReaderAtBodyContents().ReadSubtree();
                XmlReaderSettings wrapperSettings = new XmlReaderSettings();
                wrapperSettings.CloseInput = true;
                wrapperSettings.Schemas = schemaSet;
                wrapperSettings.ValidationFlags = XmlSchemaValidationFlags.None;
                wrapperSettings.ValidationType = ValidationType.Schema;
                wrapperSettings.ValidationEventHandler +=
                    new ValidationEventHandler(InspectionValidationHandler);
                XmlReader wrappedReader = XmlReader.Create(bodyReader, wrapperSettings);

                // pull body into a memory backed writer to validate
                this.isRequest = isRequest;
                MemoryStream memStream = new MemoryStream();
                XmlDictionaryWriter xdw = XmlDictionaryWriter.CreateBinaryWriter(memStream);
                xdw.WriteNode(wrappedReader, false);
                xdw.Flush(); memStream.Position = 0;
                XmlDictionaryReader xdr = XmlDictionaryReader.CreateBinaryReader(memStream, quotas);

                // reconstruct the message with the validated body
                Message replacedMessage = Message.CreateMessage(message.Version, null, xdr);
                replacedMessage.Headers.CopyHeadersFrom(message.Headers);
                replacedMessage.Properties.CopyProperties(message.Properties);
                message = replacedMessage;
            }
        }
Пример #2
0
 private void MoveToInitial(XmlDictionaryReaderQuotas quotas, XmlBinaryReaderSession session, OnXmlDictionaryReaderClose onClose)
 {
     MoveToInitial(quotas);
     _maxBytesPerRead = quotas.MaxBytesPerRead;
     _arrayState = ArrayState.None;
     _isTextWithEndElement = false;
 }
Пример #3
0
        public void SetZero()
        {
            // having ExpectedExceptions for each test and splitting
            // methods is messy, so am just having all of them
            // in this test.
            Q q = new Q();

            try {
                q.MaxArrayLength = 0;
                Assert.Fail("MaxArrayLength = 0 should fail.");
            } catch (ArgumentException) {
            }
            try {
                q.MaxBytesPerRead = 0;
                Assert.Fail("MaxBytesPerRead = 0 should fail.");
            } catch (ArgumentException) {
            }
            try {
                q.MaxDepth = 0;
                Assert.Fail("MaxDepth = 0 should fail.");
            } catch (ArgumentException) {
            }
            try {
                q.MaxNameTableCharCount = 0;
                Assert.Fail("MaxNameTableCharCount = 0 should fail.");
            } catch (ArgumentException) {
            }
            try {
                q.MaxStringContentLength = 0;
                Assert.Fail("MaxStringContentLength = 0 should fail.");
            } catch (ArgumentException) {
            }
        }
        public FileTransferServiceProxy()
        {
            this.m_BasicHttpBinding = new BasicHttpBinding();
            this.m_EndpointAddress = new EndpointAddress(EndpointAddressUrl);

            this.m_BasicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
            this.m_BasicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
            this.m_BasicHttpBinding.MaxReceivedMessageSize = 2147483647;

            XmlDictionaryReaderQuotas readerQuotas = new XmlDictionaryReaderQuotas();
            readerQuotas.MaxArrayLength = 25 * 208000;
            readerQuotas.MaxStringContentLength = 25 * 208000;
            this.m_BasicHttpBinding.ReaderQuotas = readerQuotas;

            this.m_ChannelFactory = new ChannelFactory<Contract.IFileTransferService>(this.m_BasicHttpBinding, this.m_EndpointAddress);
            this.m_ChannelFactory.Credentials.UserName.UserName = YellowstonePathology.YpiConnect.Contract.Identity.GuestWebServiceAccount.UserName;
            this.m_ChannelFactory.Credentials.UserName.Password = YellowstonePathology.YpiConnect.Contract.Identity.GuestWebServiceAccount.Password;

            foreach (System.ServiceModel.Description.OperationDescription op in this.m_ChannelFactory.Endpoint.Contract.Operations)
            {
                var dataContractBehavior = op.Behaviors.Find<System.ServiceModel.Description.DataContractSerializerOperationBehavior>();
                if (dataContractBehavior != null)
                {
                    dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
                }
            }

            this.m_FileTransferServiceChannel = this.m_ChannelFactory.CreateChannel();
        }
Пример #5
0
        public void ReadonlyCheck()
        {
            // having ExpectedExceptions for each test and splitting
            // methods is messy, so am just having all of them
            // in this test.
            Q q = Q.Max;

            try {
                q.MaxArrayLength = int.MaxValue;
                Assert.Fail("Default MaxArrayLength is readonly");
            } catch (InvalidOperationException) {
            }
            try {
                q.MaxBytesPerRead = int.MaxValue;
                Assert.Fail("Default MaxBytesPerRead is readonly");
            } catch (InvalidOperationException) {
            }
            try {
                q.MaxDepth = int.MaxValue;
                Assert.Fail("Default MaxDepth is readonly");
            } catch (InvalidOperationException) {
            }
            try {
                q.MaxNameTableCharCount = int.MaxValue;
                Assert.Fail("Default MaxNameTableCharCount is readonly");
            } catch (InvalidOperationException) {
            }
            try {
                q.MaxStringContentLength = int.MaxValue;
                Assert.Fail("Default MaxStringContentLength is readonly");
            } catch (InvalidOperationException) {
            }
        }
 public MtomMessageEncoder(System.ServiceModel.Channels.MessageVersion version, Encoding writeEncoding, int maxReadPoolSize, int maxWritePoolSize, int maxBufferSize, XmlDictionaryReaderQuotas quotas)
 {
     if (version == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("version");
     }
     if (writeEncoding == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writeEncoding");
     }
     TextEncoderDefaults.ValidateEncoding(writeEncoding);
     this.writeEncoding = writeEncoding;
     this.maxReadPoolSize = maxReadPoolSize;
     this.maxWritePoolSize = maxWritePoolSize;
     this.readerQuotas = new XmlDictionaryReaderQuotas();
     quotas.CopyTo(this.readerQuotas);
     this.maxBufferSize = maxBufferSize;
     this.onStreamedReaderClose = new OnXmlDictionaryReaderClose(this.ReturnStreamedReader);
     this.thisLock = new object();
     if (version.Envelope == EnvelopeVersion.Soap12)
     {
         this.contentEncodingMap = TextMessageEncoderFactory.Soap12Content;
     }
     else
     {
         if (version.Envelope != EnvelopeVersion.Soap11)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "Invalid MessageVersion", new object[0])));
         }
         this.contentEncodingMap = TextMessageEncoderFactory.Soap11Content;
     }
     this.version = version;
 }
Пример #7
0
 public void SetInput(Stream stream, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose)
 {
     SetReadEncodings(encodings);
     CheckContentType(contentType);
     Initialize(stream, contentType, quotas, maxBufferSize);
     this.onClose = onClose;
 }
 internal void InitializeFrom(XmlDictionaryReaderQuotas readerQuotas)
 {
     if (readerQuotas == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("readerQuotas");
     }
     if (readerQuotas.MaxDepth != EncoderDefaults.MaxDepth)
     {
         SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxDepth, readerQuotas.MaxDepth);                
     }
     if (readerQuotas.MaxStringContentLength != EncoderDefaults.MaxStringContentLength)
     {
         SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxStringContentLength, readerQuotas.MaxStringContentLength);
     }
     if (readerQuotas.MaxArrayLength != EncoderDefaults.MaxArrayLength)
     {
         SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxArrayLength, readerQuotas.MaxArrayLength);
     }
     if (readerQuotas.MaxBytesPerRead != EncoderDefaults.MaxBytesPerRead)
     {
         SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBytesPerRead, readerQuotas.MaxBytesPerRead);
     }
     if (readerQuotas.MaxNameTableCharCount != EncoderDefaults.MaxNameTableCharCount)
     {
         SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxNameTableCharCount, readerQuotas.MaxNameTableCharCount);
     } 
 }
        public void WriteXml(XmlWriter xmlWriter)
        {

            if (wsdl != null)
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    wsdl.Write(ms);

                    XmlDictionaryReaderQuotas quota = new XmlDictionaryReaderQuotas();
                    quota.MaxDepth = 32;
                    quota.MaxStringContentLength = 8192;
                    quota.MaxArrayLength = 16384;
                    quota.MaxBytesPerRead = 4096;
                    quota.MaxNameTableCharCount = 16384;

                    ms.Seek(0, SeekOrigin.Begin);

                    XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(ms, null, quota, null);

                    if ((reader.MoveToContent() == XmlNodeType.Element) && (reader.Name == "wsdl:definitions"))
                    {

                        xmlWriter.WriteNode(reader, false);
                    }

                    reader.Close();
                }
            }

        }
 public static XmlDictionaryReader CreateJsonReader(byte[] buffer, XmlDictionaryReaderQuotas quotas)
 {
     if (buffer == null)
         throw new ArgumentNullException("buffer");
     else
         return JsonReaderWriterFactory.CreateJsonReader(buffer, 0, buffer.Length, (Encoding)null, quotas, (OnXmlDictionaryReaderClose)null);
 }
Пример #11
0
 public static void SetReaderQuotas(XmlDictionaryReaderQuotas readerQuotas)
 {
     readerQuotas.MaxStringContentLength = int.MaxValue;
     readerQuotas.MaxArrayLength = int.MaxValue;
     readerQuotas.MaxBytesPerRead = int.MaxValue;
     readerQuotas.MaxDepth = int.MaxValue;
 }
 internal void ApplyConfiguration(XmlDictionaryReaderQuotas readerQuotas)
 {
     if (readerQuotas == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("readerQuotas");
     }
     if (this.MaxDepth != 0)
     {
         readerQuotas.MaxDepth = this.MaxDepth;
     }
     if (this.MaxStringContentLength != 0)
     {
         readerQuotas.MaxStringContentLength = this.MaxStringContentLength;
     }
     if (this.MaxArrayLength != 0)
     {
         readerQuotas.MaxArrayLength = this.MaxArrayLength;
     }
     if (this.MaxBytesPerRead != 0)
     {
         readerQuotas.MaxBytesPerRead = this.MaxBytesPerRead;
     }
     if (this.MaxNameTableCharCount != 0)
     {
         readerQuotas.MaxNameTableCharCount = this.MaxNameTableCharCount;
     }
 }
Пример #13
0
        internal static XmlDictionaryReaderQuotas GetBufferedReadQuotas(XmlDictionaryReaderQuotas encoderQuotas)
        {
            XmlDictionaryReaderQuotas bufferedReadQuotas = new XmlDictionaryReaderQuotas();
            encoderQuotas.CopyTo(bufferedReadQuotas);

            // now we have the quotas from the encoder, we need to update the values with the new quotas from the default read quotas. 
            if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxStringContentLength))
            {
                bufferedReadQuotas.MaxStringContentLength = EncoderDefaults.BufferedReadDefaultMaxStringContentLength;
            }

            if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxArrayLength))
            {
                bufferedReadQuotas.MaxArrayLength = EncoderDefaults.BufferedReadDefaultMaxArrayLength;
            }

            if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxBytesPerRead))
            {
                bufferedReadQuotas.MaxBytesPerRead = EncoderDefaults.BufferedReadDefaultMaxBytesPerRead;
            }

            if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxNameTableCharCount))
            {
                bufferedReadQuotas.MaxNameTableCharCount = EncoderDefaults.BufferedReadDefaultMaxNameTableCharCount;
            }

            if (IsDefaultQuota(bufferedReadQuotas, XmlDictionaryReaderQuotaTypes.MaxDepth))
            {
                bufferedReadQuotas.MaxDepth = EncoderDefaults.BufferedReadDefaultMaxDepth;
            }

            return bufferedReadQuotas;
        }
 private void ApplyConfiguration(XmlDictionaryReaderQuotas readerQuotas)
 {
     if (readerQuotas == null)
         throw new ArgumentNullException("readerQuotas");
     
     if (this.ReaderQuotasElement.MaxDepth != 0)
     {
         readerQuotas.MaxDepth = this.ReaderQuotasElement.MaxDepth;
     }
     if (this.ReaderQuotasElement.MaxStringContentLength != 0)
     {
         readerQuotas.MaxStringContentLength = this.ReaderQuotasElement.MaxStringContentLength;
     }
     if (this.ReaderQuotasElement.MaxArrayLength != 0)
     {
         readerQuotas.MaxArrayLength = this.ReaderQuotasElement.MaxArrayLength;
     }
     if (this.ReaderQuotasElement.MaxBytesPerRead != 0)
     {
         readerQuotas.MaxBytesPerRead = this.ReaderQuotasElement.MaxBytesPerRead;
     }
     if (this.ReaderQuotasElement.MaxNameTableCharCount != 0)
     {
         readerQuotas.MaxNameTableCharCount = this.ReaderQuotasElement.MaxNameTableCharCount;
     }
 }
 internal static XmlDictionaryReader CreateSplicedReader(byte[] decryptedBuffer, XmlAttributeHolder[] outerContext1, XmlAttributeHolder[] outerContext2, XmlAttributeHolder[] outerContext3, XmlDictionaryReaderQuotas quotas)
 {
     MemoryStream stream = new MemoryStream();
     XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream);
     writer.WriteStartElement("x");
     WriteNamespaceDeclarations(outerContext1, writer);
     writer.WriteStartElement("y");
     WriteNamespaceDeclarations(outerContext2, writer);
     writer.WriteStartElement("z");
     WriteNamespaceDeclarations(outerContext3, writer);
     writer.WriteString(" ");
     writer.WriteEndElement();
     writer.WriteEndElement();
     writer.WriteEndElement();
     writer.Flush();
     XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(SpliceBuffers(decryptedBuffer, stream.GetBuffer(), (int) stream.Length, 3), quotas);
     reader.ReadStartElement("x");
     reader.ReadStartElement("y");
     reader.ReadStartElement("z");
     if (reader.NodeType != XmlNodeType.Element)
     {
         reader.MoveToContent();
     }
     return reader;
 }
 public PeerNodeConfig(string meshId, ulong nodeId, PeerResolver resolver, PeerMessagePropagationFilter messagePropagationFilter, System.ServiceModel.Channels.MessageEncoder encoder, Uri listenUri, IPAddress listenIPAddress, int port, long maxReceivedMessageSize, int minNeighbors, int idealNeighbors, int maxNeighbors, int maxReferrals, int connectTimeout, int maintainerInterval, PeerSecurityManager securityManager, XmlDictionaryReaderQuotas readerQuotas, long maxBufferPool, int maxSendQueueSize, int maxReceiveQueueSize)
 {
     this.connectTimeout = connectTimeout;
     this.listenIPAddress = listenIPAddress;
     this.listenUri = listenUri;
     this.maxReceivedMessageSize = maxReceivedMessageSize;
     this.minNeighbors = minNeighbors;
     this.idealNeighbors = idealNeighbors;
     this.maxNeighbors = maxNeighbors;
     this.maxReferrals = maxReferrals;
     this.maxReferralCacheSize = 50;
     this.maxResolveAddresses = 3;
     this.meshId = meshId;
     this.encoder = encoder;
     this.messagePropagationFilter = messagePropagationFilter;
     this.nodeId = nodeId;
     this.port = port;
     this.resolver = resolver;
     this.maintainerInterval = maintainerInterval;
     this.maintainerRetryInterval = new TimeSpan(0x5f5e100L);
     this.maintainerTimeout = new TimeSpan(0x47868c00L);
     this.unregisterTimeout = new TimeSpan(0x47868c00L);
     this.securityManager = securityManager;
     readerQuotas.CopyTo(this.readerQuotas);
     this.maxBufferPoolSize = maxBufferPool;
     this.maxIncomingConcurrentCalls = maxReceiveQueueSize;
     this.maxSendQueueSize = maxSendQueueSize;
 }
        void ApplyConfiguration(XmlDictionaryReaderQuotas readerQuotas)
        {
            if (readerQuotas == null)
            {
                throw FxTrace.Exception.ArgumentNull("readerQuotas");
            }

            XmlDictionaryReaderQuotasElement oldQuotas = this.ReaderQuotas;

            if (oldQuotas.MaxDepth != 0)
            {
                readerQuotas.MaxDepth = oldQuotas.MaxDepth;
            }
            if (oldQuotas.MaxStringContentLength != 0)
            {
                readerQuotas.MaxStringContentLength = oldQuotas.MaxStringContentLength;
            }
            if (oldQuotas.MaxArrayLength != 0)
            {
                readerQuotas.MaxArrayLength = oldQuotas.MaxArrayLength;
            }
            if (oldQuotas.MaxBytesPerRead != 0)
            {
                readerQuotas.MaxBytesPerRead = oldQuotas.MaxBytesPerRead;
            }
            if (oldQuotas.MaxNameTableCharCount != 0)
            {
                readerQuotas.MaxNameTableCharCount = oldQuotas.MaxNameTableCharCount;
            }
        }
 public WebScriptMetadataMessageEncoder(XmlDictionaryReaderQuotas quotas)
 {
     this.readerQuotas = new XmlDictionaryReaderQuotas();
     quotas.CopyTo(this.readerQuotas);
     this.mediaType = this.contentType = applicationJavaScriptMediaType;
     this.innerReadMessageEncoder = new TextMessageEncodingBindingElement(MessageVersion.None, Encoding.UTF8).CreateMessageEncoderFactory().Encoder;
 }
 public static XmlDictionaryReader CreateJsonReader(byte[] buffer, XmlDictionaryReaderQuotas quotas)
 {
     if (buffer == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("buffer");
     }
     return CreateJsonReader(buffer, 0, buffer.Length, null, quotas, null);
 }
Пример #20
0
		private static void ConfigureQuotas(XmlDictionaryReaderQuotas readerQuotas, int quotaSize)
		{
			readerQuotas.MaxArrayLength = quotaSize;
			readerQuotas.MaxDepth = quotaSize;
			readerQuotas.MaxStringContentLength = quotaSize;
			readerQuotas.MaxBytesPerRead = quotaSize;
			readerQuotas.MaxNameTableCharCount = quotaSize;
		}
Пример #21
0
 private static void ConfigureReaderQuotas(ProxyConfiguration configuration, XmlDictionaryReaderQuotas readerQuotas)
 {
     readerQuotas.MaxArrayLength = configuration.MaxArrayLength;
     readerQuotas.MaxBytesPerRead = configuration.MaxBytesPerRead;
     readerQuotas.MaxDepth = configuration.MaxDepth;
     readerQuotas.MaxNameTableCharCount = configuration.MaxNameTableCharCount;
     readerQuotas.MaxStringContentLength = configuration.MaxStringContentLength;
 }
Пример #22
0
 protected XmlBaseReader()
 {
     this.bufferReader = new XmlBufferReader(this);
     this.nsMgr = new NamespaceManager(bufferReader);
     this.quotas = new XmlDictionaryReaderQuotas();
     this.rootElementNode = new XmlElementNode(bufferReader);
     this.atomicTextNode = new XmlAtomicTextNode(bufferReader);
     this.node = closedNode;
 }
Пример #23
0
        public static XmlDictionaryReader CreateJsonReader(byte[] buffer, XmlDictionaryReaderQuotas quotas)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            return CreateJsonReader(buffer, 0, buffer.Length, null, quotas, null);
        }
Пример #24
0
        public void CopyTo(XmlDictionaryReaderQuotas quotas)
        {
            if (quotas == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("quotas"));
            if (quotas._readOnly)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.QuotaCopyReadOnly)));

            InternalCopyTo(quotas);
        }
        public void CopyTo(XmlDictionaryReaderQuotas quotas)
        {
            if (quotas == null)
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("quotas"));
            if (quotas.readOnly)
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.QuotaCopyReadOnly)));

            InternalCopyTo(quotas); 
        }
Пример #26
0
 protected XmlBaseReader()
 {
     _bufferReader = new XmlBufferReader(this);
     _nsMgr = new NamespaceManager(_bufferReader);
     _quotas = XmlDictionaryReaderQuotas.Max;
     _rootElementNode = new XmlElementNode(_bufferReader);
     _atomicTextNode = new XmlAtomicTextNode(_bufferReader);
     _node = s_closedNode;
 }
Пример #27
0
 internal void InternalCopyTo(XmlDictionaryReaderQuotas quotas)
 {
     quotas._maxStringContentLength = _maxStringContentLength;
     quotas._maxArrayLength = _maxArrayLength;
     quotas._maxDepth = _maxDepth;
     quotas._maxNameTableCharCount = _maxNameTableCharCount;
     quotas._maxBytesPerRead = _maxBytesPerRead;
     quotas._modifiedQuotas = _modifiedQuotas;
 }
Пример #28
0
        public void StaticAndDefaultValues()
        {
            /*
             * Assert.AreEqual (
             *      int.MaxValue, Q.DefaultMaxArrayLength,
             *      "static DefaultMaxArrayLength");
             * Assert.AreEqual (
             *      int.MaxValue, Q.DefaultMaxBytesPerRead,
             *      "static DefaultMaxBytesPerRead");
             * Assert.AreEqual (
             *      int.MaxValue, Q.DefaultMaxDepth,
             *      "static DefaultMaxDepth");
             * Assert.AreEqual (
             *      int.MaxValue, Q.DefaultMaxNameTableCharCount,
             *      "static DefaultMaxNameTableCharCount");
             * Assert.AreEqual (
             *      int.MaxValue, Q.DefaultMaxStringContentLength,
             *      "static DefaultMaxStringContentLength");
             */

            Q q = new Q();              //Q.Default;

            Assert.AreEqual(
                0x4000, q.MaxArrayLength,
                "default - MaxArrayLength");
            Assert.AreEqual(
                0x1000, q.MaxBytesPerRead,
                "default - MaxBytesPerRead");
            Assert.AreEqual(
                0x20, q.MaxDepth,
                "default - MaxDepth");
            Assert.AreEqual(
                0x4000, q.MaxNameTableCharCount,
                "default - MaxNameTableCharCount");
            Assert.AreEqual(
                0x2000, q.MaxStringContentLength,
                "default - MaxStringContentLength");

            q = Q.Max;

            Assert.AreEqual(
                int.MaxValue, q.MaxArrayLength,
                "max - MaxArrayLength");
            Assert.AreEqual(
                int.MaxValue, q.MaxBytesPerRead,
                "max - MaxBytesPerRead");
            Assert.AreEqual(
                int.MaxValue, q.MaxDepth,
                "max - MaxDepth");
            Assert.AreEqual(
                int.MaxValue, q.MaxNameTableCharCount,
                "max - MaxNameTableCharCount");
            Assert.AreEqual(
                int.MaxValue, q.MaxStringContentLength,
                "max - MaxStringContentLength");
        }
Пример #29
0
		public void StaticAndDefaultValues ()
		{
			/*
			Assert.AreEqual (
				int.MaxValue, Q.DefaultMaxArrayLength,
				"static DefaultMaxArrayLength");
			Assert.AreEqual (
				int.MaxValue, Q.DefaultMaxBytesPerRead,
				"static DefaultMaxBytesPerRead");
			Assert.AreEqual (
				int.MaxValue, Q.DefaultMaxDepth,
				"static DefaultMaxDepth");
			Assert.AreEqual (
				int.MaxValue, Q.DefaultMaxNameTableCharCount,
				"static DefaultMaxNameTableCharCount");
			Assert.AreEqual (
				int.MaxValue, Q.DefaultMaxStringContentLength,
				"static DefaultMaxStringContentLength");
			*/

			Q q = new Q (); //Q.Default;

			Assert.AreEqual (
				0x4000, q.MaxArrayLength,
				"default - MaxArrayLength");
			Assert.AreEqual (
				0x1000, q.MaxBytesPerRead,
				"default - MaxBytesPerRead");
			Assert.AreEqual (
				0x20, q.MaxDepth,
				"default - MaxDepth");
			Assert.AreEqual (
				0x4000, q.MaxNameTableCharCount,
				"default - MaxNameTableCharCount");
			Assert.AreEqual (
				0x2000, q.MaxStringContentLength,
				"default - MaxStringContentLength");

			q = Q.Max;

			Assert.AreEqual (
				int.MaxValue, q.MaxArrayLength,
				"max - MaxArrayLength");
			Assert.AreEqual (
				int.MaxValue, q.MaxBytesPerRead,
				"max - MaxBytesPerRead");
			Assert.AreEqual (
				int.MaxValue, q.MaxDepth,
				"max - MaxDepth");
			Assert.AreEqual (
				int.MaxValue, q.MaxNameTableCharCount,
				"max - MaxNameTableCharCount");
			Assert.AreEqual (
				int.MaxValue, q.MaxStringContentLength,
				"max - MaxStringContentLength");
		}
 public static XmlDictionaryReader CreateBinaryReader(byte[] buffer, int offset, int count,
                                                      IXmlDictionary dictionary,
                                                      XmlDictionaryReaderQuotas quotas,
                                                      XmlBinaryReaderSession session,
                                                      OnXmlDictionaryReaderClose onClose)
 {
     XmlBinaryReader reader = new XmlBinaryReader();
     reader.SetInput(buffer, offset, count, dictionary, quotas, session, onClose);
     return reader;
 }
Пример #31
0
		public XmlMtomDictionaryReader (
			Stream stream, Encoding encoding,
			XmlDictionaryReaderQuotas quotas)
		{
			this.stream = stream;
			this.encoding = encoding;
			this.quotas = quotas;

			Initialize ();
		}
        bool moveBodyReaderToContent = false; // false because we want the ByteStreamMessageEncoder to be compatible with previous releases

        public ByteStreamMessageEncoder(XmlDictionaryReaderQuotas quotas)
        {
            this.quotas = new XmlDictionaryReaderQuotas();
            quotas.CopyTo(this.quotas);

            this.bufferedReadReaderQuotas = EncoderHelpers.GetBufferedReadQuotas(this.quotas);

            this.maxSentMessageSizeExceededResourceString = SR.MaxSentMessageSizeExceeded("{0}");
            this.maxReceivedMessageSizeExceededResourceString = SR.MaxReceivedMessageSizeExceeded("{0}");
        }
        public XmlBufferedByteStreamReader(ByteStreamBufferedMessageData bufferedMessageData, XmlDictionaryReaderQuotas quotas) : base (quotas)
        {
            Fx.Assert(bufferedMessageData != null, "bufferedMessageData is null");
            this.bufferedMessageData = bufferedMessageData;
            this.bufferedMessageData.Open(); 

            this.offset = bufferedMessageData.Buffer.Offset;
            this.quotas = quotas;
            this.position = ReaderPosition.None;
        }
Пример #34
0
        private static Binding GetBinding()
        {
            var readerQuotas = new System.Xml.XmlDictionaryReaderQuotas
            {
                MaxDepth = 1024,
                MaxStringContentLength = int.MaxValue,
                MaxArrayLength         = 16384,
                MaxBytesPerRead        = 4096,
                MaxNameTableCharCount  = 16384
            };

            TimeSpan timeout = new TimeSpan(0, 0, 10, 0);

            return(new BasicHttpBinding()
            {
                SendTimeout = timeout,
                ReceiveTimeout = timeout,
                MaxReceivedMessageSize = int.MaxValue,
                ReaderQuotas = readerQuotas,
            });
        }
Пример #35
0
        public static List <BasicHttpBinding> GetBasicHttpBindings(string exeConfigPath)
        {
            if (string.IsNullOrWhiteSpace(exeConfigPath))
            {
                return(null);
            }
            var svcSection = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath);

            var configs = new List <BasicHttpBinding>();

            foreach (
                var section in
                svcSection.Bindings.BasicHttpBinding.ConfiguredBindings
                .Cast <BasicHttpBindingElement>())
            {
                var df      = new BasicHttpBinding();
                var binding = new BasicHttpBinding
                {
                    Name = section.Name,

                    MaxBufferPoolSize      = section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : df.MaxBufferPoolSize,
                    MaxReceivedMessageSize =
                        section.MaxReceivedMessageSize > 0 ? section.MaxReceivedMessageSize : df.MaxReceivedMessageSize,
                    CloseTimeout   = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : df.CloseTimeout,
                    OpenTimeout    = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : df.OpenTimeout,
                    SendTimeout    = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : df.SendTimeout,
                    ReceiveTimeout =
                        section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : df.ReceiveTimeout,

                    TextEncoding = section.TextEncoding ?? df.TextEncoding,

                    MessageEncoding        = section.MessageEncoding,
                    AllowCookies           = section.AllowCookies,
                    BypassProxyOnLocal     = section.BypassProxyOnLocal,
                    HostNameComparisonMode = section.HostNameComparisonMode,
                    UseDefaultWebProxy     = section.UseDefaultWebProxy,
                };

                var readerQuotasSection = section.ReaderQuotas;
                var readerQuotas        = new System.Xml.XmlDictionaryReaderQuotas();
                if (readerQuotasSection != null && readerQuotasSection.MaxDepth > 0)
                {
                    readerQuotas.MaxDepth = readerQuotasSection.MaxDepth;
                    readerQuotas.MaxStringContentLength = readerQuotasSection.MaxStringContentLength;
                    readerQuotas.MaxArrayLength         = readerQuotasSection.MaxArrayLength;
                    readerQuotas.MaxBytesPerRead        = readerQuotasSection.MaxBytesPerRead;
                    readerQuotas.MaxNameTableCharCount  = readerQuotasSection.MaxNameTableCharCount;
                }
                else
                {
                    readerQuotas = null;
                }

                var messageSection = section.Security.Message;
                var message        = new BasicHttpMessageSecurity
                {
                    ClientCredentialType = messageSection.ClientCredentialType,
                    AlgorithmSuite       = messageSection.AlgorithmSuite,
                };
                var transportSection = section.Security.Transport;
                var transport        = new HttpTransportSecurity
                {
                    ClientCredentialType = transportSection.ClientCredentialType,
                    ProxyCredentialType  = transportSection.ProxyCredentialType
                };
                var basicHttpSecurity = new BasicHttpSecurity()
                {
                    Message   = message,
                    Mode      = section.Security.Mode,
                    Transport = transport
                };

                binding.Security = basicHttpSecurity;
                if (readerQuotas != null)
                {
                    binding.ReaderQuotas = readerQuotas;
                }

                configs.Add(binding);
            }
            return(configs);
        }
Пример #36
0
        public static List <WS2007FederationHttpBinding> Get07FederationHttpBindings(string exeConfigPath)
        {
            if (string.IsNullOrWhiteSpace(exeConfigPath))
            {
                return(null);
            }

            var svcSection     = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath);
            var defaultTimeout = new TimeSpan(0, 0, 60);
            var configs        = new List <WS2007FederationHttpBinding>();
            var dfltb          = new WS2007FederationHttpBinding();

            foreach (
                var section in
                svcSection.Bindings.WS2007FederationHttpBinding.ConfiguredBindings
                .Cast <WS2007FederationHttpBindingElement>())
            {
                var binding = new WS2007FederationHttpBinding
                {
                    Name           = section.Name,
                    CloseTimeout   = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : defaultTimeout,
                    OpenTimeout    = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : defaultTimeout,
                    SendTimeout    = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : defaultTimeout,
                    ReceiveTimeout =
                        section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : defaultTimeout,
                    BypassProxyOnLocal     = section.BypassProxyOnLocal,
                    TransactionFlow        = section.TransactionFlow,
                    HostNameComparisonMode = section.HostNameComparisonMode,

                    MaxReceivedMessageSize =
                        section.MaxReceivedMessageSize > 0
                            ? section.MaxReceivedMessageSize
                            : dfltb.MaxReceivedMessageSize,
                    MaxBufferPoolSize =
                        section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : dfltb.MaxBufferPoolSize,
                    MessageEncoding    = section.MessageEncoding,
                    TextEncoding       = section.TextEncoding ?? dfltb.TextEncoding,
                    UseDefaultWebProxy = section.UseDefaultWebProxy,
                };
                var readerQuotasSection = section.ReaderQuotas;
                var readerQuotas        = new System.Xml.XmlDictionaryReaderQuotas();
                if (readerQuotasSection != null && readerQuotasSection.MaxDepth > 0)
                {
                    readerQuotas.MaxDepth = readerQuotasSection.MaxDepth;
                    readerQuotas.MaxStringContentLength = readerQuotasSection.MaxStringContentLength;
                    readerQuotas.MaxArrayLength         = readerQuotasSection.MaxArrayLength;
                    readerQuotas.MaxBytesPerRead        = readerQuotasSection.MaxBytesPerRead;
                    readerQuotas.MaxNameTableCharCount  = readerQuotasSection.MaxNameTableCharCount;
                }
                else
                {
                    readerQuotas = null;
                }
                if (readerQuotas != null)
                {
                    binding.ReaderQuotas = readerQuotas;
                }

                if (section.Security == null)
                {
                    configs.Add(binding);
                    continue;
                }

                var cfgSecurityMsg = section.Security.Message;
                if (cfgSecurityMsg == null)
                {
                    configs.Add(binding);
                    continue;
                }

                var security = new WSFederationHttpSecurity
                {
                    Mode    = section.Security.Mode,
                    Message = new FederatedMessageSecurityOverHttp
                    {
                        EstablishSecurityContext = cfgSecurityMsg.EstablishSecurityContext,
                    }
                };
                var wsSecurityMsg = security.Message;



                if (cfgSecurityMsg.IssuerMetadata?.Address != null)
                {
                    wsSecurityMsg.IssuerMetadataAddress = new EndpointAddress(cfgSecurityMsg.IssuerMetadata.Address);
                }

                if (!string.IsNullOrWhiteSpace(cfgSecurityMsg.IssuedTokenType))
                {
                    wsSecurityMsg.IssuedTokenType = cfgSecurityMsg.IssuedTokenType;
                }

                if (cfgSecurityMsg.Issuer?.Address != null)
                {
                    wsSecurityMsg.IssuerAddress = new EndpointAddress(cfgSecurityMsg.Issuer.Address);
                }

                if (cfgSecurityMsg.ClaimTypeRequirements != null && cfgSecurityMsg.ClaimTypeRequirements.Count > 0)
                {
                    foreach (var ctr in cfgSecurityMsg.ClaimTypeRequirements.Cast <ClaimTypeElement>())
                    {
                        wsSecurityMsg.ClaimTypeRequirements.Add(new ClaimTypeRequirement(ctr.ClaimType, ctr.IsOptional));
                    }
                }

                binding.Security = security;

                configs.Add(binding);
            }

            return(configs);
        }
Пример #37
0
        public static List <NetTcpBinding> GetNetTcpBindings(string exeConfigPath)
        {
            if (string.IsNullOrWhiteSpace(exeConfigPath))
            {
                return(null);
            }

            var svcSection     = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath);
            var defaultTimeout = new TimeSpan(0, 0, 60);
            var configs        = new List <NetTcpBinding>();

            foreach (
                var section in
                svcSection.Bindings.NetTcpBinding.ConfiguredBindings
                .Cast <NetTcpBindingElement>())
            {
                var dfltb   = new NetTcpBinding();
                var binding = new NetTcpBinding
                {
                    Name           = section.Name,
                    CloseTimeout   = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : defaultTimeout,
                    OpenTimeout    = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : defaultTimeout,
                    SendTimeout    = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : defaultTimeout,
                    ReceiveTimeout =
                        section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : defaultTimeout,
                    MaxReceivedMessageSize =
                        section.MaxReceivedMessageSize > 0
                            ? section.MaxReceivedMessageSize
                            : dfltb.MaxReceivedMessageSize,
                    MaxBufferPoolSize =
                        section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : dfltb.MaxBufferPoolSize,
                    MaxConnections = section.MaxConnections > 0 ? section.MaxConnections : dfltb.MaxConnections,

                    ListenBacklog          = section.ListenBacklog > 0 ? section.ListenBacklog : dfltb.ListenBacklog,
                    PortSharingEnabled     = section.PortSharingEnabled,
                    TransactionFlow        = section.TransactionFlow,
                    TransferMode           = section.TransferMode,
                    HostNameComparisonMode = section.HostNameComparisonMode
                };
                var readerQuotasSection = section.ReaderQuotas;
                var readerQuotas        = new System.Xml.XmlDictionaryReaderQuotas();
                if (readerQuotasSection != null && readerQuotasSection.MaxDepth > 0)
                {
                    readerQuotas.MaxDepth = readerQuotasSection.MaxDepth;
                    readerQuotas.MaxStringContentLength = readerQuotasSection.MaxStringContentLength;
                    readerQuotas.MaxArrayLength         = readerQuotasSection.MaxArrayLength;
                    readerQuotas.MaxBytesPerRead        = readerQuotasSection.MaxBytesPerRead;
                    readerQuotas.MaxNameTableCharCount  = readerQuotasSection.MaxNameTableCharCount;
                }
                else
                {
                    readerQuotas = null;
                }
                var netTcpSecurity = new NetTcpSecurity {
                    Mode = section.Security.Mode
                };
                var tcpTransportSecurity = new TcpTransportSecurity();

                var msgSecurityOverTcp = new MessageSecurityOverTcp
                {
                    ClientCredentialType = section.Security.Message.ClientCredentialType,
                    AlgorithmSuite       = section.Security.Message.AlgorithmSuite
                };
                netTcpSecurity.Message   = msgSecurityOverTcp;
                netTcpSecurity.Transport = tcpTransportSecurity;
                binding.Security         = netTcpSecurity;
                if (readerQuotas != null)
                {
                    binding.ReaderQuotas = readerQuotas;
                }
                binding.ReliableSession = new OptionalReliableSession
                {
                    Enabled           = section.ReliableSession.Enabled,
                    InactivityTimeout = section.ReliableSession.InactivityTimeout,
                    Ordered           = section.ReliableSession.Ordered
                };


                configs.Add(binding);
            }
            return(configs);
        }
Пример #38
0
        public static List <WSHttpBinding> GetWsHttpBindings(string exeConfigPath)
        {
            if (string.IsNullOrWhiteSpace(exeConfigPath))
            {
                return(null);
            }

            var svcSection = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath);

            var configs = new List <WSHttpBinding>();

            foreach (
                var section in
                svcSection.Bindings.WSHttpBinding.ConfiguredBindings
                .Cast <WSHttpBindingElement>())
            {
                var df      = new WSHttpBinding();
                var binding = new WSHttpBinding
                {
                    Name = section.Name,

                    MaxBufferPoolSize      = section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : df.MaxBufferPoolSize,
                    MaxReceivedMessageSize = section.MaxReceivedMessageSize > 0 ? section.MaxReceivedMessageSize : df.MaxReceivedMessageSize,
                    CloseTimeout           = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : df.CloseTimeout,
                    OpenTimeout            = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : df.OpenTimeout,
                    SendTimeout            = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : df.SendTimeout,
                    ReceiveTimeout         =
                        section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : df.ReceiveTimeout,

                    TextEncoding = section.TextEncoding ?? df.TextEncoding,

                    MessageEncoding        = section.MessageEncoding,
                    AllowCookies           = section.AllowCookies,
                    BypassProxyOnLocal     = section.BypassProxyOnLocal,
                    TransactionFlow        = section.TransactionFlow,
                    HostNameComparisonMode = section.HostNameComparisonMode,
                    UseDefaultWebProxy     = section.UseDefaultWebProxy,
                };

                var readerQuotasSection = section.ReaderQuotas;
                var readerQuotas        = new System.Xml.XmlDictionaryReaderQuotas();
                if (readerQuotasSection != null && readerQuotasSection.MaxDepth > 0)
                {
                    readerQuotas.MaxDepth = readerQuotasSection.MaxDepth;
                    readerQuotas.MaxStringContentLength = readerQuotasSection.MaxStringContentLength;
                    readerQuotas.MaxArrayLength         = readerQuotasSection.MaxArrayLength;
                    readerQuotas.MaxBytesPerRead        = readerQuotasSection.MaxBytesPerRead;
                    readerQuotas.MaxNameTableCharCount  = readerQuotasSection.MaxNameTableCharCount;
                }
                else
                {
                    readerQuotas = null;
                }

                var reliableSessionSection = section.ReliableSession;
                var dfRss           = new OptionalReliableSession();
                var reliableSession = new OptionalReliableSession
                {
                    Enabled           = reliableSessionSection.Enabled,
                    Ordered           = reliableSessionSection.Ordered,
                    InactivityTimeout =
                        reliableSessionSection.InactivityTimeout != TimeSpan.Zero
                            ? reliableSessionSection.InactivityTimeout
                            : dfRss.InactivityTimeout,
                };

                var messageSection = section.Security.Message;
                var message        = new NonDualMessageSecurityOverHttp
                {
                    EstablishSecurityContext   = messageSection.EstablishSecurityContext,
                    ClientCredentialType       = messageSection.ClientCredentialType,
                    NegotiateServiceCredential = messageSection.NegotiateServiceCredential,
                    AlgorithmSuite             = messageSection.AlgorithmSuite
                };

                var transportSection = section.Security.Transport;
                var transport        = new HttpTransportSecurity
                {
                    ClientCredentialType = transportSection.ClientCredentialType,
                    ProxyCredentialType  = transportSection.ProxyCredentialType
                };

                var wsHttpSecuritySection = section.Security;
                var wsHttpSecurity        = new WSHttpSecurity
                {
                    Mode      = wsHttpSecuritySection.Mode,
                    Transport = transport,
                    Message   = message
                };
                ;
                binding.Security = wsHttpSecurity;
                if (readerQuotas != null)
                {
                    binding.ReaderQuotas = readerQuotas;
                }
                binding.ReliableSession = reliableSession;

                configs.Add(binding);
            }
            return(configs);
        }
Пример #39
0
 public void SetInput(Stream stream, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose)
 {
     throw new NotImplementedException();
 }
Пример #40
0
 public void SetInput(byte[] buffer, int offset, int count, Encoding[] encodings, string contentType, XmlDictionaryReaderQuotas quotas, int maxBufferSize, OnXmlDictionaryReaderClose onClose)
 {
     throw new NotImplementedException();
 }
Пример #41
0
        public static List <NetMsmqBinding> GetNetMsmqBindings(string exeConfigPath)
        {
            if (string.IsNullOrWhiteSpace(exeConfigPath))
            {
                return(null);
            }

            var svcSection = Read.Config.ExeConfig.GetServiceModelSection(exeConfigPath);

            var configs = new List <NetMsmqBinding>();

            foreach (
                var section in
                svcSection.Bindings.NetMsmqBinding.ConfiguredBindings
                .Cast <NetMsmqBindingElement>())
            {
                var df      = new NetMsmqBinding();
                var binding = new NetMsmqBinding
                {
                    Name = section.Name,
                    MaxBufferPoolSize      = section.MaxBufferPoolSize > 0 ? section.MaxBufferPoolSize : df.MaxBufferPoolSize,
                    MaxReceivedMessageSize = section.MaxReceivedMessageSize > 0 ? section.MaxReceivedMessageSize : df.MaxReceivedMessageSize,
                    CloseTimeout           = section.CloseTimeout != TimeSpan.Zero ? section.CloseTimeout : df.CloseTimeout,
                    OpenTimeout            = section.OpenTimeout != TimeSpan.Zero ? section.OpenTimeout : df.OpenTimeout,
                    SendTimeout            = section.SendTimeout != TimeSpan.Zero ? section.SendTimeout : df.SendTimeout,
                    ReceiveTimeout         =
                        section.ReceiveTimeout != TimeSpan.Zero ? section.ReceiveTimeout : df.ReceiveTimeout,

                    MaxRetryCycles    = section.MaxRetryCycles > 0 ? section.MaxRetryCycles : df.MaxRetryCycles,
                    ReceiveRetryCount = section.ReceiveRetryCount > 0 ? section.ReceiveRetryCount : df.ReceiveRetryCount,
                    RetryCycleDelay   = section.RetryCycleDelay != TimeSpan.Zero ? section.RetryCycleDelay : df.RetryCycleDelay,
                    TimeToLive        = section.TimeToLive != TimeSpan.Zero ? section.TimeToLive : df.TimeToLive,


                    DeadLetterQueue       = section.DeadLetterQueue,
                    Durable               = section.Durable,
                    ExactlyOnce           = section.ExactlyOnce,
                    ReceiveErrorHandling  = section.ReceiveErrorHandling,
                    UseSourceJournal      = section.UseSourceJournal,
                    UseMsmqTracing        = section.UseMsmqTracing,
                    QueueTransferProtocol = section.QueueTransferProtocol,
                    UseActiveDirectory    = section.UseActiveDirectory
                };

                var readerQuotasSection = section.ReaderQuotas;
                var readerQuotas        = new System.Xml.XmlDictionaryReaderQuotas();
                if (readerQuotasSection != null && readerQuotasSection.MaxDepth > 0)
                {
                    readerQuotas.MaxDepth = readerQuotasSection.MaxDepth;
                    readerQuotas.MaxStringContentLength = readerQuotasSection.MaxStringContentLength;
                    readerQuotas.MaxArrayLength         = readerQuotasSection.MaxArrayLength;
                    readerQuotas.MaxBytesPerRead        = readerQuotasSection.MaxBytesPerRead;
                    readerQuotas.MaxNameTableCharCount  = readerQuotasSection.MaxNameTableCharCount;
                }
                else
                {
                    readerQuotas = null;
                }
                var msmqSecurity = new NetMsmqSecurity {
                    Mode = section.Security.Mode
                };
                var securityTransportSection = section.Security.Transport;
                var msmqSecurityTransport    = new MsmqTransportSecurity
                {
                    MsmqAuthenticationMode  = securityTransportSection.MsmqAuthenticationMode,
                    MsmqEncryptionAlgorithm = securityTransportSection.MsmqEncryptionAlgorithm,
                    MsmqProtectionLevel     = securityTransportSection.MsmqProtectionLevel,
                    MsmqSecureHashAlgorithm = securityTransportSection.MsmqSecureHashAlgorithm
                };
                var msmqSecurityMessage = new MessageSecurityOverMsmq
                {
                    ClientCredentialType = section.Security.Message.ClientCredentialType
                };
                msmqSecurity.Message   = msmqSecurityMessage;
                msmqSecurity.Transport = msmqSecurityTransport;
                binding.Security       = msmqSecurity;
                if (readerQuotas != null)
                {
                    binding.ReaderQuotas = readerQuotas;
                }
                configs.Add(binding);
            }
            return(configs);
        }