Skip to Main Content

Java Card

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

APDU reading mart card serial number PROBLEM !!!!!!!!

843851Nov 2 2009 — edited Nov 3 2009
Hi.
I want to read serial number from smart card with help of OCF and reader.
But I can not find solution?

The next piece o code returns:

sw1 = 6d +>>>>>>>> Card does not support instruction class+
sw2 = 00
data = null
import opencard.core.event.CTListener;
import opencard.core.event.CardTerminalEvent;
import opencard.core.event.EventGenerator;
import opencard.core.service.SmartCard;
import opencard.core.terminal.CardTerminal;
import opencard.core.terminal.CommandAPDU;
import opencard.core.terminal.ResponseAPDU;
import opencard.opt.util.PassThruCardService;

public class Listener implements CTListener {
	private SmartCard smartcard = null;
	private CardTerminal terminal = null;
	private int slotID = 0;

	public void register() {
		EventGenerator.getGenerator().addCTListener(this);
		try {
			EventGenerator.getGenerator().createEventsForPresentCards(this);
		} catch (Exception e) {
			e.printStackTrace(System.err);
			unregister();
		}
	}

	public void unregister()

	{
		EventGenerator.getGenerator().removeCTListener(this);
	}

	public void cardInserted(CardTerminalEvent event) {
	
		try {
			smartcard = SmartCard.getSmartCard(event);

			PassThruCardService ptcs = (PassThruCardService) smartcard
					.getCardService(PassThruCardService.class, true);

		
			PassThruCardService ptcs = (PassThruCardService) smartcard
					.getCardService(PassThruCardService.class, true);

			CommandAPDU  apdu = new CommandAPDU(0x0045);


			ResponseAPDU res = ptcs.sendCommandAPDU(apdu);

			System.out.print(apdu.toString() + res.toString());

			System.out.printf("sw1 = %02x\n", res.sw1());
			System.out.printf("sw2 = %02x\n", res.sw2());
			System.out.println("data = " + res.data());

			

			terminal = event.getCardTerminal();
			slotID = event.getSlotID();
		} catch (Exception e) {

			e.printStackTrace();
		}
	}

	public void cardRemoved(CardTerminalEvent event) {
		
	}
}
Can anybody help me?
Thank in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 1 2009
Added on Nov 2 2009
18 comments
2,345 views