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.nio.ByteBuffer;
0N/A
0N/A/**
0N/A * A Smart Card with which a connection has been established. Card objects
0N/A * are obtained by calling {@link CardTerminal#connect CardTerminal.connect()}.
0N/A *
0N/A * @see CardTerminal
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 Card {
0N/A
0N/A /**
0N/A * Constructs a new Card object.
0N/A *
0N/A * <p>This constructor is called by subclasses only. Application should
0N/A * call the {@linkplain CardTerminal#connect CardTerminal.connect()}
0N/A * method to obtain a Card
0N/A * object.
0N/A */
0N/A protected Card() {
0N/A // empty
0N/A }
0N/A
0N/A /**
0N/A * Returns the ATR of this card.
0N/A *
0N/A * @return the ATR of this card.
0N/A */
0N/A public abstract ATR getATR();
0N/A
0N/A /**
0N/A * Returns the protocol in use for this card.
0N/A *
0N/A * @return the protocol in use for this card, for example "T=0" or "T=1"
0N/A */
0N/A public abstract String getProtocol();
0N/A
0N/A /**
0N/A * Returns the CardChannel for the basic logical channel. The basic
0N/A * logical channel has a channel number of 0.
0N/A *
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 * @throws IllegalStateException if this card object has been disposed of
0N/A * via the {@linkplain #disconnect disconnect()} method
0N/A */
0N/A public abstract CardChannel getBasicChannel();
0N/A
0N/A /**
0N/A * Opens a new logical channel to the card and returns it. The channel is
0N/A * opened by issuing a <code>MANAGE CHANNEL</code> command that should use
0N/A * the format <code>[00 70 00 00 01]</code>.
0N/A *
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 * @throws CardException is a new logical channel could not be opened
0N/A * @throws IllegalStateException if this card object has been disposed of
0N/A * via the {@linkplain #disconnect disconnect()} method
0N/A */
0N/A public abstract CardChannel openLogicalChannel() throws CardException;
0N/A
0N/A /**
0N/A * Requests exclusive access to this card.
0N/A *
0N/A * <p>Once a thread has invoked <code>beginExclusive</code>, only this
0N/A * thread is allowed to communicate with this card until it calls
0N/A * <code>endExclusive</code>. Other threads attempting communication
0N/A * will receive a CardException.
0N/A *
0N/A * <p>Applications have to ensure that exclusive access is correctly
0N/A * released. This can be achieved by executing
0N/A * the <code>beginExclusive()</code> and <code>endExclusive</code> calls
0N/A * in a <code>try ... finally</code> block.
0N/A *
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 * @throws CardException if exclusive access has already been set
0N/A * or if exclusive access could not be established
0N/A * @throws IllegalStateException if this card object has been disposed of
0N/A * via the {@linkplain #disconnect disconnect()} method
0N/A */
0N/A public abstract void beginExclusive() throws CardException;
0N/A
0N/A /**
0N/A * Releases the exclusive access previously established using
0N/A * <code>beginExclusive</code>.
0N/A *
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 * @throws IllegalStateException if the active Thread does not currently have
0N/A * exclusive access to this card or
0N/A * if this card object has been disposed of
0N/A * via the {@linkplain #disconnect disconnect()} method
0N/A * @throws CardException if the operation failed
0N/A */
0N/A public abstract void endExclusive() throws CardException;
0N/A
0N/A /**
0N/A * Transmits a control command to the terminal device.
0N/A *
0N/A * <p>This can be used to, for example, control terminal functions like
0N/A * a built-in PIN pad or biometrics.
0N/A *
0N/A * @param controlCode the control code of the command
0N/A * @param command the command data
0N/A *
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 * @throws NullPointerException if command is null
0N/A * @throws CardException if the card operation failed
0N/A * @throws IllegalStateException if this card object has been disposed of
0N/A * via the {@linkplain #disconnect disconnect()} method
0N/A */
0N/A public abstract byte[] transmitControlCommand(int controlCode,
0N/A byte[] command) throws CardException;
0N/A
0N/A /**
0N/A * Disconnects the connection with this card. After this method returns,
0N/A * calling methods on this object or in CardChannels associated with this
0N/A * object that require interaction with the card will raise an
0N/A * IllegalStateException.
0N/A *
0N/A * @param reset whether to reset the card after disconnecting.
0N/A *
0N/A * @throws CardException if the card operation failed
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 void disconnect(boolean reset) throws CardException;
0N/A
0N/A}