JNI2CTAPI Driver Version 1.1.0
for Linux and
Windows 9x/NT/2000
© 2000 CardContact Software & System Consulting
Requirements:
JDK 1.2.2 or higher
gcc version 2.90 or higher (for Linux) / Watcom C/C++ Version 10.0 or higher (for Win32)
a
shared lib or DLL containing the CTAPI-interface
(for ORGA´s
ECO5000 card reader take a look at www.cardcontact.de)
OpenCard
Framework V1.2 (only used by the test-program)
If you have any problems with this package feel
free to contact us at info@cardcontact.de.
There is a fully functional version of this driver already included in this package. You do not need to recompile it yourself (but you can).
Take a look at the following sections how to install this driver on your operating system.
For Linux:
Installation:
Extract the files using "tar -xzf jni2ctapi.tar.gz". Then login as
"root", change
your directory to JNI2CTAPI and type "make install" to copy the
"libjni2ctapi.so" into
$(JAVA_HOME)/jre/lib/i386 (Make sure that JAVA_HOME is set correctly
to your Java directory, e.g. /usr/local/jdk1.2.2).
Then add the file "jni2ctapi.jar" located in the
JNI2CTAPI-home-directory to your CLASSPATH. This makes the JNI
classes available for the java environment.
Build:
Extract the files using "tar -xzf jni2ctapi.tar.gz". Change your
directory to JNI2CTAPI and type "make".
If the compiler completes, follow the steps described above.
For Windows 9x/NT/2000:
Installation:
Extract all the files using WinZIP or any other program that can handle
zipped TAR-files.
Then copy the »jni2ctapi.dll« file located in the "\windows"-directory
of this package to your WINDOWS\system
directory.
Furthermore add the file "jni2ctapi.jar" to
your CLASSPATH.
Build:
Extract all the files using WinZIP or any other program that can handle
zipped TAR-files.
A project file for Watcom C/C++ is located in the
windows-directory of this package. There should be no problem using
another C-compiler (like Visual Studio, Borland C++, etc.) to compile
this package. Just add the files »ctapi_wrapper.cpp« and
»dllproxy.c« to your project and compile it as a DLL. Furthermore type »make jni2ctapi.jar« in a
command shell. This will create the JAR-archive containing the
JNI-interface.
Then follow the steps described above.
Testing:
A small test file has been included, which you can build with "make test". This program was tested with ORGA´s ECO 5000 card reader but it
should work with almost every kind of CTAPI programmed in accordance to the MCT
specs.
Connect the ECO 5000 reader to your PC. Insert a card and type "java test_ctapi". The program will reset the card, display the ATR and
issue a SELECT MF command (which should response with 6xxx or 9xxx).
Finally the EJECT ICC command is sent to the card terminal.
If the test program was successful, the JNI2CTAPI interface was set up correctly. You can now use the CTAPI interface to develop JAVA applications accessing smartcards through CTAPI.
The JNI2CTAPI driver implements the CTAPI-interface according to the MKT
specifications. Due to limitations of the JNI the length of response
byte is returned through the return value of CT_Data (see
documentation).
All files are packed in the package "de.cardcontact.jni2ctapi".
(For example de.cardcontact.jni2ctapi.cardterminal_api; )
Constructor for the JNI2CTAPI interface.
|
cardterminal_api (String readername) |
---|---|
readername |
Name of the shared lib containing the CTAPI-functions; |
The CT_Init function opens and initializes the card reader. This function must be called at first.
|
int CT_Init (char ctn, char pn) |
---|---|
ctn |
number of the card terminal |
pn |
port number of the terminal (e.g. 0 = /dev/ttyS0) |
return value |
< 0 : an error occured = 0 : card terminal successfully opened |
The CT_Close function closes the connection to the card reader.
|
int CT_Close (char ctn) |
---|---|
ctn |
number of the card terminal |
return value |
< 0 : an error occured = 0 : card terminal successfully closed |
The CT_Data function sends and receives data from the card.
|
int CT_Data (char ctn,
byte dad, byte sad, int lenc,
|
---|---|
ctn |
number of the card terminal |
dad |
destination address |
sad |
source address |
lenc |
Length of the following command |
command |
the command |
lenr |
length of the response buffer |
response |
the response buffer |
return |
< 2 : an error occured >= 2 : success, return value = number of bytes received, length of response |