@Test public void testSetApduRequestCase1() { Iso7816CommandBuilder iso7816CommandBuilder = new Iso7816CommandBuilder(CommandRef.COMMAND_1, null); ApduRequest apduRequest = iso7816CommandBuilder.setApduRequest( (byte) 0xCC, CommandRef.COMMAND_1, (byte) 0xB1, (byte) 0xB2, null, null); logger.info("APDU case1: {}", ByteArrayUtil.toHex(apduRequest.getBytes())); Assert.assertArrayEquals(ByteArrayUtil.fromHex("CC 11 B1 B2 00"), apduRequest.getBytes()); Assert.assertFalse(apduRequest.isCase4()); }
protected ApduRequest setApduRequest( byte cla, SeCommand command, byte p1, byte p2, byte[] dataIn, Byte le) { boolean case4; if (dataIn != null && le != null && le != 0) { throw new IllegalArgumentException( "Le must be equal to 0 when not null and ingoing data are present."); } byte[] apdu = allocateBuffer(dataIn, le); apdu[0] = cla; apdu[1] = command.getInstructionByte(); apdu[2] = p1; apdu[3] = p2; if (dataIn != null) { apdu[4] = (byte) dataIn.length; System.arraycopy(dataIn, 0, apdu, 5, dataIn.length); if (le != null) { case4 = true; apdu[apdu.length - 1] = le; } else { case4 = false; } } else { if (le != null) { apdu[4] = le; } else { apdu[4] = (byte) 0x00; } case4 = false; } return new ApduRequest(command.getName(), apdu, case4); }
AbstractIso7816CommandBuilder extends AbstractApduCommandBuilder { protected ApduRequest setApduRequest( byte cla, SeCommand command, byte p1, byte p2, byte[] dataIn, Byte le) { boolean case4; if (dataIn != null && le != null && le != 0) { throw new IllegalArgumentException( "Le must be equal to 0 when not null and ingoing data are present."); } byte[] apdu = allocateBuffer(dataIn, le); apdu[0] = cla; apdu[1] = command.getInstructionByte(); apdu[2] = p1; apdu[3] = p2; if (dataIn != null) { apdu[4] = (byte) dataIn.length; System.arraycopy(dataIn, 0, apdu, 5, dataIn.length); if (le != null) { case4 = true; apdu[apdu.length - 1] = le; } else { case4 = false; } } else { if (le != null) { apdu[4] = le; } else { apdu[4] = (byte) 0x00; } case4 = false; } return new ApduRequest(command.getName(), apdu, case4); } }
AbstractIso7816CommandBuilder extends AbstractApduCommandBuilder { protected ApduRequest setApduRequest( byte cla, SeCommand command, byte p1, byte p2, byte[] dataIn, Byte le) { boolean case4; if (dataIn != null && le != null && le != 0) { throw new IllegalArgumentException( "Le must be equal to 0 when not null and ingoing data are present."); } byte[] apdu = allocateBuffer(dataIn, le); apdu[0] = cla; apdu[1] = command.getInstructionByte(); apdu[2] = p1; apdu[3] = p2; if (dataIn != null) { apdu[4] = (byte) dataIn.length; System.arraycopy(dataIn, 0, apdu, 5, dataIn.length); if (le != null) { case4 = true; apdu[apdu.length - 1] = le; } else { case4 = false; } } else { if (le != null) { apdu[4] = le; } else { apdu[4] = (byte) 0x00; } case4 = false; } return new ApduRequest(command.getName(), apdu, case4); } AbstractIso7816CommandBuilder(SeCommand commandReference, ApduRequest request); }
AbstractIso7816CommandBuilder extends AbstractApduCommandBuilder { protected ApduRequest setApduRequest( byte cla, SeCommand command, byte p1, byte p2, byte[] dataIn, Byte le) { boolean case4; if (dataIn != null && le != null && le != 0) { throw new IllegalArgumentException( "Le must be equal to 0 when not null and ingoing data are present."); } byte[] apdu = allocateBuffer(dataIn, le); apdu[0] = cla; apdu[1] = command.getInstructionByte(); apdu[2] = p1; apdu[3] = p2; if (dataIn != null) { apdu[4] = (byte) dataIn.length; System.arraycopy(dataIn, 0, apdu, 5, dataIn.length); if (le != null) { case4 = true; apdu[apdu.length - 1] = le; } else { case4 = false; } } else { if (le != null) { apdu[4] = le; } else { apdu[4] = (byte) 0x00; } case4 = false; } return new ApduRequest(command.getName(), apdu, case4); } AbstractIso7816CommandBuilder(SeCommand commandReference, ApduRequest request);  }
AbstractIso7816CommandBuilder extends AbstractApduCommandBuilder { protected ApduRequest setApduRequest( byte cla, SeCommand command, byte p1, byte p2, byte[] dataIn, Byte le) { boolean case4; if (dataIn != null && le != null && le != 0) { throw new IllegalArgumentException( "Le must be equal to 0 when not null and ingoing data are present."); } byte[] apdu = allocateBuffer(dataIn, le); apdu[0] = cla; apdu[1] = command.getInstructionByte(); apdu[2] = p1; apdu[3] = p2; if (dataIn != null) { apdu[4] = (byte) dataIn.length; System.arraycopy(dataIn, 0, apdu, 5, dataIn.length); if (le != null) { case4 = true; apdu[apdu.length - 1] = le; } else { case4 = false; } } else { if (le != null) { apdu[4] = le; } else { apdu[4] = (byte) 0x00; } case4 = false; } return new ApduRequest(command.getName(), apdu, case4); } AbstractIso7816CommandBuilder(SeCommand commandReference, ApduRequest request);   }