Package org.nfctools

Examples of org.nfctools.NfcException


      if (command.isDataOnly()) {
        commandAPDU = new CommandAPDU(0xff, 0, 0, 0, command.getData(), command.getOffset(),
            command.getLength());
      }
      else
        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


      currentBlock = blocks[0].getData();
      currentPage++;
      currentByte = 0;
    }
    catch (IOException e) {
      new NfcException(e);
    }
  }
View Full Code Here

      if (command.isDataOnly()) {
        commandAPDU = new CommandAPDU(0xff, 0, 0, 0, command.getData(), command.getOffset(),
            command.getLength());
      }
      else
        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

            new ByteArrayInputStream(tlvWrappedNdefMessage));
        convertRecords(reader);
        return lastReadRecords;
      }
      catch (IOException e) {
        throw new NfcException(e);
      }
    }
  }
View Full Code Here

          writeKey, writeKey));
      Application application = applicationDirectory.openApplication(MfConstants.NDEF_APP_ID);
      return application;
    }
    catch (IOException e) {
      throw new NfcException(e);
    }
  }
View Full Code Here

      application.getApplicationDirectory().makeReadOnly();
      application.makeReadOnly(new KeyValue(Key.B, writeKey));
      writable = false;
    }
    catch (IOException e) {
      throw new NfcException(e);
    }
  }
View Full Code Here

      Application application = applicationDirectory.createApplication(MfConstants.NDEF_APP_ID,
          applicationDirectory.getMaxContinousSize(), writeKey, readWriteTrailerBlock);
      return application;
    }
    catch (IOException e) {
      throw new NfcException(e);
    }
  }
View Full Code Here

      byte[] tlvWrappedNdefData = wrapNdefMessageWithTlv(convertRecordsToBytes(records),
          application.getAllocatedSize());
      application.write(new KeyValue(Key.B, writeKey), tlvWrappedNdefData);
    }
    catch (IOException e) {
      throw new NfcException(e);
    }
  }
View Full Code Here

          formatted = true;
          Application application = applicationDirectory.openApplication(MfConstants.NDEF_APP_ID);
          writable = ClassicHandler.isFormattedWritable(application, MfClassicConstants.NDEF_KEY);
        }
        else {
          throw new NfcException("Unknown tag contents");
        }
      }
      else {
        if (ClassicHandler.isBlank(readerWriter)) {
          writable = true;
        }
        else
          throw new NfcException("Unknown tag contents");
      }
    }
    catch (IOException e) {
      throw new NfcException(e);
    }
    return new MfClassicNdefOperations(readerWriter, tagInfo, formatted, writable);
  }
View Full Code Here

        }
        else if (UltralightHandler.isUltralightC(initBlocks[4].getData())) {
          memoryLayout = MemoryLayout.ULTRALIGHT_C;
        }
        else {
          throw new NfcException("Unknown tag size");
        }
        writable = true;
      }
      else if (UltralightHandler.isFormatted(initBlocks)) {
        formatted = true;
        if (capabilityBlock.getSize() == 0x06)
          memoryLayout = MemoryLayout.ULTRALIGHT;
        else if (capabilityBlock.getSize() == 0x12) {
          memoryLayout = MemoryLayout.ULTRALIGHT_C;
        }
        else {
          throw new NfcException("Unknown memory size " + capabilityBlock.getSize());
        }
        writable = !capabilityBlock.isReadOnly() && !isLocked(readerWriter, memoryLayout);
      }
      else {
        throw new NfcException("Unknown tag contents");
      }
    }
    catch (Exception e) {
      throw new NfcException(e);
    }
    return new Type2NdefOperations(memoryLayout, readerWriter, tagInfo, formatted, writable);
  }
View Full Code Here

TOP

Related Classes of org.nfctools.NfcException

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.