Path: blob/master/src/java.smartcardio/share/classes/javax/smartcardio/CardTerminal.java
41153 views
/*1* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.smartcardio;2627import java.util.*;2829/**30* A Smart Card terminal, sometimes referred to as a Smart Card Reader.31* A CardTerminal object can be obtained by calling32* {@linkplain CardTerminals#list}33* or {@linkplain CardTerminals#getTerminal CardTerminals.getTerminal()}.34*35* <p>Note that physical card readers with slots for multiple cards are36* represented by one <code>CardTerminal</code> object per such slot.37*38* @see CardTerminals39* @see TerminalFactory40*41* @since 1.642* @author Andreas Sterbenz43* @author JSR 268 Expert Group44*/45public abstract class CardTerminal {4647/**48* Constructs a new CardTerminal object.49*50* <p>This constructor is called by subclasses only. Application should51* call {@linkplain CardTerminals#list list()}52* or {@linkplain CardTerminals#getTerminal getTerminal()}53* to obtain a CardTerminal object.54*/55protected CardTerminal() {56// empty57}5859/**60* Returns the unique name of this terminal.61*62* @return the unique name of this terminal.63*/64public abstract String getName();6566/**67* Establishes a connection to the card.68* If a connection has previously established using69* the specified protocol, this method returns the same Card object as70* the previous call.71*72* @param protocol the protocol to use ("T=0", "T=1", or "T=CL"), or "*" to73* connect using any available protocol.74*75* @throws NullPointerException if protocol is null76* @throws IllegalArgumentException if protocol is an invalid protocol77* specification78* @throws CardNotPresentException if no card is present in this terminal79* @throws CardException if a connection could not be established80* using the specified protocol or if a connection has previously been81* established using a different protocol82* @throws SecurityException if a SecurityManager exists and the83* caller does not have the required84* {@linkplain CardPermission permission}85* @return the card the connection has been established with86*/87public abstract Card connect(String protocol) throws CardException;8889/**90* Returns whether a card is present in this terminal.91*92* @return whether a card is present in this terminal.93*94* @throws CardException if the status could not be determined95*/96public abstract boolean isCardPresent() throws CardException;9798/**99* Waits until a card is present in this terminal or the timeout100* expires. If the method returns due to an expired timeout, it returns101* false. Otherwise it return true.102*103* <P>If a card is present in this terminal when this104* method is called, it returns immediately.105*106* @param timeout if positive, block for up to <code>timeout</code>107* milliseconds; if zero, block indefinitely; must not be negative108* @return false if the method returns due to an expired timeout,109* true otherwise.110*111* @throws IllegalArgumentException if timeout is negative112* @throws CardException if the operation failed113*/114public abstract boolean waitForCardPresent(long timeout) throws CardException;115116/**117* Waits until a card is absent in this terminal or the timeout118* expires. If the method returns due to an expired timeout, it returns119* false. Otherwise it return true.120*121* <P>If no card is present in this terminal when this122* method is called, it returns immediately.123*124* @param timeout if positive, block for up to <code>timeout</code>125* milliseconds; if zero, block indefinitely; must not be negative126* @return false if the method returns due to an expired timeout,127* true otherwise.128*129* @throws IllegalArgumentException if timeout is negative130* @throws CardException if the operation failed131*/132public abstract boolean waitForCardAbsent(long timeout) throws CardException;133134}135136137