Package javax.smartcardio

Examples of javax.smartcardio.CardException


      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{
          System.out.println("Error during operation. Remove card from terminal");
          CARD_LEGIT=false;
          Utilities.writeToLogs(home,"[E] Signature failure ---- Error during operation. Remove card from terminal "+cID);
          throw new CardException("Signature failure");
        }
      }   
    }
    else{
      Utilities.writeToLogs(home,"[E] Handshake protocol failure "+cID);
      System.out.println("Error during operation. Remove card from terminal");
      System.exit(-1);
      throw new CardException("Handshake protocol failure");
    }
  }
View Full Code Here


        CommandAPDU apduModBalance = new CommandAPDU((byte) 0x00,INS_MODIFY_BALANCE,(byte) 0x00, (byte) 0x00,encdata,16+8);
        ResponseAPDU res           = ch.transmit(apduModBalance);

        if (res.getSW() !=  0x9000){
          Utilities.writeToLogs(home,"[E] Error while reading Card Balance "+cID);
          throw new CardException("Error while reading Card Balance");
        }
        else{
          notifyPaymentMockupFunction(payment);
          Utilities.writeToLogs(home,"[+] Paid successfully from card "+cID+" a total of "+payment+" €.");
          return true
View Full Code Here

      CommandAPDU dataApdu = new CommandAPDU((byte) 0x00, INS_GET_OWNER_INFO,(byte) 0x00, (byte) 0x00,100);
      ResponseAPDU res        = ch.transmit(dataApdu);

      if (res.getSW() !=  0x9000){
        Utilities.writeToLogs(home,"[E] Error while reading Card Balance.  Aborting operation. != 0x9000 "+cID);
        throw new CardException("Error while reading Card Balance.  Aborting operation.");
      }
      else{
        String userdata= Utilities.byteArrayToHexString(res.getData());
        String name    = userdata.substring(0, 40);
        String address = userdata.substring(40, 94);
        String date    = userdata.substring(94,100);

        System.out.printf("[+] Mr/Ms. %s \n",Utilities.hex2ascii(name))
      }   
    }
    else{
      Utilities.writeToLogs(home,"[E] Failure with getUserData");
      throw new CardException("Failure");
    }
  }
View Full Code Here

    CommandAPDU cardIDrequest = new CommandAPDU((byte) 0x00, (byte) 0x69,(byte) 0x00, (byte) 0x00,2);
    ResponseAPDU res= ch.transmit(cardIDrequest);
    byte[] cardID= res.getData();
    if (res.getSW() !=  0x9000){
      Utilities.writeToLogs(home,"[E] Error reading card ID. Check card connection & reader. ");
      throw new CardException("Error while reading Card ID");
    }
    else{
      //We set K as the CardID encrypted with the master key
      SecretKeySpec sks = new SecretKeySpec(getMasterKey(), "AES");
      try {
View Full Code Here

      CommandAPDU cardIDrequest = new CommandAPDU((byte) 0x00, INS_GET_TRNSCT_LOG,(byte) 0x00, (byte) 0x00,60);
      ResponseAPDU res= ch.transmit(cardIDrequest);
      byte[] trLog= res.getData();
      if (res.getSW() !=  0x9000){
        Utilities.writeToLogs(home,"[E] Error while reading transaction log. "+cID);
        throw new CardException("Error while reading transaction log.");
      }
      else{
        if(!verifySignature(trLog, 52))
          Utilities.writeToLogs(home,"[E] LOG SIGNATURE FAILED - CHECK FOR TAMPERED DATA. "+cID);
        int count=Utilities.getShort(trLog, 0);
View Full Code Here

    private byte[] getRecord(CommandAPDU apdu) throws CardException {
        ResponseAPDU responce = exec(apdu, "Unable read user info");
        Messages msg = Messages.findMessage(responce);
        if (!msg.isOk()) {
            throw new CardException(msg.getMessage());
        }
        return responce.getData();
    }
View Full Code Here

TOP

Related Classes of javax.smartcardio.CardException

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.