Using javax.smartcardio from openjdk7-darwin-i386-20080820
Nick Hilhorst
nick.hilhorst at orange.nl
Mon Aug 25 13:47:12 PDT 2008
Hi,
I have some code that uses javax.smartcardio that works on Windows,
but fails when I try to run it on the version of Java 6 from Apple
(same problems as described on http://lists.apple.com/archives/java-dev/2008/May/msg00144.html)
, so I decided to give the binary version of openjdk7-darwin-
i386-20080820 as built by Landon Fuller a try. Here follows my code
for getting the list of configured readers:
/**
*
* @return List of references to the readers configured in the
environment
*
* @throws CardException
*/
private static List<CardTerminal> getTerminals() throws CardException {
List<CardTerminal> terminals = null;
try {
TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null);
// TerminalFactory factory = TerminalFactory.getDefault();
System.out.println("TerminalFactory Type: " + factory.getType());
// Get the list of readers configured in the environment
terminals = factory.terminals().list();
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return terminals;
}
This fails with the following:
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.Chipknip.getTerminals(Chipknip.java:149)
at com.ongelooflijk.chipknip.Chipknip.main(Chipknip.java:29)
Caused by: java.lang.UnsupportedOperationException: PC/SC not
available on this platform
at sun.security.smartcardio.PCSC.checkAvailable(PCSC.java:48)
at sun.security.smartcardio.SunPCSC$Factory.<init>(SunPCSC.java:59)
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)
... 5 more
Caused by: java.io.IOException: No PC/SC library found on this system
at
sun.security.smartcardio.PlatformPCSC.getLibraryName(PlatformPCSC.java:
116)
at sun.security.smartcardio.PlatformPCSC.access$000(PlatformPCSC.java:
43)
at sun.security.smartcardio.PlatformPCSC$1.run(PlatformPCSC.java:63)
at sun.security.smartcardio.PlatformPCSC$1.run(PlatformPCSC.java:59)
at java.security.AccessController.doPrivileged(Native Method)
at sun.security.smartcardio.PlatformPCSC.<clinit>(PlatformPCSC.java:59)
at sun.security.smartcardio.SunPCSC$Factory.<init>(SunPCSC.java:59)
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)
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 javax.smartcardio.TerminalFactory.<clinit>(TerminalFactory.java:106)
... 2 more
When I browse the source I see that it most probably fails because it
was unable to load the library "j2pcsc". I did some googling and found
that on OS X this means that through JNI it is looking for
libj2pcsc.jnilib. But the only file I can find in the code distributed
by Landon Fuller is libj2pcsc.dylib, which I understand to be an OS X
Dynamic Library similar to a DLL on windows. I have the feeling this
is more of an issue with the build from Landon than with the OpenJDK 7
bsd port, but I'm a complete noob in these matters, so I think I'd
best leave it up to the experts to figure this one out.
I don't think this is relevant for this problem, but I'll mention it
anyway: I'm using an Omnikey CardMan 3121 and have the Smart Card
Services Update v1.1 from Shawn A. Geddis installed. The reader seems
to work fine and running pcsctest gives the expected output for the
reader as well as the inserted card.
Thanks,
Nick Hilhorst
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/bsd-port-dev/attachments/20080825/c3981d49/attachment.html
More information about the bsd-port-dev
mailing list