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

GPSystem - Reference Documentation

Class implementing the Global Platform GPSystem class

Index of Methods

Constructor

Prototype

None

Description

The GPSystem class only provides class functions. No objects can be instantiated.

Exceptions

NameValueDescription

Example


getVersion()

Prototype

String getVersion()

Description

Retrieve the version of the Global Platform Scripting specification implemented by the runtime.

Return

StringString containing the version number

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call

Example


version = GPSystem.getVersion();

assert(version == "1.1.0");

wait()

Prototype

wait(Number ms)

Description

Wait for a specified period

Arguments

TypeNameDescription
NumbermsThe time to wait in milliseconds

Return

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.ARGUMENTS_MISSINGToo few arguments in call
GPErrorGPError.INVALID_DATAThe argument stringValue contains characters not compatible with the encoding format
GPErrorGPError.INVALID_TYPEType of argument is invalid for call

Example


start = new Date().valueOf();
waitingTime = 1000;

GPSystem.wait(waitingTime);

stop = new Date().valueOf();
elapsed = stop - start;

// Allow a tolerance of 10 ms
print("Wait: " + waitingTime + " ms / Elapsed: " + elapsed + " ms");
assert(((elapsed - 50) <= waitingTime) && ((elapsed + 50) >= waitingTime));

trace()

Prototype

boolean trace(Object o)

Description

Append data to the trace file by calling the objects "toString()" method.

Arguments

TypeNameDescription
ObjectoThe object to trace

Return

BooleanBoolean value indicating the success (true) or failure (false) of the tracing

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.ARGUMENTS_MISSINGToo few arguments in call
GPErrorGPError.INVALID_DATAThe argument stringValue contains characters not compatible with the encoding format
GPErrorGPError.INVALID_TYPEType of argument is invalid for call

Example


rval = GPSystem.trace("Testoutput from GPSystem.trace()");
// assert(rval == true);

try {
	GPSystem.trace(null);
}
catch (e) {
	assert(e instanceof GPError);
	assert(e.error == GPError.INVALID_TYPE);
}

isTraceOn()

Prototype

boolean isTraceOn()

Description

Return true if the trace is enabled.

Return

BooleanBoolean value indicating if tracing is enabled

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call

Example


assert(typeof(GPSystem.isTraceOn()) == "boolean");

markTrace()

Prototype

markTrace()

Description

Mark the current position in the trace output for later retrieval of trace output using the copyTrace() method.

Return

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call

Example


GPSystem.markTrace();

copyTrace()

Prototype

String copyTrace()

Description

Return the trace starting with the position marked with the markTrace() method up to the very last entry.

Return

StringCopy of the recent trace entries or null if unsupported

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call

Example


var msg ="Hello World"; 
GPSystem.trace(msg);
var t = GPSystem.copyTrace();

if (t != null) {
	assert(t == msg + "\n");
}


getVendorObject()

Prototype

getVendorObject(String objectName)

Description

Retrieve a vendor specific object

Arguments

TypeNameDescription
StringobjectNameThe name of the object

Return

ObjectThe created object

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call
GPErrorGPError.ARGUMENTS_MISSINGToo few arguments in call
GPErrorGPError.INVALID_TYPEType of argument is invalid for call
GPErrorGPError.OBJECTCREATIONFAILEDThe desired object could not be created

Example


try {
	obj = GPSystem.getVendorObject("myObject");
}
catch (e) {
	assert(e instanceof GPError);
	assert(e.error == GPError.OBJECTCREATIONFAILED);
}

getSystemID()

Prototype

getSystemID()

Description

Get the ID of the system.

For the smart card development platform a unique object identifier is returned.

It has the following components: OpenSCDP.Runtime.MajorVersion.MinorVersion.Build.SerialNumber.

Return

ByteStringThe ID of the system or null if none available

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call

Example


var id = GPSystem.getSystemID();
print(id);
var s = id.toString(OID).split(".");

print("Runtime : " + s[s.length - 5]);
print("Major   : " + s[s.length - 4]);
print("Minor   : " + s[s.length - 3]);
print("Build   : " + s[s.length - 2]);
print("Serial  : " + s[s.length - 1]);


dateTimeByteString()

Prototype

dateTimeByteString()

Description

Return a ByteString containing the current date and time

Return

ByteStringThe current date and time

Exceptions

NameValueDescription
GPErrorGPError.INVALID_ARGUMENTSToo many arguments in call

Example


time = GPSystem.dateTimeByteString();
assert(time != null);
assert(time instanceof ByteString);

mapFilename()

Prototype

mapFilename(String filename, Number location)

mapFilename(String filename)

Description

Searches for a file at the given location and maps the filename to the system specific absolute path.

If no location is specified the function uses the default location identifier GPSystem.AUTO.

Arguments

TypeNameDescription
StringfilenameFilename
NumberlocationLocation indicator (GPSystem.CWD, GPSystem.USR, GPSystem.SYS, GPSystem.AUTO)

Return

StringAbsolute path of the file. Null if the file was not found.

Exceptions

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

Example


absFilename = GPSystem.mapFilename("config.js", GPSystem.SYS);
assert(absFilename != null);

absFilename = GPSystem.mapFilename("config.js");
assert(absFilename != null);

absFilename = GPSystem.mapFilename("novalidfile.js");
assert(absFilename == null);