java.lang.Object
javax.smartcardio.CardTerminal
A Smart Card terminal, sometimes referred to as a Smart Card Reader.
A CardTerminal object can be obtained by calling
CardTerminals.list()
or CardTerminals.getTerminal().
Note that physical card readers with slots for multiple cards are
represented by one CardTerminal
object per such slot.
- Since:
- 1.6
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract Card
Establishes a connection to the card.abstract String
getName()
Returns the unique name of this terminal.abstract boolean
Returns whether a card is present in this terminal.abstract boolean
waitForCardAbsent
(long timeout) Waits until a card is absent in this terminal or the timeout expires.abstract boolean
waitForCardPresent
(long timeout) Waits until a card is present in this terminal or the timeout expires.
-
Constructor Details
-
CardTerminal
protected CardTerminal()Constructs a new CardTerminal object.This constructor is called by subclasses only. Application should call list() or getTerminal() to obtain a CardTerminal object.
-
-
Method Details
-
getName
Returns the unique name of this terminal.- Returns:
- the unique name of this terminal.
-
connect
Establishes a connection to the card. If a connection has previously established using the specified protocol, this method returns the same Card object as the previous call.- Parameters:
protocol
- the protocol to use ("T=0", "T=1", or "T=CL"), or "*" to connect using any available protocol.- Returns:
- the card the connection has been established with
- Throws:
NullPointerException
- if protocol is nullIllegalArgumentException
- if protocol is an invalid protocol specificationCardNotPresentException
- if no card is present in this terminalCardException
- if a connection could not be established using the specified protocol or if a connection has previously been established using a different protocolSecurityException
- if a SecurityManager exists and the caller does not have the required permission
-
isCardPresent
Returns whether a card is present in this terminal.- Returns:
- whether a card is present in this terminal.
- Throws:
CardException
- if the status could not be determined
-
waitForCardPresent
Waits until a card is present in this terminal or the timeout expires. If the method returns due to an expired timeout, it returns false. Otherwise it return true.If a card is present in this terminal when this method is called, it returns immediately.
- Parameters:
timeout
- if positive, block for up totimeout
milliseconds; if zero, block indefinitely; must not be negative- Returns:
- false if the method returns due to an expired timeout, true otherwise.
- Throws:
IllegalArgumentException
- if timeout is negativeCardException
- if the operation failed
-
waitForCardAbsent
Waits until a card is absent in this terminal or the timeout expires. If the method returns due to an expired timeout, it returns false. Otherwise it return true.If no card is present in this terminal when this method is called, it returns immediately.
- Parameters:
timeout
- if positive, block for up totimeout
milliseconds; if zero, block indefinitely; must not be negative- Returns:
- false if the method returns due to an expired timeout, true otherwise.
- Throws:
IllegalArgumentException
- if timeout is negativeCardException
- if the operation failed
-