Package javax.smartcardio

Examples of javax.smartcardio.ResponseAPDU


        Utilities.writeToLogs(home, "[E] Card was teared! Card ID:"+cID);
        System.out.println("Card was teared. Terminal will now reboot.");
        System.exit(-1);
      }
      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))
View Full Code Here


  {
    try
    {
      byte[] response = this.smartCard.transmitControlCommand(features.get(FEATURE_VERIFY_PIN_DIRECT),this.createPINVerificationDataStructure(pwdId));
     
      ResponseAPDU apdu = new ResponseAPDU(response);

      //////////////////////////////////////////////////////////////////////////
      // Extra Checks
      int sw = apdu.getSW();
      if (sw == 0x63c0) throw new HBCI_Exception("PIN falsch. Noch 1 Versuch");
      if (sw == 0x63c1) throw new HBCI_Exception("PIN falsch. Noch 2 Versuche");
      if (sw == 0x63c2) throw new HBCI_Exception("PIN falsch. Noch 3 Versuche");
      if (sw == 0x6400) throw new HBCI_Exception("PIN-Eingabe aufgrund Timeout abgebrochen");
      if (sw == 0x6401) throw new HBCI_Exception("PIN-Eingabe vom User abgebrochen");
View Full Code Here

      } catch (Exception e) {} // ignore
      //////////////////////////////////////////////////////////////////////////
     

      CardChannel channel = this.smartCard.getBasicChannel();
      ResponseAPDU response = channel.transmit(command);
     
      // Command und Response loggen
      HBCIUtils.log(caller + " command : " + toHex(command.getBytes()),HBCIUtils.LOG_DEBUG);
      HBCIUtils.log(caller + " response: " + toHex(response.getBytes()),HBCIUtils.LOG_DEBUG);

      this.check(response,returncodes);
      return response.getData();
    }
    catch (HBCI_Exception e1)
    {
      throw e1;
    }
View Full Code Here

      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

      if (log.isDebugEnabled()) {
        log.debug("command  APDU => " + NfcUtils.convertBinToASCII(commandBytes));
      }

      ResponseAPDU responseAPDU = null;
      if (cardChannel != null) {
        responseAPDU = cardChannel.transmit(commandAPDU);
      }
      else {
        byte[] transmitControlResponse = card.transmitControlCommand(Acs.IOCTL_SMARTCARD_ACR122_ESCAPE_COMMAND,
            commandBytes);
        responseAPDU = new ResponseAPDU(transmitControlResponse);
      }

      responseData = responseAPDU.getData();
      if (log.isDebugEnabled())
        log.debug("response APDU <= " + NfcUtils.convertBinToASCII(responseData));

      if (!ApduUtils.isSuccess(responseAPDU))
        throw new ApduException("Error sending message [" + NfcUtils.convertBinToASCII(data) + "] (" + offset
View Full Code Here

      blockNumber = (byte)mfAccess.getCard().getBlockNumber(mfAccess.getSector(),
          mfAccess.getBlock() + currentBlock);

      CommandAPDU readBlock = new CommandAPDU(Apdu.CLS_PTS, Apdu.INS_READ_BINARY, 0x00, blockNumber, 16);
      ResponseAPDU readBlockResponse;
      try {
        readBlockResponse = cardChannel.transmit(readBlock);
        if (!ApduUtils.isSuccess(readBlockResponse)) {
          throw new MfException("Reading block failed. Sector: " + mfAccess.getSector() + ", Block: "
              + mfAccess.getBlock() + " Key: " + mfAccess.getKey().name() + ", Response: "
              + readBlockResponse);
        }

      }
      catch (CardException e) {
        throw new IOException(e);
      }

      returnBlocks[currentBlock] = blockResolver.resolveBlock(mfAccess.getCard(), mfAccess.getSector(),
          currentBlock + mfAccess.getBlock(), readBlockResponse.getData());

    }
    return returnBlocks;
  }
View Full Code Here

  protected void loginIntoSector(MfAccess mfAccess, CardChannel cardChannel, byte memoryKeyId) throws IOException {
    try {
      CommandAPDU loadKey = new CommandAPDU(Apdu.CLS_PTS, Apdu.INS_EXTERNAL_AUTHENTICATE,
          Acs.P1_LOAD_KEY_INTO_VOLATILE_MEM, memoryKeyId, mfAccess.getKeyValue());
      ResponseAPDU loadKeyResponse = cardChannel.transmit(loadKey);
      if (!ApduUtils.isSuccess(loadKeyResponse)) {
        throw new MfLoginException("Loading key failed. Sector: " + mfAccess.getSector() + ", Block: "
            + mfAccess.getBlock() + " Key: " + mfAccess.getKey().name() + ", Response: " + loadKeyResponse);
      }

      byte blockNumber = (byte)mfAccess.getCard().getBlockNumber(mfAccess.getSector(), mfAccess.getBlock());

      byte keyTypeToUse = mfAccess.getKey() == Key.A ? Acs.KEY_A : Acs.KEY_B;

      CommandAPDU auth = new CommandAPDU(Apdu.CLS_PTS, Apdu.INS_INTERNAL_AUTHENTICATE_ACS, 0, 0, new byte[] {
          0x01, 0x00, blockNumber, keyTypeToUse, memoryKeyId });
      ResponseAPDU authResponse = cardChannel.transmit(auth);
      if (!ApduUtils.isSuccess(authResponse)) {
        throw new MfLoginException("Login failed. Sector: " + mfAccess.getSector() + ", Block: "
            + mfAccess.getBlock() + " Key: " + mfAccess.getKey().name() + ", Response: " + authResponse);
      }
    }
View Full Code Here

          throw new MfException("invalid block for trailer");
      }

      CommandAPDU writeBlock = new CommandAPDU(Apdu.CLS_PTS, Apdu.INS_UPDATE_BINARY, 0x00, blockNumber,
          mfBlock[currentBlock].getData());
      ResponseAPDU writeBlockResponse;
      try {
        writeBlockResponse = cardChannel.transmit(writeBlock);
        if (!ApduUtils.isSuccess(writeBlockResponse)) {
          throw new MfException("Writing block failed. Sector: " + mfAccess.getSector() + ", Block: "
              + mfAccess.getBlock() + " Key: " + mfAccess.getKey().name() + ", Response: "
View Full Code Here

        commandAPDU = new CommandAPDU(Apdu.CLS_PTS, command.getInstruction(), command.getP1(), command.getP2(),
            command.getLength());
      }
      if (log.isDebugEnabled())
        log.debug("command: " + NfcUtils.convertBinToASCII(commandAPDU.getBytes()));
      ResponseAPDU responseAPDU = cardChannel.transmit(commandAPDU);
      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

        super(card);
    }

    public String readID() throws CardException {
        exec(COMMAND_SELECT, "Incorrect card type");
        ResponseAPDU res = exec(COMMAND_GET, "Incorrect card type");
        byte[] data = res.getData();
        byte[] target = new byte[10];
        // зделано аналогично алгоритму sunray сервера
        System.arraycopy(data, 3, target, 0, 4);
        System.arraycopy(data, 19, target, 4, 2);
        System.arraycopy(data, 15, target, 6, 4);
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.