1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
| /**
* @file LoyaltyCardApplet.java
* @Loyalty Card Applet Sample Code
* @copyright Copyright(C) 2016 JavaCardOS Technologies Co., Ltd. All rights reserved.
* www.javacardos.com
*/
...
public void process(APDU apdu) {
// Good practice: Return 9000 on SELECT
if (selectingApplet()) {
return;
}
byte[] buf = apdu.getBuffer();
if ((buf[ISO7816.OFFSET_CLA] == Loyalty_CLA) ||
(buf[ISO7816.OFFSET_CLA] == ISO7816.CLA_ISO7816))
{
switch (buf[ISO7816.OFFSET_INS])
{
case INS_ISSUE_CARD:
IssueCard(apdu);
return;
case INS_CREDIT:
Credit(apdu);
return;
case INS_VERIFY:
Verify(apdu);
return;
case INS_PURCHASE :
Purchase(apdu);
return;
case INS_GET_BALANCE:
GetBalance(apdu);
return;
case INS_GET_POINTS:
GetPoints(apdu);
return;
case INS_GET_CARDID:
GetCardID(apdu);
return;
case INS_UPDATE_PIN:
UpdatePin(apdu);
return;
case INS_GET_CHANNEL:
GetChannel(apdu);
return;
case INS_EXTERNAL_AUTH:
ExternalAuth(apdu);
return;
case INS_INTERNAL_AUTH:
InternalAuth(apdu);
return;
default:
bRand = false;
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
} else {
ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
}
}
//In issue card process, there contains a PIN, key and the card ID
private void IssueCard(APDU apdu)
{
...
}
...
|
No comments:
Post a Comment