Example #1
0
		public Receiver(IDictionary properties, IServerChannelSinkProvider serverSinkProvider) 
		{	
			// administratively setup using the config values
			// static knowledge base
			ChannelName = properties.Contains(MSMQChannelProperties.ChannelName) ? 
				Convert.ToString(properties[MSMQChannelProperties.ChannelName]) : MSMQChannelDefaults.ChannelName;
			ChannelPriority = properties.Contains(MSMQChannelProperties.ChannelPriority) ? 
				Convert.ToInt32(properties[MSMQChannelProperties.ChannelPriority]) : MSMQChannelDefaults.ChannelPriority;
			ListenerPath = properties.Contains(MSMQChannelProperties.Listener) ? 
				Convert.ToString(properties[MSMQChannelProperties.Listener]) : MSMQChannelDefaults.QueuePath;
			AllowToUpdate = properties.Contains(MSMQChannelProperties.UpdateKB) ? 
				Convert.ToBoolean(properties[MSMQChannelProperties.UpdateKB]) : MSMQChannelDefaults.CanBeUpdated;
			
			// dynamically knowledge base
			NotifyTime = properties.Contains(MSMQChannelProperties.NotifyTime) ? 
				Convert.ToInt32(properties[MSMQChannelProperties.NotifyTime]) : MSMQChannelDefaults.TimeoutInSec;
			RetryTime = properties.Contains(MSMQChannelProperties.RetryTime) ?
				Convert.ToInt32(properties[MSMQChannelProperties.RetryTime]) : MSMQChannelDefaults.TimeoutInSec;
			RetryCounter = properties.Contains(MSMQChannelProperties.Retry) ? 
				Convert.ToInt32(properties[MSMQChannelProperties.Retry]) : MSMQChannelDefaults.RetryCounter;
			RetryFilter = properties.Contains(MSMQChannelProperties.RetryFilter) ? 
				Convert.ToString(properties[MSMQChannelProperties.RetryFilter]) : MSMQChannelDefaults.EmptyStr;
			NotifyUrl = properties.Contains(MSMQChannelProperties.NotifyUrl) ? 
				Convert.ToString(properties[MSMQChannelProperties.NotifyUrl]) : MSMQChannelDefaults.EmptyStr;
			AcknowledgeUrl = properties.Contains(MSMQChannelProperties.AckUrl) ? 
				Convert.ToString(properties[MSMQChannelProperties.AckUrl]) : MSMQChannelDefaults.EmptyStr;
			ExceptionUrl = properties.Contains(MSMQChannelProperties.ExceptionUrl) ? 
				Convert.ToString(properties[MSMQChannelProperties.ExceptionUrl]) : MSMQChannelDefaults.EmptyStr;
			UseTimeout = properties.Contains(MSMQChannelProperties.UseTimeout) ? 
				Convert.ToBoolean(properties[MSMQChannelProperties.UseTimeout]) : MSMQChannelDefaults.UseTimeout;
			// validate number of threads
			MaxNumberOfWorkers = MSMQChannelDefaults.MaxThreads;
			if(properties.Contains(MSMQChannelProperties.MaxThreads)) 
			{
				string maxthreads = Convert.ToString(properties[MSMQChannelProperties.MaxThreads]);
				Update(MSMQChannelProperties.MaxThreads, maxthreads);
			}
					
			// channel provider
			m_Provider = serverSinkProvider == null ? new BinaryServerFormatterSinkProvider() : serverSinkProvider;

			/*
			// Collect the rest of the channel data:
			IServerChannelSinkProvider provider = m_Provider;
			while(provider != null)
			{
				provider.GetChannelData(_data);
				provider = provider.Next;
			}
			*/
		
			IServerChannelSink next = ChannelServices.CreateServerChannelSinkChain(m_Provider, this);
			m_Sink = new MSMQServerTransportSink(next);

			// publish the MSMQChannel endpoint using the channel name.
			base.Publish(ChannelName);

			// start Listener
			StartListening(null);
		}
Example #2
0
    void Init (IServerChannelSinkProvider provider) {
      if (!_e.Incoming)
        throw new InvalidOperationException("Non-listening Endpoint passed to IceServerChannel");

      if (!(_e is TcpEndpoint))
        throw new NotSupportedException("Only TcpEndpoints are supported as servers (for now)");

      if (provider == null) {
        provider = new IceServerFormatterSinkProvider();
      }

      IServerChannelSink nextSink = ChannelServices.CreateServerChannelSinkChain (provider, this);

      TcpEndpoint te = _e as TcpEndpoint;

      string[] uris = null;
      if (te.port != 0) {
        uris = new string[1];
        uris[0] = "ice://" + te.host + ":" + te.port;
      }

      _channelData = new ChannelDataStore (uris);
      _channelData["__iceEndpoint"] = _e;

      _sink = new IceServerTransportSink (nextSink);
      //      _listener = new TcpListener (te.IPAddress, te.port);
      _listener = new TcpListener (IPAddress.Any, te.port);
      _listenerThread = null;

      StartListening (null);
    }
        } // HttpChannel

        public HttpChannel(IDictionary properties, 
                           IClientChannelSinkProvider clientSinkProvider,
                           IServerChannelSinkProvider serverSinkProvider)
        {
            Hashtable clientData = new Hashtable();
            Hashtable serverData = new Hashtable();
        
            // divide properties up for respective channels
            if (properties != null)
            {            
                foreach (DictionaryEntry entry in properties)
                {
                    switch ((String)entry.Key)
                    {
                    // general channel properties
                    case "name": _channelName = (String)entry.Value; break;
                    case "priority": _channelPriority = Convert.ToInt32((String)entry.Value, CultureInfo.InvariantCulture); break;
                    case "secure": _secure = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture); 
                                    clientData["secure"] = entry.Value;
                                    serverData["secure"] = entry.Value;
                                    break;
                    default: 
                        clientData[entry.Key] = entry.Value;
                        serverData[entry.Key] = entry.Value;
                        break;
                    }
                }
            }

            _clientChannel = new HttpClientChannel(clientData, clientSinkProvider);
            _serverChannel = new HttpServerChannel(serverData, serverSinkProvider);
        } // HttpChannel
 internal static void CollectChannelDataFromServerSinkProviders(ChannelDataStore channelData, IServerChannelSinkProvider provider)
 {
     while (provider != null)
     {
         provider.GetChannelData(channelData);
         provider = provider.Next;
     }
 }
Example #5
0
        } // TcpServerChannel

        /// <include file='doc\TcpServerChannel.uex' path='docs/doc[@for="TcpServerChannel.TcpServerChannel2"]/*' />
        public TcpServerChannel(String name, int port, IServerChannelSinkProvider sinkProvider)
        {
            _channelName = name;
            _port = port;
            _sinkProvider = sinkProvider;
            SetupMachineName();
            SetupChannel();
        } // TcpServerChannel
Example #6
0
 /// <summary>
 /// Creates both server and client channels.
 /// </summary>
 /// <param name="properties">The channel properties.</param>
 /// <param name="clientProvider">The client sink provider. It may be <c>null</c>.</param>
 /// <param name="serverProvider">The server sink provider. It may be <c>null</c>.</param>
 public IpcChannel(IDictionary properties,
     IClientChannelSinkProvider clientProvider,
     IServerChannelSinkProvider serverProvider
     )
 {
     clientChannel = new IpcClientChannel(properties, clientProvider);
     serverChannel = new IpcServerChannel(properties, serverProvider);
 }
Example #7
0
                public IpcServerChannel (string name, string portName,
                                         IServerChannelSinkProvider serverSinkProvider)
                {
                        _portName = portName;
                        _path = portName = BuildPathFromPortName (portName);

                        _innerChannel = Activator.CreateInstance(UnixChannelLoader.LoadServerChannel (), new object [] {name, portName, serverSinkProvider});
                }
Example #8
0
File: test.cs Project: mono/gert
	static void Register (string name, string port, IServerChannelSinkProvider provider)
	{
		Hashtable props = new Hashtable ();
		props ["name"] = name;
		props ["port"] = port;
		TcpChannel c = new TcpChannel (props, null, provider);
		ChannelServices.RegisterChannel (c, false);
	}
Example #9
0
 public HathiServerChannelSink(IServerChannelSinkProvider Provider, IChannelReceiver channel)
 {
     IServerChannelSink nextServer = (IServerChannelSink)new BinaryServerFormatterSink(
                                                                         BinaryServerFormatterSink.Protocol.Other, this.NextChannelSink, channel);
     if (channel != null) m_channel = channel;
     if (Provider != null) m_Provider = Provider as HathiServerSinkProvider;
     m_NextIServerChannelSink = new HathiServerChannelSink(Provider, channel, nextServer);
 }
 public IpcChannel (IDictionary properties,
                    IClientChannelSinkProvider clientSinkProvider,
                    IServerChannelSinkProvider serverSinkProvider)
 {
         if (IsUnix)
                 _innerChannel = new Unix.IpcChannel (properties, clientSinkProvider, serverSinkProvider);
         else
                 _innerChannel = new Win32.IpcChannel (properties, clientSinkProvider, serverSinkProvider);
 }
Example #11
0
 public PipeChannel(
             IDictionary properties, 
             IClientChannelSinkProvider clientProviderChain,
             IServerChannelSinkProvider serverProviderChain
         )
 {
     _clientChannel = new PipeClientChannel(properties, clientProviderChain);
       _serverChannel = new PipeServerChannel(properties, serverProviderChain);
 }
Example #12
0
                public IpcServerChannel (string name, string portName,
                                         IServerChannelSinkProvider sinkProvider)
                {
                        _portName = portName;

                        if (IpcChannel.IsUnix)
                                _innerChannel = new Unix.IpcServerChannel (name, portName, sinkProvider);
                        else
                                _innerChannel = new Win32.IpcServerChannel (name, portName, sinkProvider);
                }
        } // IpcServerChannel

        public IpcServerChannel(String name, string portName, IServerChannelSinkProvider sinkProvider) 
        {
            if (portName == null) 
                throw new RemotingException(CoreChannel.GetResourceString( 
                                            "Remoting_Ipc_NoPortNameSpecified"));
            _channelName = name; 
            _portName = portName;
            _sinkProvider = sinkProvider;
            SetupChannel();
        } // IpcServerChannel 
        public IpcServerChannel(IDictionary properties, IServerChannelSinkProvider sinkProvider, CommonSecurityDescriptor securityDescriptor)
        {
            this._channelPriority = 20;
            this._channelName = "ipc server";
            this._bExclusiveAddressUse = true;
            this._waitForStartListening = new AutoResetEvent(false);
            if (properties != null)
            {
                foreach (DictionaryEntry entry in properties)
                {
                    switch (((string) entry.Key))
                    {
                        case "name":
                            this._channelName = (string) entry.Value;
                            break;

                        case "portName":
                            this._portName = (string) entry.Value;
                            break;

                        case "priority":
                            this._channelPriority = Convert.ToInt32(entry.Value, CultureInfo.InvariantCulture);
                            break;

                        case "secure":
                            this._secure = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture);
                            break;

                        case "impersonate":
                            this._impersonate = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture);
                            this.authSet = true;
                            break;

                        case "suppressChannelData":
                            this._bSuppressChannelData = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture);
                            break;

                        case "authorizedGroup":
                            this._authorizedGroup = (string) entry.Value;
                            break;

                        case "exclusiveAddressUse":
                            this._bExclusiveAddressUse = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture);
                            break;
                    }
                }
            }
            if (this._portName == null)
            {
                throw new RemotingException(CoreChannel.GetResourceString("Remoting_Ipc_NoPortNameSpecified"));
            }
            this._sinkProvider = sinkProvider;
            this._securityDescriptor = securityDescriptor;
            this.SetupChannel();
        }
Example #15
0
		public static IServerChannelSinkProvider ServerChannelCreateSinkProviderChain(
			IServerChannelSinkProvider formatterSinkProvider)
		{
			if (formatterSinkProvider == null)
			{
				// we use MSFT BinaryFormatter by default for maximum compatibility
				formatterSinkProvider = new BinaryServerFormatterSinkProvider();
			}

			return formatterSinkProvider;
		}
Example #16
0
 public UdpServerChannel(IDictionary properties, IServerChannelSinkProvider provider)
 {
     ChannelName = properties.GetValue("name", UdpChannelHelper.DefaultName);
     ChannelPriority = properties.GetValue("priority", UdpChannelHelper.DefaultPriority);
     MachineName = properties.GetValue("machineName", Dns.GetHostName());
     Port = properties.GetValue("port", UdpChannelHelper.DefaultPort);
     ChannelDataStore = UdpChannelHelper.CreateChannelDataStore(MachineName, Port);
     ServerSinkProvider = provider ?? UdpChannelHelper.CreateServerSinkProvider();
     SetupServerSinkChain(ServerSinkProvider);
     StartListening(null);
 }
Example #17
0
                public IpcServerChannel (IDictionary properties,
                                         IServerChannelSinkProvider  sinkProvider)
                {
                        if (properties != null)
                                _portName = properties ["portName"] as string;

                        if (IpcChannel.IsUnix)
                                _innerChannel = new Unix.IpcServerChannel (properties,  sinkProvider);
                        else
                                _innerChannel = new Win32.IpcServerChannel (properties, sinkProvider);
                }
Example #18
0
		public HttpChannel (IDictionary properties,
			IClientChannelSinkProvider clientSinkProvider,
			IServerChannelSinkProvider serverSinkProvider)
		{
			if (properties != null && properties.Contains ("name")) {
				this.name = (string)properties["name"];
			}

			client = new HttpClientChannel (properties, clientSinkProvider);
			server = new HttpServerChannel (properties, serverSinkProvider);
		}
Example #19
0
 public UdpChannel(IDictionary properties, IClientChannelSinkProvider clientChain, IServerChannelSinkProvider serverChain)
 {
     if (serverChain != null || (properties != null && properties.Contains("port")))
     {
         ServerChannel = new UdpServerChannel(properties, serverChain);
     }
     else
     {
         ClientChannel = new UdpClientChannel(properties, clientChain);
     }
 }
Example #20
0
 public HathiServerChannelSink(IServerChannelSinkProvider Provider, IChannelReceiver channel, object nextobject)
 {
     if (channel != null) m_channel = channel;
     if (Provider != null) m_Provider = Provider as HathiServerSinkProvider;
     if (nextobject != null)
     {
         m_NextIServerChannelSink = nextobject as IServerChannelSink;
         if (m_NextIServerChannelSink == null)
             m_NextIServerChannelSink = new BinaryServerFormatterSink(
                     BinaryServerFormatterSink.Protocol.Other, this.NextChannelSink, channel);
     }
 }
        /// <summary>
        /// Constructs an instance of the GenuineHttpServerChannel class.
        /// </summary>
        /// <param name="properties">An IDictionary of the channel properties which hold the configuration information for the current channel.</param>
        /// <param name="iClientChannelSinkProvider">The IClientChannelSinkProvider that creates the client channel sinks for the underlying channel through which remoting messages flow through.</param>
        /// <param name="iServerChannelSinkProvider">The IServerChannelSinkProvider that creates server channel sinks for the underlying channel through which remoting messages flow through.</param>
        public GenuineHttpServerChannel(IDictionary properties, IClientChannelSinkProvider iClientChannelSinkProvider, IServerChannelSinkProvider iServerChannelSinkProvider)
            : base(iClientChannelSinkProvider, iServerChannelSinkProvider)
        {
            this.ITransportContext = TransportContextServices.CreateDefaultServerHttpContext(properties, this);
            this.InitializeInstance(properties);

            if (this._channelName == null)
                this._channelName = "ghttp";
            if (this._urlPrefix == null)
                this._urlPrefix = "ghttp";
            this._possibleChannelPrefixes = new string[] { this.UrlPrefix, this.UriPrefix };
        }
		void Init (IDictionary properties, IClientChannelSinkProvider clientSink, IServerChannelSinkProvider serverSink)
		{
			_clientChannel = new TcpClientChannel (properties,clientSink);

			if(properties["port"] != null)
				_serverChannel = new TcpServerChannel(properties, serverSink);

			object val = properties ["name"];
			if (val != null) _name = val as string;
			
			val = properties ["priority"];
			if (val != null) _priority = Convert.ToInt32 (val);
		}
		private void SetupChannel (IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
		{
			clientChannel = new HttpClientChannel (properties, clientSinkProvider);
			serverChannel = new HttpServerChannel (properties, serverSinkProvider);
			
			object val = properties ["name"];
			if (val != null) channelName = val as string;
			
			val = properties ["priority"];
			if (val != null) channelPriority = Convert.ToInt32 (val);
			
			this.properties = new AggregateDictionary (new IDictionary[] {clientChannel, serverChannel});
		}
Example #24
0
        } // TcpChannel

        /// <include file='doc\CombinedTcpChannel.uex' path='docs/doc[@for="TcpChannel.TcpChannel2"]/*' />
        public TcpChannel(IDictionary properties, 
                          IClientChannelSinkProvider clientSinkProvider,
                          IServerChannelSinkProvider serverSinkProvider)
        {
            Hashtable clientData = new Hashtable();
            Hashtable serverData = new Hashtable();

            bool portFound = false;
        
            // divide properties up for respective channels
            if (properties != null)
            {
                foreach (DictionaryEntry entry in properties)
                {
                    switch ((String)entry.Key)
                    {
                    // general channel properties
                    case "name": _channelName = (String)entry.Value; break;
                    case "priority": _channelPriority = Convert.ToInt32((String)entry.Value); break;

                    // client properties (none yet)

                    // server properties
                    case "bindTo": serverData["bindTo"] = entry.Value; break;
                    case "machineName": serverData["machineName"] = entry.Value; break; 
                    
                    case "port": 
                    {
                        serverData["port"] = entry.Value; 
                        portFound = true;
                        break;
                    }
                    case "rejectRemoteRequests": serverData["rejectRemoteRequests"] = entry.Value; break;
                    case "suppressChannelData": serverData["suppressChannelData"] = entry.Value; break;
                    case "useIpAddress": serverData["useIpAddress"] = entry.Value; break;

                    default: 
                         throw new ArgumentException(
                            String.Format(
                                CoreChannel.GetResourceString(
                                    "Remoting_Channels_BadCtorArgs"),
                                entry.Key));
                    }
                }                    
            }

            _clientChannel = new TcpClientChannel(clientData, clientSinkProvider);

            if (portFound)
                _serverChannel = new TcpServerChannel(serverData, serverSinkProvider);
        } // TcpChannel
 public TcpChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
 {
     this._channelPriority = 1;
     this._channelName = "tcp";
     Hashtable hashtable = new Hashtable();
     Hashtable hashtable2 = new Hashtable();
     bool flag = false;
     if (properties != null)
     {
         foreach (DictionaryEntry entry in properties)
         {
             string key = (string) entry.Key;
             if (key == null)
             {
                 goto Label_00CB;
             }
             if (!(key == "name"))
             {
                 if (key == "priority")
                 {
                     goto Label_0097;
                 }
                 if (key == "port")
                 {
                     goto Label_00B5;
                 }
                 goto Label_00CB;
             }
             this._channelName = (string) entry.Value;
             continue;
         Label_0097:
             this._channelPriority = Convert.ToInt32((string) entry.Value, CultureInfo.InvariantCulture);
             continue;
         Label_00B5:
             hashtable2["port"] = entry.Value;
             flag = true;
             continue;
         Label_00CB:
             hashtable[entry.Key] = entry.Value;
             hashtable2[entry.Key] = entry.Value;
         }
     }
     this._clientChannel = new TcpClientChannel(hashtable, clientSinkProvider);
     if (flag)
     {
         this._serverChannel = new TcpServerChannel(hashtable2, serverSinkProvider);
     }
 }
Example #26
0
        public BidirTcpServerChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
        {
            _name = (String) properties["name"];
            if (_name == null)
            {
                _name = "BidirTcpServer";
            }
            _port = int.Parse((String) properties["port"]);

            String[] urls = { this.GetURLBase() };

            // needed for CAOs!
            _channelData = new ChannelDataStore(urls);

            String IPAddress = Helper.GetIPAddress();

            if (serverSinkProvider == null)
            {
                serverSinkProvider = new BinaryServerFormatterSinkProvider();
            }

            if (_clientProvider == null)
            {
                _clientProvider = new BinaryClientFormatterSinkProvider();
            }

            _sinkProvider = serverSinkProvider;

            // collect channel data from all providers
            IServerChannelSinkProvider provider = _sinkProvider;
            while (provider != null)
            {
                provider.GetChannelData(_channelData);
                provider = provider.Next;
            }

            // create the sink chain
            IServerChannelSink snk =
                ChannelServices.CreateServerChannelSinkChain(_sinkProvider,this);

            // add the BidirTcpServerTransportSink as a first element to the chain
            _transportSink = new BidirTcpServerTransportSink(snk, _port ,IPAddress);
            MessageHandler.RegisterServer(_transportSink,Helper.GetIPAddress() + ":" + _port);
            MessageHandler.RegisterServer(_transportSink,Helper.GetMyGUID().ToString());

            // start to listen
            this.StartListening(null);
        }
 public IpcChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider, CommonSecurityDescriptor securityDescriptor)
 {
     this._channelPriority = 20;
     this._channelName = "ipc";
     Hashtable hashtable = new Hashtable();
     Hashtable hashtable2 = new Hashtable();
     bool flag = false;
     if (properties != null)
     {
         foreach (DictionaryEntry entry in properties)
         {
             string key = (string) entry.Key;
             if (key == null)
             {
                 goto Label_00CC;
             }
             if (!(key == "name"))
             {
                 if (key == "priority")
                 {
                     goto Label_0098;
                 }
                 if (key == "portName")
                 {
                     goto Label_00B6;
                 }
                 goto Label_00CC;
             }
             this._channelName = (string) entry.Value;
             continue;
         Label_0098:
             this._channelPriority = Convert.ToInt32((string) entry.Value, CultureInfo.InvariantCulture);
             continue;
         Label_00B6:
             hashtable2["portName"] = entry.Value;
             flag = true;
             continue;
         Label_00CC:
             hashtable[entry.Key] = entry.Value;
             hashtable2[entry.Key] = entry.Value;
         }
     }
     this._clientChannel = new IpcClientChannel(hashtable, clientSinkProvider);
     if (flag)
     {
         this._serverChannel = new IpcServerChannel(hashtable2, serverSinkProvider, securityDescriptor);
     }
 }
Example #28
0
        public static ChannelDataStore ServerChannelCreateDataStore(
			string channelUri,
			IServerChannelSinkProvider sinkProviderChain)
        {
            var uris = new[] { channelUri };
            var channelData = new ChannelDataStore(uris);

            // walk throw the chain of sink providers and collect their data
            IServerChannelSinkProvider sinkProvider = sinkProviderChain;
            while (sinkProvider != null)
            {
                sinkProvider.GetChannelData(channelData);
                sinkProvider = sinkProvider.Next;
            }

            return channelData;
        }
Example #29
0
        } // HttpChannel

        /// <include file='doc\CombinedHttpChannel.uex' path='docs/doc[@for="HttpChannel.HttpChannel2"]/*' />
        public HttpChannel(IDictionary properties, 
                           IClientChannelSinkProvider clientSinkProvider,
                           IServerChannelSinkProvider serverSinkProvider)
        {
            Hashtable clientData = new Hashtable();
            Hashtable serverData = new Hashtable();
        
            // divide properties up for respective channels
            if (properties != null)
            {            
                foreach (DictionaryEntry entry in properties)
                {
                    switch ((String)entry.Key)
                    {
                    // general channel properties
                    case "name": _channelName = (String)entry.Value; break;
                    case "priority": _channelPriority = Convert.ToInt32((String)entry.Value); break;

                    // client properties
                    case "clientConnectionLimit": clientData["clientConnectionLimit"] = entry.Value; break;
                    case "proxyName": clientData["proxyName"] = entry.Value; break;
                    case "proxyPort": clientData["proxyPort"] = entry.Value; break;
                    case "useDefaultCredentials": clientData["useDefaultCredentials"] = entry.Value; break;

                    // server properties
                    case "bindTo": serverData["bindTo"] = entry.Value; break;
                    case "listen": serverData["listen"] = entry.Value; break; 
                    case "machineName": serverData["machineName"] = entry.Value; break; 
                    case "port": serverData["port"] = entry.Value; break;
                    case "suppressChannelData": serverData["suppressChannelData"] = entry.Value; break;
                    case "useIpAddress": serverData["useIpAddress"] = entry.Value; break;

                    default: 
                         throw new ArgumentException(
                            String.Format(
                                CoreChannel.GetResourceString(
                                    "Remoting_Channels_BadCtorArgs"),
                                entry.Key));
                    }
                }
            }

            _clientChannel = new HttpClientChannel(clientData, clientSinkProvider);
            _serverChannel = new HttpServerChannel(serverData, serverSinkProvider);
        } // HttpChannel
 public HttpChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
 {
     this._channelPriority = 1;
     this._channelName = "http";
     Hashtable hashtable = new Hashtable();
     Hashtable hashtable2 = new Hashtable();
     if (properties != null)
     {
         foreach (DictionaryEntry entry in properties)
         {
             string key = (string) entry.Key;
             if (key == null)
             {
                 goto Label_00F4;
             }
             if (!(key == "name"))
             {
                 if (key == "priority")
                 {
                     goto Label_0099;
                 }
                 if (key == "secure")
                 {
                     goto Label_00B7;
                 }
                 goto Label_00F4;
             }
             this._channelName = (string) entry.Value;
             continue;
         Label_0099:
             this._channelPriority = Convert.ToInt32((string) entry.Value, CultureInfo.InvariantCulture);
             continue;
         Label_00B7:
             this._secure = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture);
             hashtable["secure"] = entry.Value;
             hashtable2["secure"] = entry.Value;
             continue;
         Label_00F4:
             hashtable[entry.Key] = entry.Value;
             hashtable2[entry.Key] = entry.Value;
         }
     }
     this._clientChannel = new HttpClientChannel(hashtable, clientSinkProvider);
     this._serverChannel = new HttpServerChannel(hashtable2, serverSinkProvider);
 }
Example #31
0
        public BidirTcpClientChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
        {
            _properties = properties;
            _provider   = clientSinkProvider;
            _name       = (String)_properties["name"];

            String[] urls = { this.GetURLBase() };
            // needed for CAOs!
            _channelData = new ChannelDataStore(urls);

            if (_provider == null)
            {
                _provider = new BinaryClientFormatterSinkProvider();
            }

            if (serverSinkProvider == null)
            {
                serverSinkProvider = new BinaryServerFormatterSinkProvider();
            }

            // collect additional channel data from all providers
            IServerChannelSinkProvider prov = serverSinkProvider;

            while (prov != null)
            {
                prov.GetChannelData(_channelData);
                prov = prov.Next;
            }

            // create the sink chain
            IServerChannelSink snk =
                ChannelServices.CreateServerChannelSinkChain(serverSinkProvider, this);

            // add the BidirTcpServerTransportSink as a first element to the chain
            _serverSink = new BidirTcpServerTransportSink(snk);
            MessageHandler.RegisterServer(_serverSink, Helper.GetMyGUID().ToString());
        }
Example #32
0
        } // HttpServerChannel()

        /// <include file='doc\HttpServerChannel.uex' path='docs/doc[@for="HttpServerChannel.HttpServerChannel4"]/*' />
        public HttpServerChannel(IDictionary properties, IServerChannelSinkProvider sinkProvider) : base()
        {
            if (properties != null)
            {
                foreach (DictionaryEntry entry in properties)
                {
                    switch ((String)entry.Key)
                    {
                    case "name": _channelName = (String)entry.Value; break;

                    case "bindTo": _bindToAddr = IPAddress.Parse((String)entry.Value); break;

                    case "listen": _wantsToListen = Convert.ToBoolean(entry.Value); break;

                    case "machineName": _forcedMachineName = (String)entry.Value; break;

                    case "port": _port = Convert.ToInt32(entry.Value); break;

                    case "priority": _channelPriority = Convert.ToInt32(entry.Value); break;

                    case "suppressChannelData": _bSuppressChannelData = Convert.ToBoolean(entry.Value); break;

                    case "useIpAddress": _bUseIpAddress = Convert.ToBoolean(entry.Value); break;

                    case "exclusiveAddressUse": _bExclusiveAddressUse = Convert.ToBoolean(entry.Value); break;

                    default:
                        break;
                    }
                }
            }

            _sinkProvider = sinkProvider;
            SetupMachineName();
            SetupChannel();
        } // HttpServerChannel
Example #33
0
        void Init(IDictionary properties, IClientChannelSinkProvider clientSink, IServerChannelSinkProvider serverSink)
        {
            _clientChannel = new TcpClientChannel(properties, clientSink);

            if (properties != null)
            {
                if (properties["port"] != null)
                {
                    _serverChannel = new TcpServerChannel(properties, serverSink);
                }

                object val = properties ["name"];
                if (val != null)
                {
                    _name = val as string;
                }

                val = properties ["priority"];
                if (val != null)
                {
                    _priority = Convert.ToInt32(val);
                }
            }
        }
Example #34
0
        public static IServerChannelSink CreateServerChannelSinkChain(
            IServerChannelSinkProvider provider, IChannelReceiver channel)
        {
            if (provider == null)
            {
                return(new DispatchChannelSink());
            }

            // add dispatch provider to end (first find last provider)
            IServerChannelSinkProvider lastProvider = provider;

            while (lastProvider.Next != null)
            {
                lastProvider = lastProvider.Next;
            }
            lastProvider.Next = new DispatchChannelSinkProvider();

            IServerChannelSink sinkChain = provider.CreateSink(channel);

            // remove dispatch provider from end
            lastProvider.Next = null;

            return(sinkChain);
        } // CreateServerChannelSinkChain
Example #35
0
        public Receiver(IDictionary properties, IServerChannelSinkProvider serverSinkProvider)
        {
            // administratively setup using the config values
            // static knowledge base
            ChannelName = properties.Contains(MSMQChannelProperties.ChannelName) ?
                          Convert.ToString(properties[MSMQChannelProperties.ChannelName]) : MSMQChannelDefaults.ChannelName;
            ChannelPriority = properties.Contains(MSMQChannelProperties.ChannelPriority) ?
                              Convert.ToInt32(properties[MSMQChannelProperties.ChannelPriority]) : MSMQChannelDefaults.ChannelPriority;
            ListenerPath = properties.Contains(MSMQChannelProperties.Listener) ?
                           Convert.ToString(properties[MSMQChannelProperties.Listener]) : MSMQChannelDefaults.QueuePath;
            AllowToUpdate = properties.Contains(MSMQChannelProperties.UpdateKB) ?
                            Convert.ToBoolean(properties[MSMQChannelProperties.UpdateKB]) : MSMQChannelDefaults.CanBeUpdated;

            // dynamically knowledge base
            NotifyTime = properties.Contains(MSMQChannelProperties.NotifyTime) ?
                         Convert.ToInt32(properties[MSMQChannelProperties.NotifyTime]) : MSMQChannelDefaults.TimeoutInSec;
            RetryTime = properties.Contains(MSMQChannelProperties.RetryTime) ?
                        Convert.ToInt32(properties[MSMQChannelProperties.RetryTime]) : MSMQChannelDefaults.TimeoutInSec;
            RetryCounter = properties.Contains(MSMQChannelProperties.Retry) ?
                           Convert.ToInt32(properties[MSMQChannelProperties.Retry]) : MSMQChannelDefaults.RetryCounter;
            RetryFilter = properties.Contains(MSMQChannelProperties.RetryFilter) ?
                          Convert.ToString(properties[MSMQChannelProperties.RetryFilter]) : MSMQChannelDefaults.EmptyStr;
            NotifyUrl = properties.Contains(MSMQChannelProperties.NotifyUrl) ?
                        Convert.ToString(properties[MSMQChannelProperties.NotifyUrl]) : MSMQChannelDefaults.EmptyStr;
            AcknowledgeUrl = properties.Contains(MSMQChannelProperties.AckUrl) ?
                             Convert.ToString(properties[MSMQChannelProperties.AckUrl]) : MSMQChannelDefaults.EmptyStr;
            ExceptionUrl = properties.Contains(MSMQChannelProperties.ExceptionUrl) ?
                           Convert.ToString(properties[MSMQChannelProperties.ExceptionUrl]) : MSMQChannelDefaults.EmptyStr;
            UseTimeout = properties.Contains(MSMQChannelProperties.UseTimeout) ?
                         Convert.ToBoolean(properties[MSMQChannelProperties.UseTimeout]) : MSMQChannelDefaults.UseTimeout;
            // validate number of threads
            MaxNumberOfWorkers = MSMQChannelDefaults.MaxThreads;
            if (properties.Contains(MSMQChannelProperties.MaxThreads))
            {
                string maxthreads = Convert.ToString(properties[MSMQChannelProperties.MaxThreads]);
                Update(MSMQChannelProperties.MaxThreads, maxthreads);
            }

            // channel provider
            m_Provider = serverSinkProvider == null ? new BinaryServerFormatterSinkProvider() : serverSinkProvider;

            /*
             * // Collect the rest of the channel data:
             * IServerChannelSinkProvider provider = m_Provider;
             * while(provider != null)
             * {
             *      provider.GetChannelData(_data);
             *      provider = provider.Next;
             * }
             */

            IServerChannelSink next = ChannelServices.CreateServerChannelSinkChain(m_Provider, this);

            m_Sink = new MSMQServerTransportSink(next);

            // publish the MSMQChannel endpoint using the channel name.
            base.Publish(ChannelName);

            // start Listener
            StartListening(null);
        }
Example #36
0
 public CustomChannel(
     IDictionary properties,
     IClientChannelSinkProvider clientSinkProvider,
     IServerChannelSinkProvider serverSinkProvider)
 {
 }
Example #37
0
 public UdpChannel(IDictionary properties, IClientChannelSinkProvider clientChain, IServerChannelSinkProvider serverChain)
 {
     if (serverChain != null || (properties != null && properties.Contains("port")))
     {
         ServerChannel = new UdpServerChannel(properties, serverChain);
     }
     else
     {
         ClientChannel = new UdpClientChannel(properties, clientChain);
     }
 }
Example #38
0
 public SimpleServerChannel(IDictionary properties,
                            IServerChannelSinkProvider serverSinkProvider)
 {
     port = (int)properties ["port"];
     Init(serverSinkProvider);
 }
        /// <summary>
        /// Constructs an instance of the GenuineUdpChannel class.
        /// </summary>
        /// <param name="properties">An IDictionary of the channel properties which hold the configuration information for the current channel.</param>
        /// <param name="iClientChannelSinkProvider">The IClientChannelSinkProvider that creates the client channel sinks for the underlying channel through which remoting messages flow through.</param>
        /// <param name="iServerChannelSinkProvider">The IServerChannelSinkProvider that creates server channel sinks for the underlying channel through which remoting messages flow through.</param>
        public GenuineUdpChannel(IDictionary properties, IClientChannelSinkProvider iClientChannelSinkProvider, IServerChannelSinkProvider iServerChannelSinkProvider)
            : base(iClientChannelSinkProvider, iServerChannelSinkProvider)
        {
            this.ITransportContext = TransportContextServices.CreateDefaultUdpContext(properties, this);
            this.InitializeInstance(properties);

            if (this._channelName == null)
            {
                this._channelName = "gudp";
            }
            if (this._urlPrefix == null)
            {
                this._urlPrefix = "gudp";
            }
            this._possibleChannelPrefixes = new string[] { this.UrlPrefix, this.UriPrefix, GetBroadcastUriPrefix(this.UrlPrefix), GetBroadcastUriPrefix(this.UriPrefix) };

            // retrieve settings
            string uriToListen = this["Address"] as string;

            foreach (DictionaryEntry entry in properties)
            {
                if (string.Compare(entry.Key.ToString(), "Address", true) == 0)
                {
                    uriToListen = entry.Value.ToString();
                }
            }
            if (uriToListen == null || uriToListen.Length <= 0 || !uriToListen.StartsWith(this.UrlPrefix + ":"))
            {
                throw GenuineExceptions.Get_Server_IncorrectAddressToListen(uriToListen);
            }

            this.StartListening(uriToListen);
        }
Example #40
0
        internal static void RegisterChannelConfig(ChannelData channel)
        {
            IServerChannelSinkProvider serverSinks = null;
            IClientChannelSinkProvider clientSinks = null;

            // Create server providers
            for (int n = channel.ServerProviders.Count - 1; n >= 0; n--)
            {
                ProviderData prov = channel.ServerProviders[n] as ProviderData;
                IServerChannelSinkProvider sinkp = (IServerChannelSinkProvider)CreateProvider(prov);
                sinkp.Next  = serverSinks;
                serverSinks = sinkp;
            }

            // Create client providers
            for (int n = channel.ClientProviders.Count - 1; n >= 0; n--)
            {
                ProviderData prov = channel.ClientProviders[n] as ProviderData;
                IClientChannelSinkProvider sinkp = (IClientChannelSinkProvider)CreateProvider(prov);
                sinkp.Next  = clientSinks;
                clientSinks = sinkp;
            }

            // Create the channel

            Type type = Type.GetType(channel.Type);

            if (type == null)
            {
                throw new RemotingException("Type '" + channel.Type + "' not found");
            }

            Object[] parms;
            Type[]   signature;
            bool     clienc  = typeof(IChannelSender).IsAssignableFrom(type);
            bool     serverc = typeof(IChannelReceiver).IsAssignableFrom(type);

            if (clienc && serverc)
            {
                signature = new Type [] { typeof(IDictionary), typeof(IClientChannelSinkProvider), typeof(IServerChannelSinkProvider) };
                parms     = new Object[] { channel.CustomProperties, clientSinks, serverSinks };
            }
            else if (clienc)
            {
                signature = new Type [] { typeof(IDictionary), typeof(IClientChannelSinkProvider) };
                parms     = new Object[] { channel.CustomProperties, clientSinks };
            }
            else if (serverc)
            {
                signature = new Type [] { typeof(IDictionary), typeof(IServerChannelSinkProvider) };
                parms     = new Object[] { channel.CustomProperties, serverSinks };
            }
            else
            {
                throw new RemotingException(type + " is not a valid channel type");
            }

            ConstructorInfo ctor = type.GetConstructor(signature);

            if (ctor == null)
            {
                throw new RemotingException(type + " does not have a valid constructor");
            }

            IChannel ch;

            try
            {
                ch = (IChannel)ctor.Invoke(parms);
            }
            catch (TargetInvocationException ex)
            {
                throw ex.InnerException;
            }

            lock (registeredChannels.SyncRoot)
            {
                if (channel.DelayLoadAsClientChannel == "true" && !(ch is IChannelReceiver))
                {
                    delayedClientChannels.Add(ch);
                }
                else
                {
                    RegisterChannel(ch);
                }
            }
        }
Example #41
0
 public UnixChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
 {
     this.Init(properties, clientSinkProvider, serverSinkProvider);
 }
        } // IpcChannel

        public IpcChannel(IDictionary properties,
                          IClientChannelSinkProvider clientSinkProvider,
                          IServerChannelSinkProvider serverSinkProvider)
            : this(properties, clientSinkProvider, serverSinkProvider, null)
        {
        }
Example #43
0
 public eAntServerSinkProvider()
 {
     m_Properties.Add("includeVersions", true);
     this.m_nextIServerChannelSink = new BinaryServerFormatterSinkProvider(m_Properties, m_ProviderData);
 }
Example #44
0
 public static IServerChannelSink CreateServerChannelSinkChain(IServerChannelSinkProvider provider, IChannelReceiver channel)
 {
     throw new NotImplementedException();
 }
Example #45
0
 public SimpleChannel(IDictionary properties,
                      IClientChannelSinkProvider clientSinkProvider,
                      IServerChannelSinkProvider serverSinkProvider)
 {
     throw new NotImplementedException();
 }
        public TcpServerChannel(IDictionary properties, IServerChannelSinkProvider sinkProvider, IAuthorizeRemotingConnection authorizeCallback)
        {
            _authorizeRemotingConnection = authorizeCallback;
            if (properties != null)
            {
                foreach (DictionaryEntry entry in properties)
                {
                    switch ((String)entry.Key)
                    {
                    case "name": _channelName = (String)entry.Value; break;

                    case "bindTo": _bindToAddr = IPAddress.Parse((String)entry.Value); break;

                    case "port": _port = Convert.ToInt32(entry.Value, CultureInfo.InvariantCulture); break;

                    case "priority": _channelPriority = Convert.ToInt32(entry.Value, CultureInfo.InvariantCulture); break;

                    case "secure": _secure = Convert.ToBoolean(entry.Value); break;

                    case "impersonate": _impersonate = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture); authSet = true; break;

                    case "protectionLevel": _protectionLevel = (ProtectionLevel)(entry.Value is ProtectionLevel ? entry.Value :
                                                                                 Enum.Parse(typeof(ProtectionLevel),
                                                                                            (String)entry.Value, true));
                        authSet = true;
                        break;

                    case "machineName": _forcedMachineName = (String)entry.Value; break;

                    case "rejectRemoteRequests":
                    {
                        bool bReject = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture);
                        if (bReject)
                        {
                            if (Socket.OSSupportsIPv4)
                            {
                                _bindToAddr = IPAddress.Loopback;
                            }
                            else
                            {
                                _bindToAddr = IPAddress.IPv6Loopback;
                            }
                        }
                        break;
                    }

                    case "suppressChannelData": _bSuppressChannelData = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture); break;

                    case "useIpAddress": _bUseIpAddress = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture); break;

                    case "exclusiveAddressUse": _bExclusiveAddressUse = Convert.ToBoolean(entry.Value, CultureInfo.InvariantCulture); break;

                    case "authorizationModule":
                        _authorizeRemotingConnection = (IAuthorizeRemotingConnection)Activator.CreateInstance(Type.GetType((String)entry.Value, true));
                        break;

                    default:
                        break;
                    }
                }
            }

            _sinkProvider = sinkProvider;
            SetupMachineName();
            SetupChannel();
        } // TcpServerChannel
Example #47
0
        /// <summary>
        /// Starts the Petra Server.
        ///
        /// </summary>
        /// <returns>void</returns>
        public void Startup()
        {
            try
            {
                //
                // Uncomment the following lines to see which DLL's are loaded into the Default AppDomain at application start.
                // It can help in identifying which DLL's are loaded later in addition to those that were loaded at application start.

/*
 *          Console.WriteLine("Loaded Assemblies in AppDomain " + Thread.GetDomain().FriendlyName + " (at Server start):");
 *          foreach (Assembly tmpAssembly in Thread.GetDomain().GetAssemblies())
 *          {
 *              Console.WriteLine(tmpAssembly.FullName);
 *          }
 */
                new TAppSettingsManager();

                TLanguageCulture.Init();

                TheServerManager = new TServerManager();

                // Ensure Logging and an 'ordered cooperative shutdown' in case of an Unhandled Exception
                TheServerManager.HookupProperShutdownProcessing();

                Console.WriteLine();
                TLogging.Log(TheServerManager.ServerInfoVersion);
                TLogging.Log(Catalog.GetString("Configuration file: " + TheServerManager.ConfigurationFileName));

                //
                // Connect to main Database
                //
                try
                {
                    TheServerManager.EstablishDBConnection();
                }
                catch (FileNotFoundException ex)
                {
                    TLogging.Log(ex.Message);
                    TLogging.Log("Please check your OpenPetra.build.config file ...");
                    TLogging.Log("Maybe a nant initConfigFile helps ...");
                    throw new EOPAppException();
                }
                catch (Exception ex)
                {
                    TLogging.Log(ex.Message);
                    throw;
                }

                // Setup Server Timed Processing
                try
                {
                    TheServerManager.SetupServerTimedProcessing();
                }
                catch (Exception)
                {
                    throw;
                }

                //
                // Remote the remoteable objects
                //
                try
                {
                    if (TAppSettingsManager.HasValue("LifetimeServices.LeaseTimeInSeconds"))
                    {
                        TLogging.Log(Catalog.GetString("Reading parameters for server remote configuration from config file..."));

                        BinaryServerFormatterSinkProvider TCPSink = new BinaryServerFormatterSinkProvider();
                        TCPSink.TypeFilterLevel = TypeFilterLevel.Low;
                        IServerChannelSinkProvider EncryptionSink = TCPSink;

                        if (TAppSettingsManager.GetValue("Server.ChannelEncryption.PrivateKeyfile", "", false).Length > 0)
                        {
                            EncryptionSink      = new EncryptionServerSinkProvider();
                            EncryptionSink.Next = TCPSink;
                        }

                        Hashtable ChannelProperties = new Hashtable();
                        ChannelProperties.Add("port", TAppSettingsManager.GetValue("Server.Port"));

                        string SpecificIPAddress = TAppSettingsManager.GetValue("ListenOnIPAddress", "", false);

                        if (SpecificIPAddress.Length > 0)
                        {
                            ChannelProperties.Add("machineName", SpecificIPAddress);
                        }

                        TcpChannel Channel = new TcpChannel(ChannelProperties, null, EncryptionSink);
                        ChannelServices.RegisterChannel(Channel, false);

                        RemotingConfiguration.RegisterWellKnownServiceType(typeof(Ict.Petra.Server.App.Core.TServerManager),
                                                                           "Servermanager", WellKnownObjectMode.Singleton);
                        RemotingConfiguration.RegisterWellKnownServiceType(typeof(Ict.Common.Remoting.Server.TClientManager),
                                                                           "Clientmanager", WellKnownObjectMode.Singleton);
                        RemotingConfiguration.RegisterWellKnownServiceType(typeof(TCrossDomainMarshaller),
                                                                           TClientManager.CROSSDOMAINURL, WellKnownObjectMode.Singleton);

                        LifetimeServices.LeaseTime            = TimeSpan.FromSeconds(TAppSettingsManager.GetDouble("LifetimeServices.LeaseTimeInSeconds", 5.0f));
                        LifetimeServices.RenewOnCallTime      = TimeSpan.FromSeconds(TAppSettingsManager.GetDouble("LifetimeServices.RenewOnCallTime", 5.0f));
                        LifetimeServices.LeaseManagerPollTime =
                            TimeSpan.FromSeconds(TAppSettingsManager.GetDouble("LifetimeServices.LeaseManagerPollTime", 1.0f));
                    }
                    else
                    {
                        TLogging.Log(Catalog.GetString("Reading server remote configuration from config file..."));

                        if (TheServerManager.ConfigurationFileName == "")
                        {
                            RemotingConfiguration.Configure(Environment.GetCommandLineArgs()[0] + ".config", false);
                        }
                        else
                        {
                            RemotingConfiguration.Configure(TheServerManager.ConfigurationFileName, false);
                        }

                        RemotingConfiguration.RegisterWellKnownServiceType(typeof(TCrossDomainMarshaller),
                                                                           TClientManager.CROSSDOMAINURL, WellKnownObjectMode.Singleton);
                    }
                }
                catch (RemotingException rex)
                {
                    if (rex.Message.IndexOf("SocketException") > 1)
                    {
                        TLogging.Log("A SocketException has been thrown.");
                        TLogging.Log("Most probably problem is that the address port is used twice!");
                        throw new EOPAppException();
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (Exception)
                {
                    throw;
                }

                Thread.Sleep(50);
                TrackingServices.RegisterTrackingHandler(new TRemotingTracker());

                // Display information that the Server is ready to accept .NET Remoting requests
                TLogging.Log(TheServerManager.ServerInfoState);

                //
                // Server startup done.
                // From now on just listen on .NET Remoting Framework object invocations or on
                // menu commands...
                //

                bool RunWithoutMenu = TAppSettingsManager.GetBoolean("RunWithoutMenu", false);

                if ((!RunWithoutMenu))
                {
                    Console.WriteLine(Environment.NewLine + Catalog.GetString("-> Press \"m\" for menu."));
                    WriteServerPrompt();
                }

                // All exceptions that are raised from various parts of the Server are handled below.
                // Note: The Server stops after handling these exceptions!!!
                if (RunWithoutMenu)
                {
                    RunInBackground();
                }
                else
                {
                    RunMenu();
                }

                // THE VERY END OF THE SERVER :(
            }
            catch (System.Net.Sockets.SocketException exp)
            {
                TLogging.Log(
                    Environment.NewLine + "Unable to start the Server: The IP Port " + TSrvSetting.IPBasePort.ToString() +
                    " is being used by a different instance of the Server or some other application." + Environment.NewLine + exp.ToString());
            }
            catch (System.Runtime.Remoting.RemotingException exp)
            {
                System.Diagnostics.Debug.WriteLine(exp.ToString());
                TLogging.Log(Environment.NewLine + "Exception occured while setting up Remoting Framework:" + Environment.NewLine + exp.ToString());
            }
            catch (EOPAppException)
            {
                // This Exception is used if no more messages shall be done ...
            }
            catch (Exception exp)
            {
                TLogging.Log(Environment.NewLine + "Exception occured:" + Environment.NewLine + exp.ToString());
            }
        }
Example #48
0
        private void Init(IDictionary properties, IClientChannelSinkProvider clientSink, IServerChannelSinkProvider serverSink)
        {
            this._clientChannel = new UnixClientChannel(properties, clientSink);
            if (properties["path"] != null)
            {
                this._serverChannel = new UnixServerChannel(properties, serverSink);
            }
            object item = properties["name"];

            if (item != null)
            {
                this._name = item as string;
            }
            item = properties["priority"];
            if (item != null)
            {
                this._priority = Convert.ToInt32(item);
            }
        }
        /// <summary>
        /// Constructs an instance of the GenuineTcpChannel class.
        /// </summary>
        /// <param name="properties">An IDictionary of the channel properties which hold the configuration information for the current channel.</param>
        /// <param name="iClientChannelSinkProvider">The IClientChannelSinkProvider that creates the client channel sinks for the underlying channel through which remoting messages flow through.</param>
        /// <param name="iServerChannelSinkProvider">The IServerChannelSinkProvider that creates server channel sinks for the underlying channel through which remoting messages flow through.</param>
        public GenuineTcpChannel(IDictionary properties, IClientChannelSinkProvider iClientChannelSinkProvider, IServerChannelSinkProvider iServerChannelSinkProvider)
            : base(iClientChannelSinkProvider, iServerChannelSinkProvider)
        {
            this.ITransportContext = TransportContextServices.CreateDefaultTcpContext(properties, this);
            this.InitializeInstance(properties);

            if (this._channelName == null)
            {
                this._channelName = "gtcp";
            }
            if (this._urlPrefix == null)
            {
                this._urlPrefix = "gtcp";
            }
            this._possibleChannelPrefixes = new string[] { this.UrlPrefix, this.UriPrefix };

            // Start listening
            this.StartListening(null);
        }
Example #50
0
 public IceServerChannel(IDictionary properties,
                         IServerChannelSinkProvider serverSinkProvider)
 {
     throw new NotImplementedException();
 }
Example #51
0
        } // IpcServerChannel

        public IpcServerChannel(IDictionary properties, IServerChannelSinkProvider sinkProvider)
            : this(properties, sinkProvider, null)
        {
        }
Example #52
0
 public IceServerChannel(Ice.Endpoint ep,
                         IServerChannelSinkProvider serverSinkProvider)
 {
     _e = Ice.Manager.GetManager().GetEndpoint(ep);
     Init(serverSinkProvider);
 }
Example #53
0
        private void Initialise(TypeFilterLevel typeFilterLevel, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider, int port, bool listen, bool keepAlive, ulong keepAliveTime, ulong KeepAliveInterval, short maxRetries, int retryDelay, IPAddress bindToAddress)
        {
            _tcpKeepAliveEnabled  = keepAlive;
            _tcpKeepAliveTime     = keepAliveTime;
            _tcpKeepAliveInterval = KeepAliveInterval;
            _maxRetries           = maxRetries;
            _retryDelay           = retryDelay;
            _bindToAddress        = bindToAddress;

            if (clientSinkProvider == null)
            {
                clientSinkProvider = new BinaryClientFormatterSinkProvider();
            }
            if (serverSinkProvider == null)
            {
                Trace.WriteLine("Setting serialization filter: {0}", typeFilterLevel);
                BinaryServerFormatterSinkProvider tempProvider = new BinaryServerFormatterSinkProvider();
                tempProvider.TypeFilterLevel = typeFilterLevel;
                serverSinkProvider           = tempProvider;
            }

            // Initialise clientSinkProvider
            this.clientSinkProvider = clientSinkProvider;
            while (clientSinkProvider.Next != null)
            {
                clientSinkProvider = clientSinkProvider.Next;
            }
            clientSinkProvider.Next = new ClientTransportSinkProvider();

            messageSink = new ServerTransportSink(ChannelServices.CreateServerChannelSinkChain(serverSinkProvider, this));
            serverSinkProvider.GetChannelData(channelData);

            if (listen)
            {
                StartListening(port);
            }

            channelData = new TcpExChannelData(this);

            Manager.BeginReadMessage(_channelID, null, new AsyncCallback(messageSink.ReceiveMessage), _channelID);
        }
        /// <summary>
        /// Adds a specified server sink provider into the server sink chain.
        /// </summary>
        /// <param name="protocolSetup">Protocol setup</param>
        /// <param name="serverSinkProvider">Server sink provider to be added</param>
        /// <returns>Protocol setup</returns>
        public static IServerProtocolSetup AddServerSink(this IServerProtocolSetup protocolSetup, IServerChannelSinkProvider serverSinkProvider)
        {
            if (protocolSetup == null)
            {
                throw new ArgumentNullException("protocolSetup");
            }

            if (serverSinkProvider == null)
            {
                throw new ArgumentNullException("serverSinkProvider");
            }

            protocolSetup.ServerSinkChain.Add(serverSinkProvider);

            return(protocolSetup);
        }
Example #55
0
 protected override IChannel CreateChannel(IDictionary objChannelProperties, IClientChannelSinkProvider objClientFormatter, IServerChannelSinkProvider objServerFormatter)
 {
     return(new HttpChannel(objChannelProperties, objClientFormatter, objServerFormatter));
 }
Example #56
0
        void BuildSink(IServerChannelSinkProvider sinkProvider)
        {
            //resolve names (modified from TcpChannel)
            if (machineName == null)
            {
                if (useIPAddress)
                {
                    if (!bindAddress.Equals(IPAddress.Any))
                    {
                        machineName = bindAddress.ToString();
                    }
                    else
                    {
                        IPHostEntry hostEntry = Dns.Resolve(Dns.GetHostName());
                        if (hostEntry.AddressList.Length == 0)
                        {
                            throw new RemotingException("IP address could not be determined for this host");
                        }
                        // We DON'T want to take the resolved address from the hostEntry, since the socket
                        // should still bind to IPAddress.Any, so that we get the loopback too
                        machineName = hostEntry.AddressList[0].ToString();
                    }
                }
                else
                {
                    IPHostEntry hostEntry = Dns.GetHostByName(Dns.GetHostName());
                    bindAddress = hostEntry.AddressList[0];
                    machineName = hostEntry.HostName;
                }
            }

            if (sinkProvider == null)
            {
                //build a default chain that can handle wsdl, soap, binary
                sinkProvider           = new SdlChannelSinkProvider();        //for wsdl
                sinkProvider.Next      = new SoapServerFormatterSinkProvider();
                sinkProvider.Next.Next = new BinaryServerFormatterSinkProvider();
            }

            //MS compat: channelData is null when port < 0
            if (port >= 0)
            {
                channelData = new ChannelDataStore(null);
                IServerChannelSinkProvider provider = sinkProvider;
                while (provider != null)
                {
                    provider.GetChannelData(channelData);
                    provider = provider.Next;
                }
            }

            //create the sink chain and add an HTTP sink
            IServerChannelSink nextSink = ChannelServices.CreateServerChannelSinkChain(sinkProvider, this);

            sink = new HttpServerTransportSink(nextSink);

            // BaseChannelWithProperties wants this to be set with the chain
            base.SinksWithProperties = nextSink;

            StartListening(null);
        }
 /// <summary>
 /// Constructs an instance of the BasicChannelWithSecurity class.
 /// </summary>
 /// <param name="iClientChannelSinkProvider">The client channel sink provider.</param>
 /// <param name="iServerChannelSinkProvider">The server channel sink provider.</param>
 public BasicChannelWithSecurity(IClientChannelSinkProvider iClientChannelSinkProvider, IServerChannelSinkProvider iServerChannelSinkProvider)
 {
     this._iClientChannelSinkProvider = iClientChannelSinkProvider;
     this._iServerChannelSinkProvider = iServerChannelSinkProvider;
 }
Example #58
0
        /// <summary>
        /// Erzeugt einen fertig konfigurierten Remoting-Kanal.
        /// <remarks>
        /// Wenn der Kanal in der aktuellen Anwendungsdomäne bereits registriert wurde, wird null zurückgegeben.
        /// </remarks>
        /// </summary>
        /// <returns>Remoting Kanal</returns>
        public IChannel CreateChannel()
        {
            // Kanal suchen
            IChannel channel = ChannelServices.GetChannel(_channelName);

            // Wenn der Kanal nicht gefunden wurde ...
            if (channel == null)
            {
                // Konfiguration für den TCP-Kanal erstellen
                System.Collections.IDictionary channelSettings = new System.Collections.Hashtable();
                channelSettings["name"] = _channelName;
                channelSettings["port"] = 0;
                channelSettings["socketCacheTimeout"] = 0;
                channelSettings["socketCachePolicy"]  = SocketCachingEnabled ? SocketCachePolicy.Default : SocketCachePolicy.AbsoluteTimeout;

                // Standardmäßige Windows-Authentifizierung des Remoting TCP-Kanals abschalten
                channelSettings["secure"] = false;

                // Binären Clientformatierer erzeugen
                BinaryClientFormatterSinkProvider clientFormatter = new BinaryClientFormatterSinkProvider();

                // Wenn die Kommunikation verschlüsselt werden soll ...
                if (_encryption)
                {
                    // Client-Verschlüsselungs-Kanalsenkenanbieter erzeugen
                    CryptoClientChannelSinkProvider clientEncryption = new CryptoClientChannelSinkProvider();

                    // Verschlüsselung konfigurieren
                    clientEncryption.Algorithm   = _algorithm;
                    clientEncryption.Oaep        = _oaep;
                    clientEncryption.MaxAttempts = _maxAttempts;

                    // Verschlüsselungs-Kanalsenkenanbieter hinter den Formatierer hängen
                    clientFormatter.Next = clientEncryption;
                }
                // Variable für ersten Server-Senkenanbieter in der Kette
                IServerChannelSinkProvider firstServerSinkProvider = null;

                // Binären Clientformatierer erzeugen
                BinaryServerFormatterSinkProvider serverFormatter = new BinaryServerFormatterSinkProvider();

                // Binäre Serialisierung von komplexen Objekten aktivieren
                serverFormatter.TypeFilterLevel = TypeFilterLevel.Full;

                // Wenn die Kommunikation verschlüsselt werden soll ...
                if (_encryption)
                {
                    // Server-Verschlüsselungs-Kanalsenkenanbieter erzeugen
                    CryptoServerChannelSinkProvider serverEncryption = new CryptoServerChannelSinkProvider();

                    // Verschlüsselung konfigurieren
                    serverEncryption.Algorithm           = _algorithm;
                    serverEncryption.Oaep                = _oaep;
                    serverEncryption.RequireCryptoClient = true;

                    // Formatierer hinter den Verschlüsselungs-Kanalsenkenanbieter hängen
                    serverEncryption.Next = serverFormatter;

                    // Verschlüsselungs-Kanalsenkenanbieter als ersten Senkenanbieter festlegen
                    firstServerSinkProvider = serverEncryption;
                }
                else
                {
                    // Server-Formatierer als ersten Senkenanbieter festlegen
                    firstServerSinkProvider = serverFormatter;
                }

                // Neuen TCP-Kanal erzeugen
                channel = new TcpChannel(channelSettings, clientFormatter, firstServerSinkProvider);

                // Wenn Zyan nicht mit mono ausgeführt wird ...
                if (!MonoCheck.IsRunningOnMono)
                {
                    // Sicherstellen, dass vollständige Ausnahmeinformationen übertragen werden
                    if (RemotingConfiguration.CustomErrorsMode != CustomErrorsModes.Off)
                    {
                        RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.Off;
                    }
                }
                // Kanal zurückgeben
                return(channel);
            }
            // Nichts zurückgeben
            return(null);
        }
Example #59
0
 public HttpServerChannel(string name, int port, IServerChannelSinkProvider sinkProvider)
 {
     this.name = name;
     this.port = port;
     BuildSink(sinkProvider);
 }
        /// <summary>
        /// Adds a specified server sink provider into the server sink chain after the formatter.
        /// </summary>
        /// <param name="protocolSetup">Protocol setup</param>
        /// <param name="serverSinkProvider">Server sink provider to be added</param>
        /// <returns>Protocol setup</returns>
        public static IServerProtocolSetup AddServerSinkAfterFormatter(this IServerProtocolSetup protocolSetup, IServerChannelSinkProvider serverSinkProvider)
        {
            if (protocolSetup == null)
            {
                throw new ArgumentNullException("protocolSetup");
            }

            if (serverSinkProvider == null)
            {
                throw new ArgumentNullException("serverSinkProvider");
            }

            IServerFormatterSinkProvider formatter = GetServerFormatter(protocolSetup);

            if (formatter == null)
            {
                throw new ApplicationException(LanguageResource.ApplicationException_NoFormatterSpecified);
            }

            int index = protocolSetup.ServerSinkChain.IndexOf((IServerChannelSinkProvider)formatter);

            protocolSetup.ServerSinkChain.Insert(index + 1, serverSinkProvider);

            return(protocolSetup);
        }