⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jcrespec08rmi.html

📁 JAVA CARD 开发包规格说明,版本为2.2.2
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<PRE CLASS="ScreenText"><A NAME="pgfId-430016"></A>            u1 jc_rmi_data_tag = 0x5E</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430018"></A>            u1 jc_rmi_data_length</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430020"></A>            u2 version = 0x0202</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430022"></A>            u1 invoke_ins</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430024"></A>            union {</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430026"></A>                normal_ref_response normal_initial_ref</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430028"></A>                normal_null_response null_initial_ref</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430030"></A>                error_response initial_ref_error</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430032"></A>                } initial_ref</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430034"></A>    }</PRE></TD></TR></TBODY></TABLE><BR></DIV><P CLASS="Paragraph"><A NAME="pgfId-427521"></A>The <KBD CLASS="Filename-Command">jc_rmi_data_length</KBD> item is the combined length in bytes of the <KBD CLASS="Filename-Command">version</KBD> item, <KBD CLASS="Filename-Command">invoke_ins</KBD> item and the <KBD CLASS="Filename-Command">initial_ref</KBD> item. The <KBD CLASS="Filename-Command">application_data_length</KBD> item is <KBD CLASS="Filename-Command">jc_rmi_data_length + 2</KBD>. The <KBD CLASS="Filename-Command">fci_length</KBD> item is <KBD CLASS="Filename-Command">application_data_length + 2</KBD>.</P><P CLASS="Paragraph"><A NAME="pgfId-427817"></A>The response data includes <KBD CLASS="Filename-Command">invoke_ins</KBD>, the instruction byte to use in the method invocation command. It also includes <KBD CLASS="Filename-Command">initial_ref</KBD>, the initial remote object reference descriptor. The <KBD CLASS="Filename-Command">initial_ref</KBD> item corresponds to the remote object designated as the initial reference to the <KBD CLASS="Filename-Command">RMIService</KBD> instance during construction. The <KBD CLASS="Filename-Command">initial_ref</KBD> item can be a normal_ref_response item described in <A HREF="JCRESpec08rmi.html#62334" CLASS="XRef">Section 8.3.5.1, Normal Response Encoding</A> or a <KBD CLASS="Filename-Command">null</KBD> representation using a <KBD CLASS="Filename-Command">normal_null_response</KBD> item described in that same section, if the initial remote reference object is not enabled for remote access. Also, note that if an error occurs during the marshalling of the initial remote reference descriptor, an error response is returned in <KBD CLASS="Filename-Command">initial_ref</KBD> instead of using the error_response item format described in <A HREF="JCRESpec08rmi.html#47978" CLASS="XRef">Section 8.3.5.3, Error Response Encoding</A>.</P><BR><HR NOSHADE SIZE=1><TABLE CLASS="TipNote" DIR="LTR" WIDTH="100%" SUMMARY="TipNote"><COLGROUP SPAN="1" WIDTH="100%"><TR ALIGN="left" VALIGN="top"><TD ROWSPAN="1" COLSPAN="1" ABBR="TipNoteText"><P CLASS="TipNote"><B CLASS="TipNote">Note - </B><A NAME="pgfId-418214"></A>Even though the <KBD CLASS="Filename-Command">select_response</KBD> structure uses the C-like &quot;union&quot; notation, the lengths of the alternate representations within the union do not use any padding to normalize their lengths.</P></TD></TR></TABLE><HR NOSHADE SIZE=1><BR><P CLASS="Paragraph"><A NAME="pgfId-427530"></A>The format of the <KBD CLASS="Filename-Command">remote_ref_descriptor</KBD> to be used in this response as well as all subsequent responses (<KBD CLASS="Filename-Command">remote_ref_with_class</KBD> or <KBD CLASS="Filename-Command">remote_ref_with_interfaces</KBD>) is determined by the value of the P2 byte of the SELECT FILE command.</P><BR><HR NOSHADE SIZE=1><TABLE CLASS="TipNote" DIR="LTR" WIDTH="100%" SUMMARY="TipNote"><COLGROUP SPAN="1" WIDTH="100%"><TR ALIGN="left" VALIGN="top"><TD ROWSPAN="1" COLSPAN="1" ABBR="TipNoteText"><P CLASS="TipNote"><B CLASS="TipNote">Note - </B><A NAME="pgfId-417342"></A>Only the <KBD CLASS="Filename-Command">RMIService</KBD> instance that processes the SELECT FILE command sets (or changes) the format of the remote object reference descriptor based on the value of the P2 byte. Once set or changed, the <KBD CLASS="Filename-Command">RMIService</KBD> instance uses only that format in all Java Card RMI responses it generates.</P></TD></TR></TABLE><HR NOSHADE SIZE=1><BR><H3 CLASS="Head2"><A NAME="pgfId-411279"></A>8.4.2	<A NAME="68263"></A>INVOKE <A NAME="marker-420198"></A>Command</H3><P CLASS="Paragraph"><A NAME="pgfId-425864"></A><A HREF="JCRESpec08rmi.html#28170" CLASS="XRef">TABLE 8-2</A> lists the format required for the Invoke command for a remote method invocation request.</P><BR><TABLE CLASS="Titled" BORDER=1 BORDERCOLORLIGHT="#FFFFFF" BORDERCOLORDARK="#000000" CELLPADDING=5 CELLSPACING=0 DIR="LTR"><CAPTION CLASS="TableCaption"><A NAME="pgfId-425876"> </A> TABLE 8-2 	 <A NAME="28170"> </A> Invoke Command Format </CAPTION><THEAD><TR><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-425882"></A>Field</P></TH><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-425884"></A>Value</P></TH><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-425886"></A>Description</P></TH></TR></THEAD><TBODY><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-425888"></A>CLA</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-428486"></A>%b1000 yycc or</P><P CLASS="TableText"><A NAME="pgfId-428493"></A>%b1010 yycc or</P><P CLASS="TableText"><A NAME="pgfId-428498"></A>%b11y0 dddd</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-428953"></A>The <KBD CLASS="Filename-Command">cc</KBD> in bits (b2,b1) denotes the origin logical channel number in the range 1-3. The <KBD CLASS="Filename-Command">yy</KBD> in bits (b4,b3) of the type 4 formats denote secure messaging.</P><P CLASS="TableText"><A NAME="pgfId-428954"></A>The <KBD CLASS="Filename-Command">dddd</KBD> in bits (b4-b1) denote the origin logical channel number in the range 4-19 using <KBD CLASS="Filename-Command">0</KBD> origin notation. The <KBD CLASS="Filename-Command">y</KBD> in bit b6 of the type 16 format denotes secure messaging.</P><P CLASS="TableText"><A NAME="pgfId-428524"></A>See <A HREF="JCRESpec04selection.html#44855" CLASS="XRef">TABLE 4-2</A> for CLA field encoding formats.</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-425894"></A>INS</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-425896"></A>value of<KBD CLASS="Filename-Command"> invoke_ins</KBD></P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-425898"></A><KBD CLASS="Filename-Command">invoke_ins</KBD> returned in the previous <KBD CLASS="Filename-Command">select_response</KBD></P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-425900"></A>P1</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-425902"></A>02</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-425904"></A>RMI major version #</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-425906"></A>P2</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-425908"></A>02</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-425910"></A>RMI minor version #</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-426010"></A>Data</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-426012"></A>As described below</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-426014"></A>As described below</P></TD></TR></TBODY></TABLE><BR><P CLASS="Paragraph"><A NAME="pgfId-427567"></A>Following is the structure of the data part of the request command:</P><DIV CLASS="Code"><BR><TABLE CLASS="Code" BORDER=1 BORDERCOLORLIGHT="#FFFFFF" BORDERCOLORDARK="#000000" CELLPADDING=5 CELLSPACING=0 DIR="LTR"><TBODY><TR><TD SCOPE="ROW"><PRE CLASS="ScreenText"><A NAME="pgfId-430255"></A>invoke_data {</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430257"></A>     u2 object_id</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430259"></A>     u2 method_id</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430261"></A>     param parameters[]</PRE><PRE CLASS="ScreenText"><A NAME="pgfId-430263"></A>   }</PRE></TD></TR></TBODY></TABLE><BR></DIV><P CLASS="Paragraph"><A NAME="pgfId-411492"></A>The <KBD CLASS="Filename-Command">object_id</KBD> is the remote object identifier of the object whose remote method is to be invoked. The method to be invoked is specified by the <KBD CLASS="Filename-Command">method_id</KBD> item, and each <KBD CLASS="Filename-Command">parameter</KBD> is specified by a <KBD CLASS="Filename-Command">param</KBD> structure. </P><P CLASS="Paragraph"><A NAME="pgfId-413722"></A>The response format uses the return_response structure as described in <A HREF="JCRESpec08rmi.html#21974" CLASS="XRef">Section 8.3.5, Return Value Encoding</A>.</P><H2 CLASS="Head1"><A NAME="pgfId-413763"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>8.5	<A NAME="marker-420199"></A><KBD CLASS="Filename-Command">RMIService</KBD> Class</H2><P CLASS="Paragraph"><A NAME="pgfId-413766"></A>The <KBD CLASS="Filename-Command">RMIService</KBD> class implements the Java Card RMI protocol and processes the RMI access commands described earlier: SELECT FILE and INVOKE. It performs the function of the transport layer for Java Card RMI commands on the card.</P><P CLASS="Paragraph"><A NAME="pgfId-413802"></A>The <KBD CLASS="Filename-Command">RMIService</KBD> object maintains a list of remote objects that have been returned during the current applet selection session. It enforces the following rules for the lifetime of the remote object references:</P><UL><LI CLASS="Bullet1"><A NAME="pgfId-417352"></A>A remote reference is valid only when the INVOKE command is processed by the <KBD CLASS="Filename-Command">RMIService</KBD> instance that returned the reference.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-417359"></A>A remote reference is valid with any applet instance in the package of the applet instance that returned it.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-417366"></A>A remote reference is valid as long as at least one applet instance within the same package has been active at all times since the point in time when the remote reference was returned.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-417373"></A>A valid remote object cannot be garbage collected during the lifetime of the remote reference.</LI><P CLASS="Linebreak"></P></UL><P CLASS="Paragraph"><A NAME="pgfId-420230"></A>In addition, a remote object reference descriptor of an object must only be returned from the card if it is exported. See the class <KBD CLASS="Filename-Command">javacard.framework.service.CardRemoteObject</KBD>. Otherwise, an exception is thrown. See the class <KBD CLASS="Filename-Command">javacard.framework.service.RMIService</KBD>.</P><H3 CLASS="Head2"><A NAME="pgfId-420231"></A>8.5.1	<KBD CLASS="Filename-Command">setInvokeInstructionByte</KBD> Method</H3><P CLASS="Paragraph"><A NAME="pgfId-413746"></A>This method sets the value of invoke_ins described in <A HREF="JCRESpec08rmi.html#79682" CLASS="XRef">Section 8.4.1, SELECT FILE Command</A>, which is returned in the response to the SELECT FILE command. The change in the Java Card RMI protocol only goes into effect the next time this <KBD CLASS="Filename-Command">RMIService</KBD> instance processes the SELECT FILE command. If this method is not called, the default instruction byte value (<KBD CLASS="Filename-Command">DEFAULT_RMI_INVOKE_INSTRUCTION</KBD>) is used.</P><H3 CLASS="Head2"><A NAME="pgfId-411220"></A>8.5.2	<KBD CLASS="Filename-Command">processCommand</KBD> Method</H3><P CLASS="Paragraph"><A NAME="pgfId-413791"></A>The <KBD CLASS="Filename-Command">processCommand</KBD> method of the <KBD CLASS="Filename-Command">RMIService</KBD> class is invoked by the applet to process an incoming RMI message. <KBD CLASS="Filename-Command">RMIService</KBD> collaborates with other services by using the common service format (CSF) in the APDU buffer. It processes only the incoming Java Card RMI APDU commands and produces output as described in the previous sections.</P><P CLASS="Paragraph"><A NAME="pgfId-413839"></A>When called with a SELECT FILE command with format described in <A HREF="JCRESpec08rmi.html#79682" CLASS="XRef">Section 8.4.1, SELECT FILE Command</A>, this method builds a response APDU as described in that section.</P><P CLASS="Paragraph"><A NAME="pgfId-413846"></A>When called with an INVOKE command with the format described in <A HREF="JCRESpec08rmi.html#68263" CLASS="XRef">Section 8.4.2, INVOKE Command</A>, this method must call the specified remote method of the identified remote object with the specified parameters. It must catch all exceptions thrown by the remote method. When an exception is caught or the remote method returns, this method must build a response APDU in the format described in <A HREF="JCRESpec08rmi.html#68263" CLASS="XRef">Section 8.4.2, INVOKE Command</A>.</P><P CLASS="Paragraph"><A NAME="pgfId-413878"></A>Prior to invoking the remote method, the following errors must be detected and must result in an error response in the format described in <A HREF="JCRESpec08rmi.html#47978" CLASS="XRef">Section 8.3.5.3, Error Response Encoding</A>:</P><UL><LI CLASS="Bullet1"><A NAME="pgfId-427597"></A>The remote object identifier is not valid.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-427598"></A>The remote object identifier was not returned during the current selection session.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-413888"></A>The method identifier does not match any remote methods in the remote class associated with the identified remote object.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-413889"></A>The length of the INVOKE message is inconsis

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -