private void Parse(string iiopUrl, Codec codec, IList /* TaggedComponent */ additionalComponents) { Uri uri = new Uri(iiopUrl); if (IiopLocIiopAddr.IsResponsibleForProtocol(uri.Scheme)) { m_objAddr = new IiopLocIiopAddr(uri.Scheme, uri.Host, uri.Port); } else if (IiopLocIiopSslAddr.IsResponsibleForProtocol(uri.Scheme)) { m_objAddr = new IiopLocIiopSslAddr(uri.Scheme, uri.Host, uri.Port); } else { throw new INTERNAL(145, CompletionStatus.Completed_MayBe); } try { m_objectUri = uri.PathAndQuery; if ((m_objectUri != null) && (m_objectUri.StartsWith("/"))) { m_objectUri = m_objectUri.Substring(1); int startIndex = 0; string escaped = IorUtil.EscapeNonAscii(m_objectUri, ref startIndex); m_keyBytes = IorUtil.GetKeyBytesForId(escaped, startIndex); } } catch (Exception) { throw new INV_OBJREF(146, CompletionStatus.Completed_MayBe); } m_profiles = new IorProfile[] { GetProfileFor(m_objAddr, GetKeyAsByteArray(), codec, additionalComponents) }; }
/// <summary>takes a proxy and returns the IOR / corbaloc / ...</summary> public string object_to_string(object obj) { MarshalByRefObject mbr = obj as MarshalByRefObject; if (mbr == null) { throw new BAD_PARAM(265, CompletionStatus.Completed_Yes); } if (RemotingServices.IsTransparentProxy(mbr)) { string uri = RemotingServices.GetObjectUri(mbr); CheckIsValidUri(uri); if (IiopUrlUtil.IsIorString(uri)) { return(uri); } else { // create an IOR assuming type is CORBA::Object return(IiopUrlUtil.CreateIorForUrl(uri, String.Empty).ToString()); } } else { // local object return(IorUtil.CreateIorForObjectFromThisDomain(mbr).ToString()); } }
/// <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 void CalculateKeyBytesFromKeyString() { string id = KeyString; // TODO: not really correct: need to resolve %HexHex escape sequences m_keyBytes = IorUtil.GetKeyBytesForId(id); }
public void EscapeNonAsciiTest() { int startIndex = 0; string result = IorUtil.EscapeNonAscii("foo", ref startIndex); Assert.AreEqual(0, startIndex); Assert.AreEqual("foo", result); Assert.AreEqual(@"fran\u00E7ois", IorUtil.EscapeNonAscii("françois", ref startIndex)); Assert.AreEqual("françois", IorUtil.UnescapeNonAscii(@"fran\u00E7ois")); Assert.AreEqual(@"fran\u00E7\\u00B9ois", IorUtil.EscapeNonAscii(@"franç\u00B9ois", ref startIndex)); Assert.AreEqual(@"franç\u00B9ois", IorUtil.UnescapeNonAscii(@"fran\u00E7\\u00B9ois")); }
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); }