java.lang.Object
javax.smartcardio.Card
de.gematik.smartcards.pcsc.Icc
All Implemented Interfaces:
ApduLayer, MessageLayer

public final class Icc extends Card implements ApduLayer
Class extending Card and implementing ApduLayer.
Author:
gematik
See Also:
  • Method Details

    • getATR

      public ATR getATR()
      Returns the ATR of this card.
      Specified by:
      getATR in class Card
      Returns:
      the ATR of this card.
    • getAnswerToReset

      public AnswerToReset getAnswerToReset()
      Getter.
      Returns:
      AnswerToReset of connected smart card
    • getProtocol

      public String getProtocol()
      Returns the protocol in use for this card.
      Specified by:
      getProtocol in class Card
      Returns:
      the protocol in use for this card, for example "T=0" or "T=1"
    • getBasicChannel

      public CardChannel getBasicChannel()
      Returns the CardChannel for the basic logical channel. The basic logical channel has a channel number of 0.
      Specified by:
      getBasicChannel in class Card
      Returns:
      the CardChannel for the basic logical channel
      Throws:
      SecurityException - if a SecurityManager exists and the caller does not have the required permission
      IllegalStateException - if this card object has been disposed of via the disconnect(boolean) method
    • openLogicalChannel

      public CardChannel openLogicalChannel() throws CardException
      Opens a new logical channel to the card and returns it. The channel is opened by issuing a MANAGE CHANNEL command that should use the format [00 70 00 00 01].
      Specified by:
      openLogicalChannel in class Card
      Returns:
      the logical channel which has been opened
      Throws:
      ArithmeticException - if channel number in response data field encodes a number greater than Integer.MAX_VALUE
      CardException - if the card operation fails
    • reset

      public void reset()
      Resets the application layer of the smart card.

      All logical channels are closed and the basic logical channel is reset.

      Throws:
      IllegalArgumentException - if the card operation failed
      IllegalStateException - if the corresponding Card has been disconnected
    • beginExclusive

      public void beginExclusive() throws CardException
      Requests exclusive access to this card.

      Once a thread has invoked beginExclusive, only this thread is allowed to communicate with this card until it calls endExclusive. Other threads attempting communication will receive a CardException.

      Applications have to ensure that exclusive access is correctly released. This can be achieved by executing the beginExclusive() and endExclusive calls in a try ... finally block.

      Specified by:
      beginExclusive in class Card
      Throws:
      SecurityException - if a SecurityManager exists and the caller does not have the required permission
      CardException - if exclusive access has already been set or if exclusive access could not be established
      IllegalStateException - if this card object has been disposed of via the disconnect(boolean) method
    • endExclusive

      public void endExclusive() throws CardException
      Releases the exclusive access previously established using beginExclusive.
      Specified by:
      endExclusive in class Card
      Throws:
      SecurityException - if a SecurityManager exists and the caller does not have the required permission
      IllegalStateException - if
      1. the active Thread does not currently have exclusive access to this card
      2. this card object has been disposed of via the disconnect(boolean) method
      CardException - if the operation failed
    • transmitControlCommand

      public byte[] transmitControlCommand(int controlCode, byte[] command) throws CardException
      Transmits a control command to the terminal device.

      This can be used to, for example, control terminal functions like a built-in PIN pad or biometrics.

      Specified by:
      transmitControlCommand in class Card
      Parameters:
      controlCode - the control code of the command
      command - the command data
      Returns:
      the response from the terminal device
      Throws:
      SecurityException - if a SecurityManager exists and the caller does not have the required permission
      NullPointerException - if command is null
      CardException - if the card operation failed
      IllegalStateException - if this card object has been disposed of via the disconnect() method
    • disconnect

      public void disconnect(boolean reset) throws CardException
      Disconnects the connection with this card.

      After this method returns, calling methods on this object or in {CardChannels associated with this object that require interaction with the card will raise an IllegalStateException.

      Specified by:
      disconnect in class Card
      Parameters:
      reset - whether to reset the card after disconnecting
      Throws:
      CardException - if the card operation failed
    • getTime

      public double getTime()
      Returns execution time of previous command-response pair.
      Specified by:
      getTime in interface MessageLayer
      Returns:
      execution time in seconds of previous command-response pair
    • send

      public byte[] send(byte[] command)
      Sends given message.

      This method is used by the implementation of send(CommandApdu). The purpose of this method is to provide a transparent channel. E.g., if a CommandApdu is constructed from octet string '00 B0 8102 00 0003' (i.e., READ BINARY with ShortFileIdentifier=1 and offset=2 and Ne=3, ISO-case 2E (extended)), then send(CommandApdu) converts that CommandApdu to '00 B0 8102 03' (i.e., ISO-case 2S (short)).

      Specified by:
      send in interface MessageLayer
      Parameters:
      command - command APDU
      Returns:
      corresponding response APDU
      See Also:
    • send

      public ResponseApdu send(CommandApdu apdu)
      Sends given command APDU.

      E.g. if a CommandApdu is constructed from octet string '00 B0 8102 00 0003' (i.e., READ BINARY with ShortFileIdentifier=1 and offset=2 and Ne=3, ISO-case 2E (extended)), then this method converts that CommandApdu to '00 B0 8102 03' (i.e., ISO-case 2S (short)). Thus, if the intention is to send an ISO-case 2E method send(byte[]) has to be used.

      Specified by:
      send in interface ApduLayer
      Parameters:
      apdu - command APDU to be sent
      Returns:
      corresponding ResponseApdu
    • toString

      public String toString()
      Returns String representation.
      Overrides:
      toString in class Object
      Returns:
      "PC/SC ICC in " + IfdName + protocol + state