com.datecs.rfid

## Class ISO14443Card

- java.lang.Object
- - com.datecs.rfid.ContactlessCard
  - - com.datecs.rfid.ISO14443Card

-     public class ISO14443Card
      extends ContactlessCard

  A class that represents ISO14443 cards.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `ISO14443Card.DESFire`

  - ### Field Summary

    - ### Fields inherited from class com.datecs.rfid.ContactlessCard

      `afi, atqa, blockSize, capacity, CARD_EPASSPORT, CARD_FELICA, CARD_ISO14443A, CARD_ISO14443B, CARD_ISO15693, CARD_MIFARE_CLASSIC_1K, CARD_MIFARE_CLASSIC_4K, CARD_MIFARE_DESFIRE, CARD_MIFARE_MINI, CARD_MIFARE_PLUS, CARD_MIFARE_ULTRALIGHT, CARD_MIFARE_ULTRALIGHT_C, CARD_PAYMENT, CARD_PICOPASS_14443B, CARD_PICOPASS_15693, CARD_ST_SRI, CARD_UNKNOWN, channel, dsfid, hyatt64Card, maxBlocks, mModule, sak, type, uid`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ISO14443Card(RC663 module)` Constructs a new instance of this class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `authenticate(char type, int address, byte[] key)` Authenticate mifare card block with direct key data.
    `void` | `authenticate(char type, int address, int keyIndex)` Authenticate mifare card block with previously stored key.
    `protected boolean` | `deinitialise()` Deinitialise card.
    `ISO14443Card.DESFire` | `DESFire()`
    `byte[]` | `executeAPDU(int cla, int ins, int p1, int p2, byte[] data)` Execute APDU command.
    `byte[]` | `executeAPDU(int cla, int ins, int p1, int p2, byte[] data, int le)` Execute APDU command.
    `byte[]` | `getATS()` Get ATS.
    `byte[]` | `getAttribB(int p1, int p2, int p3, int p4)` Get attribute B
    `boolean` | `initialize()` Initialize card.
    `boolean` | `isPresentB()` Check if card present.
    `void` | `loadKey(int keyIndex, char type, byte[] key)` Store key in the internal module memory for later use.
    `byte[]` | `read16(int address)` Reads one block of data from Mifare Classic/Ultralight cards.
    `byte[]` | `transceive(byte[] data)` Transceive data to ISO14443
    `byte[]` | `transceiveA(byte[] data)` Transceive data to ISO14443 A
    `byte[]` | `transceiveB(byte[] data)` Transceive data to ISO14443 B
    `void` | `ulcAuthenticate(byte[] key)` Performs 3DES authentication of Mifare Ultralight C card using the given key.
    `void` | `ulcSetKey(byte[] key)` Sets the 3DES key of Mifare Ultralight C cards.
    `void` | `write16(int address, byte[] data)` Writes one block of data to Mifare Classic/Ultralight cards.
    `void` | `write4(int address, byte[] data)`

    - ### Methods inherited from class com.datecs.rfid.ContactlessCard

      `getModule, getTypeName, waitRemove`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ISO14443Card

          public ISO14443Card(RC663 module)

      Constructs a new instance of this class.
      Parameters:
        `module` - The instance of `RC663` module.

  - ### Method Detail

    - #### deinitialise

          protected boolean deinitialise()
                                  throws java.io.IOException

      Description copied from class: `ContactlessCard`
      Deinitialise card.
      Specified by:
        `deinitialise` in class `ContactlessCard`
      Returns:
        on success returns true, otherwise returns false.
      Throws:
        `java.io.IOException` - if an I/O error occurs.

    - #### initialize

          public boolean initialize()
                             throws java.io.IOException

      Initialize card.
      Specified by:
        `initialize` in class `ContactlessCard`
      Returns:
        On success returns true, otherwise returns false.
      Throws:
        `java.io.IOException` - if an I/O error occurs.

    - #### loadKey

          public void loadKey(int keyIndex,
                              char type,
                              byte[] key)
                       throws java.io.IOException,
                              RFIDException

      Store key in the internal module memory for later use.
      Parameters:
        `keyIndex` - The index of the key, you can have up to 8 keys stored (0-7).
        `type` - The key type, either 'A' or 'B'.
        `key` - The 6 bytes key.
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### authenticate

          public void authenticate(char type,
                                   int address,
                                   byte[] key)
                            throws java.io.IOException,
                                   RFIDException

      Authenticate mifare card block with direct key data.

      This is less secure method, as it requires the key to be present in the program, the preferred way is to store a key once in a secure environment and then authenticate using the stored key.

      Parameters:
        `type` - The key type, either 'A' or 'B'.
        `address` - The address of the block to authenticate.
        `key` - The 6 bytes key.
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### authenticate

          public void authenticate(char type,
                                   int address,
                                   int keyIndex)
                            throws java.io.IOException,
                                   RFIDException

      Authenticate mifare card block with previously stored key.

      This the preferred method, as no key needs to reside in application.

      Parameters:
        `type` - The key type, either 'A' or 'B'.
        `address` - The address of the block to authenticate.
        `keyIndex` - The index of the stored key, you can have up to 8 keys stored (0-7).
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### read16

          public byte[] read16(int address)
                        throws java.io.IOException,
                               RFIDException

      Reads one block of data from Mifare Classic/Ultralight cards.

      A read operation gets 16 bytes of data.

      Parameters:
        `address` - The address of the block to read.
      Returns:
        The 16 byte data.
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### write16

          public void write16(int address,
                              byte[] data)
                       throws java.io.IOException,
                              RFIDException

      Writes one block of data to Mifare Classic/Ultralight cards.

      A write operation stores 16 bytes of data.

      Parameters:
        `address` - The address of the block to write.
        `data` - The data to write, must be multiple of the block size (16 bytes).
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### write4

          public void write4(int address,
                             byte[] data)
                      throws java.io.IOException,
                             RFIDException

      Throws:
        `java.io.IOException`
        `RFIDException`

    - #### ulcSetKey

          public void ulcSetKey(byte[] key)
                         throws java.io.IOException,
                                RFIDException

      Sets the 3DES key of Mifare Ultralight C cards.
      Parameters:
        `key` - The 16 bytes 3DES key to set.
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### ulcAuthenticate

          public void ulcAuthenticate(byte[] key)
                               throws java.io.IOException,
                                      RFIDException

      Performs 3DES authentication of Mifare Ultralight C card using the given key.
      Parameters:
        `key` - The 16 bytes 3DES key to authenticate with.
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### getATS

          public byte[] getATS()
                        throws java.io.IOException,
                               RFIDException

      Get ATS.
      Returns:
        ATS data.
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### getAttribB

          public byte[] getAttribB(int p1,
                                   int p2,
                                   int p3,
                                   int p4)
                            throws java.io.IOException,
                                   RFIDException

      Get attribute B
      Parameters:
        `p1` - param 1;
        `p2` - param 2;
        `p3` - param 3;
        `p4` - param 4;
      Returns:
        attribute B
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### isPresentB

          public boolean isPresentB()
                             throws java.io.IOException

      Check if card present.
      Returns:
        true if present; otherwise return false.
      Throws:
        `java.io.IOException` - If an I/O error occurs.

    - #### transceiveA

          public byte[] transceiveA(byte[] data)
                             throws java.io.IOException,
                                    RFIDException

      Transceive data to ISO14443 A
      Parameters:
        `data` - the data.
      Returns:
        the result.
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### transceiveB

          public byte[] transceiveB(byte[] data)
                             throws java.io.IOException,
                                    RFIDException

      Transceive data to ISO14443 B
      Parameters:
        `data` - the data.
      Returns:
        the result.
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### transceive

          public byte[] transceive(byte[] data)
                            throws java.io.IOException,
                                   RFIDException

      Transceive data to ISO14443
      Parameters:
        `data` - the data.
      Returns:
        the result.
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### executeAPDU

          public byte[] executeAPDU(int cla,
                                    int ins,
                                    int p1,
                                    int p2,
                                    byte[] data)
                             throws java.io.IOException,
                                    RFIDException

      Execute APDU command.
      Parameters:
        `cla` - CLA
        `ins` - INS
        `p1` - P1
        `p2` - P2
        `data` - APDU data.
      Returns:
        command response.
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### executeAPDU

          public byte[] executeAPDU(int cla,
                                    int ins,
                                    int p1,
                                    int p2,
                                    byte[] data,
                                    int le)
                             throws java.io.IOException,
                                    RFIDException

      Execute APDU command.
      Parameters:
        `cla` - CLA
        `ins` - INS
        `p1` - P1
        `p2` - P2
        `data` - APDU data.
        `le` - requested response length.
      Returns:
        command response.
      Throws:
        `java.io.IOException` - If an I/O error occurs.
        `RFIDException` - if an RF663 error occurs.

    - #### DESFire

          public ISO14443Card.DESFire DESFire()