You Are Here:

Community: Wiki

This page was last modified on 10 June 2009, at 11:08.

NFC Secure Element Example Java Card for Emulator

From Forum Nokia Wiki

This is the code for the JAR file in order to emulate a smartcard (JavaCard) in the Nokia 6131 Emulator (no other emulator is supporting this example!). Click in the emulator on Internal Secure Card => Edit => and then chose the JAR compiled out of this code. Download appropriate NetBeans Project: File:TicketEmulation6131.zip.

package at.nfcresearch.wima.examples;
 
import com.nokia.phone.sdk.concept.srv.modules.nfc.cards.SecureCard;
 
public class TicketSmartCard extends SecureCard {
// Command (APDU INS) for increading the value in the wallet
private final static byte INS_INC = 0x01;
 
// Command (APDU INS) for decreading the value in the wallet
private final static byte INS_DEC = 0x02;
 
// command (APDU INS) for reading the value in the wallet
private final static byte INS_READ = 0x03;
 
// variable holding the amount stored in the wallet.
private byte value = (byte) 0x20;
private static byte APDU_OK[] = {(byte) 0x90, 0x00};
private static byte APDU_NOT_OK[] = {0x69, 0x00};
 
public TicketSmartCard() {
super();
}
 
public byte[] exchangeData(byte[] buf) {
byte cmd = buf[1];
switch (cmd) {
case INS_INC:
if (value < 0xff) {
value++;
}
return APDU_OK;
 
case INS_DEC:
if (value > 0x00) {
value--;
}
return APDU_OK;
 
case INS_READ:
byte[] outBuffer = {value, APDU_OK[0], APDU_OK[1]};
return outBuffer;
}
 
return APDU_NOT_OK;
}
 
// Implemeation of Interface SecureCard
public void createCardUID() {
setCardUID("abcd");
 
}
 
// Implemeation of Interface SecureCard
public void initSecureCard() {
System.out.println("InnerCard initialized");
}
 
 
}

And here is the code for the Nokia 6212 SDk

/**
* @author Gerald Madlmayr
* NFC Research Lab Hagenberg, www.nfc-research.at
* @version 1.0
*
* Simulation of a SmartCard for the Emulator
*/

 
package at.nfcresearch.wima.examples;
 
 
import com.nokia.nfcsdk.nfcmgr.plugin.ISmartCardPluginData;
import com.nokia.nfcsdk.nfcmgr.plugin.SmartCardPlugin;
 
public class TicketSmartCard extends SmartCardPlugin {
// Command (APDU INS) for increading the value in the wallet
private final static byte INS_INC = 0x01;
 
// Command (APDU INS) for decreading the value in the wallet
private final static byte INS_DEC = 0x02;
 
// command (APDU INS) for reading the value in the wallet
private final static byte INS_READ = 0x03;
 
// variable holding the amount stored in the wallet.
private byte value = (byte) 0x20;
 
private static byte APDU_OK[] = {(byte)0x90, 0x00};
private static byte APDU_NOT_OK[] = {0x69, 0x00};
 
public TicketSmartCard() {
 
}
 
public byte[] exchangeData(byte[] buf) throws Exception {
byte cmd = buf[1];
switch(cmd) {
case INS_INC:
if (value < 0xff)
value++;
return APDU_OK;
 
case INS_DEC:
if (value > 0x00)
value--;
return APDU_OK;
 
case INS_READ:
byte[] outBuffer = {value, APDU_OK[0], APDU_OK[1]};
return outBuffer;
}
 
return APDU_NOT_OK;
}
 
public String getName() {
return "TicketSmartCard";
}
 
public void initialize(ISmartCardPluginData data) throws Exception {
super.initialize(data);
}
 
public void uninitialize() {
}
}

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fTalkE3aE4cargeE5fscreenE5fsaverX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ
User Rating: qfnZuserE5FratingQNx5E2E0000X