Package org.nfctools.mf

Examples of org.nfctools.mf.MfAccess


  public static ApplicationDirectory getApplicationDirectory(MfCard card, MfReaderWriter readerWriter,
      byte[] writeKeyValue) throws IOException {

    SimpleMfAccess simpleMfAccess = new SimpleMfAccess(card, Key.A, MadConstants.DEFAULT_MAD_KEY);

    TrailerBlock madTrailer = (TrailerBlock)readerWriter.readBlock(new MfAccess(simpleMfAccess, 0, card
        .getTrailerBlockNumberForSector(0), 1))[0];

    if ((madTrailer.getGeneralPurposeByte() & MadConstants.GPB_MAD_AVAILABLE) != 0) {
      if ((madTrailer.getGeneralPurposeByte() & MadConstants.GPB_MAD_V1) == MadConstants.GPB_MAD_V1) {
        madTrailer.setKey(Key.A, MadConstants.DEFAULT_MAD_KEY);
View Full Code Here


  @Deprecated
  public static boolean hasApplicationDirectory(MfCard card, MfReaderWriter readerWriter) throws IOException {
    try {
      SimpleMfAccess simpleMfAccess = new SimpleMfAccess(card, Key.A, MadConstants.DEFAULT_MAD_KEY);

      TrailerBlock madTrailer = (TrailerBlock)readerWriter.readBlock(new MfAccess(simpleMfAccess, 0, card
          .getTrailerBlockNumberForSector(0), 1))[0];

      return ((madTrailer.getGeneralPurposeByte() & MadConstants.GPB_MAD_AVAILABLE) != 0);
    }
    catch (MfLoginException e) {
View Full Code Here

      trailerBlock.setKey(Key.A, MadConstants.DEFAULT_MAD_KEY);
      trailerBlock.setKey(Key.B, writeKeyValue);
      trailerBlock.setAccessConditions(MadConstants.READ_WRITE_ACCESS_CONDITIONS);
      trailerBlock.setGeneralPurposeByte((byte)(MadConstants.GPB_MAD_AVAILABLE | MadConstants.GPB_MAD_V1));

      MfAccess mfAccess = new MfAccess(card, 0, card.getTrailerBlockNumberForSector(0), createKey, createKeyValue);
      readerWriter.writeBlock(mfAccess, trailerBlock);

      MfAccess mfAccessDataBlock = new MfAccess(card, 0, 1, Key.B, writeKeyValue);
      readerWriter.writeBlock(mfAccessDataBlock, new DataBlock(), new DataBlock());

      Mad1 mad1 = new Mad1(null, null);
      mad1.writeMad();

      return mad1;
    }

    if (card instanceof MfCard4k) {
      TrailerBlock trailerBlock = new TrailerBlock();
      trailerBlock.setKey(Key.A, MadConstants.DEFAULT_MAD_KEY);
      trailerBlock.setKey(Key.B, writeKeyValue);
      trailerBlock.setAccessConditions(MadConstants.READ_WRITE_ACCESS_CONDITIONS);
      trailerBlock.setGeneralPurposeByte((byte)(MadConstants.GPB_MAD_AVAILABLE | MadConstants.GPB_MAD_V2));

      MfAccess mfAccess = new MfAccess(card, 0, card.getTrailerBlockNumberForSector(0), createKey, createKeyValue);
      readerWriter.writeBlock(mfAccess, trailerBlock);

      MfAccess mfAccessDataBlock = new MfAccess(card, 0, 1, Key.B, writeKeyValue);
      readerWriter.writeBlock(mfAccessDataBlock, new DataBlock(), new DataBlock());

      MfAccess mfAccess2 = new MfAccess(card, 16, card.getTrailerBlockNumberForSector(16), createKey,
          createKeyValue);
      readerWriter.writeBlock(mfAccess2, trailerBlock);

      MfAccess mfAccessDataBlock2 = new MfAccess(card, 16, 1, Key.B, writeKeyValue);
      readerWriter.writeBlock(mfAccessDataBlock2, new DataBlock(), new DataBlock());

      Mad2 mad = new Mad2(null, null);
      mad.writeMad();
View Full Code Here

TOP

Related Classes of org.nfctools.mf.MfAccess

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.