com.intel.util
Class IntelApplet
- java.lang.Object
-
- com.trustedlogic.tf.Service
-
- com.intel.util.IntelApplet
-
public abstract class IntelApplet extends com.trustedlogic.tf.Service
This is the base class that must be inherited by all applets. The applets must not inherit thecom.trustedlogic.tf.Service
class directly.
-
-
Field Summary
Fields Modifier and Type Field and Description static int
APPLET_ERROR_BAD_PARAMETERS
static int
APPLET_ERROR_BAD_STATE
static int
APPLET_ERROR_GENERIC
static int
APPLET_ERROR_NOT_SUPPORTED
static int
APPLET_ERROR_SMALL_BUFFER
static int
APPLET_SUCCESS
-
Constructor Summary
Constructors Constructor and Description IntelApplet()
-
Method Summary
Methods Modifier and Type Method and Description int
getResponseBufferSize()
Returns the maximum size that can be returned by the applet in response.int
getSessionId(byte[] sessionId, int index)
Return a unique applet session identifier.int
getSessionIdLength()
Return the length of applet session identifier.java.lang.String
getUUID()
Returns the UUID of this applet in String representation.abstract int
invokeCommand(int commandId, byte[] request)
This method will be called by the VM to handle a command sent to this applet instance.int
onClose()
This method will be called by the VM when the session being handled by this applet instance is being closed and this applet instance is about to be removed.void
onCloseSession()
This method must not be used directly.int
onCommand(int command, com.trustedlogic.tf.CommandParameters params)
This method must not be used directly.int
onInit(byte[] request)
This method will be called by the VM when a new session is opened to the applet and this applet instance is being created to handle the new session.int
onOpenSession(com.trustedlogic.tf.CommandParameters params)
This method must not be used directly.void
sendAsynchMessage(byte[] data, int index, int length)
Sends message to the SW application communicating with this applet via asynchronous interface.void
setResponse(byte[] response, int index, int length)
Updates the response data to be returned duringinvokeCommand
method.void
setResponseCode(int responseCode)
Updates the response code to be returned afterinvokeCommand
method processing to the SW application.
-
-
-
Field Detail
-
APPLET_SUCCESS
public static final int APPLET_SUCCESS
- See Also:
- Constant Field Values
-
APPLET_ERROR_GENERIC
public static final int APPLET_ERROR_GENERIC
- See Also:
- Constant Field Values
-
APPLET_ERROR_BAD_PARAMETERS
public static final int APPLET_ERROR_BAD_PARAMETERS
- See Also:
- Constant Field Values
-
APPLET_ERROR_BAD_STATE
public static final int APPLET_ERROR_BAD_STATE
- See Also:
- Constant Field Values
-
APPLET_ERROR_NOT_SUPPORTED
public static final int APPLET_ERROR_NOT_SUPPORTED
- See Also:
- Constant Field Values
-
APPLET_ERROR_SMALL_BUFFER
public static final int APPLET_ERROR_SMALL_BUFFER
- See Also:
- Constant Field Values
-
-
Method Detail
-
onOpenSession
public final int onOpenSession(com.trustedlogic.tf.CommandParameters params)
This method must not be used directly.- Overrides:
onOpenSession
in classcom.trustedlogic.tf.Service
- Parameters:
params
- the list of parameters sent to the service- Returns:
- the execution status that will be forwarded to the client (see
SResult
) - See Also:
onInit(byte[])
-
onCloseSession
public final void onCloseSession()
This method must not be used directly.- Overrides:
onCloseSession
in classcom.trustedlogic.tf.Service
- See Also:
onClose()
-
onCommand
public final int onCommand(int command, com.trustedlogic.tf.CommandParameters params)
This method must not be used directly.- Specified by:
onCommand
in classcom.trustedlogic.tf.Service
- Parameters:
command
- the command identifier specified by the clientparams
- the list of parameters sent to the service- Returns:
- the execution status (see constants in
SResult
). - See Also:
invokeCommand(int commandId, byte[] request)
-
onInit
public int onInit(byte[] request)
This method will be called by the VM when a new session is opened to the applet and this applet instance is being created to handle the new session. This method cannot provide response data and therefore callingsetResponse
orsetResponseCode
methods from it will throw aNullPointerException
.- Parameters:
request
- the input data sent to the applet during session creation- Returns:
APPLET_SUCCESS
if the operation was processed successfully, any other status code in case of error (note that all error codes will be treated similarly by the VM by sending "cancel" error code to the SW application).
-
onClose
public int onClose()
This method will be called by the VM when the session being handled by this applet instance is being closed and this applet instance is about to be removed. This method cannot provide response data and therefore callingsetResponse
orsetResponseCode
methods from it will throw aNullPointerException
.- Returns:
APPLET_SUCCESS
code (the status code is not used by the VM).
-
invokeCommand
public abstract int invokeCommand(int commandId, byte[] request)
This method will be called by the VM to handle a command sent to this applet instance. To return the response data to the command, call thesetResponse
method before returning from this method. In order to provide a return value for the command, which will be delivered to the SW application communicating with the applet,setResponseCode
method should be called. The return value of theinvokeCommand
method is not guaranteed to be delivered to the SW application, and therefore should not be used for this purpose (applet is expected to returnAPPLET_SUCCESS
code from this method).- Parameters:
commandId
- the command ID (applet specific)request
- the input data for this command- Returns:
APPLET_SUCCESS
code.
-
setResponse
public final void setResponse(byte[] response, int index, int length)
Updates the response data to be returned duringinvokeCommand
method. Note that calling this method more than once will reset the response data previously set.- Parameters:
response
- the response data to be returned during command processingindex
- index in the response data arraylength
- length of the response data to be returned
-
getResponseBufferSize
public final int getResponseBufferSize()
Returns the maximum size that can be returned by the applet in response.- Returns:
- the maximum size that can be returned by the applet in response.
-
setResponseCode
public final void setResponseCode(int responseCode)
Updates the response code to be returned afterinvokeCommand
method processing to the SW application. Note that calling this method more than once will reset the code previously set. If not set, the default response code that will be returned to SW application is 0.- Parameters:
responseCode
- the response code to be returned to SW application after processing theinvokeCommand
method. Note that the possible values definition and their interpretation are under the responsibility of the applet and the SW application, and the underlying infrastructure will simply pass through this response code.
-
getUUID
public final java.lang.String getUUID()
Returns the UUID of this applet in String representation.- Returns:
- The UUID of this applet in String representation.
-
sendAsynchMessage
public final void sendAsynchMessage(byte[] data, int index, int length) throws UtilException
Sends message to the SW application communicating with this applet via asynchronous interface. Note that if the SW application did not register for receiving asynchronous messages, the message will be silently dropped. In addition, note that this interface should not be used for transferring large amount of data to prevent exhaustion of system resources, but only for notifications.- Parameters:
data
- message dataindex
- index in the message data arraylength
- length of data to be sent- Throws:
UtilOutOfResourcesException
- in case the system has no resources available for sending this message.UtilException
- in case there is a system error.
-
getSessionId
public final int getSessionId(byte[] sessionId, int index)
Return a unique applet session identifier.- Parameters:
sessionId
- output array for storing the session IDindex
- index in the output array- Returns:
- the length of the applet session identifier that was copied into sessionId array
-
getSessionIdLength
public final int getSessionIdLength()
Return the length of applet session identifier.- Returns:
- the length of applet session identifier.
-
-