Lock applet behind the pin
This commit is contained in:
parent
0b0e3d24ea
commit
80e1d752ad
2 changed files with 18 additions and 1 deletions
|
@ -1,2 +1,8 @@
|
|||
SET LENGTH=07
|
||||
SET AID=01020304050608
|
||||
SET CONTROLLENGTH=02
|
||||
SET CONTROLINFO=1122
|
||||
SET PINLENGTH=04
|
||||
SET PIN=31323334
|
||||
@rem -f to force install over old version
|
||||
gp --install %~dp0..\javacard\%PACKAGE%.cap -f
|
||||
gp --install %~dp0..\javacard\%PACKAGE%.cap --params %LENGTH%%AID%%CONTROLLENGTH%%CONTROLINFO%%PINLENGTH%%PIN% -f
|
||||
|
|
|
@ -42,6 +42,14 @@ public class MyApplet extends Applet {
|
|||
register();
|
||||
}
|
||||
|
||||
public boolean select() {
|
||||
if (pin.getTriesRemaining() == 0) {
|
||||
return false;
|
||||
} else {
|
||||
return super.select();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes an incoming APDU.
|
||||
*
|
||||
|
@ -90,6 +98,9 @@ public class MyApplet extends Applet {
|
|||
Util.arrayCopy(buffer, ISO7816.OFFSET_CDATA, storage, (short) 0, length);
|
||||
}
|
||||
break;
|
||||
case 0x20:
|
||||
length = apdu.setIncomingAndReceive();
|
||||
pin.check(buffer, (short) ISO7816.OFFSET_CDATA, (byte)length);
|
||||
default:
|
||||
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue