You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Mark Thomas (JIRA)" <ji...@apache.org> on 2019/04/25 19:31:00 UTC

[jira] [Resolved] (DAEMON-389) JnaPCSCException when using jnasmartcardio

     [ https://issues.apache.org/jira/browse/DAEMON-389?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Thomas resolved DAEMON-389.
--------------------------------
    Resolution: Not A Bug

There is insufficient information in this bug report to enable the problem to be reproduced.

It appears you are using the GlobalPlatform library. That library requires native DLLs. It appears these are not correctly configured in the Daemon case.

The users list is the place to get help.

> 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
>            Priority: Critical
>              Labels: newbie
>
> 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)