Пример #1
0
        /// <summary><see cref="Ch.Elca.Iiop.IClientTransportFactory.CreateTransport(IIorProfile)"/></summary>
        public IClientTransport CreateTransport(IIorProfile profile)
        {
            if (profile.ProfileId != TAG_INTERNET_IOP.ConstVal)
            {
                throw new INTERNAL(734, CompletionStatus.Completed_No);
            }
            object sslComponentDataObject = GetSSLComponent(profile, m_codec);

            if (sslComponentDataObject == null)
            {
                throw new INTERNAL(734, CompletionStatus.Completed_No);
            }
            SSLComponentData     sslComponent  = (SSLComponentData)sslComponentDataObject;
            IInternetIiopProfile targetProfile = (IInternetIiopProfile)profile;
            int              port    = sslComponent.GetPort();
            SecurityOptions  options = CreateClientSecurityOptions(sslComponent);
            IPAddress        asIpAddress;
            IClientTransport result =
                IPAddress.TryParse(targetProfile.HostName, out asIpAddress)
                    ? new SslClientTransport(asIpAddress, port, options)
                    : new SslClientTransport(targetProfile.HostName, port, options);

            result.ReceiveTimeOut = m_receiveTimeOut;
            result.SendTimeOut    = m_sendTimeOut;
            return(result);
        }
Пример #2
0
 /// <summary>
 /// <see cref="Ch.Elca.Iiop.IClientTransportFactory.CanUseProfile"/>
 /// </summary>
 public bool CanUseProfile(IIorProfile profile)
 {
     if (profile.ProfileId == TAG_INTERNET_IOP.ConstVal)
     {
         IInternetIiopProfile iiopProf = (IInternetIiopProfile)profile;
         if ((iiopProf.HostName != null) && (iiopProf.Port > 0))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #3
0
        public void TestIorCreation()
        {
            string iorString = "IOR:0000000000000024524d493a48656c6c6f496e746572666163653a3030303030303030303030303030303000000000010000000000000050000102000000000c31302e34302e32302e3531001f9500000000000853617948656C6C6F0000000100000001000000200000000000010001000000020501000100010020000101090000000100010100";
            Ior    ior       = new Ior(iorString);

            Assert.IsTrue(ior.Profiles.Length > 0, "nr of profiles");
            Assert.AreEqual(TAG_INTERNET_IOP.ConstVal, ior.Profiles[0].ProfileId, "first profile type");
            IInternetIiopProfile iiopProf = (IInternetIiopProfile)ior.Profiles[0];

            Assert.AreEqual("10.40.20.51", iiopProf.HostName);
            Assert.AreEqual(8085, iiopProf.Port);
            Assert.AreEqual(1, iiopProf.Version.Major);
            Assert.AreEqual(2, iiopProf.Version.Minor);
            byte[] oid = new byte[] { 0x53, 0x61, 0x79, 0x48, 0x65, 0x6C, 0x6C, 0x6F };
            CheckIorKey(oid, iiopProf.ObjectKey);


            iorString = "IOR:0000000000000024524d493a48656c6c6f496e746572666163653a3030303030303030303030303030303000000000010000000000000050000102000000000c31302e34302e32302e3531007f9500000000000853617948656C6C6F0000000100000001000000200000000000010001000000020501000100010020000101090000000100010100";
            ior       = new Ior(iorString);
            Assert.IsTrue(ior.Profiles.Length > 0, "nr of profiles");
            Assert.AreEqual(TAG_INTERNET_IOP.ConstVal, ior.Profiles[0].ProfileId, "first profile type");
            iiopProf = (IInternetIiopProfile)ior.Profiles[0];
            Assert.AreEqual("10.40.20.51", iiopProf.HostName);
            Assert.AreEqual(32661, iiopProf.Port);
            Assert.AreEqual(1, iiopProf.Version.Major);
            Assert.AreEqual(2, iiopProf.Version.Minor);
            oid = new byte[] { 0x53, 0x61, 0x79, 0x48, 0x65, 0x6C, 0x6C, 0x6F };
            CheckIorKey(oid, iiopProf.ObjectKey);

            iorString = "IOR:0000000000000024524d493a48656c6c6f496e746572666163653a3030303030303030303030303030303000000000010000000000000050000102000000000c31302e34302e32302e3531008f9500000000000853617948656C6C6F0000000100000001000000200000000000010001000000020501000100010020000101090000000100010100";
            ior       = new Ior(iorString);
            Assert.IsTrue(ior.Profiles.Length > 0, "nr of profiles");
            Assert.AreEqual(TAG_INTERNET_IOP.ConstVal, ior.Profiles[0].ProfileId, "first profile type");
            iiopProf = (IInternetIiopProfile)ior.Profiles[0];
            Assert.AreEqual("10.40.20.51", iiopProf.HostName);
            Assert.AreEqual(36757, iiopProf.Port);
            Assert.AreEqual(1, iiopProf.Version.Major);
            Assert.AreEqual(2, iiopProf.Version.Minor);
            oid = new byte[] { 0x53, 0x61, 0x79, 0x48, 0x65, 0x6C, 0x6C, 0x6F };
            CheckIorKey(oid, iiopProf.ObjectKey);

            iorString = "IOR:0000000000000024524d493a48656c6c6f496e746572666163653a3030303030303030303030303030303000000000010000000000000050000102000000000c31302e34302e32302e353100ffff00000000000853617948656C6C6F0000000100000001000000200000000000010001000000020501000100010020000101090000000100010100";
            ior       = new Ior(iorString);
            Assert.IsTrue(ior.Profiles.Length > 0, "nr of profiles");
            Assert.AreEqual(TAG_INTERNET_IOP.ConstVal, ior.Profiles[0].ProfileId, "first profile type");
            iiopProf = (IInternetIiopProfile)ior.Profiles[0];
            Assert.AreEqual("10.40.20.51", iiopProf.HostName);
            Assert.AreEqual(65535, iiopProf.Port);
            Assert.AreEqual(1, iiopProf.Version.Major);
            Assert.AreEqual(2, iiopProf.Version.Minor);
            oid = new byte[] { 0x53, 0x61, 0x79, 0x48, 0x65, 0x6C, 0x6C, 0x6F };
            CheckIorKey(oid, iiopProf.ObjectKey);
        }
Пример #4
0
 /// <summary>
 /// <see cref="Ch.Elca.Iiop.IClientTransportFactory.CanUseProfile"/>
 /// </summary>
 public bool CanUseProfile(IIorProfile profile)
 {
     if (profile.ProfileId == TAG_INTERNET_IOP.ConstVal)
     {
         IInternetIiopProfile iiopProf = (IInternetIiopProfile)profile;
         return((iiopProf.HostName != null) && HasSSLComponent(profile));
     }
     else
     {
         return(false);
     }
 }
Пример #5
0
 /// <summary><see cref="Ch.Elca.Iiop.IClientTransportFactory.GetEndpointKey(Ior)"/></summary>
 public string GetEndpointKey(IIorProfile target)
 {
     if (target.ProfileId == TAG_INTERNET_IOP.ConstVal)
     {
         IInternetIiopProfile prof = (IInternetIiopProfile)target;
         return("iiop" + prof.Version.Major + "." +
                prof.Version.Minor + "://" + prof.HostName + ":" + prof.Port);
     }
     else
     {
         return(String.Empty);
     }
 }
Пример #6
0
 /// <summary><see cref="Ch.Elca.Iiop.IClientTransportFactory.GetEndpointKey(IIorProfile)"/></summary>
 public string GetEndpointKey(IIorProfile target)
 {
     if (target.ProfileId == TAG_INTERNET_IOP.ConstVal)
     {
         object sslComponent       = GetSSLComponent(target, m_codec);
         IInternetIiopProfile prof = (IInternetIiopProfile)target;
         return("iiop-ssl" + prof.Version.Major + "." +
                prof.Version.Minor + "://" + prof.HostName + ":" + ((SSLComponentData)sslComponent).Port);
     }
     else
     {
         return(String.Empty);
     }
 }
Пример #7
0
        public void TestNonUsableProfileIncluded()
        {
            string iorString = "IOR:000000000000001b49444c3a636d6956322f5573657241636365737356323a312e3000020000000210ca1000000000650000000800000008646576312d73660033de6f8e0000004d000000020000000855736572504f41000000001043415355736572416363657373563200c3fbedfb0000000e007c4c51000000fd57aacdaf801a0000000e007c4c51000000fd57aacdaf80120000009400000000000000980001023100000008646576312d736600200b00020000004d000000020000000855736572504f41000000001043415355736572416363657373563200c3fbedfb0000000e007c4c51000000fd57aacdaf801a0000000e007c4c51000000fd57aacdaf8012000000140000000200000002000000140000000400000001000000230000000400000001000000000000000800000000cb0e0001";
            Ior    ior       = new Ior(iorString);

            Assert.AreEqual("IDL:cmiV2/UserAccessV2:1.0", ior.TypID, "wrong RepositoryId");
            IInternetIiopProfile iiopProf = ior.FindInternetIiopProfile();

            Assert.NotNull(iiopProf, "iiop ior profile not found");
            Assert.AreEqual("dev1-sf", iiopProf.HostName, "wrong hostname");
            Assert.AreEqual(8203, iiopProf.Port, "wrong port");
            Assert.AreEqual(1, iiopProf.Version.Major, "wrong major");
            Assert.AreEqual(2, iiopProf.Version.Minor, "wrong minor");
            Assert.AreEqual(2, ior.Profiles.Length, "wrong number of profiles");
        }
Пример #8
0
        /// <summary>
        /// This method parses an url for the IIOP channel.
        /// It extracts the channel URI and the objectURI
        /// </summary>
        /// <param name="url">the url to parse</param>
        /// <param name="objectURI">the objectURI</param>
        /// <returns>the channel-Uri</returns>
        internal Uri ParseUrl(string url, out string objectUri,
                              out GiopVersion version)
        {
            Uri uri = null;

            if (url.StartsWith("iiop"))
            {
                IiopLoc iiopLoc = new IiopLoc(url, m_codec,
                                              m_defaultAdditionalTaggedComponents);
                uri = iiopLoc.ParseUrl(out objectUri, out version);
            }
            else if (url.StartsWith("IOR"))
            {
                Ior ior = new Ior(url);
                IInternetIiopProfile profile = ior.FindInternetIiopProfile();
                if (profile != null)
                {
                    uri = new Uri("iiop" + profile.Version.Major + "." + profile.Version.Minor +
                                  Uri.SchemeDelimiter + profile.HostName + ":" + profile.Port);
                    objectUri = IorUtil.GetObjectUriForObjectKey(profile.ObjectKey);
                    version   = profile.Version;
                }
                else
                {
                    uri       = null;
                    objectUri = null;
                    version   = new GiopVersion(1, 0);
                }
            }
            else if (url.StartsWith("corbaloc"))
            {
                Corbaloc loc = new Corbaloc(url, m_codec,
                                            m_defaultAdditionalTaggedComponents);
                uri = loc.ParseUrl(out objectUri, out version);
            }
            else
            {
                // not possible
                uri       = null;
                objectUri = null;
                version   = new GiopVersion(1, 0);
            }
            return(uri);
        }
Пример #9
0
 /// <summary><see cref="Ch.Elca.Iiop.IClientTransportFactory.CreateTransport(IIorProfile)"/></summary>
 public IClientTransport CreateTransport(IIorProfile targetProfile)
 {
     if (targetProfile.ProfileId == TAG_INTERNET_IOP.ConstVal)
     {
         IInternetIiopProfile iiopProf    = (IInternetIiopProfile)targetProfile;
         IPAddress            asIpAddress = ConvertToIpAddress(iiopProf.HostName);
         IClientTransport     result;
         if (asIpAddress == null)
         {
             ArrayList hostNames = new ArrayList();
             ArrayList ports     = new ArrayList();
             hostNames.Add(iiopProf.HostName);
             ports.Add(iiopProf.Port);
             foreach (TaggedComponent taggedComponent in
                      iiopProf.TaggedComponents.GetComponents(ALTERNATE_IIOP_ADDRESS.ConstVal))
             {
                 string hostName = System.Text.ASCIIEncoding.ASCII.GetString(
                     taggedComponent.component_data,
                     8,
                     BitConverter.ToInt32(taggedComponent.component_data, 4) - 1);
                 ushort port = BitConverter.ToUInt16(taggedComponent.component_data,
                                                     taggedComponent.component_data.Length - 2);
                 hostNames.Add(hostName);
                 ports.Add(port);
                 Debug.WriteLine(string.Format("CreateTransport(): host {0}:{1} from IOR added to list", hostName, port));
             }
             result = new TcpClientTransport((string[])hostNames.ToArray(ReflectionHelper.StringType),
                                             (int[])ports.ToArray(ReflectionHelper.Int32Type));
         }
         else
         {
             result = new TcpClientTransport(asIpAddress, iiopProf.Port);
         }
         result.ReceiveTimeOut = m_receiveTimeOut;
         result.SendTimeOut    = m_sendTimeOut;
         return(result);
     }
     else
     {
         throw new INTERNAL(3001, CompletionStatus.Completed_No);
     }
 }