Skip to content

Commit

Permalink
added AllowAll ARA dummy applet
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Jul 5, 2012
1 parent f6e81a4 commit 7149bae
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 0 deletions.
114 changes: 114 additions & 0 deletions samples/AllowAll/com/gieseckedevrient/javacard/allowall/AllowAll.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package com.gieseckedevrient.javacard.allowall;

import javacard.framework.*;

public class AllowAll extends Applet implements MultiSelectable
{
static final byte INS_GET_DATA = (byte) 0xCA;
static final short TAG_CMD_GET_NEXT = (short) 0xFF60;
static final short TAG_CMD_GET_SPECIFIC = (short) 0xFF50;
static final short TAG_CMD_GET_ALL = (short) 0xFF40;
static final short TAG_CMD_GET_REFRESH = (short) 0xDF20;


private final static byte[] RESPONSE_GET_REFRESH = { (byte)0xDF, (byte)0x20, (byte)0x08, (byte)0x01, (byte)0x02, (byte)0x03, (byte)0x04, (byte)0x05, (byte)0x06, (byte)0x07, (byte)0x08 };

private final static byte[] RESPONSE_GET_SPECIFIC = { (byte)0xFF, (byte)0x50, (byte)0x08, (byte) 0xE3, (byte) 0x06, (byte)0xD0, (byte)0x01, (byte)0x01, (byte)0xD1, (byte)0x01, (byte)0x01 };

private final static byte[] RESPONSE_GET_ALL = {(byte)0xFF, (byte)0x40,(byte)0x10, (byte)0xE2,(byte)0x0E, (byte)0xE1,(byte)0x04, (byte)0x4F,(byte)0x00, (byte)0xC1, (byte)0x00, (byte)0xE3, (byte)0x06, (byte)0xD0, (byte)0x01, (byte)0x01, (byte)0xD1, (byte)0x01, (byte)0x01 };


public static void install(byte[] abArray, short sOffset, byte bLength)
{
(new AllowAll()).register( abArray, (short) (sOffset + 1), abArray[sOffset] );
}

public boolean select(boolean appInstAlreadyActive)
{
return true;
}

public void deselect(boolean appInstStillActive)
{
return;
}

public void process(APDU oAPDU) throws ISOException
{
short sSW1SW2 = ISO7816.SW_NO_ERROR;
short sOutLength = (short)0;

byte[] abData = oAPDU.getBuffer();

byte bINS = abData[ ISO7816.OFFSET_INS ];

short sMode = Util.getShort( abData, ISO7816.OFFSET_P1 );

if( selectingApplet() == true )
{
return;
}

try
{
if( bINS != INS_GET_DATA )
ISOException.throwIt( ISO7816.SW_INS_NOT_SUPPORTED );

if( sMode == TAG_CMD_GET_ALL )
{
sOutLength = Util.arrayCopyNonAtomic( RESPONSE_GET_ALL,
(short)0,
abData,
(short)0,
(short)RESPONSE_GET_ALL.length
);
}
else if( sMode == TAG_CMD_GET_SPECIFIC )
{
oAPDU.setIncomingAndReceive();

sOutLength = Util.arrayCopyNonAtomic( RESPONSE_GET_SPECIFIC,
(short)0,
abData,
(short)0,
(short)RESPONSE_GET_SPECIFIC.length
);
}
else if( sMode == TAG_CMD_GET_NEXT )
{
ISOException.throwIt( ISO7816.SW_CONDITIONS_NOT_SATISFIED );
}
else if( sMode == TAG_CMD_GET_REFRESH )
{
sOutLength = Util.arrayCopyNonAtomic( RESPONSE_GET_REFRESH,
(short)0,
abData,
(short)0,
(short)RESPONSE_GET_REFRESH.length
);
}
else
{
ISOException.throwIt( ISO7816.SW_WRONG_P1P2 );
}
}
catch( ISOException e )
{
sSW1SW2 = e.getReason();
}
catch( Exception e )
{
sSW1SW2 = ISO7816.SW_UNKNOWN;
}

if( sSW1SW2 != ISO7816.SW_NO_ERROR )
{
ISOException.throwIt( sSW1SW2 );
}

if( sOutLength > (short)0 )
{
oAPDU.setOutgoingAndSend( (short)0, sOutLength );
}
}
}
6 changes: 6 additions & 0 deletions samples/AllowAll/compiler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

export JC_HOME=$PWD/java_card_kit-2_2_1
export PATH=$PATH:$JC_HOME/bin

javac -g -source 1.3 -target 1.1 -classpath $JC_HOME/lib/api.jar com/gieseckedevrient/javacard/allowall/*.java
8 changes: 8 additions & 0 deletions samples/AllowAll/converter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

JC_HOME=$PWD/java_card_kit-2_2_1
PATH=$PATH:$JC_HOME/bin

java -classpath $JC_HOME/lib/converter.jar:$JC_HOME/lib/api.jar com.sun.javacard.converter.Converter -noverify -i -classdir . -out CAP -exportpath $JC_HOME/api_export_files -applet 0xA0:0x00:0x00:0x01:0x51:0x41:0x43:0x4C:0x00 com.gieseckedevrient.javacard.allowall.AllowAll com.gieseckedevrient.javacard.allowall 0xA0:0x00:0x00:0x01:0x51:0x41:0x43:0x4C 1.0

cp com/gieseckedevrient/javacard/allowall/javacard/allowall.cap .

0 comments on commit 7149bae

Please sign in to comment.