|
XCMS Toolkit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectschemajic.codec.Encoder
schemajic.codec.ASN1Encoder
schemajic.encoder.DEREncoder
public class DEREncoder
Encoder for Distinguished Encoding Rules (DER) of ASN.1.
Tag-Length_Value (TLV) encoding is as follows:
[T][L][V:[T][L][V:[T][L][V]]]
1 2 3
L1 is the total of the encoded lengths
of T2 + L2 + T3 + L3 + V3.
In order to produce an encoding of this nature, the decoded value's
structure must be recursively processed, encoding the tags, calculating
the lengths, encoding the lengths, and building a list of encoded TLVs.
When processing of the decoded structure has been completed, the encoding-list is then processed, writing the encoded TLVs to an output stream.
Encoding an ASN.1 SEQUENCE:
Create a list to hold our EncodableEntry objects.
Create a CompositValue 's' for this sequence and append
it to the encodable-list.
For each field in the sequence:
If the field is primitive:
Construct an AtomicValue f for the field and
append it to the encodable-list.
Encode the value into a byte[].
Set f.value to byte[].
Add f.getTotalLength() to s.
If the field is a sequence :
recurse.
Processing a list of Encodable objects:
Encode the first taglist to the stream
Encode the length of the following data, including
the length of the encoded tag(s) to the stream
if the next encodable is atomic :
encode the next encodable to the stream
if the next encodable is composite :
encodeComposite()
| Field Summary | |
|---|---|
protected GeneralizedTimeFormat |
_gtFormat
|
| Constructor Summary | |
|---|---|
DEREncoder()
|
|
| Method Summary | |
|---|---|
void |
encode(ASN1Value value,
java.io.OutputStream out)
Encode a value according to the Distinguished Encoding Rules to an OutputStream. |
void |
encodeBitString(byte[] value,
int sigBits,
java.io.OutputStream out)
|
void |
encodeBoolean(boolean value,
java.io.OutputStream out)
|
void |
encodeEnumerated(int value,
java.io.OutputStream out)
|
void |
encodeInteger(int value,
java.io.OutputStream out)
|
void |
encodeObjectIdentifier(int[] value,
java.io.OutputStream out)
|
void |
encodeOctetString(byte[] value,
java.io.OutputStream out)
|
void |
encodeRelativeObjectIdentifier(int[] value,
java.io.OutputStream out)
|
java.lang.Object |
visit(ASN1BitString value,
java.lang.Object object)
From X.690 8.6 Encoding of a bitstring value 8.6.1 The encoding of a bitstring value shall be either primitive or constructed at the option of the sender. |
java.lang.Object |
visit(ASN1BMPString value,
java.lang.Object object)
An ASN.1 type BMPString visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1Boolean value,
java.lang.Object object)
All bits in the single octet shall be set to 1 X680 - 11.1 ( DER ) |
java.lang.Object |
visit(ASN1Choice value,
java.lang.Object object)
If the Tag of a Choice is EXPLICIT, the tag for the Choice itself must be encoded. |
java.lang.Object |
visit(ASN1Enumerated value,
java.lang.Object object)
Encode an Enumerated. |
java.lang.Object |
visit(ASN1GeneralizedTime value,
java.lang.Object object)
GeneralizedTime is encoded as a VisibleString. |
java.lang.Object |
visit(ASN1GeneralString value,
java.lang.Object object)
An ASN.1 type GeneralString visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1IA5String value,
java.lang.Object object)
An ASN.1 type IA5String visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1Integer value,
java.lang.Object object)
Encode an Integer. |
java.lang.Object |
visit(ASN1ISO646String value,
java.lang.Object object)
An ASN.1 type ISO646String visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1Null value,
java.lang.Object object)
An ASN.1 type NULL visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1NumericString value,
java.lang.Object object)
An ASN.1 type NumericString visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1ObjectIdentifier value,
java.lang.Object object)
Encode an ObjectIdentifier. |
java.lang.Object |
visit(ASN1OctetString value,
java.lang.Object object)
Encode an OctetString. |
java.lang.Object |
visit(ASN1OpenType value,
java.lang.Object object)
If the OpenType contains a decoded ASN.1 value, then encode the contained value, otherwise assume that the user has provided a correctly encoded value and copy that value into the output stream. |
java.lang.Object |
visit(ASN1PrintableString value,
java.lang.Object object)
An ASN.1 type PrintableString visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1RelativeOID value,
java.lang.Object object)
Encode each subidentifier as 7-bits. |
java.lang.Object |
visit(ASN1Sequence value,
java.lang.Object object)
Encode each field of the Sequence. |
java.lang.Object |
visit(ASN1SequenceOf value,
java.lang.Object object)
An ASN.1 SEQUENCE OF type visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1SetOf value,
java.lang.Object object)
An ASN.1 SET OF type visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1T61String value,
java.lang.Object object)
An ASN.1 type T61String visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1TeletexString value,
java.lang.Object object)
An ASN.1 type TeletexString visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1UniversalString value,
java.lang.Object object)
An ASN.1 type UniversalString visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1UTF8String value,
java.lang.Object object)
An ASN.1 type UTF8String visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1VideotexString value,
java.lang.Object object)
An ASN.1 type VideotexString visit method with value and
object parameters. |
java.lang.Object |
visit(ASN1VisibleString value,
java.lang.Object object)
An ASN.1 type VisibleString visit method with value and
object parameters. |
java.lang.Object |
visit(XEROctetString value,
java.lang.Object object)
TODO: description goes here |
| Methods inherited from class schemajic.codec.ASN1Encoder |
|---|
getCurrentTags, getOutputStream, setCurrentTags, setOutputStream |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected GeneralizedTimeFormat _gtFormat
| Constructor Detail |
|---|
public DEREncoder()
| Method Detail |
|---|
public void encode(ASN1Value value,
java.io.OutputStream out)
throws EncodingException
encode in class Encodervalue - the value of an ASN.1 type to be encodedout - target of an encoding transform
EncodingException
public java.lang.Object visit(ASN1BitString value,
java.lang.Object object)
throws VisitorException
visit in interface ValueVisitorvalue - a value of ASN.1 type BIT STRING in its encoded formobject - visit an object of ASN.1 type BIT STRING
VisitorException
public java.lang.Object visit(ASN1Boolean value,
java.lang.Object object)
throws VisitorException
visit in interface ValueVisitorvalue - a value of an ASN.1 type BOOLEAN in its encoded formobject - visit an object of ASN.1 type BOOLEAN
VisitorException
public java.lang.Object visit(ASN1Choice value,
java.lang.Object object)
throws VisitorException
visit in interface ValueVisitorvalue - a value of some ASN.1 CHOICE type in its encoded formobject - visit an object of the ASN.1 CHOICE type
VisitorException
public java.lang.Object visit(ASN1Enumerated value,
java.lang.Object object)
throws VisitorException
visit in interface ValueVisitorvalue - a value of ASN.1 type ENUMERATED in its encoded formobject - visit an object of ASN.1 type ENUMERATED
VisitorException
public java.lang.Object visit(ASN1GeneralizedTime value,
java.lang.Object object)
throws VisitorException
visit in interface ValueVisitorvalue - a value of ASN.1 type GeneralizedTime in its encoded formobject - visit an object of ASN.1 type GeneralizedTime
VisitorException
public java.lang.Object visit(ASN1Integer value,
java.lang.Object object)
throws VisitorException
visit in interface ValueVisitorvalue - a value of ASN.1 type INTEGER in its encoded formobject - visit an object of ASN.1 type INTEGER
VisitorException
public java.lang.Object visit(ASN1Null value,
java.lang.Object object)
throws VisitorException
ValueVisitorNULL visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type NULL in its encoded formobject - visit an object of ASN.1 type NULL
VisitorException
public java.lang.Object visit(ASN1ObjectIdentifier value,
java.lang.Object object)
throws VisitorException
visit in interface ValueVisitorvalue - a value of ASN.1 type OBJECT IDENTIFIER in its encoded formobject - visit an object of ASN.1 type OBJECT IDENTIFIER
VisitorException
public java.lang.Object visit(ASN1OctetString value,
java.lang.Object object)
throws VisitorException
visit in interface ValueVisitorvalue - a value of ASN.1 type OCTET STRING in its encoded formobject - visit an object of ASN.1 type OCTET STRING
VisitorException
public java.lang.Object visit(XEROctetString value,
java.lang.Object object)
throws VisitorException
visit in interface ValueVisitorvalue - a value of ASN.1 type OCTET STRING in its XER encoded formobject - visit an object of ASN.1 type OCTET STRING
VisitorException
public java.lang.Object visit(ASN1RelativeOID value,
java.lang.Object object)
throws VisitorException
visit in interface ValueVisitorvalue - a value of ASN.1 type RELATIVE_OID in its encoded formobject - visit an object of ASN.1 type RELATIVE_OID
VisitorException
public java.lang.Object visit(ASN1Sequence value,
java.lang.Object object)
throws VisitorException
visit in interface ValueVisitorvalue - a value of ASN.1 type SEQUENCE in its encoded formobject - visit an object of ASN.1 type SEQUENCE
VisitorException
public java.lang.Object visit(ASN1SequenceOf value,
java.lang.Object object)
throws VisitorException
ValueVisitorSEQUENCE OF type visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type SEQUENCE OF in its encoded formobject - visit an object of ASN.1 type SEQUENCE OF
VisitorException
public java.lang.Object visit(ASN1SetOf value,
java.lang.Object object)
throws VisitorException
ValueVisitorSET OF type visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type SET OF in its encoded formobject - visit an object of ASN.1 type SET OF
VisitorException
public java.lang.Object visit(ASN1OpenType value,
java.lang.Object object)
throws VisitorException
visit in interface ValueVisitorvalue - a value of an ASN.1 type in its encoded form (an open type)object - visit an object of the ASN.1 open type
VisitorException
public void encodeBoolean(boolean value,
java.io.OutputStream out)
throws EncodingException
EncodingException
public void encodeBitString(byte[] value,
int sigBits,
java.io.OutputStream out)
throws EncodingException
EncodingException
public void encodeEnumerated(int value,
java.io.OutputStream out)
throws EncodingException
EncodingException
public void encodeInteger(int value,
java.io.OutputStream out)
throws EncodingException
EncodingException
public void encodeObjectIdentifier(int[] value,
java.io.OutputStream out)
throws EncodingException
EncodingException
public void encodeOctetString(byte[] value,
java.io.OutputStream out)
throws EncodingException
EncodingException
public void encodeRelativeObjectIdentifier(int[] value,
java.io.OutputStream out)
throws EncodingException
EncodingException
public java.lang.Object visit(ASN1VisibleString value,
java.lang.Object object)
throws VisitorException
ValueVisitorVisibleString visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type VisibleString in its encoded formobject - visit an object of ASN.1 type VisibleString
VisitorException
public java.lang.Object visit(ASN1BMPString value,
java.lang.Object object)
throws VisitorException
ValueVisitorBMPString visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type BMPString in its encoded formobject - visit an object of ASN.1 type BMPString
VisitorException
public java.lang.Object visit(ASN1GeneralString value,
java.lang.Object object)
throws VisitorException
ValueVisitorGeneralString visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type GeneralString in its encoded formobject - visit an object of ASN.1 type GeneralString
VisitorException
public java.lang.Object visit(ASN1IA5String value,
java.lang.Object object)
throws VisitorException
ValueVisitorIA5String visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type IA5String in its encoded formobject - visit an object of ASN.1 type IA5String
VisitorException
public java.lang.Object visit(ASN1ISO646String value,
java.lang.Object object)
throws VisitorException
ValueVisitorISO646String visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type ISO646String in its encoded formobject - visit an object of ASN.1 type ISO646String
VisitorException
public java.lang.Object visit(ASN1NumericString value,
java.lang.Object object)
throws VisitorException
ValueVisitorNumericString visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type NumericString in its encoded formobject - visit an object of ASN.1 type NumericString
VisitorException
public java.lang.Object visit(ASN1PrintableString value,
java.lang.Object object)
throws VisitorException
ValueVisitorPrintableString visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type PrintableString in its encoded formobject - visit an object of ASN.1 type PrintableString
VisitorException
public java.lang.Object visit(ASN1T61String value,
java.lang.Object object)
throws VisitorException
ValueVisitorT61String visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type T61String in its encoded formobject - visit an object of ASN.1 type T61String
VisitorException
public java.lang.Object visit(ASN1TeletexString value,
java.lang.Object object)
throws VisitorException
ValueVisitorTeletexString visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type TeletexString in its encoded formobject - visit an object of ASN.1 type TeletexString
VisitorException
public java.lang.Object visit(ASN1UniversalString value,
java.lang.Object object)
throws VisitorException
ValueVisitorUniversalString visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type UniversalString in its encoded formobject - visit an object of ASN.1 type UniversalString
VisitorException
public java.lang.Object visit(ASN1UTF8String value,
java.lang.Object object)
throws VisitorException
ValueVisitorUTF8String visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type UTF8String in its encoded formobject - visit an object of ASN.1 type UTF8String
VisitorException
public java.lang.Object visit(ASN1VideotexString value,
java.lang.Object object)
throws VisitorException
ValueVisitorVideotexString visit method with value and
object parameters.
visit in interface ValueVisitorvalue - a value of ASN.1 type VideotexString in its encoded formobject - visit an object of ASN.1 type VideotexString
VisitorException
|
XCMS Toolkit | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||