apdu.html
来自「JAVA CARD 开发包规格说明,版本为2.2.2」· HTML 代码 · 共 1,404 行 · 第 1/5 页
HTML
1,404 行
<li><em>In T=1 protocol, if all the remaining bytes do not fit in the buffer, this method may return less bytes than the maximum incoming block size (IFSC).</em> <li><em>In T=0 protocol, if all the remaining bytes do not fit in the buffer, this method may return less than a full buffer of bytes to optimize and reduce protocol overhead.</em> <li><em>In T=1 protocol, if this method throws an </em><code>APDUException</code><em> with </em><code>T1_IFD_ABORT</code><em> reason code, the Java Card runtime environment will restart APDU command processing using the newly received command. No more input data can be received. No output data can be transmitted. No error status response can be returned.</em> <li><em>This method sets the state of the <code>APDU</code> object to <code>STATE_PARTIAL_INCOMING</code> if all incoming bytes are not received.</em> <li><em>This method sets the state of the <code>APDU</code> object to <code>STATE_FULL_INCOMING</code> if all incoming bytes are received.</em> </ul><P><DD><DL><DT><B>Parameters:</B><DD><CODE>bOff</CODE> - the offset into APDU buffer<DT><B>Returns:</B><DD>number of bytes read. Returns 0 if no bytes are available<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>setIncomingAndReceive()</code> not called or if <code>setOutgoing()</code> or <code>setOutgoingNoChaining()</code> previously invoked. <li><code>APDUException.BUFFER_BOUNDS</code> if not enough buffer space for incoming block size. <li><code>APDUException.IO_ERROR</code> on I/O error. <li><code>APDUException.T1_IFD_ABORT</code> if T=1 protocol is in use and the CAD sends in an ABORT S-Block command to abort the data transfer. </ul><DT><B>See Also:</B><DD><A HREF="../../javacard/framework/APDU.html#getInBlockSize()"><CODE>getInBlockSize()</CODE></A></DL></DD></DL><HR><A NAME="setIncomingAndReceive()"><!-- --></A><H3>setIncomingAndReceive</H3><PRE>public short <B>setIncomingAndReceive</B>() throws <A HREF="../../javacard/framework/APDUException.html" title="class in javacard.framework">APDUException</A></PRE><DL><DD>This is the primary receive method. Calling this method indicates that this APDU has incoming data. This method gets as many bytes as will fit without buffer overflow in the APDU buffer following the header. It gets all the incoming bytes if they fit. <p>This method should only be called on a case 3 or case 4 command, otherwise erroneous behavior may result. <p>Notes:<ul> <li><em>In T=0 ( Case 3&4 ) protocol, the P3 param is assumed to be Lc.</em> <li><em>Data is read into the buffer at offset 5 for normal APDU semantics.</em> <li><em>Data is read into the buffer at offset 7 for an extended length APDU (Case 3E/4E).</em> <li><em>In T=1 protocol, if all the incoming bytes do not fit in the buffer, this method may return less bytes than the maximum incoming block size (IFSC).</em> <li><em>In T=0 protocol, if all the incoming bytes do not fit in the buffer, this method may return less than a full buffer of bytes to optimize and reduce protocol overhead.</em> <li><em>This method sets the transfer direction to be inbound and calls </em><code>receiveBytes(5)</code><em> for normal semantics or </em><code>receiveBytes(7)</code><em> for extended semantics.</em> <li><em>This method may only be called once in a </em><code>Applet.process()</code><em> method.</em> <li><em>This method sets the state of the <code>APDU</code> object to <code>STATE_PARTIAL_INCOMING</code> if all incoming bytes are not received.</em> <li><em>This method sets the state of the <code>APDU</code> object to <code>STATE_FULL_INCOMING</code> if all incoming bytes are received.</em> </ul><P><DD><DL><DT><B>Returns:</B><DD>number of data bytes read. The Le byte, if any, is not included in the count. Returns 0 if no bytes are available.<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>setIncomingAndReceive()</code> already invoked or if <code>setOutgoing()</code> or <code>setOutgoingNoChaining()</code> previously invoked. <li><code>APDUException.IO_ERROR</code> on I/O error. <li><code>APDUException.T1_IFD_ABORT</code> if T=1 protocol is in use and the CAD sends in an ABORT S-Block command to abort the data transfer. </ul><DT><B>See Also:</B><DD><A HREF="../../javacard/framework/APDU.html#getIncomingLength()"><CODE>getIncomingLength()</CODE></A>, <A HREF="../../javacard/framework/APDU.html#getOffsetCdata()"><CODE>getOffsetCdata()</CODE></A></DL></DD></DL><HR><A NAME="sendBytes(short, short)"><!-- --></A><H3>sendBytes</H3><PRE>public void <B>sendBytes</B>(short bOff, short len) throws <A HREF="../../javacard/framework/APDUException.html" title="class in javacard.framework">APDUException</A></PRE><DL><DD>Sends <code>len</code> more bytes from APDU buffer at specified offset <code>bOff</code>. <p>If the last part of the response is being sent by the invocation of this method, the APDU buffer must not be altered. If the data is altered, incorrect output may be sent to the CAD. Requiring that the buffer not be altered allows the implementation to reduce protocol overhead by transmitting the last part of the response along with the status bytes. <p>Notes:<ul> <li><em>If </em><code>setOutgoingNoChaining()</code><em> was invoked, output block chaining must not be used.</em> <li><em>In T=0 protocol, if </em><code>setOutgoingNoChaining()</code><em> was invoked, Le bytes must be transmitted before </em><code>(ISO7816.SW_BYTES_REMAINING_00+remaining bytes)</code><em> response status is returned.</em> <li><em>In T=0 protocol, if this method throws an </em><code>APDUException</code><em> with </em><code>NO_T0_GETRESPONSE</code><em> or </em><code>NO_T0_REISSUE</code><em> reason code, the Java Card runtime environment will restart APDU command processing using the newly received command. No more output data can be transmitted. No error status response can be returned.</em> <li><em>In T=1 protocol, if this method throws an </em><code>APDUException</code><em> with </em><code>T1_IFD_ABORT</code><em> reason code, the Java Card runtime environment will restart APDU command processing using the newly received command. No more output data can be transmitted. No error status response can be returned.</em> <li><em>This method sets the state of the <code>APDU</code> object to <code>STATE_PARTIAL_OUTGOING</code> if all outgoing bytes have not been sent.</em> <li><em>This method sets the state of the <code>APDU</code> object to <code>STATE_FULL_OUTGOING</code> if all outgoing bytes have been sent.</em> </ul><P><DD><DL><DT><B>Parameters:</B><DD><CODE>bOff</CODE> - the offset into APDU buffer<DD><CODE>len</CODE> - the length of the data in bytes to send<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>setOutgoingLength()</code> not called or <code>setOutgoingAndSend()</code> previously invoked or response byte count exceeded or if <code>APDUException.NO_T0_GETRESPONSE</code> or <code>APDUException.NO_T0_REISSUE</code> or <code>APDUException.T1_IFD_ABORT</code> previously thrown. <li><code>APDUException.BUFFER_BOUNDS</code> if <code>bOff</code> is negative or <code>len</code> is negative or <code>bOff+len</code> exceeds the buffer size. <li><code>APDUException.IO_ERROR</code> on I/O error. <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.T1_IFD_ABORT</code> if T=1 protocol is in use and the CAD sends in an ABORT S-Block command to abort the data transfer. </ul><DT><B>See Also:</B><DD><A HREF="../../javacard/framework/APDU.html#setOutgoing()"><CODE>setOutgoing()</CODE></A>, <A HREF="../../javacard/framework/APDU.html#setOutgoingNoChaining()"><CODE>setOutgoingNoChaining()</CODE></A></DL></DD></DL><HR><A NAME="sendBytesLong(byte[], short, short)"><!-- --></A><H3>sendBytesLong</H3><PRE>public void <B>sendBytesLong</B>(byte[] outData, short bOff, short len) throws <A HREF="../../javacard/framework/APDUException.html" title="class in javacard.framework">APDUException</A>, <A HREF="../../java/lang/SecurityException.html" title="class in java.lang">SecurityException</A></PRE><DL><DD>Sends <code>len</code> more bytes from <code>outData</code> byte array starting at specified offset <code>bOff</code>. <p>If the last of the response is being sent by the invocation of this method, the APDU buffer must not be altered. If the data is altered, incorrect output may be sent to the CAD. Requiring that the buffer not be altered allows the implementation to reduce protocol overhead by transmitting the last part of the response along with the status bytes. <p>The Java Card runtime environment may use the APDU buffer to send data to the CAD. <p>Notes:<ul> <li><em>If </em><code>setOutgoingNoChaining()</code><em> was invoked, output block chaining must not be used.</em> <li><em>In T=0 protocol, if </em><code>setOutgoingNoChaining()</code><em> was invoked, Le bytes must be transmitted before </em><code>(ISO7816.SW_BYTES_REMAINING_00+remaining bytes)</code><em> response status is returned.</em> <li><em>In T=0 protocol, if this method throws an </em><code>APDUException</code><em> with </em><code>NO_T0_GETRESPONSE</code><em> or </em><code>NO_T0_REISSUE</code><em> reason code, the Java Card runtime environment will restart APDU command processing using the newly received command. No more output data can be transmitted. No error status response can be returned.</em> <li><em>In T=1 protocol, if this method throws an </em><code>APDUException</code><em> with </em><code>T1_IFD_ABORT</code><em> reason code, the Java Card runtime environment will restart APDU command processing using the newly received command. No more output data can be transmitted. No error status response can be returned.</em> <li><em>This method sets the state of the <code>APDU</code> object to <code>STATE_PARTIAL_OUTGOING</code> if all outgoing bytes have not been sent.</em> <li><em>This method sets the state of the <code>APDU</code> object to <code>STATE_FULL_OUTGOING</code> if all outgoing bytes have been sent.</em> </ul> <p><P><DD><DL><DT><B>Parameters:</B><DD><CODE>outData</CODE> - the source data byte array<DD><CODE>bOff</CODE> - the offset into OutData array<DD><CODE>len</CODE> - the byte length of the data to send<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html" title="class in java.lang">SecurityException</A></CODE> - if the <code>outData</code> array is not accessible in the caller's context<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>setOutgoingLength()</code> not called or <code>setOutgoingAndSend()</code> previously invoked or response byte count exceeded or if <code>APDUException.NO_T0_GETRESPONSE</code> or <code>APDUException.NO_T0_REISSUE</code> or <code>APDUException.NO_T0_REISSUE</code> previously thrown. <li><code>APDUException.IO_ERROR</code> on I/O error. <li><code>APDUException.NO_T0_GETRESPONSE</code> if T=0 protocol is in use and 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.T1_IFD_ABORT</code> if T=1 protocol is in use and the CAD sends in an ABORT S-Block command to abort the data transfer. </ul><DT><B>See Also:</B><DD><A HREF="../../javacard/framework/APDU.html#setOutgoing()"><CODE>setOutgoing()</CODE></A>, <A HREF="../../javacard/framework/APDU.html#setOutgoingNoChaining()"><CODE>setOutgoingNoChaining()</CODE></A></DL></DD></DL><HR><A NAME="setOutgoingAndSend(short, short)"><!-- --></A><H3>setOutgoingAndSend</H3><PRE>public void <B>setOutgoingAndSend</B>(short bOff, short len) throws <A HREF="../../javacard/framework/APDUException.html" title="class in javacard.framework">APDUException</A></PRE><DL><DD>This is the "convenience" send method. It provides for the most efficient way to send a short response which fits in the buffer and needs the least protocol overhead. This method is a combination of <code>setOutgoing(), setOutgoingLength( len )</code> followed by <code>sendBytes ( bOff, len )</code>. In addition, once this method is invoked, <code>sendBytes()</code> and <code>sendBytesLong()</code> methods cannot be invoked and the APDU buffer must not be altered.<p> Sends <code>len</code> byte response from the APDU buffer starting at the specified offset <code>bOff</code>. <p>Notes:<ul> <li><em>No other </em><code>APDU</code><em> send methods can be invoked.</em> <li><em>The APDU buffer must not be altered. If the data is altered, incorrect output may be sent to the CAD.</em> <li><em>The actual data transmission may only take place on return from </em><code>Applet.process()</code> <li><em>This method sets the state of the <code>APDU</code> object to <code>STATE_FULL_OUTGOING</code>.</em> </ul> <p><P><DD><DL><DT><B>Parameters:</B><DD><CODE>bOff</CODE> - the offset into APDU buffer<DD><CODE>len</CODE> - the bytelength of the data to send<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>setOutgoingAndSend()</code> previously invoked. <li><code>APDUException.IO_ERROR</code> on I/O error. <li><code>APDUException.BAD_LENGTH</code> if <code>len</code> is negative or greater than 256 and the currently selected applet does not implement the <code>javacardx.apdu.ExtendedLength</code> interface.</ul></DL></DD></DL><HR><A NAME="getCurrentState()"><!-- --></A><H3>getCurrentState</H3><PRE>public byte <B>getCurrentState</B>()</PRE><DL><DD>This method returns the current processing state of the <CODE>APDU</CODE> object. It is used by the <CODE>BasicService</CODE> class to help services collaborate in the processing of an incoming APDU command. Valid codes are listed in <CODE>STATE_*</CODE> constants above. See <A HREF="../../javacard/framework/APDU.html#STATE_INITIAL"><CODE>STATE_INITIAL</CODE></A>.<P><DD><DL><DT><B>Returns:</B><DD>the current processing state of the APDU<DT><B>See Also:</B><DD><A HREF="../../javacard/framework/service/BasicService.html" title="class in javacard.framework.service"><CODE>javacard.framework.service.BasicService</CODE></A></DL></DD></DL><HR><A NAME="getCurrentAPDU()"><!-- --></A><H3>getCurrentAPDU</H3><PRE>public static <A HREF="../../javacard/framework/APDU.html" title="class in javacard.framework">APDU</A> <B>getCurrentAPDU</B>() throws <A HREF="../../java/lang/SecurityException.html" title="class in java.lang">SecurityException</A></PRE><DL><DD>This method is called during the <code>Applet.process(APDU)</code> method to obtain a reference to the current <CODE>APDU</CODE> object. This method can only be called in the context of the currently selected applet. <p>Note:<ul> <li><em>Do not call this method directly or indirectly from within a method invoked remotely via Java Card RMI method invocation from the client. The APDU object and APDU buffer are reserved for use by RMIService. Remote method parameter data may become corrupted.</em></ul><P><DD><DL><DT><B>Returns:</B><DD>the current <CODE>APDU</CODE> object being processed<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html" title="class in java.lang">SecurityException</A></CODE> - if <ul> <li>the current context is not the context of the currently selected applet instance or <li>this method was not called, directly or indirectly, from the applet's process method (called directly by the Java Card runtime environment), or <li>the method is called during applet installation or deletion. </ul></DL></DD></DL><HR><A NAME="getCurrentAPDUBuffer()"><!-- --></A><H3>getCurrentAPDUBuffer</H3><PRE>publ
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?