|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.io.OutputStream
|
+--java.io.FilterOutputStream
|
+--codec.asn1.AbstractEncoder
|
+--codec.asn1.DEREncoder
If ,right after instantiating the encoder, the strict parameter is set to true, the encoder uses the strict encoding rules from X680/X690 for Sets and SetOfs. As long as the flag is not set, the encoder behaves as usual.
| Fields inherited from class java.io.FilterOutputStream |
out |
| Constructor Summary | |
DEREncoder(OutputStream out)
Creates an encoder that writes its output to the given output stream. |
|
| Method Summary | |
protected int |
getHeaderLength(int tag,
int len)
This method computes the number of octets needed to encode the identifier and length octets of the ASN.1 type with the given tag
and contents length. |
void |
help(byte[] b)
|
boolean |
isStrict()
returns the value of the strict parameter. |
void |
setStrict(boolean _strictness)
Sets the value of the strict parameter. |
protected int |
significantBits(int n)
Counts the number of significant bits in the given integer. |
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
protected void |
writeBase128(int n)
Writes the given integer to the output in base 128 representation with bit 7 of all octets except the last one being set to "1". |
protected void |
writeBase256(int n)
Writes the given integer to the output in base 256 with the minimal number of octets. |
void |
writeBitString(ASN1BitString t)
Encodes a bitstring. |
void |
writeBoolean(ASN1Boolean t)
|
void |
writeCollection(ASN1Collection t)
|
protected void |
writeHeader(ASN1Type t,
boolean primitive)
Encodes the identifier and length octets. |
protected void |
writeHeader(int tag,
int cls,
boolean prim,
int len)
This method encodes identifier and length octets. |
void |
writeInteger(ASN1Integer t)
|
void |
writeNull(ASN1Null t)
|
void |
writeObjectIdentifier(ASN1ObjectIdentifier t)
|
void |
writeOctetString(ASN1OctetString t)
|
void |
writeReal(ASN1Type t)
|
protected void |
writeStrictSetOf(ASN1SetOf t)
This method fixes the DER SET OF strict encoding issue brought up by pea-counter implementations of decoders that insist on sorting the SET OF components by encoding -- something no sane implementation requires. |
void |
writeString(ASN1String t)
|
void |
writeTaggedType(ASN1TaggedType t)
|
void |
writeTime(ASN1Time t)
|
void |
writeType(ASN1Type t)
Writes an arbitrary ASN1Type. |
void |
writeTypeIdentifier(ASN1Type t)
|
| Methods inherited from class java.io.FilterOutputStream |
close, flush, write |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public DEREncoder(OutputStream out)
out - The output stream to which the encoded ASN.1 objects are
written.| Method Detail |
public boolean isStrict()
public void setStrict(boolean _strictness)
protected void writeHeader(ASN1Type t,
boolean primitive)
throws ASN1Exception,
IOException
RunLengthEncoder on the given type in order to
establish the length of it and of any contained types. This method must
not be called with OPTIONAL types else errors may occur. It is the
responsibility of the caller to ascertain this precondition. Only the
headers of types that are tagged EXPLICIT are
encoded. If the given type is tagged IMPLICIT then this method simply
returns.t - The type of which the header is encoded.primitive - true if the encoding is PRIMITIVE and
false if it is CONSTRUCTED.
public void writeBoolean(ASN1Boolean t)
throws ASN1Exception,
IOException
public void writeInteger(ASN1Integer t)
throws ASN1Exception,
IOException
public void help(byte[] b)
public void writeBitString(ASN1BitString t)
throws ASN1Exception,
IOException
public void writeOctetString(ASN1OctetString t)
throws ASN1Exception,
IOException
public void writeNull(ASN1Null t)
throws ASN1Exception,
IOException
public void writeObjectIdentifier(ASN1ObjectIdentifier t)
throws ASN1Exception,
IOException
public void writeReal(ASN1Type t)
public void writeString(ASN1String t)
throws ASN1Exception,
IOException
public void writeCollection(ASN1Collection t)
throws ASN1Exception,
IOException
protected void writeStrictSetOf(ASN1SetOf t)
throws ASN1Exception,
IOException
public void writeTime(ASN1Time t)
throws ASN1Exception,
IOException
public void writeTaggedType(ASN1TaggedType t)
throws ASN1Exception,
IOException
public void writeTypeIdentifier(ASN1Type t)
public void write(byte[] b)
throws IOException
write in class FilterOutputStream
public void write(byte[] b,
int off,
int len)
throws IOException
write in class FilterOutputStream
public void writeType(ASN1Type t)
throws ASN1Exception,
IOException
ASN1Type. The given type is written
only if it is not declared OPTIONAL. The type is written by calling its
encode method with this as the
argument. The called emthod then should invoke the appropriate encoder
method of the primitive type to which the given type corresponds.writeType in class AbstractEncodert - The type to write.ASN1Exception - if the given type cannot be encoded.IOException - if an I/O error occurs.
protected void writeHeader(int tag,
int cls,
boolean prim,
int len)
throws IOException
0x00 0x00 after encoding
the content octets.writeHeader in class AbstractEncodertag - The ASN.1 tagcls - The ASN.1 tag class.prim - true if the encoding is PRIMITIVE and
false if it is CONSTRUCTED.len - The number of content octets or -1 to indicate INDEFINITE
LENGTH encoding.
protected int getHeaderLength(int tag,
int len)
ASN.1 type with the given tag
and contents length. The given length can be negative in which case
INDEFINITE LENGTH encoding is assumed.getHeaderLength in class AbstractEncodertag - The ASN.1 tag.len - The number of contents octets of the ASN.1 type with the
given tag and length.
protected void writeBase128(int n)
throws IOException
writeBase128 in class AbstractEncodern - The integer to be written to the output.IOException - Thrown by the underlying output stream.
protected void writeBase256(int n)
throws IOException
writeBase256 in class AbstractEncodern - The integer to be written to the output.IOException - Thrown by the underlying output stream.protected int significantBits(int n)
significantBits in class AbstractEncodern - The integer.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||