Merge pull request #496 from nicolas-raoul/unit-test-for-issue2907
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Channels / HttpsTransportBindingElement.cs
index 396a4276574c4cdafebf497b1ab6ed87e9102232..52f3a0e20cd515ca2b69f26e4689009b833a8104 100644 (file)
@@ -84,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
 }