apdu.html
来自「JAVA CARD 开发包规格说明,版本为2.2.2」· HTML 代码 · 共 1,404 行 · 第 1/5 页
HTML
1,404 行
<A NAME="PROTOCOL_MEDIA_CONTACTLESS_TYPE_A"><!-- --></A><H3>PROTOCOL_MEDIA_CONTACTLESS_TYPE_A</H3><PRE>public static final byte <B>PROTOCOL_MEDIA_CONTACTLESS_TYPE_A</B></PRE><DL><DD>Transport protocol Media - Contactless Type A<P><DL><DT><B>See Also:</B><DD><A HREF="../../constant-values.html#javacard.framework.APDU.PROTOCOL_MEDIA_CONTACTLESS_TYPE_A">Constant Field Values</A></DL></DL><HR><A NAME="PROTOCOL_MEDIA_CONTACTLESS_TYPE_B"><!-- --></A><H3>PROTOCOL_MEDIA_CONTACTLESS_TYPE_B</H3><PRE>public static final byte <B>PROTOCOL_MEDIA_CONTACTLESS_TYPE_B</B></PRE><DL><DD>Transport protocol Media - Contactless Type B<P><DL><DT><B>See Also:</B><DD><A HREF="../../constant-values.html#javacard.framework.APDU.PROTOCOL_MEDIA_CONTACTLESS_TYPE_B">Constant Field Values</A></DL></DL><HR><A NAME="PROTOCOL_MEDIA_USB"><!-- --></A><H3>PROTOCOL_MEDIA_USB</H3><PRE>public static final byte <B>PROTOCOL_MEDIA_USB</B></PRE><DL><DD>Transport protocol Media - USB<P><DL><DT><B>See Also:</B><DD><A HREF="../../constant-values.html#javacard.framework.APDU.PROTOCOL_MEDIA_USB">Constant Field Values</A></DL></DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"><B>Method Detail</B></FONT></TH></TR></TABLE><A NAME="getBuffer()"><!-- --></A><H3>getBuffer</H3><PRE>public byte[] <B>getBuffer</B>()</PRE><DL><DD>Returns the APDU buffer byte array. <p>Note:<ul> <li><em>References to the APDU buffer byte array may be stored in local variables or method parameters.</em> <li><em>References to the APDU buffer byte array cannot be stored in class variables or instance variables or array components. See <em>Runtime Environment Specification for the Java Card Platform</em>, section 6.2.2 for details.</em> </ul><P><DD><DL><DT><B>Returns:</B><DD>byte array containing the APDU buffer</DL></DD></DL><HR><A NAME="getInBlockSize()"><!-- --></A><H3>getInBlockSize</H3><PRE>public static short <B>getInBlockSize</B>()</PRE><DL><DD>Returns the configured incoming block size. In T=1 protocol, this corresponds to IFSC (information field size for ICC), the maximum size of incoming data blocks into the card. In T=0 protocol, this method returns 1. IFSC is defined in ISO 7816-3.<p> This information may be used to ensure that there is enough space remaining in the APDU buffer when <code>receiveBytes()</code> is invoked. <p>Note:<ul> <li><em>On </em><code>receiveBytes()</code><em> the </em><code>bOff</code><em> param should account for this potential blocksize.</em> </ul><P><DD><DL><DT><B>Returns:</B><DD>incoming block size setting<DT><B>See Also:</B><DD><A HREF="../../javacard/framework/APDU.html#receiveBytes(short)"><CODE>receiveBytes(short)</CODE></A></DL></DD></DL><HR><A NAME="getOutBlockSize()"><!-- --></A><H3>getOutBlockSize</H3><PRE>public static short <B>getOutBlockSize</B>()</PRE><DL><DD>Returns the configured outgoing block size. In T=1 protocol, this corresponds to IFSD (information field size for interface device), the maximum size of outgoing data blocks to the CAD. In T=0 protocol, this method returns 258 (accounts for 2 status bytes). IFSD is defined in ISO 7816-3. <p>This information may be used prior to invoking the <code>setOutgoingLength()</code> method, to limit the length of outgoing messages when BLOCK CHAINING is not allowed. <p>Note:<ul> <li><em>On </em><code>setOutgoingLength()</code><em> the </em><code>len</code><em> param should account for this potential blocksize.</em> </ul><P><DD><DL><DT><B>Returns:</B><DD>outgoing block size setting<DT><B>See Also:</B><DD><A HREF="../../javacard/framework/APDU.html#setOutgoingLength(short)"><CODE>setOutgoingLength(short)</CODE></A></DL></DD></DL><HR><A NAME="getProtocol()"><!-- --></A><H3>getProtocol</H3><PRE>public static byte <B>getProtocol</B>()</PRE><DL><DD>Returns the ISO 7816 transport protocol type, T=1 or T=0 in the low nibble and the transport media in the upper nibble in use.<P><DD><DL><DT><B>Returns:</B><DD>the protocol media and type in progress Valid nibble codes are listed in <CODE>PROTOCOL_*</CODE> constants above. See <A HREF="../../javacard/framework/APDU.html#PROTOCOL_T0"><CODE>PROTOCOL_T0</CODE></A>.</DL></DD></DL><HR><A NAME="getNAD()"><!-- --></A><H3>getNAD</H3><PRE>public byte <B>getNAD</B>()</PRE><DL><DD>Returns the Node Address byte (NAD) in T=1 protocol, and 0 in T=0 protocol. This may be used as additional information to maintain multiple contexts.<P><DD><DL><DT><B>Returns:</B><DD>NAD transport byte as defined in ISO 7816-3</DL></DD></DL><HR><A NAME="setOutgoing()"><!-- --></A><H3>setOutgoing</H3><PRE>public short <B>setOutgoing</B>() throws <A HREF="../../javacard/framework/APDUException.html" title="class in javacard.framework">APDUException</A></PRE><DL><DD>This method is used to set the data transfer direction to outbound and to obtain the expected length of response (Le). This method should only be called on a case 2 or case 4 command, otherwise erroneous behavior may result. <p>Notes. <ul> <li><em>On a case 4 command, the </em><code>setIncomingAndReceive()</code><em> must be invoked prior to calling this method. Otherwise, erroneous behavior may result in T=0 protocol.</em> <li><em>Any remaining incoming data will be discarded.</em> <li><em>In T=0 (Case 4S) protocol, this method will return 256 with normal semantics.</em> <li><em>In T=0 (Case 2E, 4S) protocol, this method will return 32767 when the currently selected applet implements the </em><code>javacardx.apdu.ExtendedLength</code><em> interface.</em> <li><em>In T=1 (Case 2E, 4E) protocol, this method will return 32767 when the Le field in the APDU command is 0x0000 and the currently selected applet implements the </em><code>javacardx.apdu.ExtendedLength</code><em> interface.</em> <li><em>This method sets the state of the </em><code>APDU</code><em> object to </em><code>STATE_OUTGOING</code><em>.</em> </ul><P><DD><DL><DT><B>Returns:</B><DD>Le, the expected length of response<DT><B>Throws:</B><DD><CODE><A HREF="../../javacard/framework/APDUException.html" title="class in javacard.framework">APDUException</A></CODE> - with the following reason codes:<ul> <li><code>APDUException.ILLEGAL_USE</code> if this method, or <code>setOutgoingNoChaining()</code> method already invoked. <li><code>APDUException.IO_ERROR</code> on I/O error.</ul></DL></DD></DL><HR><A NAME="setOutgoingNoChaining()"><!-- --></A><H3>setOutgoingNoChaining</H3><PRE>public short <B>setOutgoingNoChaining</B>() throws <A HREF="../../javacard/framework/APDUException.html" title="class in javacard.framework">APDUException</A></PRE><DL><DD>This method is used to set the data transfer direction to outbound without using BLOCK CHAINING (See ISO 7816-3/4) and to obtain the expected length of response (Le). This method should be used in place of the <code>setOutgoing()</code> method by applets which need to be compatible with legacy CAD/terminals which do not support ISO 7816-3/4 defined block chaining. See <em>Runtime Environment Specification for the Java Card Platform</em>, section 9.4 for details. <p>Notes. <ul> <li><em>On a case 4 command, the </em><code>setIncomingAndReceive()</code><em> must be invoked prior to calling this method. Otherwise, erroneous behavior may result in T=0 protocol.</em> <li><em>Any remaining incoming data will be discarded.</em> <li><em>In T=0 (Case 4S) protocol, this method will return 256 with normal semantics.</em> <li><em>In T=0 (Case 2E, 4S) protocol, this method will return 256 when the currently selected applet implements the </em><code>javacardx.apdu.ExtendedLength</code><em> interface.</em> <li><em>When this method is used, the </em><code>waitExtension()</code><em> method cannot be used.</em> <li><em>In T=1 protocol, retransmission on error may be restricted.</em> <li><em>In T=0 protocol, the outbound transfer must be performed without using </em><code>(ISO7816.SW_BYTES_REMAINING_00+count)</code><em> response status chaining.</em> <li><em>In T=1 protocol, the outbound transfer must not set the More(M) Bit in the PCB of the I block. See ISO 7816-3.</em> <li><em>This method sets the state of the </em><code>APDU</code><em> object to </em><code>STATE_OUTGOING</code><em>.</em> </ul><P><DD><DL><DT><B>Returns:</B><DD>Le, the expected length of response data<DT><B>Throws:</B><DD><CODE><A HREF="../../javacard/framework/APDUException.html" title="class in javacard.framework">APDUException</A></CODE> - with the following reason codes:<ul> <li><code>APDUException.ILLEGAL_USE</code> if this method, or <code>setOutgoing()</code> method already invoked. <li><code>APDUException.IO_ERROR</code> on I/O error</ul></DL></DD></DL><HR><A NAME="setOutgoingLength(short)"><!-- --></A><H3>setOutgoingLength</H3><PRE>public void <B>setOutgoingLength</B>(short len) throws <A HREF="../../javacard/framework/APDUException.html" title="class in javacard.framework">APDUException</A></PRE><DL><DD>Sets the actual length of response data. If a length of <code>0</code> is specified, no data will be output. <p>Note:<ul> <li><em>In T=0 (Case 2&4) protocol, the length is used by the Java Card runtime environment to prompt the CAD for GET RESPONSE commands.</em> <li><em>This method sets the state of the <code>APDU</code> object to <code>STATE_OUTGOING_LENGTH_KNOWN</code>.</em> </ul><P><DD><DL><DT><B>Parameters:</B><DD><CODE>len</CODE> - the length of response data<DT><B>Throws:</B><DD><CODE><A HREF="../../javacard/framework/APDUException.html" title="class in javacard.framework">APDUException</A></CODE> - with the following reason codes:<ul> <li><code>APDUException.ILLEGAL_USE</code> if <code>setOutgoing()</code> or <code>setOutgoingNoChaining()</code> not called or if <code>setOutgoingAndSend()</code> already invoked, or this method already invoked. <li><code>APDUException.BAD_LENGTH</code> if any one of the following is true:<ul> <li><code>len</code> is negative.</li> <li><code>len</code> is greater than 256 and the currently selected applet does not implement the <code>javacardx.apdu.ExtendedLength</code> interface.</li> <li>T=0 protocol is in use, non BLOCK CHAINED data transfer is requested and <code>len</code> is greater than 256.</li> <li>T=1 protocol is in use, non BLOCK CHAINED data transfer is requested and <code>len</code> is greater than (IFSD-2), where IFSD is the Outgoing Block Size. The -2 accounts for the status bytes in T=1.</li> </ul> <li><code>APDUException.NO_T0_GETRESPONSE</code> if T=0 protocol is in use and the CAD does not respond to <code>(ISO7816.SW_BYTES_REMAINING_00+count)</code> response status with GET RESPONSE command on the same origin logical channel number as that of the current APDU command. <li><code>APDUException.NO_T0_REISSUE</code> if T=0 protocol is in use and the CAD does not respond to <code>(ISO7816.SW_CORRECT_LENGTH_00+count)</code> response status by re-issuing same APDU command on the same origin logical channel number as that of the current APDU command with the corrected length. <li><code>APDUException.IO_ERROR</code> on I/O error.</ul><DT><B>See Also:</B><DD><A HREF="../../javacard/framework/APDU.html#getOutBlockSize()"><CODE>getOutBlockSize()</CODE></A></DL></DD></DL><HR><A NAME="receiveBytes(short)"><!-- --></A><H3>receiveBytes</H3><PRE>public short <B>receiveBytes</B>(short bOff) throws <A HREF="../../javacard/framework/APDUException.html" title="class in javacard.framework">APDUException</A></PRE><DL><DD>Gets as many data bytes as will fit without APDU buffer overflow, at the specified offset <code>bOff</code>. Gets all the remaining bytes if they fit. <p>Notes:<ul> <li><em>The space in the buffer must allow for incoming block size.</em>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?