U pitanju je najbudjaviji HelloWorld, koji uzgred nisam ja ni pisao, bas da ne bih motao po glavi dal je kod los ili sta.
Code:
/*
* Copyright © 2003 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
// /*
// Workfile:@(#)HelloWorld.java 1.6
// Version:1.6
// Date:06/06/03
//
// Archive: /Products/Europa/samples/com/sun/javacard/samples/HelloWorld/HelloWorld.java
// Modified:06/06/03 17:05:59
// Original author: Mitch Butler
// */
package com.sun.javacard.samples.HelloWorld;
import javacard.framework.*;
/**
*/
public class HelloWorld extends Applet
{
private byte[] echoBytes;
private static final short LENGTH_ECHO_BYTES = 256;
/**
* Only this class's install method should create the applet object.
*/
protected HelloWorld()
{
echoBytes = new byte[LENGTH_ECHO_BYTES];
register();
}
/**
* Installs this applet.
* @param bArray the array containing installation parameters
* @param bOffset the starting offset in bArray
* @param bLength the length in bytes of the parameter data in bArray
*/
public static void install(byte[] bArray, short bOffset, byte bLength)
{
new HelloWorld();
}
/**
* Processes an incoming APDU.
* @see APDU
* @param apdu the incoming APDU
* @exception ISOException with the response bytes per ISO 7816-4
*/
public void process(APDU apdu)
{
byte buffer[] = apdu.getBuffer();
short bytesRead = apdu.setIncomingAndReceive();
short echoOffset = (short)0;
while ( bytesRead > 0 ) {
Util.arrayCopyNonAtomic(buffer, ISO7816.OFFSET_CDATA, echoBytes, echoOffset, bytesRead);
echoOffset += bytesRead;
bytesRead = apdu.receiveBytes(ISO7816.OFFSET_CDATA);
}
apdu.setOutgoing();
apdu.setOutgoingLength( (short) (echoOffset + 5) );
// echo header
apdu.sendBytes( (short)0, (short) 5);
// echo data
apdu.sendBytesLong( echoBytes, (short) 0, echoOffset );
}
}
Ocigledno se nisam dovoljno precizno izrazio kad sam rekao "downloadujem applet". Mislio sam na cap fajl, naravno. NB ima ovaj plugin:
Java Card Manager, hteo sam ga linkovati u prvoj poruci al iz nekog razloga nisam mogao da otvorim plugin portal na njihovom sajtu.
GPShell izvrsava ovu skriptu za instalaciju HelloWorld.cap:
Code:
enable_trace
establish_context
card_connect
select -AID a0000000030000
open_sc -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4f -enc_key 404142434445464748494a4b4c4d4e4f // Open secure channel
delete -AID a00000006203010c0101
delete -AID a00000006203010c01
delete -AID a00000006203010c0101
install -file HelloWorld.cap -nvDataLimit 500 -instParam 00 -priv 2
# getdata
# close_sc // Close secure channel
# putkey // Put key
// options:
// -keyind Key index
// -keyver Key version
// -key Key value in hex
card_disconnect
release_context
Sad sam izvrsavao liniju po liniju, prvo puca ovde: select -AID a0000000030000
Ali cak i kad sam to preskocio, nece da izvrsi: install -file HelloWorld.cap -nvDataLimit 500 -instParam 00 -priv 2
Gledao sam manifest cap fajla, AID aplikacije i paketa se razlikuju.
Da li mogu nekako da preskocim svu tu zajebanciju sa otvaranjem sigurnog kanala prema kartici i lepo metnem stvar kakva jeste?
Da li molim te mozes da mi kazes (po mogucstvu u retard-frendli-korak-po-korak formi XD) sta da uradim sa GPShellom da bih ubacio cap na karticu?