cryptix.asn1.lang

Class Tag

public class Tag extends Object

A class to handle ASN.1 Tag elements.

Copyright ©1997, 1998, 1999 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.3 $

Author: Raif S. Naffah Eric Rescorla

Field Summary
static intAPPLICATION
static intBIT_STRING
static intBOOLEAN
intclazz
booleanconstructed
static intCONTEXT
booleanexplicit
static intIA5_STRING
static intINTEGER
static intNULL
static intOBJECT_IDENTIFIER
static intOCTET_STRING
static intPRINT_STRING
static intPRIVATE
static intSEQUENCE
static intSEQUENCE_OF
static intSET
static intSET_OF
static intT61_STRING
static intUNIVERSAL
static intUTC_TIME
intvalue
Constructor Summary
Tag(int clazz, int value, boolean explicit, boolean constructed)
Constructs an ASN.1 Tag instance.
Tag(int clazz, int value, boolean explicit)
Convenience constructor.
Tag(int value, boolean explicit)
Convenience constructor.
Method Summary
static Tagdecode(InputStream in)
Constructs a Tag instance from the designated input stream.
intgetClazz()
Returns the tag's class.
static TaggetExpectedTag(int expectedClass, int expectedValue, InputStream in)
Returns the tag element of an ASN.1 object if it is of the designated expected class and type, or null otherwise.
static TaggetExpectedTag(int expectedValue, InputStream in)
Convenience method similar to the method with same name and 3 arguments, except it assumes that the tag's class is UNIVERSAL.
static TaggetExpectedTag(Tag tag, InputStream in)
Convenience method similar to the method with same name and 3 arguments, except it uses the given tag's class and value.
static byte[]getTag(InputStream in)
Get a tag off the wire as a byte[]
intgetValue()
Returns the tag's class number.
booleanisConstructed()
Returns true if the tag is constructed false otherwise.
booleanisExplicit()
Returns true if the tag is explicit, false otherwise.
static Tagpeek(InputStream in)
Returns the Tag instance parsed from the given input stream, if one is there, without modifying the stram marker.
StringtoString()

Field Detail

APPLICATION

public static final int APPLICATION

BIT_STRING

public static final int BIT_STRING

BOOLEAN

public static final int BOOLEAN

clazz

int clazz

constructed

boolean constructed

CONTEXT

public static final int CONTEXT

explicit

boolean explicit

IA5_STRING

public static final int IA5_STRING

INTEGER

public static final int INTEGER

NULL

public static final int NULL

OBJECT_IDENTIFIER

public static final int OBJECT_IDENTIFIER

OCTET_STRING

public static final int OCTET_STRING

PRINT_STRING

public static final int PRINT_STRING

PRIVATE

public static final int PRIVATE

SEQUENCE

public static final int SEQUENCE

SEQUENCE_OF

public static final int SEQUENCE_OF

SET

public static final int SET

SET_OF

public static final int SET_OF

T61_STRING

public static final int T61_STRING

UNIVERSAL

public static final int UNIVERSAL

UTC_TIME

public static final int UTC_TIME

value

int value

Constructor Detail

Tag

Tag(int clazz, int value, boolean explicit, boolean constructed)
Constructs an ASN.1 Tag instance.

Parameters: clazz The tag's class, default is UNIVERSAL. value The tag's value. explicit Whether this tag is explicit or implicit. constructed Whether this tag is constructed or not. Default is not constrcuted.

Tag

Tag(int clazz, int value, boolean explicit)
Convenience constructor. Constructs an ASN.1 Tag instance.

Parameters: clazz The tag's class, default is UNIVERSAL. value The tag's value. explicit Whether this tag is explicit or implicit.

Tag

Tag(int value, boolean explicit)
Convenience constructor. Constructs an ASN.1 Tag instance.

Parameters: value The tag's value. explicit Whether this tag is explicit or implicit.

Method Detail

decode

public static Tag decode(InputStream in)
Constructs a Tag instance from the designated input stream.

Parameters: in The input stream.

Returns: A Tag instance parsed from an input stream.

Throws: IOException If an error occurs while parsing the input stream.

getClazz

public int getClazz()
Returns the tag's class.

getExpectedTag

public static Tag getExpectedTag(int expectedClass, int expectedValue, InputStream in)
Returns the tag element of an ASN.1 object if it is of the designated expected class and type, or null otherwise. If the stream does not contain the expected tag (of given type) this method ensures that the stream marker is not modified.

Parameters: expectedClass The tag's class expected to be found at the current marker location of the given input stream. expectedValue The tag's number expected to be found at the current marker location of the given input stream. in The input source stream.

Returns: An instance of the Tag class containing the concrete Tag instance found in the input stream.

getExpectedTag

public static Tag getExpectedTag(int expectedValue, InputStream in)
Convenience method similar to the method with same name and 3 arguments, except it assumes that the tag's class is UNIVERSAL.

Parameters: expectedValue The tag's number expected to be found at the current marker location of the given input stream. in The input source stream.

Returns: An instance of the Tag class containing the concrete Tag instance found in the input stream.

getExpectedTag

public static Tag getExpectedTag(Tag tag, InputStream in)
Convenience method similar to the method with same name and 3 arguments, except it uses the given tag's class and value.

Parameters: tag The tag's instance (class and value) expected to be found at the current marker location of the given input stream. in The input source stream.

Returns: An instance of the Tag class containing the concrete Tag instance found in the input stream.

getTag

public static byte[] getTag(InputStream in)
Get a tag off the wire as a byte[]

Parameters: in The input stream

Returns: a byte with the tag bytes

Throws: IOException --EKR

getValue

public int getValue()
Returns the tag's class number.

isConstructed

public boolean isConstructed()
Returns true if the tag is constructed false otherwise.

isExplicit

public boolean isExplicit()
Returns true if the tag is explicit, false otherwise.

peek

public static Tag peek(InputStream in)
Returns the Tag instance parsed from the given input stream, if one is there, without modifying the stram marker.

Parameters: in The input stream.

Returns: A Tag instance parsed from the designated input stream.

Throws: IOException If an error occurs while parsing the input stream.

toString

public String toString()