Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@ -74,13 +74,11 @@ namespace System.ServiceModel
TransportCredentialOnly,
}
#if NET_4_5
public enum BasicHttpsSecurityMode
{
Transport,
TransportWithMessageCredential
}
#endif
public enum CommunicationState
{
@ -241,9 +239,7 @@ namespace System.ServiceModel // used to be S.SM.Ch
Ntlm,
Windows,
Certificate,
#if NET_4_5
InheritedFromHost
#endif
}
public enum HttpProxyCredentialType
@ -411,17 +407,6 @@ namespace System.ServiceModel.Security
Custom,
}
#if !NET_4_5
public enum X509CertificateValidationMode
{
None,
PeerTrust,
ChainTrust,
PeerOrChainTrust,
Custom,
}
#endif
}
namespace System.ServiceModel.Security.Tokens

View File

@ -29,302 +29,3 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if !NET_4_5 && !MOBILE
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Security;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.Text;
using System.Xml;
using System.ServiceModel.Configuration;
namespace System.ServiceModel
{
public class BasicHttpBinding : Binding,
IBindingRuntimePreferences
{
bool allow_cookies, bypass_proxy_on_local;
HostNameComparisonMode host_name_comparison_mode
= HostNameComparisonMode.StrongWildcard;
long max_buffer_pool_size = 0x80000;
int max_buffer_size = 0x10000;
long max_recv_message_size = 0x10000;
WSMessageEncoding message_encoding
= WSMessageEncoding.Text;
Uri proxy_address;
XmlDictionaryReaderQuotas reader_quotas
= new XmlDictionaryReaderQuotas ();
EnvelopeVersion env_version = EnvelopeVersion.Soap11;
static readonly Encoding default_text_encoding = new UTF8Encoding ();
Encoding text_encoding = default_text_encoding;
TransferMode transfer_mode
= TransferMode.Buffered;
bool use_default_web_proxy = true;
BasicHttpSecurity security;
public BasicHttpBinding ()
: this (BasicHttpSecurityMode.None)
{
}
#if !NET_2_1
public BasicHttpBinding (string configurationName)
: this ()
{
BindingsSection bindingsSection = ConfigUtil.BindingsSection;
BasicHttpBindingElement el =
bindingsSection.BasicHttpBinding.Bindings [configurationName];
el.ApplyConfiguration (this);
}
#endif
public BasicHttpBinding (
BasicHttpSecurityMode securityMode)
{
security = new BasicHttpSecurity (securityMode);
}
public bool AllowCookies {
get { return allow_cookies; }
set { allow_cookies = value; }
}
public bool BypassProxyOnLocal {
get { return bypass_proxy_on_local; }
set { bypass_proxy_on_local = value; }
}
#if NET_2_1
public bool EnableHttpCookieContainer {
get; set;
}
#elif NET_4_5
[Obsolete ("Use AllowCookies.")]
public bool EnableHttpCookieContainer {
get { return AllowCookies; }
set { AllowCookies = value; }
}
#endif
public HostNameComparisonMode HostNameComparisonMode {
get { return host_name_comparison_mode; }
set { host_name_comparison_mode = value; }
}
public long MaxBufferPoolSize {
get { return max_buffer_pool_size; }
set {
if (value <= 0)
throw new ArgumentOutOfRangeException ();
max_buffer_pool_size = value;
}
}
public int MaxBufferSize {
get { return max_buffer_size; }
set {
if (value <= 0)
throw new ArgumentOutOfRangeException ();
max_buffer_size = value;
}
}
public long MaxReceivedMessageSize {
get { return max_recv_message_size; }
set {
if (value <= 0)
throw new ArgumentOutOfRangeException ();
max_recv_message_size = value;
}
}
public WSMessageEncoding MessageEncoding {
get { return message_encoding; }
set { message_encoding = value; }
}
public Uri ProxyAddress {
get { return proxy_address; }
set { proxy_address = value; }
}
public XmlDictionaryReaderQuotas ReaderQuotas {
get { return reader_quotas; }
set { reader_quotas = value; }
}
public override string Scheme {
get {
switch (Security.Mode) {
case BasicHttpSecurityMode.Transport:
case BasicHttpSecurityMode.TransportWithMessageCredential:
return Uri.UriSchemeHttps;
default:
return Uri.UriSchemeHttp;
}
}
}
public BasicHttpSecurity Security {
get { return security; }
}
public EnvelopeVersion EnvelopeVersion {
get { return env_version; }
}
internal static Encoding DefaultTextEncoding {
get { return default_text_encoding; }
}
public Encoding TextEncoding {
get { return text_encoding; }
set { text_encoding = value; }
}
public TransferMode TransferMode {
get { return transfer_mode; }
set { transfer_mode = value; }
}
public bool UseDefaultWebProxy {
get { return use_default_web_proxy; }
set { use_default_web_proxy = value; }
}
public override BindingElementCollection
CreateBindingElements ()
{
var list = new List<BindingElement> ();
var security = CreateSecurityBindingElement ();
if (security != null)
list.Add (security);
#if NET_2_1
if (EnableHttpCookieContainer)
list.Add (new HttpCookieContainerBindingElement ());
#endif
list.Add (BuildMessageEncodingBindingElement ());
list.Add (GetTransport ());
return new BindingElementCollection (list.ToArray ());
}
SecurityBindingElement CreateSecurityBindingElement ()
{
SecurityBindingElement element;
switch (Security.Mode) {
#if !NET_2_1
case BasicHttpSecurityMode.Message:
if (Security.Message.ClientCredentialType != BasicHttpMessageCredentialType.Certificate)
throw new InvalidOperationException ("When Message security is enabled in a BasicHttpBinding, the message security credential type must be BasicHttpMessageCredentialType.Certificate.");
element = SecurityBindingElement.CreateMutualCertificateBindingElement (
MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10);
break;
case BasicHttpSecurityMode.TransportWithMessageCredential:
if (Security.Message.ClientCredentialType != BasicHttpMessageCredentialType.Certificate)
// FIXME: pass proper security token parameters.
element = SecurityBindingElement.CreateCertificateOverTransportBindingElement ();
else
element = new AsymmetricSecurityBindingElement ();
break;
#endif
default:
return null;
}
#if !NET_2_1
element.SetKeyDerivation (false);
element.SecurityHeaderLayout = SecurityHeaderLayout.Lax;
#endif
return element;
}
MessageEncodingBindingElement BuildMessageEncodingBindingElement ()
{
if (MessageEncoding == WSMessageEncoding.Text) {
TextMessageEncodingBindingElement tm = new TextMessageEncodingBindingElement (
MessageVersion.CreateVersion (EnvelopeVersion, AddressingVersion.None), TextEncoding);
#if !NET_2_1
ReaderQuotas.CopyTo (tm.ReaderQuotas);
#endif
return tm;
}
else
#if NET_2_1
throw new SystemException ("INTERNAL ERROR: should not happen");
#else
return new MtomMessageEncodingBindingElement (
MessageVersion.CreateVersion (EnvelopeVersion, AddressingVersion.None), TextEncoding);
#endif
}
TransportBindingElement GetTransport ()
{
HttpTransportBindingElement h;
switch (Security.Mode) {
case BasicHttpSecurityMode.Transport:
case BasicHttpSecurityMode.TransportWithMessageCredential:
h = new HttpsTransportBindingElement ();
break;
default:
h = new HttpTransportBindingElement ();
break;
}
h.AllowCookies = AllowCookies;
h.BypassProxyOnLocal = BypassProxyOnLocal;
h.HostNameComparisonMode = HostNameComparisonMode;
h.MaxBufferPoolSize = MaxBufferPoolSize;
h.MaxBufferSize = MaxBufferSize;
h.MaxReceivedMessageSize = MaxReceivedMessageSize;
h.ProxyAddress = ProxyAddress;
h.UseDefaultWebProxy = UseDefaultWebProxy;
h.TransferMode = TransferMode;
#if NET_4_0
h.ExtendedProtectionPolicy = Security.Transport.ExtendedProtectionPolicy;
#endif
#if !NET_2_1 || MOBILE
switch (Security.Transport.ClientCredentialType) {
case HttpClientCredentialType.Basic:
h.AuthenticationScheme = AuthenticationSchemes.Basic;
break;
case HttpClientCredentialType.Ntlm:
h.AuthenticationScheme = AuthenticationSchemes.Ntlm;
break;
case HttpClientCredentialType.Windows:
h.AuthenticationScheme = AuthenticationSchemes.Negotiate;
break;
case HttpClientCredentialType.Digest:
h.AuthenticationScheme = AuthenticationSchemes.Digest;
break;
case HttpClientCredentialType.Certificate:
switch (Security.Mode) {
case BasicHttpSecurityMode.Transport:
(h as HttpsTransportBindingElement).RequireClientCertificate = true;
break;
case BasicHttpSecurityMode.TransportCredentialOnly:
throw new InvalidOperationException ("Certificate-based client authentication is not supported by 'TransportCredentialOnly' mode.");
}
break;
}
#endif
return h;
}
// explicit interface implementations
bool IBindingRuntimePreferences.ReceiveSynchronously {
get { return false; }
}
}
}
#endif

View File

@ -181,9 +181,7 @@ namespace System.ServiceModel
h.ProxyAddress = ProxyAddress;
h.UseDefaultWebProxy = UseDefaultWebProxy;
h.TransferMode = TransferMode;
#if NET_4_0
h.ExtendedProtectionPolicy = Security.Transport.ExtendedProtectionPolicy;
#endif
switch (Security.Transport.ClientCredentialType) {
case HttpClientCredentialType.Basic:

View File

@ -33,14 +33,12 @@ namespace System.ServiceModel
{
public sealed class BasicHttpSecurity
{
#if NET_4_0
public BasicHttpSecurity ()
{
this.mode = BasicHttpSecurityMode.None;
this.message = new BasicHttpMessageSecurity ();
this.transport = new HttpTransportSecurity ();
}
#endif
internal BasicHttpSecurity (BasicHttpSecurityMode mode)
{
@ -55,9 +53,7 @@ namespace System.ServiceModel
public BasicHttpMessageSecurity Message {
get { return message; }
#if NET_4_0
set { message = value; }
#endif
}
public BasicHttpSecurityMode Mode {
@ -67,9 +63,7 @@ namespace System.ServiceModel
public HttpTransportSecurity Transport {
get { return transport; }
#if NET_4_0
set { transport = value; }
#endif
}
}
}

View File

@ -153,9 +153,7 @@ namespace System.ServiceModel
h.UseDefaultWebProxy = UseDefaultWebProxy;
h.TransferMode = TransferMode;
#if NET_4_0
h.ExtendedProtectionPolicy = Security.Transport.ExtendedProtectionPolicy;
#endif
switch (Security.Transport.ClientCredentialType) {
case HttpClientCredentialType.Basic:

View File

@ -130,7 +130,6 @@ namespace System.ServiceModel
if (endpoint == null)
throw new InvalidOperationException (String.Format ("Client endpoint configuration '{0}' was not found in {1} endpoints.", endpointConfig, client.Endpoints.Count));
#if NET_4_0
var binding = String.IsNullOrEmpty (endpoint.Binding) ? null : ConfigUtil.CreateBinding (endpoint.Binding, endpoint.BindingConfiguration);
var contractType = ConfigUtil.GetTypeFromConfigString (endpoint.Contract, NamedConfigCategory.Contract);
if (contractType == null)
@ -151,7 +150,6 @@ namespace System.ServiceModel
if (binding == null && endpoint.Address != null) // look for protocol mapping
Endpoint.Binding = ConfigUtil.GetBindingByProtocolMapping (endpoint.Address);
}
#endif
if (Endpoint.Binding == null)
Endpoint.Binding = ConfigUtil.CreateBinding (endpoint.Binding, endpoint.BindingConfiguration);
if (Endpoint.Address == null)

View File

@ -129,7 +129,6 @@ namespace System.ServiceModel
Initialize (instance, binding, remoteAddress);
}
#if NET_4_0
protected ClientBase (ServiceEndpoint endpoint)
: this (null, endpoint)
{
@ -139,7 +138,6 @@ namespace System.ServiceModel
: this (instance, new ChannelFactory<TChannel> (endpoint))
{
}
#endif
internal ClientBase (ChannelFactory<TChannel> factory)
: this (null, factory)
@ -353,11 +351,7 @@ namespace System.ServiceModel
public object [] Results { get; private set; }
}
#if NET_4_0
protected internal
#else
internal
#endif
class ChannelBase<T> : IClientChannel, IOutputChannel, IRequestChannel where T : class
{
ServiceEndpoint endpoint;

View File

@ -92,7 +92,6 @@ namespace System.ServiceModel
{
}
#if NET_4_0
protected DuplexClientBase (object instance, ServiceEndpoint endpoint)
: this (new InstanceContext (instance), endpoint)
{
@ -102,7 +101,6 @@ namespace System.ServiceModel
: base (instance, endpoint)
{
}
#endif
public IDuplexContextChannel InnerDuplexChannel {
get { return (IDuplexContextChannel) base.InnerChannel; }

View File

@ -53,45 +53,30 @@ namespace System.ServiceModel
[DataMember]
public string HelpLink {
get;
#if !NET_4_5
private
#endif
set;
}
[DataMember]
public ExceptionDetail InnerException {
get;
#if !NET_4_5
private
#endif
set;
}
[DataMember]
public string Message {
get;
#if !NET_4_5
private
#endif
set;
}
[DataMember]
public string StackTrace {
get;
#if !NET_4_5
private
#endif
set;
}
[DataMember]
public string Type {
get;
#if !NET_4_5
private
#endif
set;
}

View File

@ -26,9 +26,7 @@
// 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
@ -39,11 +37,7 @@ namespace System.ServiceModel
HttpProxyCredentialType proxy;
string realm = String.Empty;
#if NET_4_0
public
#else
internal
#endif
HttpTransportSecurity ()
{
}
@ -63,9 +57,7 @@ namespace System.ServiceModel
set { realm = value; }
}
#if NET_4_0
[MonoTODO]
public ExtendedProtectionPolicy ExtendedProtectionPolicy { get; set; }
#endif
}
}

View File

@ -237,12 +237,10 @@ namespace System.ServiceModel
{
}
#if NET_4_0
[MonoTODO]
public SynchronizationContext SynchronizationContext {
get { throw new NotImplementedException (); }
set { throw new NotImplementedException (); }
}
#endif
}
}

View File

@ -32,9 +32,7 @@ using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Security;
using System.ServiceModel.Security.Tokens;
#if NET_4_0
using System.ServiceModel.Configuration;
#endif
using System.Text;
using System.Xml;
@ -67,7 +65,6 @@ namespace System.ServiceModel
transport = new TcpTransportBindingElement ();
}
#if NET_4_0
public NetTcpBinding (string configurationName)
: this ()
{
@ -75,7 +72,6 @@ namespace System.ServiceModel
var el = bindingsSection.NetTcpBinding.Bindings [configurationName];
el.ApplyConfiguration (this);
}
#endif
internal NetTcpBinding (TcpTransportBindingElement transport,
NetTcpSecurity security,
@ -133,9 +129,7 @@ namespace System.ServiceModel
public NetTcpSecurity Security {
get { return security; }
#if NET_4_0
set { security = value; }
#endif
}
public EnvelopeVersion EnvelopeVersion {

View File

@ -33,12 +33,10 @@ namespace System.ServiceModel
{
public sealed class NetTcpSecurity
{
#if NET_4_0
public NetTcpSecurity ()
: this (SecurityMode.Transport)
{
}
#endif
internal NetTcpSecurity (SecurityMode mode)
{
@ -53,9 +51,7 @@ namespace System.ServiceModel
public MessageSecurityOverTcp Message {
get { return message; }
#if NET_4_0
set { message = value; }
#endif
}
public SecurityMode Mode {
@ -65,9 +61,7 @@ namespace System.ServiceModel
public TcpTransportSecurity Transport {
get { return transport; }
#if NET_4_0
set { transport = value; }
#endif
}
}
}

View File

@ -203,7 +203,6 @@ namespace System.ServiceModel
return AddServiceEndpointCore (cd, binding, ea, listenUri);
}
#if NET_4_0
public virtual void AddServiceEndpoint (ServiceEndpoint endpoint)
{
if (endpoint == null)
@ -224,7 +223,6 @@ namespace System.ServiceModel
Description.Endpoints.Add (endpoint);
}
#endif
Type PopulateType (string typeName)
{
@ -323,10 +321,8 @@ namespace System.ServiceModel
if (service != null)
LoadConfigurationSection (service);
#if NET_4_0
// simplified configuration
AddServiceBehaviors (String.Empty, false);
#endif
// TODO: consider commonBehaviors here
// ensure ServiceAuthorizationBehavior
@ -346,13 +342,8 @@ namespace System.ServiceModel
void AddServiceBehaviors (string configurationName, bool throwIfNotFound)
{
#if NET_4_0
if (configurationName == null)
return;
#else
if (String.IsNullOrEmpty (configurationName))
return;
#endif
ServiceBehaviorElement behavior = ConfigUtil.BehaviorsSection.ServiceBehaviors [configurationName];
if (behavior == null) {
if (throwIfNotFound)
@ -384,7 +375,6 @@ namespace System.ServiceModel
foreach (ServiceEndpointElement endpoint in service.Endpoints) {
ServiceEndpoint se;
#if NET_4_0
var binding = String.IsNullOrEmpty (endpoint.Binding) ? null : ConfigUtil.CreateBinding (endpoint.Binding, endpoint.BindingConfiguration);
if (!String.IsNullOrEmpty (endpoint.Kind)) {
@ -404,10 +394,6 @@ namespace System.ServiceModel
binding = ConfigUtil.GetBindingByProtocolMapping (endpoint.Address);
se = AddServiceEndpoint (endpoint.Contract, binding, endpoint.Address);
}
#else
var binding = ConfigUtil.CreateBinding (endpoint.Binding, endpoint.BindingConfiguration);
se = AddServiceEndpoint (endpoint.Contract, binding, endpoint.Address);
#endif
// endpoint behaviors
EndpointBehaviorElement epbehavior = ConfigUtil.BehaviorsSection.EndpointBehaviors [endpoint.BehaviorConfiguration];
@ -488,7 +474,6 @@ namespace System.ServiceModel
foreach (ServiceEndpoint endPoint in Description.Endpoints)
endPoint.Validate ();
#if NET_4_0
// In 4.0, it seems that if there is no configured ServiceEndpoint, infer them from the service type.
if (Description.Endpoints.Count == 0) {
foreach (Type iface in Description.ServiceType.GetInterfaces ())
@ -502,7 +487,6 @@ namespace System.ServiceModel
AddServiceEndpoint (iface.FullName, binding, baddr);
}
}
#endif
if (Description.Endpoints.FirstOrDefault (e => e.Contract != mex_contract && !e.IsSystemEndpoint) == null)
throw new InvalidOperationException ("The ServiceHost must have at least one application endpoint (that does not include metadata exchange endpoint) defined by either configuration, behaviors or call to AddServiceEndpoint methods.");

View File

@ -30,9 +30,7 @@
namespace System.ServiceModel {
#if NET_4_0
[System.Runtime.CompilerServices.TypeForwardedFrom (Consts.AssemblySystemServiceModel_3_0)]
#endif
public static class ServiceHostingEnvironment
{
internal static bool InAspNet { get; set; }
@ -45,4 +43,4 @@ namespace System.ServiceModel {
}
}
#endif
#endif

View File

@ -47,12 +47,10 @@ namespace System.ServiceModel
{
}
#if NET_4_0
[MonoTODO]
public static TimeSpan SpnLookupTime {
get { throw new NotImplementedException (); }
set { throw new NotImplementedException (); }
}
#endif
}
}

View File

@ -34,11 +34,7 @@ namespace System.ServiceModel
[MonoTODO]
public sealed class TcpTransportSecurity
{
#if NET_4_0
public
#else
internal
#endif
TcpTransportSecurity ()
{
ClientCredentialType = TcpClientCredentialType.Windows; // huh