001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package javacard.framework;
028:
029: /**
030: * <code>APDUException</code> represents an <code>APDU</code>-related exception.
031: */
032:
033: public class APDUException extends CardRuntimeException {
034:
035: // APDUException reason code
036: /**
037: * This <code>APDUException</code> reason code indicates that the
038: * method should
039: * not be invoked
040: * based on the current state of the APDU.
041: */
042: public static final short ILLEGAL_USE = 1;
043:
044: /**
045: * This reason code is used by the <code>APDU.sendBytes()</code>
046: * method to indicate
047: * that the sum of buffer offset parameter and the byte length
048: * parameter exceeds the APDU
049: * buffer size.
050: */
051: public static final short BUFFER_BOUNDS = 2;
052:
053: /**
054: * This reason code is used by the
055: * <code>APDU.setOutgoingLength()</code> method to indicate
056: * that the length parameter is greater that 256 or
057: * if non BLOCK CHAINED data transfer is requested and
058: * <code>len</code> is greater than
059: * (IFSD-2), where IFSD is the Outgoing Block Size.
060: */
061: public static final short BAD_LENGTH = 3;
062:
063: /**
064: * This reason code indicates that an unrecoverable error occurred in the
065: * I/O transmission layer.
066: */
067: public static final short IO_ERROR = 4;
068:
069: /**
070: * This reason code indicates that during T=0 protocol, the CAD
071: * did not return a GET RESPONSE
072: * command in response to a <61xx> response status to send
073: * additional data. The outgoing
074: * transfer has been aborted. No more data or status can be sent to the CAD
075: * in this <code>APDU.process()</code> method.
076: */
077: public static final short NO_T0_GETRESPONSE = 0xAA;
078:
079: /**
080: * This reason code indicates that during T=1 protocol, the CAD
081: * returned an ABORT S-Block
082: * command and aborted the data transfer. The incoming or outgoing
083: * transfer has been aborted. No more data can be received from the CAD.
084: * No more data or status can be sent to the CAD
085: * in this <code>APDU.process()</code> method.
086: */
087: public static final short T1_IFD_ABORT = 0xAB;
088:
089: /**
090: * This reason code indicates that during T=0 protocol, the CAD
091: * did not reissue the
092: * same APDU command with the corrected length in response to a
093: * <6Cxx> response status
094: * to request command reissue with the specified length. The outgoing
095: * transfer has been aborted. No more data or status can be sent to the CAD
096: * in this <code>APDU.process()</code> method.
097: */
098: public static final short NO_T0_REISSUE = 0xAC;
099:
100: /**
101: * Constructs an APDUException.
102: * @param reason the reason for the exception.
103: */
104: public APDUException(short reason) {
105: super (reason);
106: }
107:
108: /**
109: * Throws an instance of <code>APDUException</code> with the
110: * specified reason.
111: * @param reason the reason for the exception.
112: * @exception APDUException always.
113: */
114: public static void throwIt(short reason) {
115: throw new APDUException(reason);
116: }
117: }
|