Class AID
- java.lang.Object
-
- javacard.framework.AID
-
public class AID extends Object
This class encapsulates the Application Identifier (AID) associated with an applet. An AID is defined in ISO 7816-5 to be a sequence of bytes between 5 and 16 bytes in length.The Java Card runtime environment creates instances of
AID
class to identify and manage every applet on the card. Applets need not create instances of this class. An applet may request and use the Java Card runtime environment-owned instances to identify itself and other applet instances.Java Card runtime environment-owned instances of
AID
are permanent Java Card runtime environment Entry Point Objects and can be accessed from any applet context. References to these permanent objects can be stored and re-used.An applet instance can obtain a reference to Java Card runtime environment-owned instances of its own
AID
object by using theJCSystem.getAID()
method and another applet'sAID
object via theJCSystem.lookupAID()
method.An applet uses
AID
instances to request to share another applet's object or to control access to its own shared object from another applet. See Runtime Environment Specification, Java Card Platform, Classic Edition, section 6.2 for details.- See Also:
JCSystem
,SystemException
-
-
Constructor Summary
Constructors Constructor Description AID(byte[] bArray, short offset, byte length)
The Java Card runtime environment uses this constructor to create a newAID
instance encapsulating the specified AID bytes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(byte[] bArray, short offset, byte length)
Checks if the specified AID bytes inbArray
are the same as those encapsulated inthis
AID
object.boolean
equals(Object anObject)
Compares the AID bytes inthis
AID
instance to the AID bytes in the specified object.byte
getBytes(byte[] dest, short offset)
Called to get all the AID bytes encapsulated withinAID
object.byte
getPartialBytes(short aidOffset, byte[] dest, short oOffset, byte oLength)
Called to get part of the AID bytes encapsulated within theAID
object starting at the specified offset for the specified length.boolean
partialEquals(byte[] bArray, short offset, byte length)
Checks if the specified partial AID byte sequence matches the firstlength
bytes of the encapsulated AID bytes withinthis
AID
object.boolean
RIDEquals(AID otherAID)
Checks if the RID (National Registered Application provider identifier) portion of the encapsulated AID bytes within theotherAID
object matches that ofthis
AID
object.
-
-
-
Constructor Detail
-
AID
public AID(byte[] bArray, short offset, byte length) throws SystemException, NullPointerException, ArrayIndexOutOfBoundsException, SecurityException
The Java Card runtime environment uses this constructor to create a newAID
instance encapsulating the specified AID bytes.- Parameters:
bArray
- the byte array containing the AID bytesoffset
- the start of AID bytes in bArraylength
- the length of the AID bytes in bArray- Throws:
SecurityException
- if thebArray
array is not accessible in the caller's contextSystemException
- with the following reason code:SystemException.ILLEGAL_VALUE
if thelength
parameter is less than5
or greater than16
NullPointerException
- if thebArray
parameter isnull
ArrayIndexOutOfBoundsException
- if theoffset
parameter orlength
parameter is negative or ifoffset+length
is greater than the length of thebArray
parameter
-
-
Method Detail
-
getBytes
public final byte getBytes(byte[] dest, short offset) throws NullPointerException, ArrayIndexOutOfBoundsException, SecurityException
Called to get all the AID bytes encapsulated withinAID
object.- Parameters:
dest
- byte array to copy the AID bytesoffset
- within dest where the AID bytes begin- Returns:
- the length of the AID bytes
- Throws:
SecurityException
- if thedest
array is not accessible in the caller's contextNullPointerException
- if thedest
parameter isnull
ArrayIndexOutOfBoundsException
- if theoffset
parameter is negative oroffset+
length of AID bytes is greater than the length of thedest
array
-
equals
public final boolean equals(Object anObject) throws SecurityException
Compares the AID bytes inthis
AID
instance to the AID bytes in the specified object. The result istrue
if and only if the argument is notnull
and is anAID
object that encapsulates the same AID bytes asthis
object.This method does not throw
NullPointerException
.In addition to returning a
boolean
result, this method sets the result in an internal state which can be rechecked using assertion methods of theSensitiveResult
class, if supported by the platform.- Overrides:
equals
in classObject
- Parameters:
anObject
- the object to comparethis
AID
against- Returns:
true
if the AID byte values are equal,false
otherwise- Throws:
SecurityException
- ifanObject
object is not accessible in the caller's context
-
equals
public final boolean equals(byte[] bArray, short offset, byte length) throws ArrayIndexOutOfBoundsException, SecurityException
Checks if the specified AID bytes inbArray
are the same as those encapsulated inthis
AID
object. The result istrue
if and only if thebArray
argument is notnull
and the AID bytes encapsulated inthis
AID
object are equal to the specified AID bytes inbArray
.This method does not throw
NullPointerException
.In addition to returning a
boolean
result, this method sets the result in an internal state which can be rechecked using assertion methods of theSensitiveResult
class, if supported by the platform.- Parameters:
bArray
- containing the AID bytesoffset
- within bArray to beginlength
- of AID bytes in bArray- Returns:
true
if equal,false
otherwise- Throws:
SecurityException
- if thebArray
array is not accessible in the caller's contextArrayIndexOutOfBoundsException
- if theoffset
parameter orlength
parameter is negative or ifoffset+length
is greater than the length of thebArray
parameter
-
partialEquals
public final boolean partialEquals(byte[] bArray, short offset, byte length) throws ArrayIndexOutOfBoundsException, SecurityException
Checks if the specified partial AID byte sequence matches the firstlength
bytes of the encapsulated AID bytes withinthis
AID
object. The result istrue
if and only if thebArray
argument is notnull
and the inputlength
is less than or equal to the length of the encapsulated AID bytes withinthis
AID
object and the specified bytes match.This method does not throw
NullPointerException
.In addition to returning a
boolean
result, this method sets the result in an internal state which can be rechecked using assertion methods of theSensitiveResult
class, if supported by the platform.- Parameters:
bArray
- containing the partial AID byte sequenceoffset
- within bArray to beginlength
- of partial AID bytes in bArray- Returns:
true
if equal,false
otherwise- Throws:
SecurityException
- if thebArray
array is not accessible in the caller's contextArrayIndexOutOfBoundsException
- if theoffset
parameter orlength
parameter is negative or ifoffset+length
is greater than the length of thebArray
parameter
-
RIDEquals
public final boolean RIDEquals(AID otherAID) throws SecurityException
Checks if the RID (National Registered Application provider identifier) portion of the encapsulated AID bytes within theotherAID
object matches that ofthis
AID
object. The first 5 bytes of an AID byte sequence is the RID. See ISO 7816-5 for details. The result istrue
if and only if the argument is notnull
and is anAID
object that encapsulates the same RID bytes asthis
object.This method does not throw
NullPointerException
.In addition to returning a
boolean
result, this method sets the result in an internal state which can be rechecked using assertion methods of theSensitiveResult
class, if supported by the platform.- Parameters:
otherAID
- theAID
to compare against- Returns:
true
if the RID bytes match,false
otherwise- Throws:
SecurityException
- if theotherAID
object is not accessible in the caller's context
-
getPartialBytes
public final byte getPartialBytes(short aidOffset, byte[] dest, short oOffset, byte oLength) throws NullPointerException, ArrayIndexOutOfBoundsException, SecurityException
Called to get part of the AID bytes encapsulated within theAID
object starting at the specified offset for the specified length.- Parameters:
aidOffset
- offset within AID array to begin copying bytesdest
- the destination byte array to copy the AID bytes intooOffset
- offset within dest where the output bytes beginoLength
- the length of bytes requested indest
.0
implies a request to copy all remaining AID bytes.- Returns:
- the actual length of the bytes returned in
dest
- Throws:
SecurityException
- if thedest
array is not accessible in the caller's contextNullPointerException
- if thedest
parameter isnull
ArrayIndexOutOfBoundsException
- if theaidOffset
parameter is negative or greater than the length of the encapsulated AID bytes or theoOffset
parameter is negative oroOffset+length
of bytes requested is greater than the length of thedest
array
-
-