1
읽기 Scosta 스마트 카드는 smartcardio 내가 사용하고있는 코드는 내가자바 스마트 카드 - 나는 자바를 통해 표준 'Scosta'스마트 카드를 인도 정부를 읽기 위해 노력하고
package com.example.smartcardreader;
import java.util.List;
import javax.smartcardio.ATR;
import javax.smartcardio.Card;
import javax.smartcardio.CardChannel;
import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;
import javax.smartcardio.CommandAPDU;
import javax.smartcardio.ResponseAPDU;
import javax.smartcardio.TerminalFactory;
public class SmartCardReader {
public static void main(String[] args) {
try{
// show the list of available terminals
TerminalFactory factory = TerminalFactory.getDefault();
List<CardTerminal> terminals = factory.terminals().list();
System.out.println("Terminals: " + terminals);
// get the first terminal
CardTerminal terminal = terminals.get(0);
// establish a connection with the card
Card card = terminal.connect("*");
System.out.println("card: " + card);
// get the ATR
ATR atr = card.getATR();
byte[] baAtr = atr.getBytes();
System.out.print("ATR = 0x");
for(int i = 0; i < baAtr.length; i++){
System.out.printf("%02X ",baAtr[i]);
}
CardChannel channel = card.getBasicChannel();
byte[] cmdApduGetCardUid = new byte[]{
(byte)0xFF, (byte)0xCA, (byte)0x00, (byte)0x00, (byte)0x00};
ResponseAPDU respApdu = channel.transmit(
new CommandAPDU(cmdApduGetCardUid));
if(respApdu.getSW1() == 0x90 && respApdu.getSW2() == 0x00){
byte[] baCardUid = respApdu.getData();
System.out.print("Card UID = 0x");
for(int i = 0; i < baCardUid.length; i++){
System.out.printf("%02X ", baCardUid [i]);
}
}
card.disconnect(false);
} catch (CardException e) {
e.printStackTrace();
}
}
}
입니다 Mac 컴퓨터에서 개발 용 eclipse IDE 사용. 이 코드를 실행하면 터미널을 읽을 수 없어 예외가 발생합니다. USB 카드 판독기가 있고 스마트 카드를 넣었습니다. 정확하게 잘못 될 수 있음을 지적 해 주시겠습니까? 미리 감사드립니다.
독자와 함께 작업 할 수 있다면 다른 응용 프로그램을 사용해 보셨습니까? 드라이버를 설치하기 만하면됩니다. – jariq
Netbeans 및 그 작동과 Windows 컴퓨터에서 동일한 코드를 시도했다. 문제는 제 환경입니다. USB 드라이버가 올바르게 설치되어 있으며 연결된 장치 목록에도 표시됩니다. 지금 어떻게해야합니까? –
사용중인 OS X 및 Java의 버전은 무엇입니까? – jariq