Examples of MfClassicReaderWriter


Examples of org.nfctools.mf.classic.MfClassicReaderWriter

  @Override
  public void handleTag(Tag tag) {
    MemoryLayout memoryLayout = tag.getTagType().equals(TagType.MIFARE_CLASSIC_1K) ? MemoryLayout.CLASSIC_1K
        : MemoryLayout.CLASSIC_4K;
    MfClassicReaderWriter readerWriter = new AcrMfClassicReaderWriter((ApduTag)tag, memoryLayout);
    try {
      doWithReaderWriter(readerWriter);
    }
    catch (IOException e) {
      log.error(e.getLocalizedMessage(), e);
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicReaderWriter

    assertEquals(3 * 16, mad.getSlotSize(14));
  }

  @Test
  public void testMadAidSize() throws Exception {
    MfClassicReaderWriter readerWriter = loadData(blankCard);

    ApplicationDirectory applicationDirectory = readerWriter.createApplicationDirectory(MAD_KEY_CONFIG);

    assertEquals(1, applicationDirectory.getVersion());

    assertTrue(applicationDirectory.isFree(0));
    assertTrue(applicationDirectory.isFree(applicationDirectory.getNumberOfSlots() - 1));
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicReaderWriter

    assertEquals(maxFreeSpace, applicationDirectory.getMaxContinousSize());
  }

  @Test
  public void testMadCrc() throws Exception {
    MfClassicReaderWriter readerWriter = loadData(cardWithMad);
    Mad1 applicationDirectory = (Mad1)readerWriter.getApplicationDirectory(MAD_KEY_CONFIG);
    applicationDirectory.updateCrc();
    assertEquals((byte)0xf3, applicationDirectory.madData[0]);

  }
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicReaderWriter

    }
  }

  @Test
  public void testMadApplicationSizes() throws Exception {
    MfClassicReaderWriter readerWriter = loadData(blankCard);

    ApplicationDirectory applicationDirectory = readerWriter.createApplicationDirectory(MAD_KEY_CONFIG);
    Application application = applicationDirectory.createApplication(testAppId, largeAppSize, dummyKey,
        testNdefTrailerBlock);
    assertArrayEquals(testAppId.getAid(), application.getApplicationId());
    assertEquals(largeAppSize, application.getAllocatedSize());
    byte[] readData = application.read(KEY_VALUE_A);
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicReaderWriter

    assertEquals(largeAppSize, readData.length);
  }

  @Test(expected = IllegalArgumentException.class)
  public void testMadApplicationTooBig() throws Exception {
    MfClassicReaderWriter readerWriter = loadData(blankCard);
    ApplicationDirectory applicationDirectory = readerWriter.createApplicationDirectory(MAD_KEY_CONFIG);
    applicationDirectory.createApplication(testAppId, maxFreeSpace + 1, dummyKey, testNdefTrailerBlock);
  }
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicReaderWriter

    applicationDirectory.createApplication(testAppId, maxFreeSpace + 1, dummyKey, testNdefTrailerBlock);
  }

  @Test
  public void testMadOpenReadAid() throws Exception {
    MfClassicReaderWriter readerWriter = loadData(cardWithMad);

    ApplicationDirectory applicationDirectory = readerWriter.getApplicationDirectory();
    Application application = applicationDirectory.openApplication(testAppId);
    assertArrayEquals(testAppId.getAid(), application.getApplicationId());
    assertEquals(existingAppSize, application.getAllocatedSize());
    byte[] readData = application.read(KEY_VALUE_A);
    assertEquals(existingAppSize, readData.length);
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicReaderWriter

    assertEquals(existingAppSize, readData.length);
  }

  @Test
  public void testMadHasMad() throws Exception {
    MfClassicReaderWriter readerWriter = loadData(cardWithMad);
    assertTrue(readerWriter.hasApplicationDirectory());

    MfClassicReaderWriter readerWriterBlank = loadData(blankCard);
    assertFalse(readerWriterBlank.hasApplicationDirectory());
  }
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicReaderWriter

    assertFalse(readerWriterBlank.hasApplicationDirectory());
  }

  @Test
  public void testMadCreate() throws Exception {
    MfClassicReaderWriter readerWriter = loadData(blankCard);

    assertFalse(readerWriter.hasApplicationDirectory());
    readerWriter.createApplicationDirectory(MAD_KEY_CONFIG);
    assertTrue(readerWriter.hasApplicationDirectory());
  }
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicReaderWriter

    assertTrue(readerWriter.hasApplicationDirectory());
  }

  @Test
  public void testMadOpenWriteReadApplication() throws Exception {
    MfClassicReaderWriter readerWriter = loadData(cardWithMad);
    ApplicationDirectory applicationDirectory = readerWriter.getApplicationDirectory();
    Application application = applicationDirectory.openApplication(testAppId);

    assertEquals(existingAppSize, application.getAllocatedSize());

    byte[] content = new byte[application.getAllocatedSize()];
View Full Code Here

Examples of org.nfctools.mf.classic.MfClassicReaderWriter

    assertArrayEquals(content, readContent);
  }

  @Test
  public void testMadUpdateApplicationTrailer() throws Exception {
    MfClassicReaderWriter readerWriter = loadData(cardWithMad);

    ApplicationDirectory applicationDirectory = readerWriter.getApplicationDirectory();
    Application application = applicationDirectory.openApplication(testAppId);
    application.updateTrailer(KEY_VALUE_B, testNdefTrailerBlock);

    TrailerBlock readTrailer = application.readTrailer(KEY_VALUE_B);
    assertArrayEquals(testNdefTrailerBlock.getAccessConditions(), readTrailer.getAccessConditions());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.