org.jasn
Class Tags

java.lang.Object
  extended byorg.jasn.Tags

public class Tags
extends Object

This class acts as a factory for ASN.1 tags. An ASN.1 tag consists of a class and a number and is used to identify an ASN.1 value.

The tags are internally packed in int values and must be handled as opaque values that may be passed - after creation - to the decoders/encoders.

Note: The predefined tag constants (like BOOLEAN, INTEGER, ...) have a UNIVERSAL class, so that they may be directly used instead of invoking the createTag method with UNIVERSAL as first parameter.

ASN.1 defines the 4 following tag classes:

The tag numbers are restricted to values in the interval [0..MAX_TAG_NUMBER].

The getTagClass and getTagNumber methods must be used to extract the corresponding tag class and tag number.

Author:
Nicolas Vraux

Field Summary
static int APPLICATION
          The ASN.1 APPLICATION class.
static int BIT_STRING
          The universal tag for a BIT STRING value.
static int BMPSTRING
          The universal tag for a BMPString value.
static int BOOLEAN
          The universal tag for a BOOLEAN value.
static int CONTEXT
          The ASN.1 CONTEXT class.
static int EMBEDDED_PDV
          The universal tag for an EMBEDDED PDV value.
static int ENUMERATED
          The universal tag for an ENUMERATED value.
static int EOC
          The End of Content tag.
static int EXTERNAL
          The universal tag for an EXTERNAL value.
static int GENERALIZEDTIME
          The universal tag for a GeneralizedTime value.
static int GENERALSTRING
          The universal tag for a GeneralString value.
static int GRAPHICSTRING
          The universal tag for a GraphicString value.
static int IA5STRING
          The universal tag for an IA5String value.
static int INTEGER
          The universal tag for an INTEGER value.
static int MAX_TAG_NUMBER
          The maximum value allowed for a tag number.
static int NULL
          The universal tag for a NULL value.
static int NUMERICSTRING
          The universal tag for a NumericString value.
static int OBJECT_DESCRIPTOR
          The universal tag for an OBJECT DESCRIPTOR value.
static int OBJECT_IDENTIFIER
          The universal tag for an OBJECT IDENTIFIER value.
static int OCTET_STRING
          The universal tag for an OCTET STRING value.
static int PRINTABLESTRING
          The universal tag for a PrintableString value.
static int PRIVATE
          The ASN.1 PRIVATE class.
static int REAL
          The universal tag for a REAL value.
static int SEQUENCE
          The universal tag for a SEQUENCE/SEQUENCE OF value.
static int SET
          The universal tag for a SET/SET OF value.
static int T61STRING
          The universal tag for a T61String value.
static int TELETEXSTRING
          The universal tag for a TeletexString value.
static int UNIVERSAL
          The ASN.1 UNIVERSAL class.
static int UNIVERSALSTRING
          The universal tag for an UniversalString value.
static int UTCTIME
          The universal tag for an UTCTime value.
static int UTF8STRING
          The universal tag for an UTF8String value.
static int VIDEOTEXSTRING
          The universal tag for a VideotextString value.
static int VISIBLESTRING
          The universal tag for a VisibleString value.
 
Method Summary
static int createTag(int clazz, int number)
          Creates an ASN.1 Tag with the specified class and the specified number.
static int getTagClass(int tag)
          Returns the class of the specified tag.
static int getTagNumber(int tag)
          Returns the number of the specified tag.
static String toString(int tag)
          Returns a string representation of the specified tag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_TAG_NUMBER

public static final int MAX_TAG_NUMBER
The maximum value allowed for a tag number.

See Also:
Constant Field Values

EOC

public static final int EOC
The End of Content tag.

See Also:
Constant Field Values

BOOLEAN

public static final int BOOLEAN
The universal tag for a BOOLEAN value.

See Also:
Constant Field Values

INTEGER

public static final int INTEGER
The universal tag for an INTEGER value.

See Also:
Constant Field Values

BIT_STRING

public static final int BIT_STRING
The universal tag for a BIT STRING value.

See Also:
Constant Field Values

OCTET_STRING

public static final int OCTET_STRING
The universal tag for an OCTET STRING value.

See Also:
Constant Field Values

NULL

public static final int NULL
The universal tag for a NULL value.

See Also:
Constant Field Values

OBJECT_IDENTIFIER

public static final int OBJECT_IDENTIFIER
The universal tag for an OBJECT IDENTIFIER value.

See Also:
Constant Field Values

OBJECT_DESCRIPTOR

public static final int OBJECT_DESCRIPTOR
The universal tag for an OBJECT DESCRIPTOR value.

See Also:
Constant Field Values

EXTERNAL

public static final int EXTERNAL
The universal tag for an EXTERNAL value.

See Also:
Constant Field Values

REAL

public static final int REAL
The universal tag for a REAL value.

See Also:
Constant Field Values

ENUMERATED

public static final int ENUMERATED
The universal tag for an ENUMERATED value.

See Also:
Constant Field Values

EMBEDDED_PDV

public static final int EMBEDDED_PDV
The universal tag for an EMBEDDED PDV value.

See Also:
Constant Field Values

UTF8STRING

public static final int UTF8STRING
The universal tag for an UTF8String value.

See Also:
Constant Field Values

SEQUENCE

public static final int SEQUENCE
The universal tag for a SEQUENCE/SEQUENCE OF value.

See Also:
Constant Field Values

SET

public static final int SET
The universal tag for a SET/SET OF value.

See Also:
Constant Field Values

NUMERICSTRING

public static final int NUMERICSTRING
The universal tag for a NumericString value.

See Also:
Constant Field Values

PRINTABLESTRING

public static final int PRINTABLESTRING
The universal tag for a PrintableString value.

See Also:
Constant Field Values

TELETEXSTRING

public static final int TELETEXSTRING
The universal tag for a TeletexString value.

See Also:
Constant Field Values

T61STRING

public static final int T61STRING
The universal tag for a T61String value. This constant is a synonym for TELETEXSTRING.

See Also:
Constant Field Values

VIDEOTEXSTRING

public static final int VIDEOTEXSTRING
The universal tag for a VideotextString value.

See Also:
Constant Field Values

IA5STRING

public static final int IA5STRING
The universal tag for an IA5String value.

See Also:
Constant Field Values

UTCTIME

public static final int UTCTIME
The universal tag for an UTCTime value.

See Also:
Constant Field Values

GENERALIZEDTIME

public static final int GENERALIZEDTIME
The universal tag for a GeneralizedTime value.

See Also:
Constant Field Values

GRAPHICSTRING

public static final int GRAPHICSTRING
The universal tag for a GraphicString value.

See Also:
Constant Field Values

VISIBLESTRING

public static final int VISIBLESTRING
The universal tag for a VisibleString value.

See Also:
Constant Field Values

GENERALSTRING

public static final int GENERALSTRING
The universal tag for a GeneralString value.

See Also:
Constant Field Values

UNIVERSALSTRING

public static final int UNIVERSALSTRING
The universal tag for an UniversalString value.

See Also:
Constant Field Values

BMPSTRING

public static final int BMPSTRING
The universal tag for a BMPString value.

See Also:
Constant Field Values

UNIVERSAL

public static final int UNIVERSAL
The ASN.1 UNIVERSAL class.

See Also:
Constant Field Values

APPLICATION

public static final int APPLICATION
The ASN.1 APPLICATION class.

See Also:
Constant Field Values

CONTEXT

public static final int CONTEXT
The ASN.1 CONTEXT class.

See Also:
Constant Field Values

PRIVATE

public static final int PRIVATE
The ASN.1 PRIVATE class.

See Also:
Constant Field Values
Method Detail

createTag

public static int createTag(int clazz,
                            int number)
Creates an ASN.1 Tag with the specified class and the specified number.

Parameters:
clazz - the tag class.
number - the tag number.
Returns:
an internal representation of an ASN.1 tag with the specified class and the specified number.
Throws:
IllegalArgumentException - if the specified tag number is less than zeroe or greater than the maximum allowed value for a tag number (i.e MAX_TAG_NUMBER).

getTagClass

public static int getTagClass(int tag)
Returns the class of the specified tag.

Parameters:
tag - the tag value whose class is to be extracted. It must be a valid tag value, i.e one that has been created with createTag(int, int) method or one that has been returned by a decoder.
Returns:
one of the possible tag classes:

getTagNumber

public static int getTagNumber(int tag)
Returns the number of the specified tag.

Parameters:
tag - the tag value whose number is to be extracted.
Returns:
the tag number of the specified tag value.

toString

public static String toString(int tag)
Returns a string representation of the specified tag.

Parameters:
tag - the tag value.
Returns:
a string of the form: CLASS[NUMBER].


Copyright © 2004 Nicolas Vraux. All Rights Reserved.