Package org.nfctools.mf

Examples of org.nfctools.mf.MfException


    for (int x = 0; x < mfBlock.length; x++) {
      String blockNumber = createBlockNumber(mfAccess, x);

      if (mfAccess.getCard().isTrailerBlock(mfAccess.getSector(), mfAccess.getBlock() + x)) {
        if (!(mfBlock[x] instanceof TrailerBlock))
          throw new MfException("invalid block for trailer");
      }
      nfcReaderWriter.sendMessage(("0wb" + blockNumber + NfcUtils.convertBinToASCII(mfBlock[x].getData()))
          .getBytes());
      ArygonMessage message = nfcReaderWriter.receiveMessage();
      if (message.hasTamaErrorCode())
View Full Code Here


    String targetId = "00";
    log.debug("Halting Card " + card.getId() + " / TargetId: " + targetId);
    nfcReaderWriter.sendMessage(("0h" + targetId).getBytes());
    ArygonMessage message = nfcReaderWriter.receiveMessage();
    if (message.hasTamaErrorCode())
      throw new MfException("Cannot send data.");
  }
View Full Code Here

      System.arraycopy(data, 7, cardId, 0, nfcIdLength);

      return cardResolver.resolvecard(type, cardId, targetNumber);
    }
    else
      throw new MfException("no card");
  }
View Full Code Here

  @Override
  public void reselectCard(MfCard card) throws IOException {
    scanForCard();
    MfCard newcard = readCard();
    if (!NfcUtils.isEqualArray(card.getId(), newcard.getId()))
      throw new MfException("New card detected. Id does not match. (Expected: " + card + ", got: " + newcard
          + ")");
  }
View Full Code Here

        if (writeKeyValue == null)
          mad.setReadonly();
        return mad;
      }
      else {
        throw new MfException("MAD version not supported");
      }
    }
    else {
      throw new MfException("MAD not available");
    }
  }
View Full Code Here

      blockNumber = (byte)memoryLayout.getBlockNumber(access.getSector(), access.getBlock() + currentBlock);
      Command readBlock = new Command(Apdu.INS_READ_BINARY, 0x00, blockNumber, 16);
      Response readBlockResponse;
      readBlockResponse = apduTag.transmit(readBlock);
      if (!readBlockResponse.isSuccess()) {
        throw new MfException("Reading block failed. Sector: " + access.getSector() + ", Block: "
            + access.getBlock() + " Key: " + access.getKeyValue().getKey().name() + ", Response: "
            + readBlockResponse);
      }
      returnBlocks[currentBlock] = BlockResolver.resolveBlock(memoryLayout, access.getSector(), currentBlock
          + access.getBlock(), readBlockResponse.getData());
View Full Code Here

    loginIntoSector(access);
    for (int currentBlock = 0; currentBlock < mfBlock.length; currentBlock++) {
      int blockNumber = memoryLayout.getBlockNumber(access.getSector(), access.getBlock()) + currentBlock;
      if (memoryLayout.isTrailerBlock(access.getSector(), access.getBlock() + currentBlock)) {
        if (!(mfBlock[currentBlock] instanceof TrailerBlock))
          throw new MfException("invalid block for trailer");
      }
      Command writeBlock = new Command(Apdu.INS_UPDATE_BINARY, 0x00, blockNumber, mfBlock[currentBlock].getData());
      Response writeBlockResponse;
      writeBlockResponse = apduTag.transmit(writeBlock);
      if (!writeBlockResponse.isSuccess()) {
        throw new MfException("Writing block failed. Sector: " + access.getSector() + ", Block: "
            + access.getBlock() + " Key: " + access.getKeyValue().getKey().name() + ", Response: "
            + writeBlockResponse);
      }
    }
  }
View Full Code Here

    for (int currentPage = 0; currentPage < pagesToRead; currentPage++) {
      int pageNumber = startPage + currentPage;
      Command readBlock = new Command(Apdu.INS_READ_BINARY, 0x00, pageNumber, 4);
      Response readBlockResponse = tag.transmit(readBlock);
      if (!readBlockResponse.isSuccess()) {
        throw new MfException("Reading block failed. Page: " + pageNumber + ", Response: " + readBlockResponse);
      }
      returnBlocks[currentPage] = new DataBlock(readBlockResponse.getData());
    }
    return returnBlocks;
  }
View Full Code Here

    for (int currentBlock = 0; currentBlock < mfBlock.length; currentBlock++) {
      int blockNumber = startPage + currentBlock;
      Command writeBlock = new Command(Apdu.INS_UPDATE_BINARY, 0x00, blockNumber, mfBlock[currentBlock].getData());
      Response writeBlockResponse = tag.transmit(writeBlock);
      if (!writeBlockResponse.isSuccess()) {
        throw new MfException("Writing block failed. Page: " + blockNumber + ", Response: "
            + writeBlockResponse);
      }
    }
  }
View Full Code Here

    case 0x08:
      return new MfCard1k(nfcId, connectionToken);
    case 0x18:
      return new MfCard4k(nfcId, connectionToken);
    case 0x20:
      throw new MfException("DESFire not supported yet");
    }
    throw new MfException("unknown card type " + type);
  }
View Full Code Here

TOP

Related Classes of org.nfctools.mf.MfException

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.