Dear members,
I have a few queries w.r.t. to the sample implementation of an Applet Proxy Service as
given on JavaWorld.com.
http://www.javaworld.com/javaworld/jw-10-1998/jw-10-javadev_p.html
source code as follows:
protected initialize(CardServiceScheduler scheduler, SmartCard card,
boolean blocking) throws CardServiceException
{
super (BUSINESS_CARD_AID, scheduler, card, blocking);
try {
allocateCardChannel();
...some more code....
} finally {
releaseCardChannel();
}
}
Q1 - should the call to super () not be to super.initialize() ? when I try compiling
this code the compiler gives an error saying "Only constructors can call
constructors"...
Here is the code for exchanging an APDU with the card:
public String getField(int index, int field)
throws CardServiceException, CardTerminalException
{
// Class and instruction byte for the get field command.
final byte[] GET_FIELD_COMMAND_PREFIX = {(byte) 0x80, (byte) 0x02};
try {
allocateCardChannel();
...
// Send command APDU and check the response.
ResponseAPDU response = sendCommandAPDU(getCardChannel(),
BUSINESS_CARD_AID,
getFieldAPDU);
switch (response.sw() & 0xFFFF) {
case OK :
return new String(response.data());
case INDEX_OUT_OF_RANGE :
throw new CardServiceInvalidParameterException("Index out of range");
default :
throw new CardServiceUnexpectedResponseException("RC=" + response.sw());
}
} finally {
releaseCardChannel();
}
}
Q2 - in OCF 1.2 CardChannel's only sendCommandAPDU method takes only a CommandAPDU
parameter. I have written my own CardService which instantiates correctly etc., but
throws an InvalidCardChannelException when trying to send the APDU. Does the
CardChannel have to be allocated each method invocation, or should the one allocated
in the initialize method be stored in some member reference and re-used ?
Here is one example of the offending code:
public boolean doCHV(String PIN)
throws CardServiceException, CardTerminalException
{
try {
allocateCardChannel();
// Class and instruction byte for get command
final byte[] CHV_COMMAND_PREFIX = {(byte) 0x03, (byte) 0x50};
// Set up the CommandAPDU
CommandAPDU doCHVAPDU = new CommandAPDU(9);
doCHVAPDU.append(CHV_COMMAND_PREFIX);
doCHVAPDU.append((byte) 0x00); // reserved
doCHVAPDU.append((byte) 0x00); // reserved
doCHVAPDU.append((byte) 0x04);
doCHVAPDU.append(ByteString.StrToByte(PIN)); // placeholder for PIN
// Send the APDU and check the response
ResponseAPDU response = sendCommandAPDU(doCHVAPDU);
switch (response.sw() & 0xFFFF)
{
case OK:
getMedicalCardState().setCHVPerformed(true);
return true;
case INVALID_CHV:
getMedicalCardState().setCHVPerformed(true);
return false;
case PUK_REQUIRED:
getMedicalCardState().setCardBlocked(true);
throw new CardServiceException("Card is blocked");
default:
throw new CardServiceUnexpectedResponseException("RC=" +
response.sw());
}
}
finally {
releaseCardChannel();
}
}
Sorry for such a long post but I need this fixed ASAP,
Regards
Paul Sheridan
_____________________________________
Get your free E-mail at http://www.ireland.com
---
> 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.