PoTransaction { public final void processVerifyPin(byte[] pin) { Assert.getInstance() .notNull(pin, "pin") .isEqual(pin.length, CalypsoPoUtils.PIN_LENGTH, "PIN length"); if (!calypsoPo.isPinFeatureAvailable()) { throw new CalypsoPoTransactionIllegalStateException("PIN is not available for this PO."); } if (poCommandManager.hasCommands()) { throw new CalypsoPoTransactionIllegalStateException( "No commands should have been prepared prior to a PIN submission."); } if (poSecuritySettings != null && PinTransmissionMode.ENCRYPTED.equals(poSecuritySettings.getPinTransmissionMode())) { poCommandManager.addRegularCommand(new PoGetChallengeCmdBuild(calypsoPo.getPoClass())); processAtomicPoCommands(poCommandManager.getPoCommandBuilders(), ChannelControl.KEEP_OPEN); poCommandManager.notifyCommandsProcessed(); byte[] cipheredPin = samCommandProcessor.getCipheredPinData(CalypsoPoUtils.getPoChallenge(), pin, null); poCommandManager.addRegularCommand( new VerifyPinCmdBuild( calypsoPo.getPoClass(), PinTransmissionMode.ENCRYPTED, cipheredPin)); } else { poCommandManager.addRegularCommand( new VerifyPinCmdBuild(calypsoPo.getPoClass(), PinTransmissionMode.PLAIN, pin)); } processAtomicPoCommands(poCommandManager.getPoCommandBuilders(), channelControl); poCommandManager.notifyCommandsProcessed(); } PoTransaction(SeResource<CalypsoPo> poResource, PoSecuritySettings poSecuritySettings);  PoTransaction(SeResource<CalypsoPo> poResource); final void processOpening(PoTransaction.SessionSetting.AccessLevel accessLevel); final void processPoCommands(); final void processClosing(); final void processCancel(); final void processVerifyPin(byte[] pin); final void processVerifyPin(String pin); final void prepareReleasePoChannel(); final void prepareSelectFile(byte[] lid); final void prepareSelectFile(SelectFileControl control); final void prepareReadRecordFile(byte sfi, int recordNumber); final void prepareReadRecordFile(
      byte sfi, int firstRecordNumber, int numberOfRecords, int recordSize); final void prepareReadCounterFile(byte sfi, int countersNumber); final void prepareAppendRecord(byte sfi, byte[] recordData); final void prepareUpdateRecord(byte sfi, int recordNumber, byte[] recordData); final void prepareWriteRecord(byte sfi, int recordNumber, byte[] recordData); final void prepareIncreaseCounter(byte sfi, int counterNumber, int incValue); final void prepareDecreaseCounter(byte sfi, int counterNumber, int decValue); final void prepareCheckPinStatus(); final void prepareSvGet(SvSettings.Operation svOperation, SvSettings.Action svAction); final void prepareSvReload(int amount, byte[] date, byte[] time, byte[] free); final void prepareSvReload(int amount); final void prepareSvDebit(int amount, byte[] date, byte[] time); final void prepareSvDebit(int amount); final void prepareSvReadAllLogs(); final void prepareInvalidate(); final void prepareRehabilitate();  }
@Test public void testProcessVerifyPin_plain_outside_secureSession() { CalypsoPo calypsoPoRev31 = createCalypsoPo(FCI_REV31); poTransaction = new PoTransaction(new SeResource<CalypsoPo>(poReader, calypsoPoRev31)); poCommandsTestSet.put(PO_VERIFY_PIN_PLAIN_OK_CMD, PO_VERIFY_PIN_OK_RSP); poTransaction.processVerifyPin(PIN_OK); assertThat(calypsoPoRev31.getPinAttemptRemaining()).isEqualTo(3); }
@Test public void testProcessVerifyPin_encrypted_outside_secureSession() { CalypsoPo calypsoPoRev31 = createCalypsoPo(FCI_REV31); PoSecuritySettings poSecuritySettings = new PoSecuritySettings.PoSecuritySettingsBuilder(samResource) .sessionDefaultKif(AccessLevel.SESSION_LVL_DEBIT, DEFAULT_KIF_DEBIT) .sessionDefaultKeyRecordNumber( AccessLevel.SESSION_LVL_DEBIT, DEFAULT_KEY_RECORD_NUMBER_DEBIT) .pinTransmissionMode(PoTransaction.PinTransmissionMode.ENCRYPTED) .build(); poTransaction = new PoTransaction(new SeResource<CalypsoPo>(poReader, calypsoPoRev31), poSecuritySettings); samCommandsTestSet.put(SAM_SELECT_DIVERSIFIER_CMD, SW1SW2_OK_RSP); samCommandsTestSet.put(SAM_GIVE_RANDOM_CMD, SAM_GIVE_RANDOM_RSP); samCommandsTestSet.put(SAM_CARD_CIPHER_PIN_CMD, SAM_CARD_CIPHER_PIN_RSP); poCommandsTestSet.put(PO_GET_CHALLENGE_CMD, PO_GET_CHALLENGE_RSP); poCommandsTestSet.put(PO_VERIFY_PIN_ENCRYPTED_OK_CMD, PO_VERIFY_PIN_OK_RSP); poTransaction.processVerifyPin(PIN_OK); assertThat(calypsoPoRev31.getPinAttemptRemaining()).isEqualTo(3); }