Commit 3b77a048 authored by hanss's avatar hanss
Browse files

REL-9.4.0 as downloaded from the server

parent e44185b8
package uicc.hci.test.framework.api_1_hdv_gpm;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import uicc.hci.framework.HCIDevice;
import uicc.hci.framework.HCIListener;
import uicc.hci.framework.HCIMessage;
import uicc.hci.services.cardemulation.CardEmulationListener;
/**
* The method with the following header shall be compliant to its definition in the API.<br />
* <code>public static byte getPowerMode()</code>
*
*/
public class Api_1_Hdv_Gpm_1 extends Applet implements CardEmulationListener {
// Define specific SWs
/**
* Status word: Full power mode
*/
private final static short SW_FULL_POWER_MODE = ISO7816.SW_NO_ERROR + (short) 3;
/**
* Status word: Low power mode
*/
private final static short SW_LOW_POWER_MODE = ISO7816.SW_NO_ERROR + (short) 4;
/**
* Status word: Power mode could't be retrieved
*/
private final static short SW_POWER_MODE_COULD_NOT_BE_RETRIEVED = ISO7816.SW_NO_ERROR + (short) 5;
// Define specific INS bytes for HCIDevice tests
/**
* Instruction byte: Retrieve power mode
*/
private final static short INS_HELPER = (short) 0x01;
private final static short INS_RETRIEVE_POWER_MODE = (short) 0x05;
/**
* Default constructor, registers the applet.
*/
private Api_1_Hdv_Gpm_1() {
register();
}
/**
* To create an instance of the <code>Applet</code> subclass, the Java Card runtime environment will call this static method first.
* @see Applet#install(byte[], short, byte)
*/
public static void install(byte bArray[], short bOffset, byte bLength)
throws ISOException {
new Api_1_Hdv_Gpm_1();
}
/**
* Called by the Java Card runtime environment to process an incoming APDU command.
* @see Applet#process(APDU)
*/
public void process(APDU apdu) throws ISOException {
/*
* Check for SELECT command
*/
if (selectingApplet())
return;
byte buffer[] = apdu.getBuffer();
/*
* main switch
*/
switch (buffer[ISO7816.OFFSET_INS]) {
case INS_HELPER:
return;
case INS_RETRIEVE_POWER_MODE:
ISOException.throwIt(checkPowerMode(HCIDevice.getPowerMode()));
default:
ISOException.throwIt (ISO7816.SW_INS_NOT_SUPPORTED);
}
}
/**
* Checks the power mode an determine the according status word.
* @param powerMode Value, taken from {@link HCIDevice#getPowerMode()}
* @return The according status word.
*/
private short checkPowerMode(byte powerMode){
switch (powerMode) {
case HCIDevice.FULL_POWER_MODE:
return SW_FULL_POWER_MODE;
case HCIDevice.LOW_POWER_MODE:
return SW_LOW_POWER_MODE;
case (-1):
return SW_POWER_MODE_COULD_NOT_BE_RETRIEVED;
default:
return ISO7816.SW_UNKNOWN;
}
}
/**
* Not used
* This method is called by the HCI framework to inform the Listener Object about a specific event and pass the corresponding HCIMessage to the Listener Object.
* @see HCIListener#onCallback(byte, HCIMessage)
*/
public void onCallback(byte arg0, HCIMessage arg1) {
}
}
// converted by version 1.3
// on Thu Mar 19 11:50:01 CET 2015
.package uicc/hci/test/framework/api_1_hdv_gpm {
.aid 0xA0:0x0:0x0:0x0:0x9:0x0:0x5:0xFF:0xFF:0xFF:0xFF:0x89:0x15:0x2:0x0:0x0;
.version 1.0;
.imports {
0xA0:0x0:0x0:0x0:0x62:0x1:0x1 1.4; //javacard/framework
0xA0:0x0:0x0:0x0:0x9:0x0:0x5:0xFF:0xFF:0xFF:0xFF:0x89:0x16:0x1:0x0:0x0 1.1; //uicc/hci/framework
0xA0:0x0:0x0:0x0:0x9:0x0:0x5:0xFF:0xFF:0xFF:0xFF:0x89:0x16:0x2:0x1:0x0 1.0; //uicc/hci/services/cardemulation
0xA0:0x0:0x0:0x0:0x62:0x0:0x1 1.0; //java/lang
}
.applet {
0xA0:0x0:0x0:0x0:0x9:0x0:0x5:0xFF:0xFF:0xFF:0xFF:0x89:0x15:0x2:0x1:0x2 Api_1_Hdv_Gpm_1;
}
.constantPool {
// 0
staticMethodRef 0.3.0()V; // javacard/framework/Applet.<init>()V
// 1
virtualMethodRef 0.3.1()V; // register()V
// 2
classRef Api_1_Hdv_Gpm_1;
// 3
staticMethodRef Api_1_Hdv_Gpm_1/<init>()V;
// 4
virtualMethodRef 0.3.3()Z; // selectingApplet()Z
// 5
virtualMethodRef 0.10.1()[B; // getBuffer()[B
// 6
staticMethodRef 1.4.1()B; // uicc/hci/framework/HCIDevice.getPowerMode()B
// 7
staticMethodRef Api_1_Hdv_Gpm_1/checkPowerMode(B)S;
// 8
staticMethodRef 0.7.1(S)V; // javacard/framework/ISOException.throwIt(S)V
}
.class public Api_1_Hdv_Gpm_1 0 extends 0.3 { // extends javacard/framework/Applet
.shareable;
.fields {
private static final short SW_FULL_POWER_MODE = -28669; // S
private static final short SW_LOW_POWER_MODE = -28668; // S
private static final short SW_POWER_MODE_COULD_NOT_BE_RETRIEVED = -28667; // S
private static final short INS_HELPER = 1; // S
private static final short INS_RETRIEVE_POWER_MODE = 5; // S
}
.publicMethodTable 7 {
equals(Ljava/lang/Object;)Z;
register()V;
register([BSB)V;
selectingApplet()Z;
deselect()V;
getShareableInterfaceObject(Ljavacard/framework/AID;B)Ljavacard/framework/Shareable;;
select()Z;
process(Ljavacard/framework/APDU;)V;
onCallback(BLuicc/hci/framework/HCIMessage;)V;
}
.packageMethodTable 0 {
}
.implementedInterfaceInfoTable {
.interface 0.2 { // javacard/framework/Shareable
}
.interface 1.0 { // uicc/hci/framework/HCIListener
8; // onCallback(BLuicc/hci/framework/HCIMessage;)V
}
.interface 2.0 { // uicc/hci/services/cardemulation/CardEmulationListener
8; // onCallback(BLuicc/hci/framework/HCIMessage;)V
}
}
.method private <init>()V {
.stack 1;
.locals 0;
L0: aload_0;
invokespecial 0; // javacard/framework/Applet.<init>()V
aload_0;
invokevirtual 1; // register()V
return;
}
.method public static install([BSB)V 0 {
.stack 2;
.locals 0;
L0: new 2; // uicc/hci/test/framework/api_1_hdv_gpm/Api_1_Hdv_Gpm_1
dup;
invokespecial 3; // uicc/hci/test/framework/api_1_hdv_gpm/Api_1_Hdv_Gpm_1.<init>()V
pop;
return;
}
.method public process(Ljavacard/framework/APDU;)V 7 {
.stack 2;
.locals 1;
.descriptor Ljavacard/framework/APDU; 0.10;
L0: aload_0;
invokevirtual 4; // selectingApplet()Z
ifeq L2;
L1: return;
L2: aload_1;
invokevirtual 5; // getBuffer()[B
astore_2;
aload_2;
sconst_1;
baload;
slookupswitch L5 2 1 L3 5 L4;
L3: return;
L4: aload_0;
invokestatic 6; // uicc/hci/framework/HCIDevice.getPowerMode()B
invokespecial 7; // uicc/hci/test/framework/api_1_hdv_gpm/Api_1_Hdv_Gpm_1.checkPowerMode(B)S
invokestatic 8; // javacard/framework/ISOException.throwIt(S)V
L5: sspush 27904;
invokestatic 8; // javacard/framework/ISOException.throwIt(S)V
return;
}
.method private checkPowerMode(B)S {
.stack 1;
.locals 0;
L0: sload_1;
stableswitch L4 -1 1 L3 L2 L1;
L1: sspush -28669;
sreturn;
L2: sspush -28668;
sreturn;
L3: sspush -28667;
sreturn;
L4: sspush 28416;
sreturn;
}
.method public onCallback(BLuicc/hci/framework/HCIMessage;)V 8 {
.stack 0;
.locals 0;
.descriptor Luicc/hci/framework/HCIMessage; 1.1;
L0: return;
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
Package contains Test Area References for the ETSI TS 102 705: Api_1_Hdv_Gpm<br />
Method <code>getPowerMode</code>
</body>
</html>
package uicc.hci.test.framework.api_1_hdv_gsr;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import javacard.framework.SystemException;
import uicc.hci.framework.HCIDevice;
import uicc.hci.framework.HCIException;
import uicc.hci.framework.HCIListener;
import uicc.hci.framework.HCIMessage;
import uicc.hci.services.cardemulation.CardEmulationListener;
import uicc.hci.services.cardemulation.CardEmulationService;
import uicc.hci.services.connectivity.ConnectivityService;
import uicc.hci.services.readermode.ReaderService;
/**
* Checks, that the method with the following header shall be compliant to its
* definition in the API <br />
* <code>public static HCIService getHCIService(short serviceID)throws HCIException, javacard.framework.SystemException</code>
* <br />
* This applet is used for the following test scripts:
* <ul>
* <li>Test_Api_1_Hdv_Gsr_1
* <li>Test_Api_1_Hdv_Gsr_2
* <li>Test_Api_1_Hdv_Gsr_3
* <li>Test_Api_1_Hdv_Gsr_5
* <li>Test_Api_1_Hdv_Gsr_6
* <li>Test_Api_1_Hdv_Gsr_7
* </ul>
*
*/
public class Api_1_Hdv_Gsr_1 extends Applet implements CardEmulationListener {
/*
* Define specific SWs
*/
private final static short SW_SERVICE_NOT_SUPPORTED = ISO7816.SW_UNKNOWN + (short) 1;
private final static short SW_SERVICE_NOT_SUPPORTED_AS_EXPECTED = ISO7816.SW_NO_ERROR + (short) 1;
private final static short SW_SERVICE_ACCESS_NOT_GRANTED = ISO7816.SW_NO_ERROR + (short) 2;
/*
* Define specific INS bytes for HCIDevice tests
*/
private final static short INS_HCI_CE_SERVCE = (short) 0x01;
private final static short INS_HCI_CNN_SERVCE = (short) 0x02;
private final static short INS_HCI_RM_SERVCE = (short) 0x03;
private final static short INS_HCI_ILLEGAL_SERVCE = (short) 0x04;
private Api_1_Hdv_Gsr_1() {
register();
}
/*
* Define HCI specific constants
*/
private CardEmulationService ceService;
private ConnectivityService cnnService;
private ReaderService rmService;
/**
* To create an instance of the <code>Applet</code> subclass, the Java Card
* runtime environment will call this static method first.
*
* @see Applet#install(byte[], short, byte)
*/
public static void install(byte bArray[], short bOffset, byte bLength)
throws ISOException {
new Api_1_Hdv_Gsr_1();
}
/**
* Called by the Java Card runtime environment to process an incoming APDU
* command.
*
* @see Applet#process(APDU)
*/
public void process(APDU apdu) throws ISOException {
/*
* Check for SELECT command
*/
if (selectingApplet())
return;
/*
* analyze incoming data
*/
byte buffer[] = apdu.getBuffer();
switch (buffer[ISO7816.OFFSET_INS]) {
case INS_HCI_CE_SERVCE:
try {
ceService = (CardEmulationService) HCIDevice.getHCIService(HCIDevice.CARD_EMULATION_SERVICE_ID);
if (ceService == null)
ISOException.throwIt(ISO7816.SW_WRONG_DATA);
} catch (HCIException e) {
checkException(e);
}
return;
case INS_HCI_CNN_SERVCE:
try {
cnnService = (ConnectivityService) HCIDevice.getHCIService(HCIDevice.CONNECTIVITY_SERVICE_ID);
if (cnnService == null)
ISOException.throwIt(ISO7816.SW_WRONG_DATA);
} catch (HCIException e) {
checkException(e);
}
return;
case INS_HCI_RM_SERVCE:
try {
rmService = (ReaderService) HCIDevice.getHCIService(HCIDevice.READER_SERVICE_ID);
if (rmService == null)
ISOException.throwIt(ISO7816.SW_WRONG_DATA);
} catch (HCIException e) {
checkException(e);
}
return;
case INS_HCI_ILLEGAL_SERVCE:
short illegalService = (short) -1;
try {
HCIDevice.getHCIService(illegalService);
} catch (SystemException e) {
if (e.getReason() == SystemException.ILLEGAL_VALUE)
return; //expected result
}
ISOException.throwIt(SW_SERVICE_NOT_SUPPORTED);
}
//all "good" cases should have been executed before
ISOException.throwIt(ISO7816.SW_WRONG_DATA);
}
private void checkException(HCIException exp) {
if (exp.getReason() == HCIException.HCI_SERVICE_NOT_AVAILABLE) {
ISOException.throwIt(SW_SERVICE_NOT_SUPPORTED_AS_EXPECTED);
}
if (exp.getReason() == HCIException.HCI_ACCESS_NOT_GRANTED) {
ISOException.throwIt(SW_SERVICE_ACCESS_NOT_GRANTED);
}
ISOException.throwIt(SW_SERVICE_NOT_SUPPORTED);
}
/**
* Not used<br />
* This method is called by the HCI framework to inform the Listener Object about a specific event and pass the corresponding
* HCIMessage to the Listener Object.
*
* @see HCIListener#onCallback(byte, HCIMessage)
*/
public void onCallback(byte arg0, HCIMessage arg1) {
}
}
package uicc.hci.test.framework.api_1_hdv_gsr;
import javacard.framework.APDU;
import javacard.framework.Applet;
import javacard.framework.ISO7816;
import javacard.framework.ISOException;
import uicc.hci.framework.HCIDevice;
import uicc.hci.framework.HCIException;
import uicc.hci.framework.HCIListener;
import uicc.hci.framework.HCIMessage;
import uicc.hci.services.cardemulation.CardEmulationListener;
/**
* Checks, that the method with the following header shall be compliant to its definition in the API <br />
* <code>public static HCIService getHCIService(short serviceID)throws HCIException, javacard.framework.SystemException</code><br />
* This applet is used for the following test scripts:
* <ul>
* <li>Test_Api_1_Hdv_Gsr_4
* </ul>
*
*/
public class Api_1_Hdv_Gsr_2 extends Applet implements CardEmulationListener {
/*
* Define specific SWs
*/
private final static short SW_SERVICE_NOT_SUPPORTED = ISO7816.SW_UNKNOWN + (short) 1;
/*
* Define specific INS bytes
*/
private final static byte INS_HCI_NO_SERVCE = (byte) 0x01;
private boolean isNoServiceBeforeRegister;
private Api_1_Hdv_Gsr_2() {
isNoServiceBeforeRegister = false;
try {
if (HCIDevice.getHCIService(HCIDevice.CARD_EMULATION_SERVICE_ID) == null) {
isNoServiceBeforeRegister = true;
}
} catch (HCIException e){
ISOException.throwIt(SW_SERVICE_NOT_SUPPORTED);
}
register();
}
public static void install(byte bArray[], short bOffset, byte bLength)
throws ISOException {
new Api_1_Hdv_Gsr_2();
}
/**
* Called by the Java Card runtime environment to process an incoming APDU command.
* @see Applet#process(APDU)
*/
public void process(APDU apdu) throws ISOException {
/*
* Check for SELECT command
*/
if (selectingApplet())
return;
/*
* analyze incoming data
* get CLA, INS, P1, P2, Lc
*/
byte buffer[] = apdu.getBuffer();
apdu.setIncomingAndReceive();
switch (buffer[ISO7816.OFFSET_INS]) {
case INS_HCI_NO_SERVCE:
if (isNoServiceBeforeRegister)
return; //expected result
ISOException.throwIt(SW_SERVICE_NOT_SUPPORTED);
default:
ISOException.throwIt (ISO7816.SW_INS_NOT_SUPPORTED);
}
}
/**
* Not used
* This method is called by the HCI framework to inform the Listener Object about a specific event and pass the corresponding HCIMessage to the Listener Object.
* @see HCIListener#onCallback(byte, HCIMessage)
*/