Package javax.smartcardio

Examples of javax.smartcardio.ResponseAPDU


        throw new NfcException("Only data mode supported");
      if (log.isDebugEnabled())
        log.debug("command: " + NfcUtils.convertBinToASCII(commandAPDU.getBytes()));
      byte[] transmitControlResponse = card.transmitControlCommand(Acs.IOCTL_SMARTCARD_ACR122_ESCAPE_COMMAND,
          commandAPDU.getBytes());
      ResponseAPDU responseAPDU = new ResponseAPDU(transmitControlResponse);
      if (log.isDebugEnabled())
        log.debug("response: " + NfcUtils.convertBinToASCII(responseAPDU.getBytes()));
      return new Response(responseAPDU.getSW1(), responseAPDU.getSW2(), responseAPDU.getData());
    }
    catch (CardException e) {
      throw new NfcException(e);
    }
  }
View Full Code Here


     */
    @Test
    public void testGetResponseAPDU() {
        System.out.println("getResponseAPDU");
        Apdu instance = new Apdu();
        ResponseAPDU expResult = null;
        ResponseAPDU result = instance.getResponseAPDU();
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }
View Full Code Here

     */
    @Test
    public void testGetExpectedResponseAPDU() {
        System.out.println("getExpectedResponseAPDU");
        Apdu instance = new Apdu();
        ResponseAPDU expResult = null;
        ResponseAPDU result = instance.getExpectedResponseAPDU();
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }
View Full Code Here

     * Test of ResponseAPDU2String method, of class Apdu.
     */
    @Test
    public void testResponseAPDU2String_ResponseAPDU() {
        System.out.println("ResponseAPDU2String");
        ResponseAPDU command = null;
        String expResult = "";
        String result = Apdu.ResponseAPDU2String(command);
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
View Full Code Here

     * Test of ResponseAPDU2String method, of class Apdu.
     */
    @Test
    public void testResponseAPDU2String_3args() {
        System.out.println("ResponseAPDU2String");
        ResponseAPDU response = null;
        String toInsertAfterNewLine = "\n";
        int dataLimit = 0;
        String expResult = "";
        String result = Apdu.ResponseAPDU2String(response, toInsertAfterNewLine, dataLimit);
        assertEquals(expResult, result);
View Full Code Here

    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        while(length > 0)
        {
          int block = Math.min(length, BLOCK_SIZE);
            ResponseAPDU r = channel.transmit(new CommandAPDU(0x00, 0xB0, offset >> 8, offset & 0xFF, block));
            if(r.getSW() != 0x9000) {
              throw new CardException("Read binary failed: " + RSIDUtils.int2Hex(r.getSW()));
            }

            try {
                byte[] data = r.getData();
                int data_len = data.length;

                out.write(data);
              offset += data_len;
              length -= data_len;
View Full Code Here

      cmd[2] = P1;
      cmd[3] = P2;
      cmd[4] = LC;
      System.arraycopy(pin, 0, cmd, 5, 8);
      cmd[13] 0x00;
      ResponseAPDU r = null;
    try {
      r = channel.transmit(new CommandAPDU(cmd));
    } catch (CardException e) {
      throw new RSIDCardException("Greska pri autorizaciji korisnika. Pogresna loznika?");
    }
    if(r.getSW() != 0x9000) {
      throw new RSIDCardException("Greska pri autorizaciji korisnika. Pogresna loznika?");
    }
    }
View Full Code Here

        if (c.isCardPresent()){
          try{
            card = c.connect("*");
            try{
              ch =card.getBasicChannel();
              ResponseAPDU resp = ch.transmit(SELECT_APDU);
              terminal=c;

              if (resp.getSW() !=  0x9000){
                Utilities.writeToLogs(home,"[E] Problems: Card Device not selectable != 0x9000");
                throw new Exception("[!] Problems: Card Device not selectable");
              }

            }catch(Exception e){
View Full Code Here

        Utilities.writeToLogs(home, "[E] Card was teared! Card ID:"+cID);
        System.out.println("Card was teared. Terminal will now reboot.");
        System.exit(-1);
      }
      CommandAPDU apduBalance = new CommandAPDU((byte) 0x00, INS_GET_BALANCE,(byte) 0x00, (byte) 0x00,16+8);
      ResponseAPDU res        = ch.transmit(apduBalance);
      double balance          = 0;

      if (res.getSW() !=  0x9000){
        Utilities.writeToLogs(home,"[E] Error during operation. Remove card from terminal !=  0x9000 "+cID);
        throw new CardException("Error while reading Card Balance. Aborting operation.");
      }
      else{
        if(verifySignature(res.getData(), 16)){
          byte[] plainData = decryptAES128(res.getData(),0,16);
          short b          = Utilities.getShort(plainData, 0);
          balance          = (double) (b / 100.0);
          return balance;
        }
        else{
View Full Code Here

        byte[] encdata=encryptAES128(data, 0, 16);
        // Expansion of array from 16 bytes to 16+8 bytes(for MAC signature to fit)
        encdata=Arrays.copyOf(encdata, 24);
        signMessage(encdata, 16, encdata, 16);
        CommandAPDU apduInc = new CommandAPDU((byte) 0x00,INS_MODIFY_BALANCE,(byte) 0x00, (byte) 0x00,encdata,16+8);
        ResponseAPDU res           = ch.transmit(apduInc);

        if (res.getSW() !=  0x9000){
          if (res.getSW() == 0x6984){
            Utilities.writeToLogs(home,"[E] Requested topup amount surpasses card limit. Try it with less! MAX 250.00€ "+cID);
            System.out.println("[!] Requested topup amount surpasses card limit. Try it with less! MAX 250.00€");
            throw new CardException("Requested topup amount exceeds card limit");
          }
          else{
View Full Code Here

TOP

Related Classes of javax.smartcardio.ResponseAPDU

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.