// 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;
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; }
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)
{
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;
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));
_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)]
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)
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 ()
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
}
}
-
}
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;
static ConfigurationProperty client_credential_type;
static ConfigurationProperty proxy_credential_type;
static ConfigurationProperty realm;
+ static ConfigurationProperty extended_protection_policy;
static HttpTransportSecurityElement ()
{
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 ()
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; }
}
security.ClientCredentialType = ClientCredentialType;
security.ProxyCredentialType = ProxyCredentialType;
security.Realm = Realm;
+#if NET_4_0
+ // FIXME: enable this
+ // security.ExtendedProtectionPolicy = ExtendedProtectionPolicy.BuildPolicy ();
+#endif
}
}
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) {
// 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
get { return realm; }
set { realm = value; }
}
+
+#if NET_4_0
+ [MonoTODO]
+ public ExtendedProtectionPolicy ExtendedProtectionPolicy { get; set; }
+#endif
}
}