如何将Java对象转换为ASN.1流?

发布于 2024-10-18 07:35:15 字数 49 浏览 2 评论 0原文

我想知道是否有一种简单的方法将 java 对象转换为 ASN.1 字节流。提前致谢。

I wonder if there is a simple way to convert a java object to a ASN.1 byte stream. Thanks in advance.

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

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

发布评论

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

评论(4

甜点 2024-10-25 07:35:15

我使用 http://bnotes.sourceforge.net/ 它对我来说效果很好。它非常简单易用,只需阅读开发指南,你就会很快理解。

I use http://bnotes.sourceforge.net/ and it is working quite good for me. It's very simple and easy to use, just read the development guide and you will understand very fast.

哭泣的笑容 2024-10-25 07:35:15

也许您首先需要了解 ASN.1 是什么,因为您说您对它很陌生。

使用 ASN.1,您可以指定可用于形成消息的类型。当它与一组定义的编码规则相结合时,您就拥有了构成消息的字节的完整规范。

数据绑定工具(例如我的公司 Objective Systems 销售的工具)可以采用 ASN.1 规范,然后生成对 ASN.1 中定义的类型进行建模的 Java 类,并且其中包括对建模数据进行编码/解码的方法。到一组定义的编码规则(BER、PER),到字节。

谈论获取任意 Java 对象并将其转换为 ASN.1 字节流实际上没有意义,因为您缺少两个关键部分:指定消息中内容的 ASN.1 以及编码规则的选择。从理论上讲,我认为有人可以提出一个标准,根据该标准将任意 Java 对象序列化为 ASN.1,但我不知道这一点,这与数据绑定工具所做的有很大不同。

我希望我说得有道理。

Perhaps you first need to get the concept of what ASN.1 is, since you say you are new to it.

With ASN.1 you specify the types that may be used to form a message. When this is combined with a defined set of encoding rules, you then have a full specification of the bytes that constitute a message.

Databinding tools (such as one my company, Objective Systems, sells) can take an ASN.1 specification and then generate Java classes that model the types defined in the ASN.1, and which include methods to encode/decode the modeled data, according to a defined set of encoding rules (BER, PER), to bytes.

It doesn't really make sense to speak of taking an arbitrary Java object and turning it into an ASN.1 byte stream because you lack two key pieces: the ASN.1 that specifies what will be in the message and the selection of encoding rules. In theory, I suppose someone could come up with a standard according to which arbitrary Java objects would be serialized to ASN.1, but I'm not aware of such, and that would be rather different from what the databinding tools do.

I hope I've made sense.

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