Java programming for cards [closed]

0

Hello,
I have a KDE KT-2280 magnetic card reader and this reader is programmable. But I do not know how to program cards, because I never got into card programming.

Is there a Java library to program cards?

Can you help me, please? Thanks

    
asked by anonymous 07.03.2017 / 16:36

1 answer

1

Call it Javacard

Oracle Javacard

According to wikipedia:

  

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

     

The Java Card is widely used in SIM cards (used in mobile phones   GSM) and ATM cards. The first Java Card was   presented by a number of companies in 1997, including a division of   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 main   features are portability and security.

Link to 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);

  }
 }
    
07.03.2017 / 19:25