I'm an absolute beginner: I'am only trying to send to the card APDUs in the
format specified in ISO 7816-4, with the PassThruCardService provided by OCF
framework. However I can't find the APDU to create an EF or a DF under the MF.
I obtain several errors, like 6985, 6B00, 6D00, dependig by the command i give:
I've tryied readbinary, writebinary, verify...
> Have you selected the app on the card? Do you need to?
What are "app" I have to select on the card? I'm only searching a command who
allows me to write something, on the card. this is my code:
import opencard.core.service.SmartCard;
import opencard.core.service.CardRequest;
import opencard.core.event.CardTerminalEvent;
import opencard.core.event.CTListener;
import opencard.core.event.EventGenerator;
import opencard.core.terminal.CommandAPDU;
import opencard.core.terminal.ResponseAPDU;
import opencard.core.terminal.CardTerminalException;
import opencard.opt.util.PassThruCardService;
public class Test implements CTListener
{
private PassThruCardService ptcs;
public Test()
{
}
public static void main(String[] args)
{
try
{
Test test = new Test();
SmartCard.start();
EventGenerator.getGenerator().addCTListener(test);
System.out.println( "waiting smart card" );
EventGenerator.getGenerator().createEventsForPresentCards(test); //
Deprecarated
Thread.currentThread().join();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public void cardInserted(CardTerminalEvent ctEvent) throws CardTerminalException
{
System.out.println("Smart Card Inserted");
SmartCard card = SmartCard.getSmartCard(ctEvent,
new CardRequest( CardRequest.ANYCARD, ctEvent.getCardTerminal(), null));
if (card != null)
{
try
{
ptcs =
(PassThruCardService)card.getCardService(PassThruCardService.class, true);
}
catch (Exception ex)
{
ex.printStackTrace( System.err );
}
finally {
try {
byte[] risposta = sendAndCheck( new byte[] {(byte)0x00,
(byte)0x20,
(byte)0x00, (byte)0x01, (byte)0x01, (byte)0xFF } );
for (int i=0; i<risposta.length; i++)
System.out.print(risposta[i] + ", ");
SmartCard.shutdown();
System.out.println( "...shutdown" );
}
catch (Exception e) {
e.printStackTrace( System.err );
}
}
}
}
public void cardRemoved(CardTerminalEvent ctEvent) throws CardTerminalException
{
System.out.println("Smart Card Rimossa");
System.exit(0);
}
/**
* send a cmd APDU to the applet
*/
private byte[] sendAndCheck(byte[] cmd) throws CardTerminalException
{
CommandAPDU apdu;
ResponseAPDU res;
apdu = new CommandAPDU(cmd);
res = ptcs.sendCommandAPDU(apdu);
if (res.sw() != 0x9000)
{
throw new CardTerminalException("SW = 0x" + Integer.toHexString(res.sw()));
}
return res.data();
}
}
Sorry for my ignorance, but my language is not english, and I have many
difficult reading documentation and all the rest.
Thanks if you can help me.
Bye!
---
> Visit the OpenCard web site at http://www.opencard.org/ for more
> information on OpenCard---binaries, source code, documents.
> This list is being archived at http://www.opencard.org/archive/opencard/
! To unsubscribe from the [EMAIL PROTECTED] mailing list send an email
! to
! [EMAIL PROTECTED]
! containing the word
! unsubscribe
! in the body.