如何在 Java 客户端代码中解码、更改然后重新编码 CORBA IOR 文件 (Visibroker)?

发布于 2024-10-15 19:33:50 字数 286 浏览 5 评论 0原文

我正在编写代码来获取负责服务器的团队生成的 IOR 文件,并使用它将我的客户端绑定到他们的对象。听起来很容易,对吧?

由于某种超出我理解的原因(与防火墙、DMZ 等有关),IOR 文件内服务器的值不是我们可以使用的。我们必须修改它。但是,IOR 字符串是经过编码的。

Visibroker 提供了什么功能,可以让我解码 IOR 字符串、更改一个或多个值,然后重新编码并继续正常操作?

我已经研究过 IORInterceptors 和 URL Naming,但我认为它们都不起作用。

提前致谢!

I am writing code to ingest the IOR file generated by the team responsible for the server and use it to bind my client to their object. Sounds easy, right?

For some reason a bit beyond my grasp (having to do with firewalls, DMZs, etc.), the value for the server inside the IOR file is not something we can use. We have to modify it. However, the IOR string is encoded.

What does Visibroker provide that will let me decode the IOR string, change one or more values, then re-encode it and continue on as normal?

I've already looked into IORInterceptors and URL Naming but I don't think either will do the trick.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

太阳男子 2024-10-22 19:33:50

当您觉得需要破解 IOR 时,请通过编写代码或其他方式按照您的喜好来修改它,从而抵制这样做的冲动。 IOR 是由包含引用对象的服务器创建和指示的,因此当您开始在那里乱搞时,您就有点“使您的保修失效”。

相反,您应该花时间寻找正确的方法,让服务器在生成 IOR 时使用备用主机名,从而使 IOR 在您的环境中可用。大多数 ORB 都提供这样的功能。我根本不知道 Visibroker 的特定配置选项,但快速 Google 搜索显示 此页面显示出有希望的价值:

vbroker.se.iiop_ts.host    
  Specifies the host name used by this server engine. 
  The default value, null, means use the host name from the system.

希望有所帮助。

When you feel like you need to hack an IOR, resist the urge to do so by writing code and whatnot to mangle it to your liking. IORs are meant to be created and dictated by the server that contains the referenced objects, so the moment you start mucking around in there, you're kinda "voiding your warranty".

Instead, spend your time finding the right way to make the IOR usable in your environment by having the server use an alternative hostname when it generates them. Most ORBs offer such a feature. I don't know Visibroker's particular configuration options at all, but a quick Google search revealed this page that shows a promising value:

vbroker.se.iiop_ts.host    
  Specifies the host name used by this server engine. 
  The default value, null, means use the host name from the system.

Hope that helps.

孤檠 2024-10-22 19:33:50

很久以前我写过 IorParser for GNU Classpath,代码可用。我认为这是一个了解格式的正常解析器,不应该“使保修无效”。 IOR 包含多个标记的配置文件,这些配置文件的封装方式与 XML 非常相似,因此我们可以解析/修改我们需要并理解的配置文件,而其余部分保持不变。

我们需要解析的配置文件是 TAG_INTERNET_IOP 。它包含版本号、主机、端口和对象密钥。读取和写入此配置文件的代码可以在 gnu.IOR 类。很抱歉,这是系统库的一部分,不是一段很好的代码,可以在此处复制粘贴,但用几个依赖类将其删除应该不是很困难。

这个问题已被多次提出CORBA :: 使用 IIOP 获取客户端 ORB 地址和端口

Long time ago I wrote IorParser for GNU Classpath, the code is available. It is a normal parser written being aware about the format, should not "void a warranty" I think. IOR contains multiple tagged profiles that are encapsulated very much like XML so we could parse/modify profiles that we need and understand and leave the rest untouched.

The profile we need to parse is TAG_INTERNET_IOP. It contains version number, host, port and object key. Code that reads and writes this profile can be found in gnu.IOR class. I am sorry this is part of the system library and not a nice piece of code to copy paste here but it should not be very difficult to rip it out with a couple of dependent classes.

This question has been repeatedly asked as CORBA :: Get the client ORB address and port with use of IIOP

眸中客 2024-10-22 19:33:50

使用 jacORB 中的 FixIOR 工具(二进制)来修补 IOR 的地址和端口。 下载二进制文件(解压缩)并运行:

fixior <new-address> <new-port> <ior-file>

该工具将覆盖 IOR 文件的内容使用“修补”的 IOR

您可以使用 IOR 解析器 来检查结果IOR 并将其与原始 IOR 进行比较

Use the FixIOR tool (binary) from jacORB to patch the address and port of an IOR. Download the binary (unzip it) and run:

fixior <new-address> <new-port> <ior-file>

The tool will override the content of the IOR file with the 'patched' IOR

You can use IOR Parser to check the resulting IOR and compare it to your original IOR

过潦 2024-10-22 19:33:50

使用此功能可以更改 IOR。传递字符串化 IOR 作为第一个参数。

void hackIOR(const char* str, char* newIOR )
{
  size_t s = (str ? strlen(str) : 0);
  char temp[1000];
  strcpy(newIOR,"IOR:");
  const char *p = str;

  s = (s-4)/2;  // how many octets are there in the string
  p += 4;

  int i;

  for (i=0; i<(int)s; i++) {

    int j = i*2;
    char v=0;

    if (p[j] >= '0' && p[j] <= '9') {
      v = ((p[j] - '0') << 4);
    }
    else if (p[j] >= 'a' && p[j] <= 'f') {
      v = ((p[j] - 'a' + 10) << 4);
    }
    else if (p[j] >= 'A' && p[j] <= 'F') {
      v = ((p[j] - 'A' + 10) << 4);
    }
    else
      cout <<"invalid octet"<<endl;

    if (p[j+1] >= '0' && p[j+1] <= '9') {
      v += (p[j+1] - '0');
    }
    else if (p[j+1] >= 'a' && p[j+1] <= 'f') {
      v += (p[j+1] - 'a' + 10);
    }
    else if (p[j+1] >= 'A' && p[j+1] <= 'F') {
      v += (p[j+1] - 'A' + 10);
    }
    else
      cout <<"invalid octet"<<endl;
    temp[i]=v;
  }

  temp[i] = 0;

  // Now temp  has decoded IOR string. print it.
  // Replace the object ID in temp.
  // Encoded it back, with following code.

  int temp1,temp2;
  int l,k;

  for(k = 0, l = 4 ; k < s ; k++)
  {

      temp1=temp2=temp[k];

      temp1 &= 0x0F;

      temp2 = temp2 & 0xF0;

      temp2 = temp2 >> 4;

    if(temp2 >=0 && temp2 <=9)
    {
        newIOR[l++] = temp2+'0';
    }
    else if(temp2 >=10 && temp2 <=15)
    {
        newIOR[l++] = temp2+'A'-10;
    }

    if(temp1 >=0 && temp1 <=9)
    {
        newIOR[l++] = temp1+'0';
    }
    else if(temp1 >=10 && temp1 <=15)
    {
        newIOR[l++] = temp1+'A'-10;
    }
  }

  newIOR[l] = 0;

//new IOR is present in new variable newIOR.

}

希望这对你有用。

Use this function to change the IOR. pass stringified IOR as first argument.

void hackIOR(const char* str, char* newIOR )
{
  size_t s = (str ? strlen(str) : 0);
  char temp[1000];
  strcpy(newIOR,"IOR:");
  const char *p = str;

  s = (s-4)/2;  // how many octets are there in the string
  p += 4;

  int i;

  for (i=0; i<(int)s; i++) {

    int j = i*2;
    char v=0;

    if (p[j] >= '0' && p[j] <= '9') {
      v = ((p[j] - '0') << 4);
    }
    else if (p[j] >= 'a' && p[j] <= 'f') {
      v = ((p[j] - 'a' + 10) << 4);
    }
    else if (p[j] >= 'A' && p[j] <= 'F') {
      v = ((p[j] - 'A' + 10) << 4);
    }
    else
      cout <<"invalid octet"<<endl;

    if (p[j+1] >= '0' && p[j+1] <= '9') {
      v += (p[j+1] - '0');
    }
    else if (p[j+1] >= 'a' && p[j+1] <= 'f') {
      v += (p[j+1] - 'a' + 10);
    }
    else if (p[j+1] >= 'A' && p[j+1] <= 'F') {
      v += (p[j+1] - 'A' + 10);
    }
    else
      cout <<"invalid octet"<<endl;
    temp[i]=v;
  }

  temp[i] = 0;

  // Now temp  has decoded IOR string. print it.
  // Replace the object ID in temp.
  // Encoded it back, with following code.

  int temp1,temp2;
  int l,k;

  for(k = 0, l = 4 ; k < s ; k++)
  {

      temp1=temp2=temp[k];

      temp1 &= 0x0F;

      temp2 = temp2 & 0xF0;

      temp2 = temp2 >> 4;

    if(temp2 >=0 && temp2 <=9)
    {
        newIOR[l++] = temp2+'0';
    }
    else if(temp2 >=10 && temp2 <=15)
    {
        newIOR[l++] = temp2+'A'-10;
    }

    if(temp1 >=0 && temp1 <=9)
    {
        newIOR[l++] = temp1+'0';
    }
    else if(temp1 >=10 && temp1 <=15)
    {
        newIOR[l++] = temp1+'A'-10;
    }
  }

  newIOR[l] = 0;

//new IOR is present in new variable newIOR.

}

Hope this works for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文