- All Implemented Interfaces:
ApduLayer,MessageLayer
- Author:
- gematik
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidRequests exclusive access to this card.voiddisconnect(boolean reset) Disconnects the connection with this card.voidReleases the exclusive access previously established usingbeginExclusive.Getter.getATR()Returns the ATR of this card.Returns the CardChannel for the basic logical channel.Returns the protocol in use for this card.doublegetTime()Returns execution time of previous command-response pair.Opens a new logical channel to the card and returns it.voidreset()Resets the application layer of the smart card.byte[]send(byte[] command) Sends given message.send(CommandApdu apdu) Sends given command APDU.toString()ReturnsStringrepresentation.byte[]transmitControlCommand(int controlCode, byte[] command) Transmits a control command to the terminal device.
-
Method Details
-
getATR
Returns the ATR of this card. -
getAnswerToReset
Getter.- Returns:
AnswerToResetof connected smart card
-
getProtocol
Returns the protocol in use for this card.- Specified by:
getProtocolin classCard- Returns:
- the protocol in use for this card, for example "T=0" or "T=1"
-
getBasicChannel
Returns the CardChannel for the basic logical channel. The basic logical channel has a channel number of 0.- Specified by:
getBasicChannelin classCard- Returns:
- the CardChannel for the basic logical channel
- Throws:
SecurityException- if a SecurityManager exists and the caller does not have the required permissionIllegalStateException- if this card object has been disposed of via thedisconnect(boolean)method
-
openLogicalChannel
Opens a new logical channel to the card and returns it. The channel is opened by issuing aMANAGE CHANNELcommand that should use the format[00 70 00 00 01].- Specified by:
openLogicalChannelin classCard- Returns:
- the logical channel which has been opened
- Throws:
ArithmeticException- if channel number in response data field encodes a number greater thanInteger.MAX_VALUECardException- 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 failedIllegalStateException- if the correspondingCardhas beendisconnected
-
beginExclusive
Requests exclusive access to this card.Once a thread has invoked
beginExclusive, only this thread is allowed to communicate with this card until it callsendExclusive. 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()andendExclusivecalls in atry ... finallyblock.- Specified by:
beginExclusivein classCard- Throws:
SecurityException- if a SecurityManager exists and the caller does not have the required permissionCardException- if exclusive access has already been set or if exclusive access could not be establishedIllegalStateException- if this card object has been disposed of via the disconnect(boolean) method
-
endExclusive
Releases the exclusive access previously established usingbeginExclusive.- Specified by:
endExclusivein classCard- Throws:
SecurityException- if a SecurityManager exists and the caller does not have the required permissionIllegalStateException- if- the active Thread does not currently have exclusive access to this card
- this card object has been disposed of via the
disconnect(boolean)method
CardException- if the operation failed
-
transmitControlCommand
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:
transmitControlCommandin classCard- Parameters:
controlCode- the control code of the commandcommand- the command data- Returns:
- the response from the terminal device
- Throws:
SecurityException- if a SecurityManager exists and the caller does not have the required permissionNullPointerException- if command is nullCardException- if the card operation failedIllegalStateException- if this card object has been disposed of via the disconnect() method
-
disconnect
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 anIllegalStateException.- Specified by:
disconnectin classCard- 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:
getTimein interfaceMessageLayer- 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 aCommandApduis 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)), thensend(CommandApdu)converts thatCommandApduto'00 B0 8102 03'(i.e., ISO-case 2S (short)).- Specified by:
sendin interfaceMessageLayer- Parameters:
command- command APDU- Returns:
- corresponding response APDU
- See Also:
-
send
Sends given command APDU.E.g. if a
CommandApduis 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 thatCommandApduto'00 B0 8102 03'(i.e., ISO-case 2S (short)). Thus, if the intention is to send an ISO-case 2E methodsend(byte[])has to be used.- Specified by:
sendin interfaceApduLayer- Parameters:
apdu- command APDU to be sent- Returns:
- corresponding
ResponseApdu
-
toString
ReturnsStringrepresentation.
-