File: HttpTransportElement.cs

package info (click to toggle)
mono 4.6.2.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 778,148 kB
  • ctags: 914,052
  • sloc: cs: 5,779,509; xml: 2,773,713; ansic: 432,645; sh: 14,749; makefile: 12,361; perl: 2,488; python: 1,434; cpp: 849; asm: 531; sql: 95; sed: 16; php: 1
file content (268 lines) | stat: -rw-r--r-- 14,519 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
//------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
//------------------------------------------------------------------------------

namespace System.ServiceModel.Configuration
{
    using System.Configuration;
    using System.Diagnostics.CodeAnalysis;
    using System.ServiceModel;
    using System.Globalization;
    using System.Net;
    using System.Net.Security;
    using System.Runtime;
    using System.Security.Authentication.ExtendedProtection.Configuration;
    using System.Security.Principal;
    using System.ServiceModel.Channels;
    using System.ComponentModel;

    [SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationValidatorAttributeRule,
            Justification = "The ExtendedProtectionPolicyElement configuration object and the configuration validation is owned by the NCL team.")]
    public partial class HttpTransportElement : TransportElement
    {
        public HttpTransportElement()
        {
        }

        [ConfigurationProperty(ConfigurationStrings.AllowCookies, DefaultValue = HttpTransportDefaults.AllowCookies)]
        public bool AllowCookies
        {
            get { return (bool)base[ConfigurationStrings.AllowCookies]; }
            set { base[ConfigurationStrings.AllowCookies] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.RequestInitializationTimeout, DefaultValue = HttpTransportDefaults.RequestInitializationTimeoutString)]
        [TypeConverter(typeof(TimeSpanOrInfiniteConverter))]
        [ServiceModelTimeSpanValidator(MinValueString = ConfigurationStrings.TimeSpanZero)]
        public TimeSpan RequestInitializationTimeout
        {
            get { return (TimeSpan)base[ConfigurationStrings.RequestInitializationTimeout]; }
            set { base[ConfigurationStrings.RequestInitializationTimeout] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.AuthenticationScheme, DefaultValue = HttpTransportDefaults.AuthenticationScheme)]
        [StandardRuntimeFlagEnumValidator(typeof(AuthenticationSchemes))]
        public AuthenticationSchemes AuthenticationScheme
        {
            get { return (AuthenticationSchemes)base[ConfigurationStrings.AuthenticationScheme]; }
            set { base[ConfigurationStrings.AuthenticationScheme] = value; }
        }

        public override Type BindingElementType
        {
            get { return typeof(HttpTransportBindingElement); }
        }

        [ConfigurationProperty(ConfigurationStrings.BypassProxyOnLocal, DefaultValue = HttpTransportDefaults.BypassProxyOnLocal)]
        public bool BypassProxyOnLocal
        {
            get { return (bool)base[ConfigurationStrings.BypassProxyOnLocal]; }
            set { base[ConfigurationStrings.BypassProxyOnLocal] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.DecompressionEnabled, DefaultValue = HttpTransportDefaults.DecompressionEnabled)]
        public bool DecompressionEnabled
        {
            get { return (bool)base[ConfigurationStrings.DecompressionEnabled]; }
            set { base[ConfigurationStrings.DecompressionEnabled] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.HostNameComparisonMode, DefaultValue = HttpTransportDefaults.HostNameComparisonMode)]
        [ServiceModelEnumValidator(typeof(HostNameComparisonModeHelper))]
        public HostNameComparisonMode HostNameComparisonMode
        {
            get { return (HostNameComparisonMode)base[ConfigurationStrings.HostNameComparisonMode]; }
            set { base[ConfigurationStrings.HostNameComparisonMode] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.KeepAliveEnabled, DefaultValue = HttpTransportDefaults.KeepAliveEnabled)]
        public bool KeepAliveEnabled
        {
            get { return (bool)base[ConfigurationStrings.KeepAliveEnabled]; }
            set { base[ConfigurationStrings.KeepAliveEnabled] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.MaxBufferSize, DefaultValue = TransportDefaults.MaxBufferSize)]
        [IntegerValidator(MinValue = 1)]
        public int MaxBufferSize
        {
            get { return (int)base[ConfigurationStrings.MaxBufferSize]; }
            set { base[ConfigurationStrings.MaxBufferSize] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.MaxPendingAccepts, DefaultValue = HttpTransportDefaults.DefaultMaxPendingAccepts)]
        [IntegerValidator(MinValue = 0, MaxValue = HttpTransportDefaults.MaxPendingAcceptsUpperLimit)]
        public int MaxPendingAccepts
        {
            get { return (int)base[ConfigurationStrings.MaxPendingAccepts]; }
            set { base[ConfigurationStrings.MaxPendingAccepts] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.MessageHandlerFactory, DefaultValue = HttpTransportDefaults.MessageHandlerFactory)]
        [HttpMessageHandlerFactoryValidator]
        public HttpMessageHandlerFactoryElement MessageHandlerFactory
        {
            get { return (HttpMessageHandlerFactoryElement)this[ConfigurationStrings.MessageHandlerFactory]; }
            set { base[ConfigurationStrings.MessageHandlerFactory] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.ProxyAddress, DefaultValue = HttpTransportDefaults.ProxyAddress)]
        public Uri ProxyAddress
        {
            get { return (Uri)base[ConfigurationStrings.ProxyAddress]; }
            set { base[ConfigurationStrings.ProxyAddress] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.ProxyAuthenticationScheme, DefaultValue = HttpTransportDefaults.ProxyAuthenticationScheme)]
        [StandardRuntimeEnumValidator(typeof(AuthenticationSchemes))]
        public AuthenticationSchemes ProxyAuthenticationScheme
        {
            get { return (AuthenticationSchemes)base[ConfigurationStrings.ProxyAuthenticationScheme]; }
            set { base[ConfigurationStrings.ProxyAuthenticationScheme] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.Realm, DefaultValue = HttpTransportDefaults.Realm)]
        [StringValidator(MinLength = 0)]
        public string Realm
        {
            get { return (string)base[ConfigurationStrings.Realm]; }
            set
            {
                if (String.IsNullOrEmpty(value))
                {
                    value = String.Empty;
                }
                base[ConfigurationStrings.Realm] = value;
            }
        }

        [ConfigurationProperty(ConfigurationStrings.TransferMode, DefaultValue = HttpTransportDefaults.TransferMode)]
        [ServiceModelEnumValidator(typeof(TransferModeHelper))]
        public TransferMode TransferMode
        {
            get { return (TransferMode)base[ConfigurationStrings.TransferMode]; }
            set { base[ConfigurationStrings.TransferMode] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.UnsafeConnectionNtlmAuthentication, DefaultValue = HttpTransportDefaults.UnsafeConnectionNtlmAuthentication)]
        public bool UnsafeConnectionNtlmAuthentication
        {
            get { return (bool)base[ConfigurationStrings.UnsafeConnectionNtlmAuthentication]; }
            set { base[ConfigurationStrings.UnsafeConnectionNtlmAuthentication] = value; }
        }

        [ConfigurationProperty(ConfigurationStrings.UseDefaultWebProxy, DefaultValue = HttpTransportDefaults.UseDefaultWebProxy)]
        public bool UseDefaultWebProxy
        {
            get { return (bool)base[ConfigurationStrings.UseDefaultWebProxy]; }
            set { base[ConfigurationStrings.UseDefaultWebProxy] = value; }
        }


        [ConfigurationProperty(ConfigurationStrings.ExtendedProtectionPolicy)]
        public ExtendedProtectionPolicyElement ExtendedProtectionPolicy
        {
            get { return (ExtendedProtectionPolicyElement)base[ConfigurationStrings.ExtendedProtectionPolicy]; }
            private set { base[ConfigurationStrings.ExtendedProtectionPolicy] = value; }
        }

        [System.Diagnostics.CodeAnalysis.SuppressMessage(FxCop.Category.Configuration, "Configuration104")]
        [ConfigurationProperty(ConfigurationStrings.WebSocketSettingsSectionName)]
        public WebSocketTransportSettingsElement WebSocketSettings
        {
            get { return (WebSocketTransportSettingsElement)base[ConfigurationStrings.WebSocketSettingsSectionName]; }
            set { base[ConfigurationStrings.WebSocketSettingsSectionName] = value; }
        }

        public override void ApplyConfiguration(BindingElement bindingElement)
        {
            base.ApplyConfiguration(bindingElement);
            HttpTransportBindingElement binding = (HttpTransportBindingElement)bindingElement;

            binding.AllowCookies = this.AllowCookies;
            binding.AuthenticationScheme = this.AuthenticationScheme;
            binding.BypassProxyOnLocal = this.BypassProxyOnLocal;
            binding.DecompressionEnabled = this.DecompressionEnabled;
            binding.KeepAliveEnabled = this.KeepAliveEnabled;
            binding.HostNameComparisonMode = this.HostNameComparisonMode;
            PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;
            if (propertyInfo[ConfigurationStrings.MaxBufferSize].ValueOrigin != PropertyValueOrigin.Default)
            {
                binding.MaxBufferSize = this.MaxBufferSize;
            }
            binding.MaxPendingAccepts = this.MaxPendingAccepts;
            binding.ProxyAddress = this.ProxyAddress;
            binding.ProxyAuthenticationScheme = this.ProxyAuthenticationScheme;
            binding.Realm = this.Realm;
            binding.RequestInitializationTimeout = this.RequestInitializationTimeout;
            binding.TransferMode = this.TransferMode;
            binding.UnsafeConnectionNtlmAuthentication = this.UnsafeConnectionNtlmAuthentication;
            binding.UseDefaultWebProxy = this.UseDefaultWebProxy;
            binding.ExtendedProtectionPolicy = ChannelBindingUtility.BuildPolicy(this.ExtendedProtectionPolicy);
            this.WebSocketSettings.ApplyConfiguration(binding.WebSocketSettings);
            if (this.MessageHandlerFactory != null)
            {
                binding.MessageHandlerFactory = HttpMessageHandlerFactory.CreateFromConfigurationElement(this.MessageHandlerFactory);
            }
        }

        public override void CopyFrom(ServiceModelExtensionElement from)
        {
            base.CopyFrom(from);

            HttpTransportElement source = (HttpTransportElement)from;
#pragma warning suppress 56506 // [....], base.CopyFrom() validates the argument
            this.AllowCookies = source.AllowCookies;
            this.RequestInitializationTimeout = source.RequestInitializationTimeout;
            this.AuthenticationScheme = source.AuthenticationScheme;
            this.BypassProxyOnLocal = source.BypassProxyOnLocal;
            this.DecompressionEnabled = source.DecompressionEnabled;
            this.KeepAliveEnabled = source.KeepAliveEnabled;
            this.HostNameComparisonMode = source.HostNameComparisonMode;
            this.MaxBufferSize = source.MaxBufferSize;
            this.MaxPendingAccepts = source.MaxPendingAccepts;
            this.ProxyAddress = source.ProxyAddress;
            this.ProxyAuthenticationScheme = source.ProxyAuthenticationScheme;
            this.Realm = source.Realm;
            this.TransferMode = source.TransferMode;
            this.UnsafeConnectionNtlmAuthentication = source.UnsafeConnectionNtlmAuthentication;
            this.UseDefaultWebProxy = source.UseDefaultWebProxy;
            this.WebSocketSettings = source.WebSocketSettings;
            this.MessageHandlerFactory = source.MessageHandlerFactory;
            ChannelBindingUtility.CopyFrom(source.ExtendedProtectionPolicy, this.ExtendedProtectionPolicy);
        }

        protected override TransportBindingElement CreateDefaultBindingElement()
        {
            return new HttpTransportBindingElement();
        }

        protected internal override void InitializeFrom(BindingElement bindingElement)
        {
            base.InitializeFrom(bindingElement);
            HttpTransportBindingElement source = (HttpTransportBindingElement)bindingElement;
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.AllowCookies, source.AllowCookies);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.AuthenticationScheme, source.AuthenticationScheme);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.DecompressionEnabled, source.DecompressionEnabled);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.BypassProxyOnLocal, source.BypassProxyOnLocal);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.KeepAliveEnabled, source.KeepAliveEnabled);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.HostNameComparisonMode, source.HostNameComparisonMode);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxBufferSize, source.MaxBufferSize);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxPendingAccepts, source.MaxPendingAccepts);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ProxyAddress, source.ProxyAddress);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ProxyAuthenticationScheme, source.ProxyAuthenticationScheme);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.Realm, source.Realm);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.RequestInitializationTimeout, source.RequestInitializationTimeout);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TransferMode, source.TransferMode);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.UnsafeConnectionNtlmAuthentication, source.UnsafeConnectionNtlmAuthentication);
            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.UseDefaultWebProxy, source.UseDefaultWebProxy);
            this.WebSocketSettings.InitializeFrom(source.WebSocketSettings);
            if (source.MessageHandlerFactory != null)
            {
                this.MessageHandlerFactory = source.MessageHandlerFactory.GenerateConfigurationElement();
            }

            ChannelBindingUtility.InitializeFrom(source.ExtendedProtectionPolicy, this.ExtendedProtectionPolicy);
        }
    }
}