Package org.nfctools.mf.mad

Examples of org.nfctools.mf.mad.Application


    if (lastReadRecords != null) {
      return lastReadRecords;
    }
    else {
      try {
        Application application = getApplication();
        // TODO create TagInputStream for better performance
        byte[] tlvWrappedNdefMessage = application.read(new KeyValue(Key.A, MfConstants.NDEF_KEY));
        if (log.isDebugEnabled())
          log.debug(NfcUtils.convertBinToASCII(tlvWrappedNdefMessage));
        TypeLengthValueReader reader = new TypeLengthValueReader(
            new ByteArrayInputStream(tlvWrappedNdefMessage));
        convertRecords(reader);
View Full Code Here


  private Application getApplication() {
    try {
      ApplicationDirectory applicationDirectory = readerWriter.getApplicationDirectory(new MadKeyConfig(Key.A,
          writeKey, writeKey));
      Application application = applicationDirectory.openApplication(MfConstants.NDEF_APP_ID);
      return application;
    }
    catch (IOException e) {
      throw new NfcException(e);
    }
View Full Code Here

  @Override
  public void makeReadOnly() {
    assertFormatted();
    assertWritable();
    try {
      Application application = getApplication();
      application.getApplicationDirectory().makeReadOnly();
      application.makeReadOnly(new KeyValue(Key.B, writeKey));
      writable = false;
    }
    catch (IOException e) {
      throw new NfcException(e);
    }
View Full Code Here

    }
  }

  @Override
  public void format(Record... records) {
    Application application = createNewApplication();
    writeRecord(application, records);
    formatted = true;
  }
View Full Code Here

      ApplicationDirectory applicationDirectory = readerWriter.createApplicationDirectory(new MadKeyConfig(Key.A,
          MfConstants.TRANSPORT_KEY, writeKey));
      TrailerBlock readWriteTrailerBlock = ClassicHandler.createReadWriteDataTrailerBlock();
      readWriteTrailerBlock.setKey(Key.A, writeKey);
      readWriteTrailerBlock.setKey(Key.B, writeKey);
      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

      tagInfo = readerWriter.getTagInfo();
      if (readerWriter.hasApplicationDirectory()) {
        ApplicationDirectory applicationDirectory = readerWriter.getApplicationDirectory();
        if (applicationDirectory.hasApplication(MfConstants.NDEF_APP_ID)) {
          formatted = true;
          Application application = applicationDirectory.openApplication(MfConstants.NDEF_APP_ID);
          writable = ClassicHandler.isFormattedWritable(application, MfClassicConstants.NDEF_KEY);
        }
        else {
          throw new NfcException("Unknown tag contents");
        }
View Full Code Here

    /*
     * The specs states that the TLV terminator can be left out if the message ends with the available space.
     * One might want to check if the available size on the card is one byte less than the tlv wrapped message. If
     * it is the case the TLV terminator could be removed.
     */
    Application application = applicationDirectory.createApplication(MfNdefConstants.NDEF_APP_ID,
        tlvWrappedNdefData.length, writeKeyValue, trailerBlock);

    if (log.isDebugEnabled())
      log.debug("Length: " + tlvWrappedNdefData.length + " [" + NfcUtils.convertBinToASCII(tlvWrappedNdefData)
          + "]");

    application.write(new KeyValue(Key.B, writeKeyValue), tlvWrappedNdefData);
  }
View Full Code Here

    ApplicationDirectory applicationDirectory = MadUtils.getApplicationDirectory(card, readerWriter);

    if (applicationDirectory.hasApplication(MfNdefConstants.NDEF_APP_ID)) {

      Application application = applicationDirectory.openApplication(MfNdefConstants.NDEF_APP_ID);

      byte[] tlvWrappedNdefMessage = application.read(new KeyValue(Key.A, MfConstants.NDEF_KEY));

      if (log.isDebugEnabled())
        log.debug(NfcUtils.convertBinToASCII(tlvWrappedNdefMessage));

      TypeLengthValueReader lengthValueReader = new TypeLengthValueReader(new ByteArrayInputStream(
View Full Code Here

TOP

Related Classes of org.nfctools.mf.mad.Application

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.