Example #1
0
        /// <summary>
        /// tell the server which client we are, so that it can provide the right service
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public override IMessage Invoke(IMessage msg)
        {
            msg.Properties["__Uri"] = this.CrossDomainURL;

            LogicalCallContext callContext = (LogicalCallContext)msg.Properties["__CallContext"];

            callContext.SetData("__ClientID", this.clientID);
            callContext.SetData("__ServiceID", this.serviceID);

            return(this.messageSink.SyncProcessMessage(msg));
        }
        [System.Security.SecurityCritical]  // auto-generated
        internal static byte[] DoDispatch(byte[] reqStmBuff,
                                          SmuggledMethodCallMessage smuggledMcm,
                                          out SmuggledMethodReturnMessage smuggledMrm)
        {
            //*********************** DE-SERIALIZE REQ-MSG ********************

            IMessage desReqMsg = null;

            if (smuggledMcm != null)
            {
                ArrayList deserializedArgs = smuggledMcm.FixupForNewAppDomain();
                desReqMsg = new MethodCall(smuggledMcm, deserializedArgs);
            }
            else
            {
                MemoryStream reqStm = new MemoryStream(reqStmBuff);
                desReqMsg = CrossAppDomainSerializer.DeserializeMessage(reqStm);
            }

            LogicalCallContext lcc = Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext;

            lcc.SetData(LCC_DATA_KEY, true);
            // now we can delegate to the DispatchMessage to do the rest

            IMessage retMsg = ChannelServices.SyncDispatchMessage(desReqMsg);

            lcc.FreeNamedDataSlot(LCC_DATA_KEY);

            smuggledMrm = SmuggledMethodReturnMessage.SmuggleIfPossible(retMsg);
            if (smuggledMrm != null)
            {
                return(null);
            }
            else
            {
                if (retMsg != null)
                {
                    // Null out the principal since we won't use it on the other side.
                    // This is handled inside of SmuggleIfPossible for method call
                    // messages.
                    LogicalCallContext callCtx = (LogicalCallContext)
                                                 retMsg.Properties[Message.CallContextKey];
                    if (callCtx != null)
                    {
                        if (callCtx.Principal != null)
                        {
                            callCtx.Principal = null;
                        }
                    }

                    return(CrossAppDomainSerializer.SerializeMessage(retMsg).GetBuffer());
                }

                //*********************** SERIALIZE RET-MSG ********************
                return(null);
            }
        } // DoDispatch
Example #3
0
        //Workaround is to set the activityid in remoting call's LogicalCallContext
        static LogicalCallContext SetActivityIdInLogicalCallContext(LogicalCallContext logicalCallContext)
        {
            if (TraceUtility.ActivityTracing)
            {
                logicalCallContext.SetData(activityIdSlotName, DiagnosticTraceBase.ActivityId);
            }

            return(logicalCallContext);
        }
 public IMessage SyncProcessMessage(IMessage msg)
 {
     // only for method calls
     if (msg as IMethodCallMessage != null)
     {
         LogicalCallContext lcc =
             (LogicalCallContext)msg.Properties["__CallContext"];
         lcc.SetData("priority", Thread.CurrentThread.Priority);
         return(_nextMsgSink.SyncProcessMessage(msg));
     }
     else
     {
         return(_nextMsgSink.SyncProcessMessage(msg));
     }
 }
Example #5
0
        internal static LogicalCallContext CreateLogicalCallContext(bool createEmpty)
        {
            var lcc = Current._lcc;
            LogicalCallContext ctx = null;

            if (lcc != null && lcc.HasInfo)
            {
                ctx = new LogicalCallContext();
                foreach (DictionaryEntry entry in lcc.Datastore)
                {
                    ctx.SetData((string)entry.Key, entry.Value);
                }
            }
            else if (createEmpty)
            {
                ctx = new LogicalCallContext();
            }

            return(ctx);
        }
Example #6
0
        internal static byte[] DoDispatch(byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, out SmuggledMethodReturnMessage smuggledMrm)
        {
            IMessage msg1;

            if (smuggledMcm != null)
            {
                ArrayList deserializedArgs = smuggledMcm.FixupForNewAppDomain();
                msg1 = (IMessage) new MethodCall(smuggledMcm, deserializedArgs);
            }
            else
            {
                msg1 = CrossAppDomainSerializer.DeserializeMessage(new MemoryStream(reqStmBuff));
            }
            LogicalCallContext logicalCallContext1 = Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext;
            string             name1 = "__xADCall";
            // ISSUE: variable of a boxed type
            __Boxed <bool> local = (ValueType)true;

            logicalCallContext1.SetData(name1, (object)local);
            IMessage msg2  = ChannelServices.SyncDispatchMessage(msg1);
            string   name2 = "__xADCall";

            logicalCallContext1.FreeNamedDataSlot(name2);
            smuggledMrm = SmuggledMethodReturnMessage.SmuggleIfPossible(msg2);
            if (smuggledMrm != null)
            {
                return((byte[])null);
            }
            if (msg2 == null)
            {
                return((byte[])null);
            }
            LogicalCallContext logicalCallContext2 = (LogicalCallContext)msg2.Properties[(object)Message.CallContextKey];

            if (logicalCallContext2 != null && logicalCallContext2.Principal != null)
            {
                logicalCallContext2.Principal = (IPrincipal)null;
            }
            return(CrossAppDomainSerializer.SerializeMessage(msg2).GetBuffer());
        }
Example #7
0
        internal static byte[] DoDispatch(byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, out SmuggledMethodReturnMessage smuggledMrm)
        {
            IMessage msg = null;

            if (smuggledMcm != null)
            {
                ArrayList deserializedArgs = smuggledMcm.FixupForNewAppDomain();
                msg = new MethodCall(smuggledMcm, deserializedArgs);
            }
            else
            {
                MemoryStream stm = new MemoryStream(reqStmBuff);
                msg = CrossAppDomainSerializer.DeserializeMessage(stm);
            }
            LogicalCallContext logicalCallContext = CallContext.GetLogicalCallContext();

            logicalCallContext.SetData("__xADCall", true);
            IMessage message2 = ChannelServices.SyncDispatchMessage(msg);

            logicalCallContext.FreeNamedDataSlot("__xADCall");
            smuggledMrm = SmuggledMethodReturnMessage.SmuggleIfPossible(message2);
            if (smuggledMrm != null)
            {
                return(null);
            }
            if (message2 == null)
            {
                return(null);
            }
            LogicalCallContext context2 = (LogicalCallContext)message2.Properties[Message.CallContextKey];

            if ((context2 != null) && (context2.Principal != null))
            {
                context2.Principal = null;
            }
            return(CrossAppDomainSerializer.SerializeMessage(message2).GetBuffer());
        }
 private void PopulateIdentity(LogicalCallContext callContext, string identity)
 {
     callContext.SetData("__identitycontext__", new IdentityContextData(identity));
 }
 private static LogicalCallContext SetActivityIdInLogicalCallContext(LogicalCallContext logicalCallContext)
 {
     logicalCallContext.SetData("E2ETrace.ActivityID", DiagnosticTrace.ActivityId);
     return(logicalCallContext);
 }
Example #10
0
 void PopulateIdentity(LogicalCallContext callContext, String identity)
 {
     callContext.SetData(IdentityContextData.IdentityContext, new IdentityContextData(identity));
 }