Author: atsushi
Date: 2007-03-07 12:40:20 -0500 (Wed, 07 Mar 2007)
New Revision: 73897

Modified:
   trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChannelListenerBase.cs
   trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/MessageSecurityBindingSupport.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecurityChannelListener.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecurityRequestContext.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchOperation.cs
   
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointDispatcher.cs
   
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog
   
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageTest.cs
Log:
2007-03-07  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * MessageSecurityBindingSupport.cs : for now, comment out the code
          that makes authenticator creation optional.
        * SecurityRequestContext.cs : don't decrypt message when it is
          WS-Trust messages. Also, do not secure SOAP Fault (it is likely
          to fail).
        * SecurityChannelListener.cs : GetProperty<T>() now returns
          MessageSecurityBindingSupport when requested. It is used by
          EndpointDispatcher to check if it supports WS-Trust negotiation.
        * ChannelListenerBase.cs :
          removed extra TODO and field. Implemented GetProperty<T>().
        * Message.cs : In CreateMessage() for SOAP Fault, create
          SimpleMessage with IsFault = true.

        * EndpointDispatcher.cs : now dispatcher-side foundation for token
          negotiation is ready. Handle negotiation message on its own way.
        * DispatchOperation.cs : instead of returning irrelevant SOAP Fault,
          simply raise an error and let FaultConverter do better work.

        * MessageTest.cs : added IsFault().



Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog    
    2007-03-07 17:18:33 UTC (rev 73896)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog    
    2007-03-07 17:40:20 UTC (rev 73897)
@@ -1,5 +1,20 @@
 2007-03-07  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * MessageSecurityBindingSupport.cs : for now, comment out the code
+         that makes authenticator creation optional.
+       * SecurityRequestContext.cs : don't decrypt message when it is
+         WS-Trust messages. Also, do not secure SOAP Fault (it is likely
+         to fail).
+       * SecurityChannelListener.cs : GetProperty<T>() now returns
+         MessageSecurityBindingSupport when requested. It is used by
+         EndpointDispatcher to check if it supports WS-Trust negotiation.
+       * ChannelListenerBase.cs :
+         removed extra TODO and field. Implemented GetProperty<T>().
+       * Message.cs : In CreateMessage() for SOAP Fault, create
+         SimpleMessage with IsFault = true.
+
+2007-03-07  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * SecurityRequestContext.cs : try to reply fault with the inner
          channel when an error occurred internally.
        * FaultConverter.cs : implemented based on OperationContext (at normal

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChannelListenerBase.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChannelListenerBase.cs
   2007-03-07 17:18:33 UTC (rev 73896)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/ChannelListenerBase.cs
   2007-03-07 17:40:20 UTC (rev 73897)
@@ -36,7 +36,6 @@
                IChannelListener, ICommunicationObject,
                IDefaultCommunicationTimeouts
        {
-               IChannelListener inner_listener;
                IDefaultCommunicationTimeouts timeouts;
 
                protected ChannelListenerBase ()
@@ -84,10 +83,9 @@
                        get { return timeouts.SendTimeout; }
                }
 
-               [MonoTODO]
                public virtual T GetProperty<T> () where T : class
                {
-                       throw new NotImplementedException ();
+                       return null;
                }
 
                public IAsyncResult BeginWaitForChannel (

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs   
    2007-03-07 17:18:33 UTC (rev 73896)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs   
    2007-03-07 17:40:20 UTC (rev 73897)
@@ -51,12 +51,10 @@
                        set { body_id = value; }
                }
 
-               [MonoTODO]
                public virtual bool IsEmpty {
                        get { return false; }
                }
 
-               [MonoTODO]
                public virtual bool IsFault {
                        get { return false; }
                }
@@ -337,8 +335,8 @@
                public static Message CreateMessage (MessageVersion version,
                        MessageFault fault, string action)
                {
-                       return CreateMessage (version, action,
-                               new MessageFaultBodyWriter (fault, version));
+                       return new SimpleMessage (version, action,
+                               new MessageFaultBodyWriter (fault, version), 
true);
                }
 
                public static Message CreateMessage (MessageVersion version,

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/MessageSecurityBindingSupport.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/MessageSecurityBindingSupport.cs
 2007-03-07 17:18:33 UTC (rev 73896)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/MessageSecurityBindingSupport.cs
 2007-03-07 17:40:20 UTC (rev 73897)
@@ -172,6 +172,7 @@
 
                protected void PrepareAuthenticator ()
                {
+#if false
                        // This check is almost extra, though it is needed
                        // to check correct signing token existence.
                        //
@@ -179,6 +180,7 @@
                        // Ssl parameters do not support token provider and
                        // still do not fail. X509 parameters do fail.
                        if 
(RecipientParameters.InternalSupportsClientAuthentication)
+#endif
                                authenticator = CreateTokenAuthenticator 
(RecipientParameters, out auth_token_resolver);
                }
 

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecurityChannelListener.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecurityChannelListener.cs
       2007-03-07 17:18:33 UTC (rev 73896)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecurityChannelListener.cs
       2007-03-07 17:40:20 UTC (rev 73897)
@@ -56,6 +56,13 @@
                        get { return security; }
                }
 
+               public override T GetProperty<T> ()
+               {
+                       if (typeof (T) == typeof 
(MessageSecurityBindingSupport))
+                               return (T) (object) security;
+                       return base.GetProperty<T> ();
+               }
+
                TChannel CreateSecurityWrapper (TChannel src)
                {
                        if (typeof (TChannel) == typeof (IReplyChannel))

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecurityRequestContext.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecurityRequestContext.cs
        2007-03-07 17:18:33 UTC (rev 73896)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Channels/SecurityRequestContext.cs
        2007-03-07 17:40:20 UTC (rev 73897)
@@ -70,11 +70,17 @@
                public override Message RequestMessage {
                        get {
                                if (msg == null) {
-                                       try {
-                                               msg = new 
RecipientSecureMessageDecryptor (SourceBuffer.CreateMessage (), 
security).DecryptMessage ();
-                                       } finally {
-                                               if (msg == null)
-                                                       msg = 
SourceBuffer.CreateMessage ();
+                                       msg = SourceBuffer.CreateMessage (); // 
default
+                                       switch (msg.Headers.Action) {
+                                       case Constants.WstIssueAction:
+                                       case Constants.WstIssueReplyAction:
+                                       case Constants.WstRenewAction:
+                                       case Constants.WstCancelAction:
+                                       case Constants.WstValidateAction:
+                                               break;
+                                       default:
+                                               msg = new 
RecipientSecureMessageDecryptor (msg, security).DecryptMessage ();
+                                               break;
                                        }
                                }
                                return msg;
@@ -121,7 +127,9 @@
                public override void Reply (Message message, TimeSpan timeout)
                {
                        try {
-                               message = SecureMessage (message);
+                               // FIXME: it also needs to exclude WS-Trust RSTR
+                               if (!message.IsFault)
+                                       message = SecureMessage (message);
                                source.Reply (message, timeout);
                        } catch (Exception ex) {
                                FaultConverter fc = 
FaultConverter.GetDefaultFaultConverter (msg.Version);

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog  
    2007-03-07 17:18:33 UTC (rev 73896)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/ChangeLog  
    2007-03-07 17:40:20 UTC (rev 73897)
@@ -1,5 +1,12 @@
 2007-03-07  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * EndpointDispatcher.cs : now dispatcher-side foundation for token
+         negotiation is ready. Handle negotiation message on its own way.
+       * DispatchOperation.cs : instead of returning irrelevant SOAP Fault,
+         simply raise an error and let FaultConverter do better work.
+
+2007-03-07  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * EndpointDispatcher.cs : use ErrorHandlers when error was raised.
          Handle exceptions to make into SOAP Fault, using FaultConverter.
        * ChannelDispatcher.cs : simply get ServiceEndpoint at Attach().

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchOperation.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchOperation.cs
   2007-03-07 17:18:33 UTC (rev 73896)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/DispatchOperation.cs
   2007-03-07 17:40:20 UTC (rev 73897)
@@ -243,7 +243,7 @@
                                InstanceContext ictx = 
parent.InstanceContextProvider.GetExistingInstanceContext (req, null);
                                if (ictx == null)
                                        //FIXME: What should be done here?
-                                       return CreateActionNotSupported (req);
+                                       throw new InvalidOperationException 
("The instance context provider failed to get or create an instance context");
                                instance = ictx.GetServiceInstance ();
                        } else {
                                instance = parent.InstanceProvider != null ?

Modified: 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointDispatcher.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointDispatcher.cs
  2007-03-07 17:18:33 UTC (rev 73896)
+++ 
trunk/olive/class/System.ServiceModel/System.ServiceModel.Dispatcher/EndpointDispatcher.cs
  2007-03-07 17:40:20 UTC (rev 73897)
@@ -32,6 +32,7 @@
 using System.ServiceModel.Description;
 using System.ServiceModel.Channels;
 using System.ServiceModel.Dispatcher;
+using System.ServiceModel.Security.Tokens;
 using System.Text;
 
 namespace System.ServiceModel.Dispatcher
@@ -162,10 +163,27 @@
                                throw new EndpointNotFoundException 
(String.Format ("The request message has the target '{0}' which is not 
reachable in this service contract", rc.RequestMessage.Headers.To));
 
                        Message req = rc.RequestMessage;
+                       Message res = null;
+
                        DispatchOperation op = GetOperation (req);
-                       Message res = op.ProcessRequest (req);
+                       if (op == null) {
+                               // process WS-Trust based negotiation
+                               MessageSecurityBindingSupport support =
+                                       
ChannelDispatcher.Listener.GetProperty<MessageSecurityBindingSupport> ();
+                               if (support != null && req.Headers.FindHeader 
("Security", Constants.WssNamespace) < 0) {
+                                       CommunicationSecurityTokenAuthenticator 
nego =
+                                               support.TokenAuthenticator as 
CommunicationSecurityTokenAuthenticator;
+                                       if (nego != null)
+                                               res = 
nego.Communication.ProcessNegotiation (req);
+                               }
+                               if (res == null)
+                                       op = 
DispatchRuntime.UnhandledDispatchOperation;
+                       }
                        if (res == null)
+                               res = op.ProcessRequest (req);
+                       if (res == null)
                                throw new InvalidOperationException 
(String.Format ("The operation '{0}' returned a null message.", op.Action));
+
                        rc.Reply (res, se.Binding.SendTimeout);
                }
 
@@ -193,6 +211,10 @@
                                        throw new EndpointNotFoundException 
(String.Format ("The input message has the target '{0}' which is not reachable 
in this service contract", msg.Headers.To));
 
                                DispatchOperation op = GetOperation (msg);
+                               // IInputChannel is also simpler since there
+                               // is no chance for token negotiation.
+                               if (op == null)
+                                       op = 
DispatchRuntime.UnhandledDispatchOperation;
                                op.ProcessInput (msg);
                        }
                }
@@ -220,8 +242,7 @@
                                        if (d.Action == action)
                                                return d;
                        }
-
-                       return DispatchRuntime.UnhandledDispatchOperation;
+                       return null;
                }
                
                void HandleError (Exception ex)

Modified: 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog
   2007-03-07 17:18:33 UTC (rev 73896)
+++ 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/ChangeLog
   2007-03-07 17:40:20 UTC (rev 73897)
@@ -1,3 +1,7 @@
+2007-03-07  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
+       * MessageTest.cs : added IsFault().
+
 2007-03-06  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * SecurityBindingElementTest.cs :

Modified: 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageTest.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageTest.cs
      2007-03-07 17:18:33 UTC (rev 73896)
+++ 
trunk/olive/class/System.ServiceModel/Test/System.ServiceModel.Channels/MessageTest.cs
      2007-03-07 17:40:20 UTC (rev 73897)
@@ -310,5 +310,14 @@
                        Message m = Message.CreateMessage 
(MessageVersion.Default, "action", 1);
                        Assert.AreEqual (m.ToString (), m.ToString ());
                }
+
+               [Test]
+               public void IsFault ()
+               {
+                       Message m = Message.CreateMessage 
(MessageVersion.Default, "action", 1);
+                       Assert.IsFalse (m.IsFault, "#1");
+                       m = Message.CreateMessage (MessageVersion.Default, new 
FaultCode ("ActionNotSupported", "urn:myfault"), "I dunno", "urn:myaction");
+                       Assert.IsTrue (m.IsFault, "#2");
+               }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to