Add ExtendedProtectionPolicy members. Required by .config files by .NET svcutil.
authorAtsushi Eno <atsushi@ximian.com>
Wed, 20 Oct 2010 09:06:02 +0000 (18:06 +0900)
committerAtsushi Eno <atsushi@ximian.com>
Wed, 20 Oct 2010 09:06:02 +0000 (18:06 +0900)
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpTransportBindingElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpTransportElement.cs
mcs/class/System.ServiceModel/System.ServiceModel.Configuration/HttpTransportSecurityElement.cs
mcs/class/System.ServiceModel/System.ServiceModel/BasicHttpBinding.cs
mcs/class/System.ServiceModel/System.ServiceModel/HttpTransportSecurity.cs

index acd10c63099b6f524eaae0c6ec63aa27a8f52362..8e65f76f9d083b3f0ec6db4e0a1b2f165c5f01e0 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Atsushi Enomoto <atsushi@ximian.com>
 //
-// Copyright (C) 2005 Novell, Inc.  http://www.novell.com
+// Copyright (C) 2005-2010 Novell, Inc.  http://www.novell.com
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
 //
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
 using System.Net;
 using System.Net.Security;
+#if NET_4_0
+using System.Security.Authentication.ExtendedProtection;
+#endif
 using System.ServiceModel.Channels;
 #if !NET_2_1
 using System.ServiceModel.Channels.Http;
@@ -81,50 +85,90 @@ namespace System.ServiceModel.Channels
                        auth_scheme = other.auth_scheme;
                        proxy_auth_scheme = other.proxy_auth_scheme;
 #endif
+
+#if NET_4_0
+                       DecompressionEnabled = other.DecompressionEnabled;
+                       LegacyExtendedProtectionPolicy = other.LegacyExtendedProtectionPolicy;
+                       ExtendedProtectionPolicy = other.ExtendedProtectionPolicy;
+#endif
                }
 
 #if !MOONLIGHT
+#if NET_4_0
+               [DefaultValue (AuthenticationSchemes.Anonymous)]
+#endif
                public AuthenticationSchemes AuthenticationScheme {
                        get { return auth_scheme; }
                        set { auth_scheme = value; }
                }
 
+#if NET_4_0
+               [DefaultValue (AuthenticationSchemes.Anonymous)]
+#endif
                public AuthenticationSchemes ProxyAuthenticationScheme {
                        get { return proxy_auth_scheme; }
                        set { proxy_auth_scheme = value; }
                }
 #endif
 
+#if NET_4_0
+               [DefaultValue (false)]
+#endif
                public bool AllowCookies {
                        get { return allow_cookies; }
                        set { allow_cookies = value; }
                }
 
+#if NET_4_0
+               [DefaultValue (false)]
+#endif
                public bool BypassProxyOnLocal {
                        get { return bypass_proxy_on_local; }
                        set { bypass_proxy_on_local = value; }
                }
 
+#if NET_4_0
+               [DefaultValue (false)]
+               [MonoTODO]
+               public bool DecompressionEnabled { get; set; }
+#endif
+
+#if NET_4_0
+               [DefaultValue (HostNameComparisonMode.StrongWildcard)]
+#endif
                public HostNameComparisonMode HostNameComparisonMode {
                        get { return host_cmp_mode; }
                        set { host_cmp_mode = value; }
                }
 
+#if NET_4_0
+               [DefaultValue (true)]
+#endif
                public bool KeepAliveEnabled {
                        get { return keep_alive_enabled; }
                        set { keep_alive_enabled = value; }
                }
 
+#if NET_4_0
+               [DefaultValue (0x10000)]
+#endif
                public int MaxBufferSize {
                        get { return max_buffer_size; }
                        set { max_buffer_size = value; }
                }
 
+#if NET_4_0
+               [DefaultValue (null)]
+               [TypeConverter (typeof (UriTypeConverter))]
+#endif
                public Uri ProxyAddress {
                        get { return proxy_address; }
                        set { proxy_address = value; }
                }
 
+#if NET_4_0
+               [DefaultValue ("")]
+#endif
                public string Realm {
                        get { return realm; }
                        set { realm = value; }
@@ -134,21 +178,39 @@ namespace System.ServiceModel.Channels
                        get { return Uri.UriSchemeHttp; }
                }
 
+#if NET_4_0
+               [DefaultValue (TransferMode.Buffered)]
+#endif
                public TransferMode TransferMode {
                        get { return transfer_mode; }
                        set { transfer_mode = value; }
                }
 
+#if NET_4_0
+               [DefaultValue (false)]
+#endif
                public bool UnsafeConnectionNtlmAuthentication {
                        get { return unsafe_ntlm_auth; }
                        set { unsafe_ntlm_auth = value; }
                }
 
+#if NET_4_0
+               [DefaultValue (true)]
+#endif
                public bool UseDefaultWebProxy {
                        get { return use_default_proxy; }
                        set { use_default_proxy = value; }
                }
 
+#if NET_4_0
+               [Obsolete ("Use ExtendedProtectionPolicy")]
+               [MonoTODO]
+               public object LegacyExtendedProtectionPolicy { get; set; }
+
+               [MonoTODO]
+               public ExtendedProtectionPolicy ExtendedProtectionPolicy { get; set; }
+#endif
+
                public override bool CanBuildChannelFactory<TChannel> (
                        BindingContext context)
                {
index 1933d25a0e805b07a76f1a253c699be5edba244c..7ab8f4eed590eb593b0bd439101e20cd8d66cda1 100644 (file)
@@ -35,6 +35,10 @@ using System.Configuration;
 using System.Net;
 using System.Net.Security;
 using System.Reflection;
+#if NET_4_0
+using System.Security.Authentication.ExtendedProtection;
+using System.Security.Authentication.ExtendedProtection.Configuration;
+#endif
 using System.Security.Cryptography.X509Certificates;
 using System.Security.Principal;
 using System.IdentityModel.Claims;
@@ -123,7 +127,9 @@ namespace System.ServiceModel.Configuration
                protected override ConfigurationPropertyCollection Properties {
                        get {
                                if (_properties == null) {
-                                       _properties = base.Properties;
+                                       _properties = new ConfigurationPropertyCollection ();
+                                       foreach (ConfigurationProperty cp in base.Properties)
+                                               _properties.Add (cp);
                                        _properties.Add (new ConfigurationProperty ("allowCookies", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
                                        _properties.Add (new ConfigurationProperty ("authenticationScheme", typeof (AuthenticationSchemes), "Anonymous", null, null, ConfigurationPropertyOptions.None));
                                        _properties.Add (new ConfigurationProperty ("bypassProxyOnLocal", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
@@ -136,11 +142,31 @@ namespace System.ServiceModel.Configuration
                                        _properties.Add (new ConfigurationProperty ("transferMode", typeof (TransferMode), "Buffered", null, null, ConfigurationPropertyOptions.None));
                                        _properties.Add (new ConfigurationProperty ("unsafeConnectionNtlmAuthentication", typeof (bool), "false", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
                                        _properties.Add (new ConfigurationProperty ("useDefaultWebProxy", typeof (bool), "true", new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+#if NET_4_0
+                                       _properties.Add (new ConfigurationProperty ("decompressionEnabled", typeof (bool), false, new BooleanConverter (), null, ConfigurationPropertyOptions.None));
+                                       _properties.Add (new ConfigurationProperty ("extendedProtectionPolicy", typeof (ExtendedProtectionPolicyElement), null, new ExtendedProtectionPolicyTypeConverter (), null, ConfigurationPropertyOptions.None));
+#endif
                                }
                                return _properties;
                        }
                }
 
+#if NET_4_0
+               [ConfigurationProperty ("decompressionEnabled",
+                        Options = ConfigurationPropertyOptions.None)]
+               public bool DecompressionEnabled {
+                       get { return (bool) base ["decompressionEnabled"]; }
+                       set { base ["decompressionEnabled"] = value; }
+               }
+
+               [ConfigurationProperty ("extendedProtectionPolicy",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ExtendedProtectionPolicyElement ExtendedProtectionPolicy {
+                       get { return (ExtendedProtectionPolicyElement) base ["extendedProtectionPolicy"]; }
+                       set { base ["extendedProtectionPolicy"] = value; }
+               }
+#endif
+
                [ConfigurationProperty ("proxyAddress",
                         Options = ConfigurationPropertyOptions.None,
                         DefaultValue = null)]
@@ -208,6 +234,11 @@ namespace System.ServiceModel.Configuration
                        b.TransferMode = TransferMode;
                        b.UnsafeConnectionNtlmAuthentication = UnsafeConnectionNtlmAuthentication;
                        b.UseDefaultWebProxy = UseDefaultWebProxy;
+#if NET_4_0
+                       b.DecompressionEnabled = DecompressionEnabled;
+                       // FIXME: enable this.
+                       //b.ExtendedProtectionPolicy = ExtendedProtectionPolicy.BuildPolicy ();
+#endif
                }
 
                public override void CopyFrom (ServiceModelExtensionElement from)
@@ -226,6 +257,15 @@ namespace System.ServiceModel.Configuration
                        TransferMode = e.TransferMode;
                        UnsafeConnectionNtlmAuthentication = e.UnsafeConnectionNtlmAuthentication;
                        UseDefaultWebProxy = e.UseDefaultWebProxy;
+#if NET_4_0
+                       DecompressionEnabled = e.DecompressionEnabled;
+                       // FIXME: enable this.
+                       /*
+                       ExtendedProtectionPolicy = new ExtendedProtectionPolicyElement () { PolicyEnforcement = e.ExtendedProtectionPolicy.PolicyEnforcement, ProtectionScenario = e.ExtendedProtectionPolicy.ProtectionScenario };
+                       foreach (var sne in ExtendedProtectionPolicy.CustomServiceNames)
+                               ExtendedProtectionPolicy.CustomServiceNames.Add (sne);
+                       */
+#endif
                }
 
                protected override TransportBindingElement CreateDefaultBindingElement ()
@@ -249,7 +289,15 @@ namespace System.ServiceModel.Configuration
                        TransferMode = b.TransferMode;
                        UnsafeConnectionNtlmAuthentication = b.UnsafeConnectionNtlmAuthentication;
                        UseDefaultWebProxy = b.UseDefaultWebProxy;
+#if NET_4_0
+                       DecompressionEnabled = b.DecompressionEnabled;
+                       // FIXME: enable this.
+                       /*
+                       ExtendedProtectionPolicy = new ExtendedProtectionPolicyElement () { PolicyEnforcement = b.ExtendedProtectionPolicy.PolicyEnforcement, ProtectionScenario = b.ExtendedProtectionPolicy.ProtectionScenario };
+                       foreach (var sn in b.ExtendedProtectionPolicy.CustomServiceNames)
+                               ExtendedProtectionPolicy.CustomServiceNames.Add (new ServiceNameElement () { Name = sn.ToString () });
+                       */
+#endif
                }
        }
-
 }
index 1e578bd877b287fa3f7675047de12fc3449731bc..4640bed514525093bf4593831144bb8c6acc7914 100644 (file)
@@ -35,6 +35,10 @@ using System.Configuration;
 using System.Net;
 using System.Net.Security;
 using System.Reflection;
+#if NET_4_0
+using System.Security.Authentication.ExtendedProtection;
+using System.Security.Authentication.ExtendedProtection.Configuration;
+#endif
 using System.Security.Cryptography.X509Certificates;
 using System.Security.Principal;
 using System.IdentityModel.Claims;
@@ -63,6 +67,7 @@ namespace System.ServiceModel.Configuration
                static ConfigurationProperty client_credential_type;
                static ConfigurationProperty proxy_credential_type;
                static ConfigurationProperty realm;
+               static ConfigurationProperty extended_protection_policy;
 
                static HttpTransportSecurityElement ()
                {
@@ -79,9 +84,16 @@ namespace System.ServiceModel.Configuration
                                typeof (string), "", new StringConverter (), null,
                                ConfigurationPropertyOptions.None);
 
+#if NET_4_0
+                       extended_protection_policy = new ConfigurationProperty ("extendedProtectionPolicy",
+                               typeof (ExtendedProtectionPolicyElement), null, new ExtendedProtectionPolicyTypeConverter (), null,
+                               ConfigurationPropertyOptions.None);
+#endif
+
                        properties.Add (client_credential_type);
                        properties.Add (proxy_credential_type);
                        properties.Add (realm);
+                       properties.Add (extended_protection_policy);
                }
 
                public HttpTransportSecurityElement ()
@@ -99,6 +111,15 @@ namespace System.ServiceModel.Configuration
                        set { base [client_credential_type] = value; }
                }
 
+#if NET_4_0
+               [ConfigurationProperty ("extendedProtectionPolicy",
+                        Options = ConfigurationPropertyOptions.None)]
+               public ExtendedProtectionPolicyElement extendedProtectionPolicy {
+                       get { return (ExtendedProtectionPolicyElement) base [extended_protection_policy]; }
+                       set { base [extended_protection_policy] = value; }
+               }
+#endif
+
                protected override ConfigurationPropertyCollection Properties {
                        get { return properties; }
                }
@@ -127,6 +148,10 @@ namespace System.ServiceModel.Configuration
                        security.ClientCredentialType = ClientCredentialType;
                        security.ProxyCredentialType = ProxyCredentialType;
                        security.Realm = Realm;
+#if NET_4_0
+                       // FIXME: enable this
+                       // security.ExtendedProtectionPolicy = ExtendedProtectionPolicy.BuildPolicy ();
+#endif
                }
        }
 
index 297f9e25f6eb4d547c22a6b36954021fb52581a1..b1f18761be7a2fb0732d0d11dc7561c04d7a45d1 100644 (file)
@@ -251,6 +251,9 @@ namespace System.ServiceModel
                        h.ProxyAddress = ProxyAddress;
                        h.UseDefaultWebProxy = UseDefaultWebProxy;
                        h.TransferMode = TransferMode;
+#if NET_4_0
+                       h.ExtendedProtectionPolicy = Security.Transport.ExtendedProtectionPolicy;
+#endif
 
 #if !NET_2_1
                        switch (Security.Mode) {
index cb5f1c0215721ee5b838f6d1ec922731101dc18c..ba3f7a9bd373928ed904b8c43c4084ab8249fdae 100644 (file)
@@ -26,6 +26,9 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 using System;
+#if NET_4_0
+using System.Security.Authentication.ExtendedProtection;
+#endif
 using System.ServiceModel.Security;
 
 namespace System.ServiceModel
@@ -54,5 +57,10 @@ namespace System.ServiceModel
                        get { return realm; }
                        set { realm = value; }
                }
+
+#if NET_4_0
+               [MonoTODO]
+               public ExtendedProtectionPolicy ExtendedProtectionPolicy { get; set; }
+#endif
        }
 }