public class SET extends ConstructedType
A SET object is DER encoded using the constructed encoding practice
by splitting it into separately encoded components. Therefore the SEQUENCE
class is extended to be a subclass of the ConstructedType
class. Each component can be added to the current SET object
by using a proper addComponent
method of the ConstructedType
super class.
The constructed form can be recognized by bit 6 of the (first) identifier octet(s) of the DER encoded bit stream, which is set to 1.
The following example creates a new SET object and adds an INTERGER, BOOLEAN, and a PrintableString component:
SET set = new SET(); set.addComponent(new INTEGER(3)); set.addComponent(new BOOLEAN(true)); set.addComponent(new PrintableString("Test"));Of course, sets may be nested meaning that one SET contains another SET as one of its components. The nesting may be of any depth.
ASN1Object
,
ASN
,
ConstructedType
,
ConstructedType.addComponent(iaik.asn1.ASN1Object)
Modifier and Type | Field and Description |
---|---|
protected boolean |
sorted |
content_count, content_data
asnType, constructed, encode_listener, indefinite_length, isStringType, stream_mode
Constructor and Description |
---|
SET()
Creates a new SET.
|
SET(boolean sorted)
Creates a new SET.
|
Modifier and Type | Method and Description |
---|---|
protected void |
decode(int length,
java.io.InputStream is)
Decodes the next available data from the InputStream.
|
protected void |
encode(java.io.OutputStream os)
DER encodes this ASN1Object and writes the result to the supplied OutputStream.
|
java.lang.String |
toString()
Returns a String that represents the value of this SET.
|
addComponent, addComponent, addEncodeListener, clone, countComponents, getComponentAt, getComponents, getValue, removeComponent, removeComponent, setComponent, setValue
addEncodeListener, encodeObject, getAsnType, indefiniteLength, isA, isConstructed, isStringType, setIndefiniteLength
public SET()
Components may be added by means of the
addComponent
method of the ConstructedType
super
class.
public SET(boolean sorted)
sorted
is set to
true
the components are sorted by their encodings. This
constructor only shall be used for creating SET OF structures where all
components have the same type. In this way, an application may prefer to
call the createSetOf(ASN1Type[] array, boolean sorted)
method of class
ASN
for creating the SET OF.sorted
- whether to sort the components by their encodings or notpublic java.lang.String toString()
toString
in class ASN1Object
ASN1Object.toString()
protected void encode(java.io.OutputStream os) throws java.io.IOException
ConstructedType
encode
in class ConstructedType
os
- the output stream to which to write the datajava.io.IOException
- if an error occurs while reading from the streamprotected void decode(int length, java.io.InputStream is) throws CodingException, java.io.IOException
length
bytes represent the encoding of this
ASN1Object to be decoded. If length < 0
,
the supplied ASN1Object has been encoded by means of the
indefinite length encoding method, and so the encoding has to be parsed
for two consecutive EOC octets of all zeros. Indefinite length
encoding only is appropriate (and therefore allowed) for constructed
ASN.1 types.
This is a protected method and will not be used by
an application for DER decoding an encoded ASN1Object. An application
will call one of the decode
methods of the
DerCoder
class for performing
the decoding. The DerCoder then determines the number of
bytes (length
) obtained by the particular
ASN1Object and internally calls the decode
method of that ASN1Object.
decode
in class ConstructedType
length
- the length of the ASN1Object which shall be decoded, i.e. the
number of the bytes representing the ASN1Object to be decodedis
- the input stream from which the data is read injava.io.IOException
- if an error occurs while reading from the streamCodingException
- if a decoding error occurs