Miguel Febres created DAEMON-389:
------------------------------------
Summary: JnaPCSCException when using jnasmartcardio
Key: DAEMON-389
URL: https://issues.apache.org/jira/browse/DAEMON-389
Project: Commons Daemon
Issue Type: Bug
Components: Jsvc
Environment: MacOS Sierra 10.12.4
Reporter: Miguel Febres
The following code works properly when running the JAR directly in console. The
connection to the smart card reader works fine and the card info is printer on
screen.
{code:java}
public static void main(String[] args) throws CardException, GPException,
NoSuchAlgorithmException {
GlobalPlatform gp;
Card card;
CardTerminal terminal = TerminalManager.getTheReader(null);
card = terminal.connect("*");
card.beginExclusive();
gp = new GlobalPlatform(card.getBasicChannel());
gp.select(null);
byte[] info = gp.getCPLC();
String cardInfo = HexUtils.encodeHexString_imp(info);
card.disconnect(true);
System.out.println("Hexa Card Info: " + cardInfo);
}
{code}
However, when using JSVC to launch the JAR as a daemon, I get a
JnaPCSCException (SCardEstablishContext got response 0x8010001d
(SCARD_E_NO_SERVICE: The Smart card resource manager is not running.)
The full code is:
{code:java}
package com.st.simple.card.client;
import java.security.NoSuchAlgorithmException;
import javax.smartcardio.Card;
import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;
import org.apache.commons.daemon.Daemon;
import org.apache.commons.daemon.DaemonContext;
import org.apache.commons.daemon.DaemonInitException;
import apdu4j.HexUtils;
import apdu4j.TerminalManager;
import pro.javacard.gp.GPException;
import pro.javacard.gp.GlobalPlatform;
public class Client implements Daemon {
public static void main(String[] args) throws CardException,
GPException, NoSuchAlgorithmException {
GlobalPlatform gp;
Card card;
CardTerminal terminal = TerminalManager.getTheReader(null);
card = terminal.connect("*");
card.beginExclusive();
gp = new GlobalPlatform(card.getBasicChannel());
gp.select(null);
byte[] info = gp.getCPLC();
String cardInfo = HexUtils.encodeHexString_imp(info);
card.disconnect(true);
System.out.println("Hexa Card Info: " + cardInfo);
}
@Override
public void destroy() {
// TODO Auto-generated method stub
}
@Override
public void init(DaemonContext arg0) throws DaemonInitException,
Exception {
// TODO Auto-generated method stub
}
@Override
public void start() throws Exception {
// TODO Auto-generated method stub
main(null);
}
@Override
public void stop() throws Exception {
// TODO Auto-generated method stub
}
}
{code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)