internal static core.v2_0.services.access_control.CallChain UnmarshalLegacyCallChain(SignedCallChain signed)
        {
            TypeCode chainTypeCode =
                OrbServices.GetSingleton().create_tc_for_type(typeof(core.v2_0.services.access_control.CallChain));

            return((core.v2_0.services.access_control.CallChain)InterceptorsInitializer.Codec.decode_value(signed.encoded, chainTypeCode));
        }
示例#2
0
 public void ShareDataKeys(List <byte[]> keys)
 {
     omg.org.CORBA.TypeCode byteTC     = OrbServices.GetSingleton().create_octet_tc();
     omg.org.CORBA.TypeCode sequenceTC = OrbServices.GetSingleton().create_sequence_tc(0, byteTC);
     omg.org.CORBA.TypeCode arrayTC    = OrbServices.GetSingleton().create_array_tc(keys.Count, sequenceTC);
     Share(new Any(keys.ToArray(), arrayTC));
 }
示例#3
0
        static void Main()
        {
            log4net.Config.XmlConfigurator.Configure();

            OrbServices.CreateAndRegisterIiopChannel(0);

            String              componentModel       = Resources.ComponentDesc;
            TextReader          file                 = new StringReader(componentModel);
            XmlTextReader       componentInformation = new XmlTextReader(file);
            XmlComponentBuilder builder              = new XmlComponentBuilder(componentInformation);
            ComponentContext    pingContext          = builder.build();

            //Escrevendo a IOR do IComponent no arquivo.
            IComponent  pingComponent = pingContext.GetIComponent();
            OrbServices orb           = OrbServices.GetSingleton();
            String      ior           = orb.object_to_string(pingComponent);

            String       iorPath = Resources.IorFilename;
            StreamWriter stream  = new StreamWriter(iorPath);

            try {
                stream.Write(ior);
            }
            finally {
                stream.Close();
            }

            Console.WriteLine("Componente ping está no ar.");
            Console.ReadLine();
        }
示例#4
0
        public void TestSlotModifyInClientRecContextAndServer()
        {
            try {
                int slotId = m_testInterceptorInit.RequestIntercept.SlotId;
                ORB orb    = OrbServices.GetSingleton();
                omg.org.PortableInterceptor.Current current =
                    (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
                int contextEntryVal = 4;
                current.set_slot(slotId, contextEntryVal);

                System.Int32 arg    = 1;
                System.Int32 result = m_testService.TestAddToContextData(arg);
                Assertion.AssertEquals(arg + contextEntryVal, result);

                Assertion.Assert("service context not present", m_testInterceptorInit.RequestIntercept.HasReceivedContextElement);
                Assertion.AssertEquals("service context content", arg + contextEntryVal,
                                       m_testInterceptorInit.RequestIntercept.ContextElement.TestEntry);

                current =
                    (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
                Assertion.AssertEquals("slot was modified", contextEntryVal, current.get_slot(slotId));
            } finally {
                m_testInterceptorInit.RequestIntercept.ClearInvocationHistory();
            }
        }
示例#5
0
        public void SetUp()
        {
            m_orb = OrbServices.GetSingleton();

            m_channel = new IiopChannel(TEST_PORT);
            ChannelServices.RegisterChannel(m_channel, false);
        }
示例#6
0
 private void IntializeForInterception(IInterceptionOption[] interceptionOptions)
 {
     // flow lifetime is bound to message lifetime, GiopClientRequest is only a wrapper around message and
     // can be recreated during message lifetime.
     m_interceptionFlow =
         (ClientRequestInterceptionFlow)SimpleGiopMsg.GetInterceptionFlow(m_requestMessage);
     if (m_interceptionFlow == null)
     {
         ClientRequestInterceptor[] interceptors =
             OrbServices.GetSingleton().InterceptorManager.GetClientRequestInterceptors(interceptionOptions);
         if (interceptors.Length == 0)
         {
             m_interceptionFlow = new ClientRequestInterceptionFlow();
         }
         else
         {
             m_interceptionFlow = new ClientRequestInterceptionFlow(interceptors);
         }
         SimpleGiopMsg.SetInterceptionFlow(m_requestMessage, m_interceptionFlow);
     }
     if (m_interceptionFlow.NeedsRequestInfo())
     {
         // optimization: needs not be created, if non-intercepted.
         m_clientRequestInfo = new ClientRequestInfoImpl(this);
     }
 }
示例#7
0
        static void Main()
        {
            Console.WriteLine("Pressione 'enter' quando o componente Hello estiver no ar.");
            Console.ReadLine();

            OrbServices.CreateAndRegisterIiopChannel();
            String       helloIorPath = Resources.IorFilename;
            StreamReader stream       = new StreamReader(helloIorPath);
            String       helloIor;

            try {
                helloIor = stream.ReadToEnd();
            }
            finally {
                stream.Close();
            }

            OrbServices orb        = OrbServices.GetSingleton();
            IComponent  icomponent = orb.string_to_object(helloIor) as IComponent;
            Hello       hello      = icomponent.getFacetByName("Hello") as Hello;

            hello.sayHello();

            Console.ReadLine();
        }
示例#8
0
        public static void Main(String[] args)
        {
            IOrbServices        orb = OrbServices.GetSingleton();
            TestInterceptorInit testInterceptorInit = new TestInterceptorInit();

            orb.RegisterPortableInterceptorInitalizer(testInterceptorInit);

            // register the channel
            int         port = 8087;
            IiopChannel chan = new IiopChannel(port);

            ChannelServices.RegisterChannel(chan, false);

            orb.CompleteInterceptorRegistration();

            TestInterceptorControlService controlService =
                new TestInterceptorControlService(testInterceptorInit);
            string objectURIControlService = "interceptorControl";

            RemotingServices.Marshal(controlService, objectURIControlService);

            TestService test      = new TestService();
            string      objectURI = "test";

            RemotingServices.Marshal(test, objectURI);

            Console.WriteLine("server running");
            Thread.Sleep(Timeout.Infinite);
        }
        internal static CallChain UnmarshalCallChain(SignedData signed)
        {
            TypeCode chainTypeCode =
                OrbServices.GetSingleton().create_tc_for_type(typeof(CallChain));

            return((CallChain)InterceptorsInitializer.Codec.decode_value(signed.encoded, chainTypeCode));
        }
        private static void Main()
        {
            Assembly.Load("OpenBus.Legacy.Idl");
            string hostName         = DemoConfig.Default.busHostName;
            ushort hostPort         = DemoConfig.Default.busHostPort;
            string loginFile        = DemoConfig.Default.loginFile;
            bool   useSSL           = DemoConfig.Default.useSSL;
            string clientUser       = DemoConfig.Default.clientUser;
            string clientThumbprint = DemoConfig.Default.clientThumbprint;
            string serverUser       = DemoConfig.Default.serverUser;
            string serverThumbprint = DemoConfig.Default.serverThumbprint;
            ushort serverSSLPort    = DemoConfig.Default.serverSSLPort;
            ushort serverOpenPort   = DemoConfig.Default.serverOpenPort;
            string busIORFile       = DemoConfig.Default.busIORFile;

            if (useSSL)
            {
                Utils.InitSSLORB(clientUser, clientThumbprint, serverUser, serverThumbprint, serverSSLPort, serverOpenPort, true, true, "required", false, false);
            }
            else
            {
                ORBInitializer.InitORB();
            }

/*
 *    ConsoleAppender appender = new ConsoleAppender {
 *                                                     Threshold = Level.Off,
 *                                                     Layout =
 *                                                       new SimpleLayout(),
 *                                                   };
 *    BasicConfigurator.Configure(appender);
 */
            ConnectionProperties props   = new ConnectionPropertiesImpl();
            OpenBusContext       context = ORBInitializer.Context;
            Connection           conn;

            if (useSSL)
            {
                string ior = File.ReadAllText(busIORFile);
                conn = context.ConnectByReference((MarshalByRefObject)OrbServices.CreateProxy(typeof(MarshalByRefObject), ior), props);
            }
            else
            {
                conn = context.ConnectByAddress(hostName, hostPort, props);
            }
            context.SetDefaultConnection(conn);

            byte[]           encoded = File.ReadAllBytes(loginFile);
            SharedAuthSecret secret  = context.DecodeSharedAuth(encoded);

            conn.LoginBySharedAuth(secret);

            Assert.IsNotNull(conn.Login);
            Assert.IsNotNull(conn.Login.Value.id);
            Assert.IsNotNull(conn.Login.Value.entity);

            conn.Logout();
            Logger.Info("Fim.");
        }
示例#11
0
        private void RegisterInterceptors()
        {
            IOrbServices orb = OrbServices.GetSingleton();

            m_testInterceptorInit = new TestInterceptorInit();
            orb.RegisterPortableInterceptorInitalizer(m_testInterceptorInit);
            orb.CompleteInterceptorRegistration();
        }
示例#12
0
        public bool NoValueInScope()
        {
            ORB orb = OrbServices.GetSingleton();

            omg.org.PortableInterceptor.Current current =
                (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
            return(current.get_slot(m_slotId) == null);
        }
        public string fetchHello(byte[] encodedChain)
        {
            OpenBusContext context = ORBInitializer.Context;
            CallerChain    chain;

            try {
                chain = context.DecodeChain(encodedChain);
            }
            catch (InvalidEncodedStreamException e) {
                Console.WriteLine(e);
                throw new ArgumentException("Cadeia em formato inválido.", e);
            }
            context.JoinChain(chain);

            ServiceProperty[] properties =
            {
                new ServiceProperty("offer.domain",                             "Interoperability Tests"),
                new ServiceProperty("openbus.component.interface",
                                    Repository.GetRepositoryID(typeof(Hello))),
                new ServiceProperty("openbus.component.name",                   "RestrictedHello")
            };
            List <ServiceOfferDesc> offers =
                Utils.FindOffer(ORBInitializer.Context.OfferRegistry, properties, 1, 10, 1);

            foreach (ServiceOfferDesc desc in offers)
            {
                try {
                    if (OrbServices.GetSingleton().non_existent(desc.service_ref))
                    {
                        continue;
                    }
                }
                catch (TRANSIENT) {
                    continue;
                }
                catch (COMM_FAILURE) {
                    continue;
                }
                MarshalByRefObject helloObj =
                    desc.service_ref.getFacet(Repository.GetRepositoryID(typeof(Hello)));
                if (helloObj == null)
                {
                    Console.WriteLine(
                        "Não foi possível encontrar uma faceta com esse nome.");
                    continue;
                }

                Hello hello = helloObj as Hello;
                if (hello == null)
                {
                    Console.WriteLine("Faceta encontrada não implementa Hello.");
                    continue;
                }
                return(hello.sayHello());
            }

            return("");
        }
        private static CredentialData UnmarshalCredential(ServiceContext serviceContext)
        {
            OrbServices orb = OrbServices.GetSingleton();
            TypeCode    credentialTypeCode =
                orb.create_tc_for_type(typeof(CredentialData));

            byte[] data = serviceContext.context_data;
            return((CredentialData)InterceptorsInitializer.Codec.decode_value(data, credentialTypeCode));
        }
示例#15
0
 private void DeactivateConsumer()
 {
     if (_subsId != 0)
     {
         _theSession.channel.unsubscribe(_subsId);
         OrbServices.DeactivateObject((MarshalByRefObject)_consumer);
         _subsId = 0;
     }
 }
示例#16
0
 private void DeactivateObserver()
 {
     if (_obsId != 0)
     {
         _theSession.unsubscribeObserver(_obsId);
         OrbServices.DeactivateObject((MarshalByRefObject)_observer);
         _obsId = 0;
     }
 }
示例#17
0
 public ServerRequestInterceptor GetServerRequestInterceptor(OrbServices orb)
 {
     lock (this) {
         if (m_serverInterceptor == null)
         {
             m_serverInterceptor = new BiDirIiopServerInterceptor(orb);
         }
         return(m_serverInterceptor);
     }
 }
示例#18
0
 public ClientRequestInterceptor GetClientRequestInterceptor(OrbServices orb)
 {
     lock (this) {
         if (m_clientInterceptor == null)
         {
             m_clientInterceptor = new BiDirIiopClientInterceptor(orb);
         }
         return(m_clientInterceptor);
     }
 }
示例#19
0
 private void UpdateActivation()
 {
     if (_observer != null)
     {
         try
         {
             DeactivateObserver();
         }
         catch (Exception e)
         {
             Logger.Warn("Failed to deactivate previously activated observer: " + e);
         }
         try
         {
             OrbServices.ActivateObject((MarshalByRefObject)_observer);
             _obsId = _theSession.subscribeObserver(_observer);
             Logger.Info("Observer subscribed");
         }
         catch (Exception e)
         {
             if (_obsId != 0)
             {
                 _theSession.unsubscribeObserver(_obsId);
             }
             Logger.Error("Error subscribing to the session: " + e);
             throw;
         }
     }
     if (_consumer != null)
     {
         try
         {
             DeactivateConsumer();
         }
         catch (Exception e)
         {
             Logger.Warn("Failed to deactivate previously activated consumer: " + e);
         }
         try
         {
             OrbServices.ActivateObject((MarshalByRefObject)_consumer);
             _subsId = _theSession.channel.subscribe(_consumer);
             Logger.Info("Consumer registered");
         }
         catch (Exception e)
         {
             if (_subsId != 0)
             {
                 _theSession.channel.unsubscribe(_subsId);
             }
             Logger.Error("Error subscribing to the channel: " + e);
             throw;
         }
     }
 }
示例#20
0
        public void TestAnyContainer()
        {
            System.String testString = "abcd";
            OrbServices   orb        = OrbServices.GetSingleton();

            omg.org.CORBA.TypeCode wstringTc = orb.create_wstring_tc(0);
            Any any    = new Any(testString, wstringTc);
            Any result = m_testService.EchoAny(any);

            Assertion.AssertEquals(any.Value, result.Value);
        }
示例#21
0
        public object RetrieveIdlIntArrayAsAny([IdlArray(0L, 5)] int[] arg)
        {
            // test with explicit typecode-creation
            IOrbServices orbServices = OrbServices.GetSingleton();

            omg.org.CORBA.TypeCode arrayTC =
                orbServices.create_array_tc(5, orbServices.create_tc_for_type(typeof(int)));
            Any arrayAsAny = new Any(arg, arrayTC);

            return(arrayAsAny);
        }
        /// <summary>
        /// Verifica se o objeto CORBA implementa a interface (repository ID).
        /// </summary>
        /// <param name="obj">O objeto CORBA.</param>
        /// <param name="interfaceName">A interface (repository ID).</param>
        /// <returns></returns>
        public static bool CheckInterface(MarshalByRefObject obj, string interfaceName)
        {
            OrbServices orb = OrbServices.GetSingleton();

            try {
                return(orb.is_a(obj, interfaceName));
            }
            catch (NullReferenceException) {
                return(false);
            }
        }
 public OpenBusContextImpl(int connectionIdSlotId, int ignoreThreadSlotId,
                           int joinedChainSlotId, int chainSlotId)
 {
     _connections        = new ConditionalWeakTable <Object, Connection>();
     _connectionIdSlotId = connectionIdSlotId;
     _ignoreThreadSlotId = ignoreThreadSlotId;
     _joinedChainSlotId  = joinedChainSlotId;
     _chainSlotId        = chainSlotId;
     _orb   = OrbServices.GetSingleton();
     _lock  = new ReaderWriterLockSlim();
     _codec = InterceptorsInitializer.Codec;
 }
示例#24
0
        public System.Int32 TestAddToContextData(System.Int32 arg)
        {
            ORB orb = OrbServices.GetSingleton();

            omg.org.PortableInterceptor.Current current =
                (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
            int contextData = (int)current.get_slot(m_slotId);
            int result      = contextData + arg;

            current.set_slot(m_slotId, result);
            return(result);
        }
示例#25
0
        public void SetUp()
        {
            m_orb = OrbServices.GetSingleton();

            m_profile =
                new InternetIiopProfile(new GiopVersion(1, 2),
                                        "localhost",
                                        1001,
                                        new byte[] { 1, 0, 0, 0 });

            m_clientChannel = new IiopClientChannel();
            ChannelServices.RegisterChannel(m_clientChannel, false);
        }
示例#26
0
        public object RetrieveIdlInt3DimArray2x2x3AsAny([IdlArray(0L, 2)][IdlArrayDimension(0L, 1, 2)][IdlArrayDimension(0L, 2, 3)] System.Int32[,,] arg)
        {
            // test with explicit typecode-creation
            IOrbServices orbServices = OrbServices.GetSingleton();

            omg.org.CORBA.TypeCode arrayTC =
                orbServices.create_array_tc(3, orbServices.create_tc_for_type(typeof(int)));
            arrayTC = orbServices.create_array_tc(2, arrayTC);
            arrayTC = orbServices.create_array_tc(2, arrayTC);
            Any arrayAsAny = new Any(arg, arrayTC);

            return(arrayAsAny);
        }
示例#27
0
 /// <summary>
 /// Resolves a name to a service.
 /// </summary>
 /// <param name="name">name to resolve</param>
 /// <returns>resolved service</returns>
 /// <exception cref="ServiceException">
 /// if a CORBA-related error occurs while resolving the service name
 /// </exception>
 public T Resolve(Name name)
 {
     try {
         MarshalByRefObject reference = this.DirContext.resolve(name.Components);
         // Touch the object to immediately fail if it is unavailable
         OrbServices.GetSingleton().non_existent(reference);
         // Jeez, C#...
         return((T)((object)reference));
     } catch (AbstractCORBASystemException e) {
         throw new ServiceException("Failed to resolve service name " + name, e);
     } catch (TargetInvocationException e) {
         throw new ServiceException("Failed to resolve service name " + name, e.InnerException);
     }
 }
示例#28
0
 public void receive_request(ServerRequestInfo ri)
 {
     // modify request scope after copy to the thread scope -> must not be propagated to the thread scope.
     if (ri.operation == "TestReceiveReqNotChangeThreadScope")
     {
         ri.set_slot(m_slotId, 2 * (int)ri.get_slot(m_slotId));
     }
     else if (ri.operation == "TestReceiveReqChangeThreadScope")
     {
         ORB orb = OrbServices.GetSingleton();
         omg.org.PortableInterceptor.Current current =
             (omg.org.PortableInterceptor.Current)orb.resolve_initial_references("PICurrent");
         current.set_slot(m_slotId, 3 * (int)current.get_slot(m_slotId));
     }
 }
示例#29
0
        public void TestNilReferenceAsAny()
        {
            OrbServices orb = OrbServices.GetSingleton();

            omg.org.CORBA.TypeCode nilRefTC = orb.create_tc_for_type(typeof(System.MarshalByRefObject));
            Any    nilRefAny = new Any(null, nilRefTC);
            object result    = m_testService.EchoAny(nilRefAny);

            Assert.IsNull(result, "result not null");

            Any    nilRefAny2 = new Any(null, orb.create_interface_tc(String.Empty, String.Empty));
            object result2    = m_testService.EchoAny(nilRefAny2);

            Assert.IsNull(result2, "result not null");
        }
示例#30
0
        public void TestULongAsAny()
        {
            int arg    = 74;
            int result = (int)m_testService.RetrieveULongAsAny(arg);

            Assert.AreEqual(arg, result, "wrong result of retrieveULongAsAny");

            OrbServices orb  = OrbServices.GetSingleton();
            int         arg2 = 89;

            omg.org.CORBA.TypeCode ulongTC = orb.create_ulong_tc();
            Any any     = new Any(arg2, ulongTC);
            int result2 = m_testService.ExtractFromULongAny(any);

            Assert.AreEqual(arg2, result2, "wrong result of ExtractFromULongAny");
        }