Interface StorageCardSelectionExtension

All Superinterfaces:
org.eclipse.keypop.reader.selection.spi.CardSelectionExtension

public interface StorageCardSelectionExtension extends org.eclipse.keypop.reader.selection.spi.CardSelectionExtension
Extends the CardSelectionExtension interface of the "Keypop Reader API" to provide means to define optional commands to be executed during the selection phase.
Since:
1.0.0
  • Method Details

    • prepareReadBlock

      StorageCardSelectionExtension prepareReadBlock(int blockAddress)
      Prepares the reading of a specific block from the storage card.

      Block addresses start at 0 and the maximum value is equal to ProductType.getBlockCount() - 1.

      Once this command is processed, the result is available in StorageCard.

      Parameters:
      blockAddress - The address of the block to be read.
      Returns:
      The current instance.
      Throws:
      IllegalArgumentException - If the block address is out of range.
      Since:
      1.0.0
      See Also:
    • prepareReadBlocks

      StorageCardSelectionExtension prepareReadBlocks(int fromBlockAddress, int toBlockAddress)
      Prepares the reading of a range of blocks from the storage card.

      Block addresses start at 0 and the maximum value is equal to ProductType.getBlockCount() - 1.

      Once this command is processed, the result is available in StorageCard via StorageCard.getBlock(int) and StorageCard.getBlocks(int, int) methods.

      Parameters:
      fromBlockAddress - The starting block address (inclusive).
      toBlockAddress - The ending block address (inclusive).
      Returns:
      The current instance.
      Throws:
      IllegalArgumentException - If one of the arguments is out of range.
      Since:
      1.0.0
      See Also:
    • prepareMifareClassicAuthenticate

      StorageCardSelectionExtension prepareMifareClassicAuthenticate(int blockAddress, MifareClassicKeyType mifareClassicKeyType, byte[] key)
      Prepares a Mifare Classic authentication command using a provided key.

      This method is specific to Mifare Classic cards and must be called before reading from or writing to protected sectors. The authentication applies to the entire sector containing the specified block address.

      The key must be a 6-byte array representing the Mifare Classic key value.

      When the key value is provided this way, it will be sent to the reader to be stored as a volatile key at index 0 (see Load Key command of the PC/SC standard). This volatile key is temporary and will be erased after usage, when the reader is powered off.

      Security Note: This method transmits the key value over the communication channel between the application and the reader. For production environments and security-sensitive applications, it is recommended to use prepareMifareClassicAuthenticate(int, MifareClassicKeyType, int) instead, which references a pre-stored key in the reader without transmitting the key value.

      Parameters:
      blockAddress - The address of any block within the sector to authenticate.
      mifareClassicKeyType - The type of key to use (Key A or Key B).
      key - The 6-byte key data for authentication.
      Returns:
      The current instance.
      Throws:
      IllegalArgumentException - If the block address is out of range, or if the key is null or not exactly 6 bytes long.
      UnsupportedOperationException - If the current card type does not support authentication.
      Since:
      1.1.0
    • prepareMifareClassicAuthenticate

      StorageCardSelectionExtension prepareMifareClassicAuthenticate(int blockAddress, MifareClassicKeyType mifareClassicKeyType, int keyNumber)
      Prepares a Mifare Classic authentication command using a key stored in the reader.

      This method is specific to Mifare Classic cards and must be called before reading from or writing to protected sectors. The authentication applies to the entire sector containing the specified block address.

      The key is referenced by its storage index in the reader's key storage. This allows using pre-configured keys without transmitting them over the communication channel.

      Parameters:
      blockAddress - The address of any block within the sector to authenticate.
      mifareClassicKeyType - The type of key to use (Key A or Key B).
      keyNumber - The index of the key in the reader's key storage.
      Returns:
      The current instance.
      Throws:
      IllegalArgumentException - If the block address is out of range, or if the key number is invalid.
      UnsupportedOperationException - If the current card type does not support authentication.
      Since:
      1.1.0