public final class DerOutputStream extends java.io.ByteArrayOutputStream implements DerEncoder
At this time, this class supports only a subset of the types of DER data encodings which are defined. That subset is sufficient for generating most X.509 certificates.
| Constructor and Description |
|---|
DerOutputStream()
Construct a DER output stream.
|
DerOutputStream(int size)
Construct a DER output stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
encode(DerOutputStream out)
Write the current contents of this
DerOutputStream
to an OutputStream. |
DerOutputStream |
putBitString(byte[] bits)
Marshals a DER bit string on the output stream.
|
DerOutputStream |
putBMPString(java.lang.String s)
Marshals a string as a DER encoded BMPString.
|
DerOutputStream |
putBoolean(boolean val)
Marshals a DER boolean on the output stream.
|
DerOutputStream |
putDerValue(DerValue val)
Marshals pre-encoded DER value onto the output stream.
|
DerOutputStream |
putEnumerated(int i)
Marshals a DER enumerated on the output stream.
|
DerOutputStream |
putGeneralizedTime(java.util.Date d)
Marshals a DER Generalized Time/date value.
|
DerOutputStream |
putGeneralString(java.lang.String s)
Marshals a string as a DER encoded GeneralString.
|
DerOutputStream |
putIA5String(java.lang.String s)
Marshals a string as a DER encoded IA5String.
|
DerOutputStream |
putInteger(java.math.BigInteger i)
Marshals a DER integer on the output stream.
|
DerOutputStream |
putInteger(byte[] buf)
Marshals a DER integer on the output stream.
|
DerOutputStream |
putInteger(int i)
Marshals a DER integer on the output stream.
|
DerOutputStream |
putInteger(java.lang.Integer i)
Marshals a DER integer on the output stream.
|
void |
putLength(int len)
Put the encoding of the length in the stream.
|
DerOutputStream |
putNull()
Marshals a DER "null" value on the output stream.
|
DerOutputStream |
putOctetString(byte[] octets)
DER-encodes an ASN.1 OCTET STRING value on the output stream.
|
DerOutputStream |
putOID(ObjectIdentifier oid)
Marshals an object identifier (OID) on the output stream.
|
DerOutputStream |
putOrderedSet(byte tag,
DerEncoder[] set)
Marshals the contents of a set on the output stream.
|
DerOutputStream |
putOrderedSetOf(byte tag,
DerEncoder[] set)
Marshals the contents of a set on the output stream.
|
DerOutputStream |
putPrintableString(java.lang.String s)
Marshals a string as a DER encoded PrintableString.
|
DerOutputStream |
putSequence(DerValue[] seq)
Marshals a sequence on the output stream.
|
DerOutputStream |
putSet(DerValue[] set)
Marshals the contents of a set on the output stream without
ordering the elements.
|
DerOutputStream |
putT61String(java.lang.String s)
Marshals a string as a DER encoded T61String.
|
DerOutputStream |
putTruncatedUnalignedBitString(BitArray ba)
Marshals a truncated DER bit string on the output stream.
|
DerOutputStream |
putUnalignedBitString(BitArray ba)
Marshals a DER bit string on the output stream.
|
DerOutputStream |
putUTCTime(java.util.Date d)
Marshals a DER UTC time/date value.
|
DerOutputStream |
putUTF8String(java.lang.String s)
Marshals a string as a DER encoded UTF8String.
|
DerOutputStream |
write(byte tag,
byte[] buf)
Writes tagged, pre-marshaled data.
|
DerOutputStream |
write(byte tag,
DerOutputStream out)
Writes tagged data using buffer-to-buffer copy.
|
DerOutputStream |
write(DerEncoder encoder)
Write a DerEncoder onto the output stream.
|
DerOutputStream |
writeImplicit(byte tag,
DerOutputStream value)
Writes implicitly tagged data using buffer-to-buffer copy.
|
public DerOutputStream(int size)
size - how large a buffer to preallocate.public DerOutputStream()
public DerOutputStream write(byte tag, byte[] buf)
tag - the DER value tag for the data, such as
DerValue.tag_Sequencebuf - buffered data, which must be DER-encodedpublic DerOutputStream write(byte tag, DerOutputStream out)
tag - the DER value tag for the data, such as
DerValue.tag_Sequenceout - buffered datapublic DerOutputStream writeImplicit(byte tag, DerOutputStream value)
tag - the DER value of the context-specific tag that replaces
original tag of the value in the output, such as in
<field> [N] IMPLICIT <type>
For example, FooLength [1] IMPLICIT INTEGER, with value=4;
would be encoded as "81 01 04" whereas in explicit
tagging it would be encoded as "A1 03 02 01 04".
Notice that the tag is A1 and not 81, this is because with
explicit tagging the form is always constructed.value - original value being implicitly taggedpublic DerOutputStream putDerValue(DerValue val)
public DerOutputStream putBoolean(boolean val)
public DerOutputStream putEnumerated(int i)
i - the enumerated value.public DerOutputStream putInteger(java.math.BigInteger i)
i - the integer in the form of a BigInteger.public DerOutputStream putInteger(byte[] buf)
buf - the integer in bytes, equivalent to BigInteger::toByteArray.public DerOutputStream putInteger(java.lang.Integer i)
i - the integer in the form of an Integer.public DerOutputStream putInteger(int i)
i - the integer.public DerOutputStream putBitString(byte[] bits)
bits - the bit string, MSB firstpublic DerOutputStream putUnalignedBitString(BitArray ba)
ba - the bit string, MSB firstpublic DerOutputStream putTruncatedUnalignedBitString(BitArray ba)
ba - the bit string, MSB firstpublic DerOutputStream putOctetString(byte[] octets)
octets - the octet stringpublic DerOutputStream putNull()
public DerOutputStream putOID(ObjectIdentifier oid)
public DerOutputStream putSequence(DerValue[] seq)
public DerOutputStream putSet(DerValue[] set)
public DerOutputStream putOrderedSetOf(byte tag, DerEncoder[] set)
public DerOutputStream putOrderedSet(byte tag, DerEncoder[] set)
public DerOutputStream putUTF8String(java.lang.String s)
public DerOutputStream putPrintableString(java.lang.String s)
public DerOutputStream putT61String(java.lang.String s)
public DerOutputStream putIA5String(java.lang.String s)
public DerOutputStream putBMPString(java.lang.String s)
public DerOutputStream putGeneralString(java.lang.String s)
public DerOutputStream putUTCTime(java.util.Date d)
YYMMDDhhmmss{Z|+hhmm|-hhmm} ... emits only using Zulu time and with seconds (even if seconds=0) as per RFC 5280.
public DerOutputStream putGeneralizedTime(java.util.Date d)
YYYYMMDDhhmmss{Z|+hhmm|-hhmm} ... emits only using Zulu time and with seconds (even if seconds=0) as per RFC 5280.
public void putLength(int len)
len - the length of the attribute.public void encode(DerOutputStream out)
DerOutputStream
to an OutputStream.encode in interface DerEncoderout - the stream on which the DER encoding is written.public DerOutputStream write(DerEncoder encoder)
encoder - the DerEncoder