-
public final class Asn1NodeThis represents a primitive or constructed data defined by ASN.1. A constructed node can have child nodes. A non-constructed node can have a value. This class is read-only. To build a node, you can use the newBuilder method to get a Builder instance. This class is not thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classAsn1Node.BuilderThis class is used to build an Asn1Node instance of a constructed tag. This class is notthread-safe.
-
Method Summary
Modifier and Type Method Description static Asn1Node.BuildernewBuilder(int tag)Creates a new ASN.1 data node builder with the given tag. intgetTag()booleanisConstructed()booleanhasChild(int tag, Array<int> tags)Tests if a node has a child. Asn1NodegetChild(int tag, Array<int> tags)Gets the first child node having the given {@code tag}and{@code tags}.List<Asn1Node>getChildren(int tag)Gets all child nodes which have the given {@code tag}.List<Asn1Node>getChildren()Gets all child nodes of this node. booleanhasValue()intasInteger()longasRawLong()StringasString()Array<byte>asBytes()intasBits()Gets the data as an integer for BIT STRING. booleanasBoolean()intgetEncodedLength()intgetDataLength()voidwriteToBytes(Array<byte> dest, int offset)Writes the DER encoded bytes of this node into a byte array. Array<byte>toBytes()Writes the DER encoded bytes of this node into a new byte array. StringtoHex()Gets a hex string representing the DER encoded bytes of this node. StringgetHeadAsHex()Gets header (tag + length) as hex string. -
-
Method Detail
-
newBuilder
static Asn1Node.Builder newBuilder(int tag)
Creates a new ASN.1 data node builder with the given tag. The tag is an encoded tag includingthe tag class, tag number, and constructed mask.
-
getTag
int getTag()
-
isConstructed
boolean isConstructed()
-
hasChild
boolean hasChild(int tag, Array<int> tags)
Tests if a node has a child.
- Parameters:
tag- The tag of an immediate child.tags- The tags of lineal descendant.
-
getChild
Asn1Node getChild(int tag, Array<int> tags)
Gets the first child node having the given
{@code tag}and{@code tags}.- Parameters:
tag- The tag of an immediate child.tags- The tags of lineal descendant.
-
getChildren
List<Asn1Node> getChildren(int tag)
Gets all child nodes which have the given
{@code tag}.
-
getChildren
List<Asn1Node> getChildren()
Gets all child nodes of this node. If it's a constructed node having encoded data, it'schildren will be decoded here.
-
hasValue
boolean hasValue()
-
asInteger
int asInteger()
-
asRawLong
long asRawLong()
-
asBits
int asBits()
Gets the data as an integer for BIT STRING. DER actually stores the bits in a reversed order.The returned integer here has the order fixed (first bit is at the lowest position). Thismethod currently only support at most 32 bits which fit in an integer.
-
asBoolean
boolean asBoolean()
-
getEncodedLength
int getEncodedLength()
-
getDataLength
int getDataLength()
-
writeToBytes
void writeToBytes(Array<byte> dest, int offset)
Writes the DER encoded bytes of this node into a byte array. The number of written bytes is getEncodedLength.
-
getHeadAsHex
String getHeadAsHex()
Gets header (tag + length) as hex string.
-
-
-
-