-
-
Notifications
You must be signed in to change notification settings - Fork 4
Java Code Tutorial, Intermediate
AbstractTCPAdapter implementations exist for vsmartcard and Oracle Java Card SDK simulator.
Once you've created the simulator, pass in the necessary host (which default to 0.0.0.0 when listening and 127.0.0.1 when connecting) and port parameters.
VirtualCardEngine sim = JavaCardEngine.create();
// Set up the virtual card as needed with sim.installApplet();
AbstractTCPAdapter adapter = new VSmartCardClient("192.168.100.1", 26394, sim);It is intended to run in a thread, and will pass the commands from the remote side to your applet(s).
ExecutorService executor = Executors.newSingleThreadExecutor();
executor.submit(adapter);The adapter can be tuned to expose a specific protocol via the PC/SC adapter or to have a specific ATR.
adapter = adapter.withProtocol("T=CL"); // Applets will see all APDU-s as from contactless A interface
adapter = adapter.withATR(Hex.decode("XXYY")); // PC/SC driver will report XXYY as ATR to applications
adapter = adapter.withHost("192.168.100.1"); // Override the default host (either 0.0.0.0 or 127.0.0.1)
adapter = adapter.withPort(38712); // Override the default portYou can fetch the applet instance for debugging purposes with sim.getApplet(AID aid). If the applet was installed with installExposedApplet() public fields can be accessed directly. Otherwise just a proxy of the Applet class is returned.
-
JavaCardEngine(installing/deleting applets etc) should NOT be used from multiple threads, but only from the thread that calledJavaCardEngine.create() - Accessing a single
JavaCardEngineconcurrently from multiple threads via acquiredEngineSessionobjects via.connect()methods is thread-safe - Like a real Java Card,
JavaCardEngineis in essence a single-threaded resource
Continue with Java Code Tutorial, Advanced.
javacard.pro - custom JavaCard applet development services · Editing locked due to malicious SPAM, sorry :(