I won开发者_运维知识库der if there is a simple way to convert a java object to a ASN.1 byte stream. Thanks in advance.
There is this project, too: http://sourceforge.net/projects/jac-asn1/
and http://harmony.apache.org/subcomponents/classlibrary/asn1_framework.html
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.
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.
I see java library from at least the below
- http://www.chaosinmotion.com/asn1.m
- bouncycastle
精彩评论