Using javax.smartcardio from openjdk7-darwin-i386-20080820
Nick Hilhorst
nick.hilhorst at orange.nl
Fri Oct 24 11:50:08 PDT 2008
Yesterday I finally got javax.smartcardio to work from both soylatte
1.6 as well as openjdk 7. The solution was setting the Java system
property sun.security.smartcardio.library to /System/Library/
Frameworks/PCSC.framework/PCSC, which I did by adding the following as
a Default VM Argument in Eclipse:
-Dsun.security.smartcardio.library=/System/Library/Frameworks/
PCSC.framework/PCSC
I vaguely remember that I came across some code, as I was going
through the java sources, where several default locations for
libpcsclite were probed. For a native darwin port it might be useful
to change one of these to the library mentioned above.
By the way, this still won't work from the Java 6 version provided by
Apple, because Java is 64 bit and the library is 32 bit and PPC only.
On Sep 6, 2008, at 15:59 , Nick Hilhorst wrote:
> 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/20081024/facb7470/attachment.html
More information about the bsd-port-dev
mailing list