Merge pull request #495 from nicolas-raoul/fix-for-issue2907-with-no-formatting-changes
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Channels / HttpsTransportBindingElement.cs
index b1889cfb1bbdb71964261714813102014d8c3275..52f3a0e20cd515ca2b69f26e4689009b833a8104 100644 (file)
@@ -40,7 +40,7 @@ namespace System.ServiceModel.Channels
                : HttpTransportBindingElement, ITransportTokenAssertionProvider,
                IPolicyExportExtension, IWsdlExportExtension
        {
-               bool req_cli_cert = true;
+               bool req_cli_cert = false;
 
                public HttpsTransportBindingElement ()
                {
@@ -50,7 +50,7 @@ namespace System.ServiceModel.Channels
                        HttpsTransportBindingElement other)
                        : base (other)
                {
-                       throw new NotImplementedException ();
+                       req_cli_cert = other.req_cli_cert;
                }
 
                public bool RequireClientCertificate {
@@ -62,11 +62,10 @@ namespace System.ServiceModel.Channels
                        get { return Uri.UriSchemeHttps; }
                }
 
-               [MonoTODO]
                public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
                        BindingContext context)
                {
-                       throw new NotImplementedException ();
+                       return base.BuildChannelFactory <TChannel> (context);
                }
 
 #if !NET_2_1
@@ -75,7 +74,7 @@ namespace System.ServiceModel.Channels
                        BuildChannelListener<TChannel> (
                        BindingContext context)
                {
-                       throw new NotImplementedException ();
+                       return base.BuildChannelListener <TChannel> (context);
                }
 #endif
 
@@ -85,11 +84,54 @@ namespace System.ServiceModel.Channels
                }
 
 #if !NET_2_1
-               [MonoTODO]
                public XmlElement GetTransportTokenAssertion ()
                {
-                       throw new NotImplementedException ();
+                       var doc = new XmlDocument ();
+                       var token = doc.CreateElement ("sp", "HttpsToken", PolicyImportHelper.SecurityPolicyNS);
+                       token.SetAttribute ("RequireClientCertificate", req_cli_cert ? "true" : "false");
+                       return token;
+               }
+
+               // overriden only in full profile
+               public override T GetProperty<T> (BindingContext context)
+               {
+                       if (typeof (T) == typeof (ISecurityCapabilities))
+                               return (T) (object) new HttpsBindingProperties (this);
+                       return base.GetProperty<T> (context);
                }
 #endif
        }
+
+#if !NET_2_1
+       class HttpsBindingProperties : HttpBindingProperties
+       {
+               HttpsTransportBindingElement source;
+
+               public HttpsBindingProperties (HttpsTransportBindingElement source)
+                       : base (source)
+               {
+                       this.source = source;
+               }
+
+               public override ProtectionLevel SupportedRequestProtectionLevel {
+                       get { return ProtectionLevel.EncryptAndSign; }
+               }
+
+               public override ProtectionLevel SupportedResponseProtectionLevel {
+                       get { return ProtectionLevel.EncryptAndSign; }
+               }
+
+               public override bool SupportsClientAuthentication {
+                       get { return source.RequireClientCertificate || base.SupportsClientAuthentication; }
+               }
+
+               public override bool SupportsServerAuthentication {
+                       get { return true; }
+               }
+
+               public override bool SupportsClientWindowsIdentity {
+                       get { return source.RequireClientCertificate || base.SupportsClientWindowsIdentity; }
+               }
+       }
+#endif
 }