Posted By:
madhusudhan_v
Posted On:
Friday, January 23, 2009 06:01 AM
Hi All, My Environment is jdk1.5.0_12 jre1.5.0_12 Gemalto GemCombiXpresso R4 GPShell 1.4.2.0 & Global Platform Windows Xp Pro I have sucessfully loaded many applets into the Javacard with the above setup. Currently i am trying to create a shareable interface class and load it to the card. When i try to load the packages created by the shaeable interface and applet packagesassociated with the shareable interface i am getting the following error in GPShell prompt "load_applet() returns 0x80206985 (6985: Command not allowed - Conditions of use not satisfied.)" The Procedure Followed
More>>
Hi All,
My Environment is
jdk1.5.0_12
jre1.5.0_12
Gemalto GemCombiXpresso R4
GPShell 1.4.2.0 & Global Platform
Windows Xp Pro
I have sucessfully loaded many applets into the Javacard with the above setup.
Currently i am trying to create a shareable interface class and load it to the card.
When i try to load the packages created by the shaeable interface and applet packagesassociated with the shareable interface i am getting the following error in GPShell prompt
"load_applet() returns 0x80206985 (6985: Command not allowed - Conditions of use not satisfied.)"
The Procedure Followed
1) Created three java files as below
server.java-The server applet which implements the shareable object.
client.java- The Aplet which uses the shareable interface object.
shareable.java- The shareable interface package.
2) Compiled them sucessfuly
3) converted the class files to cap files sucessfully
4) generated the bin files required for loading by following steps given in gpshell doc.
5) Failed to load applets into the card ("load_applet() returns 0x80206985 (6985: Command not allowed - Conditions of use not satisfied.)
The Code for each of this files is attached,
Kindly let me know if i am wrong at any stage
Also i was not able to load any packages other than applets into the card, is there a different process
to be followed to upload packages.
The Code for each of this files is as shown below
Shareable.java
package com.sun.javacard.samples.ShareableInterfaceTest.ShareableInterFace;
import javacard.framework.*;
public interface ShareableInterFace extends Shareable
{
public void grantMiles (short amount);
}
server.java
package com.sun.javacard.samples.ShareableInterfaceTest.Server; // Folder Name Where the java file is located
import javacard.framework.*;
import com.sun.javacard.samples.ShareableInterfaceTest.ShareableInterFace.*;// importing the shareable interface class package
public class Server extends Applet implements ShareableInterFace // Server is the java file name
{
public Server (byte[] bArray,short bOffset,byte bLength)
{
register();
}
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new Server(bArray, bOffset, bLength);
}
public void process(APDU apdu)
{
byte[] buffer = apdu.getBuffer();
if (buffer[ISO7816.OFFSET_INS] == (byte)(0xA4))
{
return;
}
switch (buffer[ISO7816.OFFSET_INS])
{
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
} // end of process method
short Miles=1000;
public Shareable getShareableInterfaceObject(AID client_aid, byte parameter)
{
return this;
}
public void grantMiles(short amount)
{
Miles=(short)(Miles+amount);
}
}
client.java
package com.sun.javacard.samples.ShareableInterfaceTest.Client; // Folder Name Where the java file is located
import javacard.framework.*;
import com.sun.javacard.samples.ShareableInterfaceTest.ShareableInterFace.*; // shareable interface class file import
public class Client extends Applet
{ // ECouponjava1 is the java file name
private static final byte[] SERVER_AID = {(byte)0xA0, (byte)0x00,
(byte)0x00, (byte)0x00,(byte)0xff, (byte)0xff
};
private Client (byte[] bArray,short bOffset,byte bLength)
{
register();
} // end of the constructor
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new Client(bArray, bOffset, bLength);
}
public void process(APDU apdu)
{
byte[] buffer = apdu.getBuffer();
// process the received APDUs
}
private void TestSIO(APDU apdu)
{
byte[] buffer = apdu.getBuffer();
AID JCRec_ServerAID= JCSystem.lookupAID(SERVER_AID,(short)0,(byte)SERVER_AID.length);
if(JCRec_ServerAID==null)
ISOException.throwIt(SW_APP_DN_EXIST);
ShareableInterFace sio= (ShareableInterFace)JCSystem.getAppletShareableInterfaceObject(JCRec_ServerAID,(byte)0);
short amt=100,AmtCal=0;
sio.grantMiles((short)amt);
short le = apdu.setOutgoing();
apdu.setOutgoingLength((byte)2);
buffer[0] = (byte)(AmtCal >> 8);
buffer[1] = (byte)(AmtCal & 0xFF);
apdu.sendBytes((byte)0, (byte)2);
}
} //
The Cap file conversion files are as below
server
-out CAP
-exportpath .
-applet 0xA0:0x00:0x00:0x00:0xff:0xff
com.sun.javacard.samples.ShareableInterfaceTest.Server.Server
com.sun.javacard.samples.ShareableInterfaceTest.Server
0xA0:0x00:0x00:0x00:0xff:0xff:0x50:0x4b:0x47 1.0
client
-out CAP EXP JCA
-exportpath .
-applet 0xA0:0x00:0x00:0x00:0xff:0x00
com.sun.javacard.samples.ShareableInterfaceTest.Client.Client
com.sun.javacard.samples.ShareableInterfaceTest.Client
0xA0:0x00:0x00:0x00:0xff:0x00:0x50:0x4b:0x47 1.0
shareable
-out CAP EXP JCA
-exportpath .
com.sun.javacard.samples.ShareableInterfaceTest.ShareableInterFace
0xA0:0x00:0x00:0x00:0xff:0xfe:0x50:0x4b:0x47 1.0
<<Less