Java programming for cards

Asked

Viewed 267 times

0

Hello,
I have a KDE KT-2280 magnetic card reader and this reader is programmable.
Only I don’t know how to program cards, because I’ve never touched on card programming.

Is there a Java library for programming cards?

Can you help me, please?
Thank you

1 answer

1

Chama se Javacard

Oracle Javacard

According to wikipedia:

Java Card is a technology that allows small applications (applets) based on Java platform run securely on smart cards and similar devices with limitations of processing and storage, such as the Java Ring.

Java Card is widely used in SIM cards (used in mobile phones GSM) and ATM cards. The first Java Card was presented in 1997 by several companies, including a extinct Schlumberger Limited (divided into Axalto and Gemplus, which ended up merging).

Java Card products are based on Platform specifications Java Card developed by Sun Microsystems, and its core features are portability and security.

Link to the Article here

Follow a Hello World! in Javacard created by Igor Medeiros.

 /*
 * Package:  br.com.igormedeiros
 * Filename: HelloWorldJC.java
 * Class:    HelloWorldJC
 * Date:     [[8 de maio]] de [[2005]] 14:55:52
 */
 package br.com.igormedeiros;
 import javacard.framework.*;

 /**
 * Class HelloWorldJC
 */
 public class HelloWorldJC extends javacard.framework.Applet {

 // CLA Byte
 final static byte HELLO_CLA = (byte) 0xB0;

 // Verify PIN
 final static byte INS_HELLO = (byte) 0x20;

 public static void install(byte[] bArray, short bOffset, byte bLength) {
  (new HelloWorldJC()).register(
   bArray,
   (short) (bOffset + 1),
   bArray[bOffset]);
 }

 // processa o comando APDU
 public void process(APDU apdu) {
  byte[] buffer = apdu.getBuffer();
  if ((buffer[ISO7816.OFFSET_CLA] == 0)
   && (buffer[ISO7816.OFFSET_INS] == (byte) (0xA4)))
   return;

  // Validate the CLA byte
  if (buffer[ISO7816.OFFSET_CLA] != HELLO_CLA)
   ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);

  // Select the apropriate instruction (Byte INS)
  switch (buffer[ISO7816.OFFSET_INS]) {
   case INS_HELLO :
    getHello(apdu);
    return;
   default :
    ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
  }
 }
 /**
  * @param apdu
  * @author Igor Medeiros
  * Get user id attribute
  */
 private void getHello(APDU apdu) {
  // cadeia de bytes com a mensagem: "hello world Java Card"
  byte[] hello =   {
    'h',
    'e',
    'l',
    'l',
    'o',
    ' ',
    'w',
    'o',
    'r',
    'l',
    'd',
    ' ',
    'J',
    'a',
    'v',
    'a',
    ' ',
    'C',
    'a',
    'r',
    'd' };

  // informa ao JCRE que será enviado uma resposta
  short le = apdu.setOutgoing();
  short totalBytes = (short) hello.length;

  // informa ao JCRE o tamanho da mensagem em bytes
  apdu.setOutgoingLength(totalBytes);

  // envia a mensgem para o host
  apdu.sendBytesLong(hello, (short) 0, (short) hello.length);

  }
 }
  • Ué.. I answered the guy’s question and I get negative? what did you who gave negative expect? rs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.