Using javax.smartcardio from openjdk7-darwin-i386-20080820
Nick Hilhorst
nick.hilhorst at orange.nl
Sat Sep 6 06:59:14 PDT 2008
If you are running your own pcscd you need to set the Java system
property sun.security.smartcardio.library to the location of your PC/
SC library (as described on http://java.sun.com/javase/6/docs/technotes/guides/security/SunProviders.html#SunPCSCProvider)
. I did this by adding the following as a Default VM Argument in
Eclipse:
-Dsun.security.smartcardio.library=/usr/local/lib/libpcsclite.dylib
This definitely changed something for the better, but I'm not
completely there yet. I now get the following exceptions:
java.security.NoSuchAlgorithmException: Error constructing
implementation (algorithm: PC/SC, provider: SunPCSC, class:
sun.security.smartcardio.SunPCSC$Factory)
at java.security.Provider$Service.newInstance(Provider.java:1257)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:243)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:190)
at javax.smartcardio.TerminalFactory.getInstance(TerminalFactory.java:
243)
at com.ongelooflijk.chipknip.LoadTest.main(LoadTest.java:19)
Caused by: sun.security.smartcardio.PCSCException: SCARD_E_NO_SERVICE
at sun.security.smartcardio.PCSC.SCardEstablishContext(Native Method)
at
sun.security.smartcardio.PCSCTerminals.initContext(PCSCTerminals.java:
56)
at sun.security.smartcardio.SunPCSC$Factory.<init>(SunPCSC.java:60)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun
.reflect
.NativeConstructorAccessorImpl
.newInstance(NativeConstructorAccessorImpl.java:57)
at
sun
.reflect
.DelegatingConstructorAccessorImpl
.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
at java.security.Provider$Service.newInstance(Provider.java:1252)
... 4 more
I'm testing with the following program:
package com.ongelooflijk.chipknip;
import java.security.NoSuchAlgorithmException;
import java.util.Iterator;
import java.util.List;
import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;
import javax.smartcardio.TerminalFactory;
public class LoadTest {
/**
* @param args
*/
public static void main(String[] args) {
List<CardTerminal> terminals = null;
try {
TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null);
System.out.println("TerminalFactory Type: " + factory.getType());
// Get the list of readers configured in the environment
terminals = factory.terminals().list();
for (Iterator<CardTerminal> iter = terminals.iterator();
iter.hasNext();)
System.out.println("Terminal: " + iter.next());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (CardException e) {
e.printStackTrace();
}
}
}
If anyone has ideas they're more than welcome. I don't really think
this has anything to do with openjdk anymore. I have the feeling that /
usr/local/lib/libpcsclite.dylib somehow doesn't work with the pcscd
that is installed, but I have no idea how to check this. I know pcscd
is running and working, because pcsctest still gives the expected
results.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/bsd-port-dev/attachments/20080906/cde46388/attachment.html
More information about the bsd-port-dev
mailing list