|
Java Card v2.2.2 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavacardx.framework.tlv.BERTag
public abstract class BERTag
The abstract BERTag class encapsulates a BER TLV tag. The rules on the
allowed encoding of the Tag field are based on the ASN.1 BER encoding rules
of ISO/IEC 8825-1:2002.
The BERTag class and the subclasses ConstructedBERTag and
PrimitiveBERTag, also provide static methods to parse or edit a BER Tag structure
representation in a byte array.
| Field Summary | |
|---|---|
static byte |
BER_TAG_CLASS_MASK_APPLICATION
Constant for BER Tag Class Application |
static byte |
BER_TAG_CLASS_MASK_CONTEXT_SPECIFIC
Constant for BER Tag Class Context-Specific |
static byte |
BER_TAG_CLASS_MASK_PRIVATE
Constant for BER Tag Class Private |
static byte |
BER_TAG_CLASS_MASK_UNIVERSAL
Constant for BER Tag Class Universal |
static boolean |
BER_TAG_TYPE_CONSTRUCTED
Constant for constructed BER Tag type |
static boolean |
BER_TAG_TYPE_PRIMITIVE
Constant for primitive BER Tag type |
| Constructor Summary | |
|---|---|
protected |
BERTag()
Constructor creates an empty BERTLV Tag object capable of encapsulating
a BER TLV Tag. |
| Method Summary | |
|---|---|
boolean |
equals(BERTag otherTag)
Compares this BER Tag with another. |
static BERTag |
getInstance(byte[] bArray,
short bOff)
Create a BERTLV Tag object from the binary representation in
the byte array. |
abstract void |
init(byte[] bArray,
short bOff)
Abstract init method. |
boolean |
isConstructed()
Used to query if this BER tag structure is constructed |
static boolean |
isConstructed(byte[] berTagArray,
short bOff)
Returns the constructed flag part of the BER Tag from its representation in the specified byte array |
byte |
size()
Returns the byte size required to represent this tag structure |
static byte |
size(byte[] berTagArray,
short bOff)
Returns the byte size required to represent the BER Tag from its representation in the specified byte array |
byte |
tagClass()
Returns the tag class part of this BER Tag structure |
static byte |
tagClass(byte[] berTagArray,
short bOff)
Returns the tag class part of the BER Tag from its representation in the specified byte array |
short |
tagNumber()
Returns the tag number part of this BER Tag structure |
static short |
tagNumber(byte[] berTagArray,
short bOff)
Returns the tag number part of the BER Tag from its representation in the specified byte array |
short |
toBytes(byte[] outBuf,
short bOffset)
Writes the representation of this BER tag structure to the byte array |
static short |
toBytes(short tagClass,
boolean isConstructed,
short tagNumber,
byte[] outArray,
short bOff)
Writes the BER Tag bytes representing the specified tag class, constructed flag and the tag number as a BER Tag representation in the specified byte array |
static boolean |
verifyFormat(byte[] berTagArray,
short bOff)
Checks if the input data is a well-formed BER Tag representation |
| Methods inherited from class java.lang.Object |
|---|
equals |
| Field Detail |
|---|
public static final byte BER_TAG_CLASS_MASK_UNIVERSAL
public static final byte BER_TAG_CLASS_MASK_APPLICATION
public static final byte BER_TAG_CLASS_MASK_CONTEXT_SPECIFIC
public static final byte BER_TAG_CLASS_MASK_PRIVATE
public static final boolean BER_TAG_TYPE_CONSTRUCTED
public static final boolean BER_TAG_TYPE_PRIMITIVE
| Constructor Detail |
|---|
protected BERTag()
BERTLV Tag object capable of encapsulating
a BER TLV Tag. All implementations must support at least 3 byte Tags
which can encode tag numbers up to 0x3FFF.
| Method Detail |
|---|
public abstract void init(byte[] bArray,
short bOff)
throws TLVException
this BERTag object from the binary representation in
the byte array. All implementations must support tag numbers up to 0x3FFF.
bArray - the byte array containing the binary representationbOff - the offset within bArray where the tag binary begins
ArrayIndexOutOfBoundsException - if accessing the input array
would cause access of data outside array bounds, or if the array offset
parameter is negative
NullPointerException - if bArray is null
TLVException - with the following reason codes:TLVException.ILLEGAL_SIZE if the tag number requested is larger than the supported
maximum size
TLVException.MALFORMED_TAG if tag representation in the byte array is malformed
public static BERTag getInstance(byte[] bArray,
short bOff)
throws TLVException
BERTLV Tag object from the binary representation in
the byte array. All implementations must support tag numbers up to 0x3FFF.
Note that the returned BERTag must be cast to the correct subclass:
PrimitiveBERTag or ConstructedBERTag to
access their specialized API.
bArray - the byte array containing the binary representationbOff - the offset within bArray where the tag binary begins
ArrayIndexOutOfBoundsException - if accessing the input array
would cause access of data outside array bounds, or if the array offset
parameter is negative
NullPointerException - if bArray is null
TLVException - with the following reason codes:TLVException.ILLEGAL_SIZE if the tag number requested is larger than the supported
maximum size
TLVException.MALFORMED_TAG if tag representation in the byte array is malformed.
public byte size()
throws TLVException
this tag structure
TLVException - with the following reason codes:TLVException.TAG_SIZE_GREATER_THAN_127 if the size of the BER Tag is > 127.
TLVException.EMPTY_TAG if the BER Tag is empty.
public short toBytes(byte[] outBuf,
short bOffset)
throws TLVException
this BER tag structure to the byte array
outBuf - the byteArray where the BER tag is writtenbOffset - offset within outBuf where BER tag value starts
ArrayIndexOutOfBoundsException - if accessing the output array
would cause access of data outside array bounds, or if the array offset
parameter is negative
NullPointerException - if outBuf is null
TLVException - with the following reason codes:TLVException.EMPTY_TAG if the BER Tag is empty.
public short tagNumber()
throws TLVException
this BER Tag structure
TLVException - with the following reason codes:TLVException.TAG_NUMBER_GREATER_THAN_32767 if the tag number is > 32767.
TLVException.EMPTY_TAG if the BER Tag is empty.
public boolean isConstructed()
this BER tag structure is constructed
true if constructed, false if primitive
TLVException - with the following reason codes:TLVException.EMPTY_TAG if the BER Tag is empty.
public byte tagClass()
this BER Tag structure
BER_TAG_CLASS_MASK_*..
constants defined above. See BER_TAG_CLASS_MASK_APPLICATION.
TLVException - with the following reason codes:TLVException.EMPTY_TAG if the BER Tag is empty.
public boolean equals(BERTag otherTag)
this BER Tag with another. Note that this method
does not throw exceptions. If the parameter otherTag is null, the method
returns false
true if the tag data encapsulated are equal, false otherwise
public static short toBytes(short tagClass,
boolean isConstructed,
short tagNumber,
byte[] outArray,
short bOff)
tagClass - encodes the tag class. Valid codes are the BER_TAG_CLASS_MASK_* constants
defined above. See BER_TAG_CLASS_MASK_APPLICATION.isConstructed - true if the tag is constructed, false if primitivetagNumber - is the tag number.outArray - output byte arraybOff - offset within byte array containing first byte
ArrayIndexOutOfBoundsException - if accessing the output array
would cause access of data outside array bounds, or if the array offset
parameter is negative
NullPointerException - if outArray is null
TLVException - with the following reason codes:TLVException.ILLEGAL_SIZE if the tag size is larger than the supported
maximum size or 32767
TLVException.INVALID_PARAM if tagClass parameter is invalid
or if the tagNumber parameter is negative
public static byte size(byte[] berTagArray,
short bOff)
throws TLVException
berTagArray - input byte array containing the BER Tag representationbOff - offset within byte array containing first byte
ArrayIndexOutOfBoundsException - if accessing the input array
would cause access of data outside array bounds, or if the array offset
parameter is negative
NullPointerException - if berTagArray is null
TLVException - with the following reason codes:TLVException.ILLEGAL_SIZE if the size of the BER Tag is greater than the maximum
Tag size supported
TLVException.TAG_SIZE_GREATER_THAN_127 if the size of the BER Tag is > 127.
TLVException.MALFORMED_TAG if tag representation in the byte array is malformed
public static short tagNumber(byte[] berTagArray,
short bOff)
throws TLVException
berTagArray - input byte arraybOff - offset within byte array containing first byte
ArrayIndexOutOfBoundsException - if accessing the input array
would cause access of data outside array bounds, or if the array offset
parameter is negative
NullPointerException - if berTagArray is null
TLVException - with the following reason codes:TLVException.ILLEGAL_SIZE if the size of the BER Tag is greater than
the maximum Tag size supported
TLVException.TAG_NUMBER_GREATER_THAN_32767 if the tag number is > 32767.
TLVException.MALFORMED_TAG if tag representation in the byte array is malformed.
public static boolean isConstructed(byte[] berTagArray,
short bOff)
berTagArray - input byte arraybOff - offset within byte array containing first byte
true if constructed, false if primitive
ArrayIndexOutOfBoundsException - if accessing the input array
would cause access of data outside array bounds, or if the array offset
parameter is negative
NullPointerException - if berTagArray is null
TLVException - with the following reason codes:TLVException.MALFORMED_TAG if tag representation in the byte array is malformed.
public static byte tagClass(byte[] berTagArray,
short bOff)
berTagArray - input byte arraybOff - offset within byte array containing first byte
BER_TAG_CLASS_MASK_*..
constants defined above. See BER_TAG_CLASS_MASK_APPLICATION.
ArrayIndexOutOfBoundsException - if accessing the input array
would cause access of data outside array bounds, or if the array offset
parameter is negative
NullPointerException - if berTagArray is null
TLVException - with the following reason codes:TLVException.MALFORMED_TAG if tag representation in the byte array is malformed.
public static boolean verifyFormat(byte[] berTagArray,
short bOff)
berTagArray - input byte arraybOff - offset within byte array containing first byte
true if input data is a well formed BER Tag structure of tag size equal to or less than the supported
maximum size, false otherwise
ArrayIndexOutOfBoundsException - if accessing the input array
would cause access of data outside array bounds, or if the array offset
parameter is negative
NullPointerException - if berTagArray is null
|
Java Card v2.2.2 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||