public void TestIiopSslLoc() { string testIiopLoc = "iiop-ssl://elca.ch:1234/test"; IiopLoc parsed = new IiopLoc(testIiopLoc, m_codec, new object[] { m_defaultCodeSetTaggedComponent }); Assert.AreEqual("test", parsed.ObjectUri); Assert.AreEqual(1, parsed.GetProfiles().Length); Assert.AreEqual(typeof(InternetIiopProfile), parsed.GetProfiles()[0].GetType()); InternetIiopProfile prof = (InternetIiopProfile)(parsed.GetProfiles()[0]); Assert.AreEqual(1, prof.Version.Major); Assert.AreEqual(2, prof.Version.Minor); Assert.AreEqual("elca.ch", prof.HostName); Assert.AreEqual(0, prof.Port); testIiopLoc = "iiop-ssl1.1://elca.ch:1234/test"; parsed = new IiopLoc(testIiopLoc, m_codec, new object[] { m_defaultCodeSetTaggedComponent }); Assert.AreEqual("test", parsed.ObjectUri); Assert.AreEqual(1, parsed.GetProfiles().Length); Assert.AreEqual(typeof(InternetIiopProfile), parsed.GetProfiles()[0].GetType()); prof = (InternetIiopProfile)(parsed.GetProfiles()[0]); Assert.AreEqual(1, prof.Version.Major); Assert.AreEqual(1, prof.Version.Minor); Assert.AreEqual("elca.ch", prof.HostName); Assert.AreEqual(0, prof.Port); Assert.IsTrue(prof.TaggedComponents.ContainsTaggedComponent( CodeSetService.SERVICE_ID)); Assert.IsTrue(prof.TaggedComponents.ContainsTaggedComponent( TAG_SSL_SEC_TRANS.ConstVal)); }
public void TestMultipleCompleteCorbaLocIiop() { string testCorbaLoc = "corbaloc:iiop:[email protected]:1234,:[email protected]:1235,:[email protected]:1236/test"; Corbaloc parsed = new Corbaloc(testCorbaLoc, m_codec, new object[] { m_defaultCodeSetTaggedComponent }); Assert.AreEqual("test", parsed.KeyString); IorProfile[] profiles = parsed.GetProfiles(); Assert.AreEqual(3, profiles.Length); Assert.AreEqual(typeof(InternetIiopProfile), profiles[0].GetType()); Assert.AreEqual(typeof(InternetIiopProfile), profiles[1].GetType()); Assert.AreEqual(typeof(InternetIiopProfile), profiles[2].GetType()); InternetIiopProfile prof = (InternetIiopProfile)(profiles[0]); Assert.AreEqual(1, prof.Version.Major); Assert.AreEqual(2, prof.Version.Minor); Assert.AreEqual("elca.ch", prof.HostName); Assert.AreEqual(1234, prof.Port); prof = (InternetIiopProfile)(profiles[1]); Assert.AreEqual(1, prof.Version.Major); Assert.AreEqual(2, prof.Version.Minor); Assert.AreEqual("elca.ch", prof.HostName); Assert.AreEqual(1235, prof.Port); prof = (InternetIiopProfile)(profiles[2]); Assert.AreEqual(1, prof.Version.Major); Assert.AreEqual(2, prof.Version.Minor); Assert.AreEqual("elca.ch", prof.HostName); Assert.AreEqual(1236, prof.Port); }
/// <summary>gets a reference to the init service running at the specified host at the specified port</summary> private CORBAInitService GetInitService(string host, int port) { lock (m_initalServices.SyncRoot) { CORBAInitService initService = null; string key = host + ":" + port; if (!m_initalServices.ContainsKey(key)) { IorProfile initServiceProfile = new InternetIiopProfile(new GiopVersion(1, 0), host, (ushort)port, IorUtil.GetKeyBytesForId(CORBAInitServiceImpl.INITSERVICE_NAME)); // don't add a codeset component, because giop 1.0 Ior initServiceIor = new Ior(Repository.GetRepositoryID(typeof(CORBAInitService)), new IorProfile[] { initServiceProfile }); string iorString = initServiceIor.ToString(); initService = (CORBAInitService)RemotingServices.Connect(typeof(CORBAInitService), iorString); // CORBAInitService type not verifiable remote -> make sure that it's possible to verify locally m_initalServices.Add(key, initService); } else { initService = (CORBAInitService)m_initalServices[key]; } return(initService); } }
private Stream PrepareLocationFwdStream(string host, ushort port, MarshalByRefObject target) { // loc fwd ior byte[] objectKey = IorUtil.GetObjectKeyForObj(target); string repositoryID = Repository.GetRepositoryID(target.GetType()); // this server support GIOP 1.2 --> create an GIOP 1.2 profile InternetIiopProfile profile = new InternetIiopProfile(new GiopVersion(1, 2), host, port, objectKey); profile.AddTaggedComponent(Services.CodeSetService.CreateDefaultCodesetComponent(m_codec)); Ior locFwdTarget = new Ior(repositoryID, new IorProfile[] { profile }); CdrOutputStreamImpl iorStream = new CdrOutputStreamImpl(new MemoryStream(), 0, new GiopVersion(1, 2)); locFwdTarget.WriteToStream(iorStream); uint encodedIorLength = (uint)iorStream.GetPosition(); // create the location fwd reply MemoryStream sourceStream = new MemoryStream(); CdrOutputStreamImpl cdrOut = new CdrOutputStreamImpl(sourceStream, 0, new GiopVersion(1, 2)); cdrOut.WriteOpaque(m_giopMagic); // version cdrOut.WriteOctet(1); cdrOut.WriteOctet(2); // flags cdrOut.WriteOctet(0); // msg-type: reply cdrOut.WriteOctet(1); // msg-length cdrOut.WriteULong(28 + encodedIorLength); // request-id cdrOut.WriteULong(5); // reply-status: location fwd cdrOut.WriteULong(3); // one service context to enforce alignement requirement for giop 1.2 cdrOut.WriteULong(1); cdrOut.WriteULong(162739); // service context id cdrOut.WriteULong(2); // length of svc context cdrOut.WriteBool(true); cdrOut.WriteBool(false); // svc context end // body: 8 aligned cdrOut.ForceWriteAlign(Aligns.Align8); locFwdTarget.WriteToStream(cdrOut); sourceStream.Seek(0, SeekOrigin.Begin); return(sourceStream); }
public void TestWithSslComponent() { string iorString = "IOR:000000000000003749444C3A43682F456C63612F49696F702F5475746F7269616C2F47657474696E67537461727465642F4164646572496D706C3A312E30000000000001000000000000005C000102000000000D3139322E3136382E312E33370000000000000005616464657200000000000002000000010000001C0000000000010001000000010001002000010109000000010001010000000014000000080000006000601F97"; Ior ior = new Ior(iorString); Assert.AreEqual(1, ior.Profiles.Length, "wrong number of profiles"); Assert.AreEqual(TAG_INTERNET_IOP.ConstVal, ior.Profiles[0].ProfileId, "first profile type"); InternetIiopProfile iiopProf = (InternetIiopProfile)ior.Profiles[0]; Assert.AreEqual("192.168.1.37", iiopProf.HostName, "wrong hostname"); Assert.AreEqual(1, iiopProf.Version.Major, "wrong major"); Assert.AreEqual(2, iiopProf.Version.Minor, "wrong minor"); Assert.AreEqual(2, iiopProf.TaggedComponents.Count, "wrong number of components in profile"); Assert.NotNull(iiopProf.TaggedComponents.GetComponentData(TAG_SSL_SEC_TRANS.ConstVal, m_codec, Ch.Elca.Iiop.Security.Ssl.SSLComponentData.TypeCode), "no ssl tagged component found"); }
private static void AddProfileComponentsFromIorInterceptors(InternetIiopProfile profile) { IORInterceptor[] interceptors = OrbServices.GetSingleton().InterceptorManager.GetIorInterceptors(); if (interceptors.Length > 0) { IORInfo info = new IORInfoImpl(profile); for (int i = 0; i < interceptors.Length; i++) { try { interceptors[i].establish_components(info); } catch (ThreadAbortException) { throw; } catch (Exception e) { // ignore exceptions Trace.WriteLine("warning: ior interceptor thrown exception: " + e); } } } }
/// <summary> /// creates an IOR for an object hosted in the local appdomain. /// </summary> /// <param name="obj"></param> /// <returns></returns> internal static Ior CreateIorForObjectFromThisDomain(MarshalByRefObject obj, Type forType, bool marshalUsingForType) { Console.WriteLine("Marshalling using for type: {0}", marshalUsingForType); ObjRef objRef = marshalUsingForType ? RemotingServices.Marshal(obj, null, forType) : RemotingServices.Marshal(obj); // make sure, the object is marshalled and get obj-ref byte[] objectKey = GetObjectKeyForUri(objRef.URI); IiopChannelData serverData = GetIiopChannelData(objRef); if (serverData != null) { string host = serverData.HostName; int port = serverData.Port; if ((objectKey == null) || (host == null)) { // the objRef: " + refToTarget + ", uri: " + // refToTarget.URI + is not serialisable, because connection data is missing // hostName=host, objectKey=objectKey throw new INV_OBJREF(1961, CompletionStatus.Completed_MayBe); } string repositoryID = forType == ReflectionHelper.MarshalByRefObjectType ? "" // CORBA::Object has "" repository id : Repository.GetRepositoryID(forType); // this server support GIOP 1.2 --> create an GIOP 1.2 profile InternetIiopProfile profile = new InternetIiopProfile(new GiopVersion(1, 2), host, (ushort)port, objectKey); // add additional tagged components according to the channel options, e.g. for SSL profile.AddTaggedComponents(serverData.AdditionalTaggedComponents); // add additional tagged components according to registered interceptors: AddProfileComponentsFromIorInterceptors(profile); Ior ior = new Ior(repositoryID, new IorProfile[] { profile }); return(ior); } else { Debug.WriteLine("ERROR: no server-channel information found!"); Debug.WriteLine("Please make sure, that an IIOPChannel has been created with specifying a listen port number (0 for automatic)!"); Debug.WriteLine("e.g. IIOPChannel chan = new IIOPChannel(0);"); throw new INTERNAL(1960, CompletionStatus.Completed_MayBe); } }
public void Setup() { m_version = new GiopVersion(1, 2); m_hostName = "localhost"; m_port = 8089; m_objectKey = new byte[] { 65 }; m_profile = new InternetIiopProfile(m_version, m_hostName, m_port, m_objectKey); m_serFactory = new SerializerFactory(); CodecFactory codecFactory = new Ch.Elca.Iiop.Interception.CodecFactoryImpl(m_serFactory); m_codec = codecFactory.create_codec( new omg.org.IOP.Encoding(ENCODING_CDR_ENCAPS.ConstVal, 1, 2)); IiopUrlUtil iiopUrlUtil = IiopUrlUtil.Create(m_codec, new object[] { Services.CodeSetService.CreateDefaultCodesetComponent(m_codec) }); m_serFactory.Initalize(new SerializerFactoryConfig(), iiopUrlUtil); }
public void TestCorbaLocIiopSsl() { string testCorbaLoc = "corbaloc:iiop-ssl:elca.ch:1234/test"; Corbaloc parsed = new Corbaloc(testCorbaLoc, m_codec, new object[] { m_defaultCodeSetTaggedComponent }); Assert.AreEqual("test", parsed.KeyString); IorProfile[] profiles = parsed.GetProfiles(); Assert.AreEqual(1, profiles.Length); Assert.AreEqual(typeof(InternetIiopProfile), profiles[0].GetType()); InternetIiopProfile prof = (InternetIiopProfile)(profiles[0]); Assert.AreEqual(1, prof.Version.Major); Assert.AreEqual(0, prof.Version.Minor); Assert.AreEqual("elca.ch", prof.HostName); Assert.AreEqual(0, prof.Port); Assert.IsTrue(profiles[0].TaggedComponents.ContainsTaggedComponent( CodeSetService.SERVICE_ID)); Assert.IsTrue(profiles[0].TaggedComponents.ContainsTaggedComponent( TAG_SSL_SEC_TRANS.ConstVal)); }
public void TestSingleCompleteCorbaLocIiop() { string testCorbaLoc = "corbaloc:iiop:[email protected]:1234/test"; Corbaloc parsed = new Corbaloc(testCorbaLoc, m_codec, new object[] { m_defaultCodeSetTaggedComponent }); Assert.AreEqual("test", parsed.KeyString); Assert.AreEqual(1, parsed.GetProfiles().Length); Assert.AreEqual(typeof(InternetIiopProfile), parsed.GetProfiles()[0].GetType()); InternetIiopProfile profile = (InternetIiopProfile)parsed.GetProfiles()[0]; Assert.IsTrue(profile.TaggedComponents.ContainsTaggedComponent( CodeSetService.SERVICE_ID)); Assert.AreEqual(1, profile.Version.Major); Assert.AreEqual(2, profile.Version.Minor); Assert.AreEqual("elca.ch", profile.HostName); Assert.AreEqual(1234, profile.Port); // port > 32768 testCorbaLoc = "corbaloc:iiop:[email protected]:61234/test"; parsed = new Corbaloc(testCorbaLoc, m_codec, new object[] { m_defaultCodeSetTaggedComponent }); Assert.AreEqual("test", parsed.KeyString); Assert.AreEqual(1, parsed.GetProfiles().Length); Assert.AreEqual(typeof(InternetIiopProfile), parsed.GetProfiles()[0].GetType()); profile = (InternetIiopProfile)parsed.GetProfiles()[0]; Assert.IsTrue(profile.TaggedComponents.ContainsTaggedComponent( CodeSetService.SERVICE_ID)); Assert.AreEqual(1, profile.Version.Major); Assert.AreEqual(2, profile.Version.Minor); Assert.AreEqual("elca.ch", profile.HostName); Assert.AreEqual(61234, profile.Port); }
public IORInfoImpl(InternetIiopProfile profile) : this(new InternetIiopProfile[] { profile }) { }