SSE4E

Home

GPError
GPSystem
ByteString
ByteBuffer
TLV
TLVList
Card
Atr
Key
Crypto
Application GPApplication GPSecDomain

ASN1
CardFile
IsoSecureChannel
ApplFactory
GPXML
JsScript
CardSim

X509
CRL
KeyStore
CMSSignedData
CMSGenerator
XMLSignature
OCSPQuery
LDAP
SOAP
URLConnection

PKCS11Provider
PKCS11Session
PKCS11Object

OutlineNode

OpenSCDP

CardSimulationAdapter - Reference Documentation

Class to control a card simulation adapter that forwards APDUs to a script implementation

Index of Methods

Constructor

Prototype

CardSimulationAdapter(String adapter, String parameter)

Description

Create a new card simulation adapter.

Currently only the JCOP Simulation adapter is available. It is configured as adapter name "JCOPSimulation" with the port number as parameter.

Arguments

TypeNameDescription
StringadapterName of the simulation adapter
StringsourceThe parameter used to initialise the adapter

Exceptions

NameValueDescription
GPErrorGPError.ARGUMENTS_MISSINGToo few arguments in call
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.INVALID_TYPEType of argument is invalid for call

Example


var sa = new CardSimulationAdapter("JCOPSimulation", "8050");

setSimulationObject()

Prototype

void setSimulationObject(Object simulation)

Description

Set the object that receives reset() and processAPDU() calls from the card simulation adapter.

The simulation object must implement the following methods:

void reset(Number coldOrWarm); ByteString processAPDU(ByteString capdu);

The parameter coldOrWarm allows to differentiate between a cold and a warm reset. This parameter is currently always 0 (cold reset).

The parameter capdu contains the raw command APDU, including CLA, INS, P1, P2 and conditionally the Lc, Command Data and Le field.

The processAPDU() method must return the response APDU as ByteString object, with the conditional response data field and the trailer bytes SW1/SW2.

Arguments

TypeNameDescription
ObjectsimulationThe object that implements the card simulation

Return

Exceptions

NameValueDescription
GPErrorGPError.ARGUMENTS_MISSINGToo few arguments in call
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.INVALID_TYPEType of argument is invalid for call

Example


// Create a very simple card simulator
var simulationObject = new Object();

// The simulator needs a processAPDU method
simulationObject.processAPDU = function(capdu) {
	print("Received APDU: " + capdu);
	var rapdu = capdu.concat(new ByteString("9000", HEX));
	return rapdu;
}

// The simulator needs a reset method
simulationObject.reset = function(type) {
	print("Reset type: " + type);
	var atr = new ByteString("3B600000", HEX);
	return atr;
}

sa.setSimulationObject(simulationObject);

start()

Prototype

void start()

Description

Starts the simulator adapter.

If the adapter is already running, it is stopped first.

Return

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call

Example


sa.start();

var card = new Card("JCOPSimulation");

var atr = card.reset(Card.RESET_COLD);

print(atr);

assert(atr.toByteString().toString(HEX) == "3B600000");

var rapdu = card.sendApdu(0x00, 0x10, 0x01, 0x02, new ByteString("1234", HEX), [0x9000]);

assert(rapdu.toString(HEX) == "00100102021234");

stop()

Prototype

void stop()

Description

Stops the simulator adapter.

Return

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call

Example


sa.stop();