+2010-04-01 Atsushi Enomoto <atsushi@ximian.com>
+
+ * HttpTransportBindingElement.cs, HttpsTransportBindingElement.cs:
+ implement HttpsTransportBindingElement.GetProperty<T>(). Extend the
+ properties type from HTTP.
+
2010-04-01 Atsushi Enomoto <atsushi@ximian.com>
* FaultConverter.cs : use addressing version from the message.
{
throw new NotImplementedException ();
}
+#endif
+ }
- class HttpBindingProperties : ISecurityCapabilities, IBindingDeliveryCapabilities
- {
- HttpTransportBindingElement source;
+#if !NET_2_1
+ class HttpBindingProperties : ISecurityCapabilities, IBindingDeliveryCapabilities
+ {
+ HttpTransportBindingElement source;
- public HttpBindingProperties (HttpTransportBindingElement source)
- {
- this.source = source;
- }
+ public HttpBindingProperties (HttpTransportBindingElement source)
+ {
+ this.source = source;
+ }
- public bool AssuresOrderedDelivery {
- get { return false; }
- }
+ public bool AssuresOrderedDelivery {
+ get { return false; }
+ }
- public bool QueuedDelivery {
- get { return false; }
- }
+ public bool QueuedDelivery {
+ get { return false; }
+ }
- public ProtectionLevel SupportedRequestProtectionLevel {
- get { return ProtectionLevel.None; }
- }
+ public virtual ProtectionLevel SupportedRequestProtectionLevel {
+ get { return ProtectionLevel.None; }
+ }
- public ProtectionLevel SupportedResponseProtectionLevel {
- get { return ProtectionLevel.None; }
- }
+ public virtual ProtectionLevel SupportedResponseProtectionLevel {
+ get { return ProtectionLevel.None; }
+ }
- public bool SupportsClientAuthentication {
- get { return source.AuthenticationScheme != AuthenticationSchemes.Anonymous; }
- }
+ public virtual bool SupportsClientAuthentication {
+ get { return source.AuthenticationScheme != AuthenticationSchemes.Anonymous; }
+ }
- public bool SupportsServerAuthentication {
- get {
- switch (source.AuthenticationScheme) {
- case AuthenticationSchemes.Negotiate:
- return true;
- default:
- return false;
- }
+ public virtual bool SupportsServerAuthentication {
+ get {
+ switch (source.AuthenticationScheme) {
+ case AuthenticationSchemes.Negotiate:
+ return true;
+ default:
+ return false;
}
}
+ }
- public bool SupportsClientWindowsIdentity {
- get {
- switch (source.AuthenticationScheme) {
- case AuthenticationSchemes.Basic:
- case AuthenticationSchemes.Digest: // hmm... why? but they return true on .NET
- case AuthenticationSchemes.Negotiate:
- case AuthenticationSchemes.Ntlm:
- return true;
- default:
- return false;
- }
+ public virtual bool SupportsClientWindowsIdentity {
+ get {
+ switch (source.AuthenticationScheme) {
+ case AuthenticationSchemes.Basic:
+ case AuthenticationSchemes.Digest: // hmm... why? but they return true on .NET
+ case AuthenticationSchemes.Negotiate:
+ case AuthenticationSchemes.Ntlm:
+ return true;
+ default:
+ return false;
}
}
}
-#endif
}
+#endif
}
{
throw new NotImplementedException ();
}
+
+ // 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
}
+2010-04-01 Atsushi Enomoto <atsushi@ximian.com>
+
+ * HttpsTransportBindingElementTest.cs :
+ added test for GetProperty<T>().
+
2010-03-29 Atsushi Enomoto <atsushi@ximian.com>
* FaultConverterTest.cs : added more TryCreateException() tests.
b.Security.Mode = BasicHttpSecurityMode.Transport;
b.BuildChannelListener<IReplyChannel> (new Uri ("http://localhost:8080"));
}
+
+ [Test]
+ public void GetProperty ()
+ {
+ var b = new HttpsTransportBindingElement ();
+ var s = b.GetProperty<ISecurityCapabilities> (new BindingContext (new CustomBinding (), new BindingParameterCollection ()));
+ Assert.IsNotNull (s, "#1");
+ Assert.AreEqual (ProtectionLevel.EncryptAndSign, s.SupportedRequestProtectionLevel, "#2");
+ Assert.AreEqual (ProtectionLevel.EncryptAndSign, s.SupportedResponseProtectionLevel, "#3");
+ Assert.IsFalse (s.SupportsClientAuthentication, "#4");
+ Assert.IsFalse (s.SupportsClientWindowsIdentity, "#5");
+ Assert.IsTrue (s.SupportsServerAuthentication, "#6");
+
+ b.RequireClientCertificate = true;
+ s = b.GetProperty<ISecurityCapabilities> (new BindingContext (new CustomBinding (), new BindingParameterCollection ()));
+ Assert.IsTrue (s.SupportsClientAuthentication, "#7");
+ Assert.IsTrue (s.SupportsClientWindowsIdentity, "#8");
+ }
}
}