Esempio n. 1
0
        public static SC.Interfaces.IRoot GetRoot(string Host, string Username, string Password)
        {
            string channelname = Host + ":" + Username;

            if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel(channelname) == null)
            {
                System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider soapFormatter = new System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider();
                SC.Remoting.ClientEncryptionSinkProvider     encrProvider = new SC.Remoting.ClientEncryptionSinkProvider();
                SC.Remoting.ClientAuthenticationSinkProvider authProvider = new SC.Remoting.ClientAuthenticationSinkProvider(Username, Password);

                soapFormatter.Next = authProvider;
                authProvider.Next  = encrProvider;

                Dictionary <string, string> props = new Dictionary <string, string>();
                props["name"]     = channelname;
                props["priority"] = System.Threading.Interlocked.Increment(ref priority).ToString();

                System.Runtime.Remoting.Channels.Http.HttpClientChannel channel = new System.Runtime.Remoting.Channels.Http.HttpClientChannel(props, soapFormatter);
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);
            }
            SC.Interfaces.IRoot root = System.Runtime.Remoting.RemotingServices.Connect(typeof(SC.Interfaces.IRoot), "http://" + Username + "@" + Host + "/ServerChecker4Root") as SC.Interfaces.IRoot;

            //SC.Interfaces.IRoot root = Activator.GetObject(typeof(SC.Interfaces.IRoot), "http://" + Host + "/ServerChecker4Root") as SC.Interfaces.IRoot;
            return(root);
        }
Esempio n. 2
0
        internal atriumDAL.DirectHelper RemoteHelper()
        {
            System.Runtime.Remoting.Channels.Http.HttpClientChannel hcc = null;
            try
            {
                hcc = RegisterChannel(hcc, myNC.UserName, myNC.Password, ServerInfo.remoteUrl);
                object      obj  = Activator.GetObject(typeof(atriumDAL.DirectHelper), ServerInfo.remoteUrl + "/RemoteActivationService.rem");
                IDictionary dict = System.Runtime.Remoting.Channels.ChannelServices.GetChannelSinkProperties(obj);
                //set credentials on the proxy object
                dict["credentials"] = cc;

                if (System.Runtime.Remoting.RemotingConfiguration.GetRegisteredActivatedClientTypes().Length == 0)
                {
                    System.Runtime.Remoting.RemotingConfiguration.RegisterActivatedClientType(typeof(atriumDAL.DirectHelper), ServerInfo.remoteUrl);
                    //get instance of your object
                }
                atriumDAL.DirectHelper helper = new atriumDAL.DirectHelper(myNC.UserName, myNC.Password, ServerInfo.dbConnect);

                //object[] url ={ new System.Runtime.Remoting.Activation.UrlAttribute(remoteServer) };
                //DALMngr = (atriumDAL.atriumDALManager)Activator.CreateInstance(typeof(atriumDAL.atriumDALManager), BindingFlags.ExactBinding , url,nc.UserName,nc.Password);

                //get channel sink object for your object and set credentials on that
                dict = System.Runtime.Remoting.Channels.ChannelServices.GetChannelSinkProperties(helper);
                dict["credentials"] = cc;

                return(helper);
            }
            catch (Exception xRemote)
            {
                ChannelServices.UnregisterChannel(hcc);

                throw;
            }
        }
Esempio n. 3
0
        protected override atDAL.DALManager RemoteDAL(string user, string fwPassword)
        {
            System.Runtime.Remoting.Channels.Http.HttpClientChannel hcc = null;
            try
            {
                hcc = RegisterChannel(hcc, user, fwPassword, ServerInfo.proxyUrl);
                object      obj  = Activator.GetObject(typeof(atriumDAL.atriumDALManager), ServerInfo.proxyUrl + "/RemoteActivationService.rem");
                IDictionary dict = System.Runtime.Remoting.Channels.ChannelServices.GetChannelSinkProperties(obj);
                //ObjRef objectReference = RemotingServices.Marshal((System.MarshalByRefObject)obj);
                //Uri objectUri = new Uri(objectReference.URI);
                //set credentials on the proxy object
                dict["credentials"]     = cc;
                dict["preauthenticate"] = true;


                if (System.Runtime.Remoting.RemotingConfiguration.GetRegisteredActivatedClientTypes().Length == 0)
                {
                    System.Runtime.Remoting.RemotingConfiguration.RegisterActivatedClientType(typeof(atriumDAL.atriumDALManager), ServerInfo.proxyUrl);
                    //get instance of your object
                }
                atriumDAL.atriumDALManager atDALMngr = new atriumDAL.atriumDALManager(myNC.UserName, myNC.Password, ServerInfo.dbConnect);

                //object[] url ={ new System.Runtime.Remoting.Activation.UrlAttribute(remoteServer) };
                //DALMngr = (atriumDAL.atriumDALManager)Activator.CreateInstance(typeof(atriumDAL.atriumDALManager), BindingFlags.ExactBinding , url,nc.UserName,nc.Password);

                //get channel sink object for your object and set credentials on that
                dict = System.Runtime.Remoting.Channels.ChannelServices.GetChannelSinkProperties(atDALMngr);
                dict["credentials"] = cc;


                //ObjRef rem= RemotingServices.GetObjRefForProxy(atDALMngr);

                return(atDALMngr);
            }
            catch (System.Reflection.TargetInvocationException tex)
            {
                if (tex.InnerException != null)
                {
                    throw tex.InnerException;
                }
                else
                {
                    throw tex;
                }
            }
            catch (Exception xRemote)
            {
                ChannelServices.UnregisterChannel(hcc);

                throw;
            }
        }
Esempio n. 4
0
        private System.Runtime.Remoting.Channels.Http.HttpClientChannel RegisterChannel(System.Runtime.Remoting.Channels.Http.HttpClientChannel hcc, string user, string fwPassword, string serverUrl)
        {
            if (ChannelServices.GetChannel("atrium" + user) == null)
            {
                System.Collections.Hashtable props = new System.Collections.Hashtable();

                props["port"]    = 0;
                props["name"]    = "atrium" + user;
                props["timeout"] = 300000;
                props["useDefaultCredentials"] = true;  //must be true to pass through authenticating firewalls

                //props["useAuthenticatedConnectionSharing"] = true;

                //props["proxyName"] = "lawmate.secure";
                //props["proxyPort"] = 80;

                hcc = new System.Runtime.Remoting.Channels.Http.HttpClientChannel(props, new BinaryClientFormatterSinkProvider());

                ChannelServices.RegisterChannel(hcc, true);
            }
            System.Uri u = new Uri(serverUrl);
            cc = new System.Net.CredentialCache();

            //set global default credentials - see CRA version
            System.Net.WebRequest.DefaultWebProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;



            if (user == "")
            {
                cc.Add(u, "Negotiate", myNC);
            }
            else
            {
                cc.Add(u, "Basic", new System.Net.NetworkCredential(user, fwPassword));
                cc.Add(u, "Digest", new System.Net.NetworkCredential(user, fwPassword));
            }
            //System.Net.HttpWebRequest wc = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(u);
            //wc.CookieContainer = new System.Net.CookieContainer();

            //wc.Credentials = cc;

            //System.Net.HttpWebResponse hw = (System.Net.HttpWebResponse)wc.GetResponse();

            return(hcc);
        }
        public static SC.Interfaces.IRoot GetRoot(string Host, string Username, string Password)
        {
            string channelname = Host + ":" + Username;
            if (System.Runtime.Remoting.Channels.ChannelServices.GetChannel(channelname) == null)
            {
                System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider soapFormatter = new System.Runtime.Remoting.Channels.SoapClientFormatterSinkProvider();
                SC.Remoting.ClientEncryptionSinkProvider encrProvider = new SC.Remoting.ClientEncryptionSinkProvider();
                SC.Remoting.ClientAuthenticationSinkProvider authProvider = new SC.Remoting.ClientAuthenticationSinkProvider(Username, Password);

                soapFormatter.Next = authProvider;
                                     authProvider.Next = encrProvider;

                Dictionary<string, string> props = new Dictionary<string, string>();
                props["name"] = channelname;
                props["priority"] = System.Threading.Interlocked.Increment(ref priority).ToString();

                System.Runtime.Remoting.Channels.Http.HttpClientChannel channel = new System.Runtime.Remoting.Channels.Http.HttpClientChannel(props, soapFormatter);
                System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);
            }
            SC.Interfaces.IRoot root = System.Runtime.Remoting.RemotingServices.Connect(typeof(SC.Interfaces.IRoot), "http://" + Username + "@" + Host + "/ServerChecker4Root") as SC.Interfaces.IRoot;

            //SC.Interfaces.IRoot root = Activator.GetObject(typeof(SC.Interfaces.IRoot), "http://" + Host + "/ServerChecker4Root") as SC.Interfaces.IRoot;
            return root;
        }
Esempio n. 6
0
 static void Main(string[] args)
 {
     var client = new System.Runtime.Remoting.Channels.Http.HttpClientChannel();
 }