0N/A/*
2362N/A * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.smartcardio;
0N/A
0N/Aimport java.util.*;
0N/A
0N/A/**
0N/A * A Smart Card terminal, sometimes refered to as a Smart Card Reader.
0N/A * A CardTerminal object can be obtained by calling
0N/A * {@linkplain CardTerminals#list}
0N/A * or {@linkplain CardTerminals#getTerminal CardTerminals.getTerminal()}.
0N/A *
0N/A * <p>Note that physical card readers with slots for multiple cards are
0N/A * represented by one <code>CardTerminal</code> object per such slot.
0N/A *
0N/A * @see CardTerminals
0N/A * @see TerminalFactory
0N/A *
0N/A * @since 1.6
0N/A * @author Andreas Sterbenz
0N/A * @author JSR 268 Expert Group
0N/A */
0N/Apublic abstract class CardTerminal {
0N/A
0N/A /**
0N/A * Constructs a new CardTerminal object.
0N/A *
0N/A * <p>This constructor is called by subclasses only. Application should
0N/A * call {@linkplain CardTerminals#list list()}
0N/A * or {@linkplain CardTerminals#getTerminal getTerminal()}
0N/A * to obtain a CardTerminal object.
0N/A */
0N/A protected CardTerminal() {
0N/A // empty
0N/A }
0N/A
0N/A /**
0N/A * Returns the unique name of this terminal.
0N/A *
0N/A * @return the unique name of this terminal.
0N/A */
0N/A public abstract String getName();
0N/A
0N/A /**
0N/A * Establishes a connection to the card.
0N/A * If a connection has previously established using
0N/A * the specified protocol, this method returns the same Card object as
0N/A * the previous call.
0N/A *
0N/A * @param protocol the protocol to use ("T=0", "T=1", or "T=CL"), or "*" to
0N/A * connect using any available protocol.
0N/A *
0N/A * @throws NullPointerException if protocol is null
0N/A * @throws IllegalArgumentException if protocol is an invalid protocol
0N/A * specification
0N/A * @throws CardNotPresentException if no card is present in this terminal
0N/A * @throws CardException if a connection could not be established
0N/A * using the specified protocol or if a connection has previously been
0N/A * established using a different protocol
0N/A * @throws SecurityException if a SecurityManager exists and the
0N/A * caller does not have the required
0N/A * {@linkplain CardPermission permission}
0N/A */
0N/A public abstract Card connect(String protocol) throws CardException;
0N/A
0N/A /**
0N/A * Returns whether a card is present in this terminal.
0N/A *
0N/A * @return whether a card is present in this terminal.
0N/A *
0N/A * @throws CardException if the status could not be determined
0N/A */
0N/A public abstract boolean isCardPresent() throws CardException;
0N/A
0N/A /**
0N/A * Waits until a card is present in this terminal or the timeout
0N/A * expires. If the method returns due to an expired timeout, it returns
0N/A * false. Otherwise it return true.
0N/A *
0N/A * <P>If a card is present in this terminal when this
0N/A * method is called, it returns immediately.
0N/A *
0N/A * @param timeout if positive, block for up to <code>timeout</code>
0N/A * milliseconds; if zero, block indefinitely; must not be negative
0N/A * @return false if the method returns due to an expired timeout,
0N/A * true otherwise.
0N/A *
0N/A * @throws IllegalArgumentException if timeout is negative
0N/A * @throws CardException if the operation failed
0N/A */
0N/A public abstract boolean waitForCardPresent(long timeout) throws CardException;
0N/A
0N/A /**
0N/A * Waits until a card is absent in this terminal or the timeout
0N/A * expires. If the method returns due to an expired timeout, it returns
0N/A * false. Otherwise it return true.
0N/A *
0N/A * <P>If no card is present in this terminal when this
0N/A * method is called, it returns immediately.
0N/A *
0N/A * @param timeout if positive, block for up to <code>timeout</code>
0N/A * milliseconds; if zero, block indefinitely; must not be negative
0N/A * @return false if the method returns due to an expired timeout,
0N/A * true otherwise.
0N/A *
0N/A * @throws IllegalArgumentException if timeout is negative
0N/A * @throws CardException if the operation failed
0N/A */
0N/A public abstract boolean waitForCardAbsent(long timeout) throws CardException;
0N/A
0N/A}