SimulatorSystem



com.licel.jcardsim.base
Class SimulatorSystem

java.lang.Object
  extended by com.licel.jcardsim.base.SimulatorSystem

public class SimulatorSystem
extends Object

Base implementation of JCSystem

See Also:
JCsystem

Field Summary
static byte currentChannel
           
static NullPointerException nullPointerException
           
static Object previousActiveObject
           
static SecurityException securityException
           
static short SW_APPLET_CRATION_FAILED
          Response status : Applet creation failed = 0x6444
static short SW_EXCEPTION_OCCURED
          Response status : Exception occured = 0x6424
 
Method Summary
static void abortTransaction()
          Aborts the atomic transaction.
static void beginTransaction()
          Begins an atomic transaction.
static void commitTransaction()
          Commits an atomic transaction.
static AID getAID()
          Returns the Java Card runtime environment-owned instance of the AID object associated with the current applet context, or null if the Applet.register() method has not yet been invoked.
static short getAvailablePersistentMemory()
          Current method implementation returns 32767.
static short getAvailableTransientDeselectMemory()
          Current method implementation returns 32767.
static short getAvailableTransientResetMemory()
          Current method implementation returns 32767.
static byte getCurrentlySelectedChannel()
           
static short getJavaContext(Object obj)
           
static Object getJavaOwner(Object obj)
           
static short getMaxCommitCapacity()
          Returns the total number of bytes in the commit buffer.
static AID getPreviousContextAID()
          Obtains the Java Card runtime environment-owned instance of the AID object associated with the previously active applet context.
static Shareable getSharedObject(AID serverAID, byte parameter)
          Called by a client applet to get a server applet's shareable interface object.
static byte getTransactionDepth()
          Returns the current transaction nesting depth level.
static short getUnusedCommitCapacity()
          Returns the number of bytes left in the commit buffer.
static boolean isAppletActive(AID theApplet)
          This method is used to determine if the specified applet is active on the card.
static boolean isAppletSelecting(Applet aThis)
           
static boolean isObjectDeletionSupported()
          Alway return false
static byte isTransient(Object theObj)
          Checks if the specified object is transient.
static AID lookupAID(byte[] buffer, short offset, byte length)
          Returns the Java Card runtime environment-owned instance of the AID object, if any, encapsulating the specified AID bytes in the buffer parameter if there exists a successfully installed applet on the card whose instance AID exactly matches that of the specified AID bytes.
static boolean[] makeTransientBooleanArray(short length, byte event)
          Creates a transient boolean array with the specified array length.
static byte[] makeTransientByteArray(short length, byte event)
          Creates a transient byte array with the specified array length.
static Object[] makeTransientObjectArray(short length, byte event)
          Creates a transient array of Object with the specified array length.
static short[] makeTransientShortArray(short length, byte event)
          Creates a transient short array with the specified array length.
static void registerApplet(Applet applet)
          This method is used by the applet to register this applet instance with the Java Card runtime environment and to assign the Java Card platform name of the applet as its instance AID bytes.
static void registerApplet(Applet applet, byte[] bArray, short bOffset, byte bLength)
          This method is used by the applet to register this applet instance with the Java Card runtime environment and assign the specified AID bytes as its instance AID bytes.
static void requestObjectDeletion()
          Always throw SystemException.ILLEGAL_USE
static void resetRuntime()
           
static void sendAPDU(byte[] buffer, short bOff, short len)
           
static void setJavaOwner(Object obj, Object owner)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SW_APPLET_CRATION_FAILED

public static final short SW_APPLET_CRATION_FAILED
Response status : Applet creation failed = 0x6444

See Also:
Constant Field Values

SW_EXCEPTION_OCCURED

public static final short SW_EXCEPTION_OCCURED
Response status : Exception occured = 0x6424

See Also:
Constant Field Values

currentChannel

public static byte currentChannel

previousActiveObject

public static Object previousActiveObject

nullPointerException

public static NullPointerException nullPointerException

securityException

public static SecurityException securityException
Method Detail

isTransient

public static byte isTransient(Object theObj)
Checks if the specified object is transient.

Note:

    This method returns NOT_A_TRANSIENT_OBJECT if the specified object is null or is not an array type.

Parameters:
theObj - the object being queried
Returns:
NOT_A_TRANSIENT_OBJECT, CLEAR_ON_RESET, or CLEAR_ON_DESELECT
See Also:
makeTransientBooleanArray(short, byte), #makeByteArray(short, byte), #makeObjectArray(short, byte), #makeShortArray(short, byte)

makeTransientBooleanArray

public static boolean[] makeTransientBooleanArray(short length,
                                                  byte event)
Creates a transient boolean array with the specified array length.

Parameters:
length - the length of the boolean array
event - the CLEAR_ON... event which causes the array elements to be cleared
Returns:
the new transient boolean array
Throws:
NegativeArraySizeException - if the length parameter is negative
SystemException - with the following reason codes:
  • SystemException.ILLEGAL_VALUE if event is not a valid event code.
  • SystemException.NO_TRANSIENT_SPACE if sufficient transient space is not available.
  • SystemException.ILLEGAL_TRANSIENT if the current applet context is not the currently selected applet context and CLEAR_ON_DESELECT is specified.

makeTransientByteArray

public static byte[] makeTransientByteArray(short length,
                                            byte event)
Creates a transient byte array with the specified array length.

Parameters:
length - the length of the byte array
event - the CLEAR_ON... event which causes the array elements to be cleared
Returns:
the new transient byte array
Throws:
NegativeArraySizeException - if the length parameter is negative
SystemException - with the following reason codes:
  • SystemException.ILLEGAL_VALUE if event is not a valid event code.
  • SystemException.NO_TRANSIENT_SPACE if sufficient transient space is not available.
  • SystemException.ILLEGAL_TRANSIENT if the current applet context is not the currently selected applet context and CLEAR_ON_DESELECT is specified.

makeTransientShortArray

public static short[] makeTransientShortArray(short length,
                                              byte event)
Creates a transient short array with the specified array length.

Parameters:
length - the length of the short array
event - the CLEAR_ON... event which causes the array elements to be cleared
Returns:
the new transient short array
Throws:
NegativeArraySizeException - if the length parameter is negative
SystemException - with the following reason codes:
  • SystemException.ILLEGAL_VALUE if event is not a valid event code.
  • SystemException.NO_TRANSIENT_SPACE if sufficient transient space is not available.
  • SystemException.ILLEGAL_TRANSIENT if the current applet context is not the currently selected applet context and CLEAR_ON_DESELECT is specified.

makeTransientObjectArray

public static Object[] makeTransientObjectArray(short length,
                                                byte event)
Creates a transient array of Object with the specified array length.

Parameters:
length - the length of the Object array
event - the CLEAR_ON... event which causes the array elements to be cleared
Returns:
the new transient Object array
Throws:
NegativeArraySizeException - if the length parameter is negative
SystemException - with the following reason codes:
  • SystemException.ILLEGAL_VALUE if event is not a valid event code.
  • SystemException.NO_TRANSIENT_SPACE if sufficient transient space is not available.
  • SystemException.ILLEGAL_TRANSIENT if the current applet context is not the currently selected applet context and CLEAR_ON_DESELECT is specified.

getAID

public static AID getAID()
Returns the Java Card runtime environment-owned instance of the AID object associated with the current applet context, or null if the Applet.register() method has not yet been invoked.

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.

See Runtime Environment Specification for the Java Card Platform, section 6.2.1 for details.

Returns:
the AID object

lookupAID

public static AID lookupAID(byte[] buffer,
                            short offset,
                            byte length)
Returns the Java Card runtime environment-owned instance of the AID object, if any, encapsulating the specified AID bytes in the buffer parameter if there exists a successfully installed applet on the card whose instance AID exactly matches that of the specified AID bytes.

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.

See Runtime Environment Specification for the Java Card Platform, section 6.2.1 for details.

Parameters:
buffer - byte array containing the AID bytes
offset - offset within buffer where AID bytes begin
length - length of AID bytes in buffer
Returns:
the AID object, if any; null otherwise. A VM exception is thrown if buffer is null, or if offset or length are out of range.

beginTransaction

public static void beginTransaction()
Begins an atomic transaction. If a transaction is already in progress (transaction nesting depth level != 0), a TransactionException is thrown.

Note:

  • This method may do nothing if the Applet.register() method has not yet been invoked. In case of tear or failure prior to successful registration, the Java Card runtime environment will roll back all atomically updated persistent state.

Throws:
TransactionException - with the following reason codes:
  • TransactionException.IN_PROGRESS if a transaction is already in progress.
See Also:
abortTransaction(), commitTransaction()

abortTransaction

public static void abortTransaction()
Aborts the atomic transaction. The contents of the commit buffer is discarded.

Note:

  • This method may do nothing if the Applet.register() method has not yet been invoked. In case of tear or failure prior to successful registration, the Java Card runtime environment will roll back all atomically updated persistent state.
  • Do not call this method from within a transaction which creates new objects because the Java Card runtime environment may not recover the heap space used by the new object instances.
  • Do not call this method from within a transaction which creates new objects because the Java Card runtime environment may, to ensure the security of the card and to avoid heap space loss, lock up the card session to force tear/reset processing.
  • The Java Card runtime environment ensures that any variable of reference type which references an object instantiated from within this aborted transaction is equivalent to a null reference.

Throws:
TransactionException - - with the following reason codes:
  • TransactionException.NOT_IN_PROGRESS if a transaction is not in progress.
See Also:
beginTransaction(), commitTransaction()

commitTransaction

public static void commitTransaction()
Commits an atomic transaction. The contents of commit buffer is atomically committed. If a transaction is not in progress (transaction nesting depth level == 0) then a TransactionException is thrown.

Note:

  • This method may do nothing if the Applet.register() method has not yet been invoked. In case of tear or failure prior to successful registration, the Java Card runtime environment will roll back all atomically updated persistent state.

Throws:
TransactionException - ith the following reason codes:
  • TransactionException.NOT_IN_PROGRESS if a transaction is not in progress.
See Also:
beginTransaction(), abortTransaction()

getTransactionDepth

public static byte getTransactionDepth()
Returns the current transaction nesting depth level. At present, only 1 transaction can be in progress at a time.

Returns:
1 if transaction in progress, 0 if not

getUnusedCommitCapacity

public static short getUnusedCommitCapacity()
Returns the number of bytes left in the commit buffer.

Note:

  • Current method implementation returns 32767.

Returns:
the number of bytes left in the commit buffer
See Also:
getMaxCommitCapacity()

getMaxCommitCapacity

public static short getMaxCommitCapacity()
Returns the total number of bytes in the commit buffer. This is approximately the maximum number of bytes of persistent data which can be modified during a transaction. However, the transaction subsystem requires additional bytes of overhead data to be included in the commit buffer, and this depends on the number of fields modified and the implementation of the transaction subsystem. The application cannot determine the actual maximum amount of data which can be modified during a transaction without taking these overhead bytes into consideration.

Note:

  • Current method implementation returns 32767.

Returns:
the total number of bytes in the commit buffer
See Also:
getUnusedCommitCapacity()

getPreviousContextAID

public static AID getPreviousContextAID()
Obtains the Java Card runtime environment-owned instance of the AID object associated with the previously active applet context. This method is typically used by a server applet, while executing a shareable interface method to determine the identity of its client and thereby control access privileges.

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.

See Runtime Environment Specification for the Java Card Platform, section 6.2.1 for details.

Returns:
the AID object of the previous context, or null if Java Card runtime environment

getAvailablePersistentMemory

public static short getAvailablePersistentMemory()
Current method implementation returns 32767.

Returns:
32767

getAvailableTransientResetMemory

public static short getAvailableTransientResetMemory()
Current method implementation returns 32767.

Returns:
32767

getAvailableTransientDeselectMemory

public static short getAvailableTransientDeselectMemory()
Current method implementation returns 32767.

Returns:
32767

getSharedObject

public static Shareable getSharedObject(AID serverAID,
                                        byte parameter)
Called by a client applet to get a server applet's shareable interface object.

This method returns null if:

  • the Applet.register() has not yet been invoked
  • the server does not exist
  • the server returns null

Parameters:
serverAID - the AID of the server applet
parameter - optional parameter data
Returns:
the shareable interface object or null
See Also:
Applet.getShareableInterfaceObject(AID, byte)

isObjectDeletionSupported

public static boolean isObjectDeletionSupported()
Alway return false

Returns:
false value

requestObjectDeletion

public static void requestObjectDeletion()
Always throw SystemException.ILLEGAL_USE


getCurrentlySelectedChannel

public static byte getCurrentlySelectedChannel()

isAppletActive

public static boolean isAppletActive(AID theApplet)
This method is used to determine if the specified applet is active on the card.

Note:

  • This method returns false if the specified applet is not active, even if its context is active.

Parameters:
theApplet - the AID of the applet object being queried
Returns:
true if and only if the applet specified by the AID parameter is currently active on this or another logical channel

sendAPDU

public static void sendAPDU(byte[] buffer,
                            short bOff,
                            short len)

registerApplet

public static void registerApplet(Applet applet)
                           throws SystemException
This method is used by the applet to register this applet instance with the Java Card runtime environment and to assign the Java Card platform name of the applet as its instance AID bytes. One of the register() methods must be called from within install() to be registered with the Java Card runtime environment. See Runtime Environment Specification for the Java Card Platform, section 3.1 for details.

Note:

  • The phrase "Java Card platform name of the applet" is a reference to the AID[AID_length] item in the applets[] item of the applet_component, as documented in Section 6.5 Applet Component in the Virtual Machine Specification for the Java Card Platform.

Throws:
SystemException - with the following reason codes:
  • SystemException.ILLEGAL_AID if the Applet subclass AID bytes are in use or if the applet instance has previously successfully registered with the Java Card runtime environment via one of the register() methods or if a Java Card runtime environment initiated install() method execution is not in progress.

registerApplet

public static void registerApplet(Applet applet,
                                  byte[] bArray,
                                  short bOffset,
                                  byte bLength)
                           throws SystemException
This method is used by the applet to register this applet instance with the Java Card runtime environment and assign the specified AID bytes as its instance AID bytes. One of the register() methods must be called from within install() to be registered with the Java Card runtime environment. See Runtime Environment Specification for the Java Card Platform, section 3.1 for details.

Note:

  • The implementation may require that the instance AID bytes specified are the same as that supplied in the install parameter data. An ILLEGAL_AID exception may be thrown otherwise.

Throws:
SystemException

isAppletSelecting

public static boolean isAppletSelecting(Applet aThis)

resetRuntime

public static void resetRuntime()

setJavaOwner

public static void setJavaOwner(Object obj,
                                Object owner)

getJavaOwner

public static Object getJavaOwner(Object obj)

getJavaContext

public static short getJavaContext(Object obj)