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

📄 jcrespec04selection.html

📁 JAVA CARD 开发包规格说明,版本为2.2.2
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<P CLASS="Linebreak"></P></UL><P CLASS="List1-"><A NAME="pgfId-416585"></A>5. 	If the P2 != <KBD CLASS="Filename-Command">0</KBD> variant is used:</P><P CLASS="ParaIndent1"><A NAME="pgfId-417246"></A>If resources for the specified logical channel are not available or the logical channel is already open, the Java Card RE responds with status code <KBD CLASS="Filename-Command">0x6A86</KBD> (<KBD CLASS="Filename-Command">SW_INCORRECT_P1P2</KBD>). </P><P CLASS="List1-"><A NAME="pgfId-413119"></A>6. 	The new logical channel on the I/O interface that received the MANAGE CHANNEL OPEN command is now open. This logical channel will be the assigned channel for the applet instance that will be selected on it.</P><P CLASS="List1-"><A NAME="pgfId-413364"></A>7. 	Determine the applet instance to be selected on the new logical channel.</P><UL><LI CLASS="Bullet1"><A NAME="pgfId-412188"></A>If the origin logical channel is the basic logical channel (logical channel 0), then:</LI><P CLASS="Linebreak"></P><UL><LI CLASS="Bullet2"><A NAME="pgfId-412189"></A>If a default applet instance for the new logical channel on the I/O interface is defined, pick the default applet instance for that logical channel as the candidate for selection on the new logical channel.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet2"><A NAME="pgfId-413169"></A>Otherwise, set the Java Card RE state so that no applet is active on the new logical channel. The Java Card RE responds with status code <KBD CLASS="Filename-Command">0x9000</KBD> and if the P2=<KBD CLASS="Filename-Command">0</KBD> variant is used, one data byte containing the newly assigned logical channel number.</LI><P CLASS="Linebreak"></P></UL><LI CLASS="Bullet1"><A NAME="pgfId-413170"></A>If the origin logical channel is not the basic logical channel:</LI><P CLASS="Linebreak"></P><UL><LI CLASS="Bullet2"><A NAME="pgfId-412192"></A>If an applet instance is active on the origin logical channel, pick the applet instance as the candidate for selection on the new logical channel.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet2"><A NAME="pgfId-413153"></A>Otherwise, set the Java Card RE state so that no applet is active on the new logical channel. The Java Card RE responds with status code <KBD CLASS="Filename-Command">0x9000</KBD> and if the P2=<KBD CLASS="Filename-Command">0</KBD> variant is used, one data byte containing the newly assigned logical channel number.</LI><P CLASS="Linebreak"></P></UL></UL><P CLASS="List1-"><A NAME="pgfId-419142"></A>8. 	If the candidate applet instance is not a multiselectable applet (as defined in <A HREF="JCRESpec04selection.html#32535" CLASS="XRef">Section 4.2, Multiselectable Applets</A>) and the candidate applet's context is active, the Java Card RE shall close the new logical channel. The Java Card RE responds with status code <KBD CLASS="Filename-Command">0x6985</KBD> (<KBD CLASS="Filename-Command">SW_CONDITIONS_NOT_SATISFIED</KBD>).</P><P CLASS="List1-"><A NAME="pgfId-413215"></A>9. 	Assign the <KBD CLASS="Filename-Command">CLEAR_ON_DESELECT</KBD> transient memory segment for the new logical channel:</P><UL><LI CLASS="Bullet1"><A NAME="pgfId-416627"></A>If the applet's context is active, assign the <KBD CLASS="Filename-Command">CLEAR_ON_DESELECT</KBD> transient memory segment associated with that context to this logical channel.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-416640"></A>Otherwise, assign a new (zero-filled) <KBD CLASS="Filename-Command">CLEAR_ON_DESELECT</KBD> transient memory segment to this new logical channel.</LI><P CLASS="Linebreak"></P></UL><P CLASS="List1-"><A NAME="pgfId-413228"></A>10. 	Check whether the candidate applet instance accepts selection:</P><UL><LI CLASS="Bullet1"><A NAME="pgfId-416650"></A>If the candidate applet's context is active, the Java Card RE shall set the candidate applet instance as the currently selected applet instance and call the <KBD CLASS="Filename-Command">MultiSelectable.select</KBD> method, where the parameter <KBD CLASS="Filename-Command">appInstAlreadyActive</KBD> is set to <KBD CLASS="Filename-Command">true</KBD> if the same applet instance is already active on another logical channel. A context switch into the candidate applet instance's context occurs at this point. For more details on contexts, see <A HREF="JCRESpec06firewall.html#43635" CLASS="XRef">Section 6.1.2, Contexts and Context Switching</A>.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-416682"></A>Otherwise, if the candidate applet's context is not active, the Java Card RE shall set the candidate applet instance as the currently selected applet instance and call the <KBD CLASS="Filename-Command">Applet.select</KBD> method. A context switch into the candidate applet instance's context occurs at this point.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-416701"></A>If the applet instance's <KBD CLASS="Filename-Command">select</KBD> method throws an exception or returns <KBD CLASS="Filename-Command">false</KBD>, then the Java Card RE closes the new logical channel. The Java Card RE responds with status code <KBD CLASS="Filename-Command">0x6999</KBD> (<KBD CLASS="Filename-Command">SW_APPLET_SELECT_FAILED</KBD>).</LI><P CLASS="Linebreak"></P></UL><P CLASS="List1-"><A NAME="pgfId-416717"></A>11. 	The Java Card RE responds with status code <KBD CLASS="Filename-Command">0x9000</KBD> (and if the P2=<KBD CLASS="Filename-Command">0</KBD> variant is used, 1 data byte containing the newly assigned logical channel number.)</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-412401"></A>Unlike the SELECT FILE commands to select an applet instance, the MANAGE CHANNEL command is never forwarded to the applet instance.</P></TD></TR></TABLE><HR NOSHADE SIZE=1><BR><H3 CLASS="Head2"><A NAME="pgfId-412407"></A>4.5.2	<A NAME="55974"></A>Applet Selection with <A NAME="marker-419777"></A>SELECT <A NAME="marker-419778"></A>FILE</H3><P CLASS="Paragraph"><A NAME="pgfId-412418"></A>Upon receiving a SELECT FILE command on an I/O interface, the Java Card RE shall run the following procedure:</P><P CLASS="List1"><A NAME="pgfId-416727"></A>1.	The Applet SELECT FILE command uses: CLA=<KBD CLASS="Filename-Command">%b000000cc*</KBD> (where <KBD CLASS="Filename-Command">cc</KBD> in the bits (b2,b1*) specifies the logical channel to be selected: 0-3), or CLA=<KBD CLASS="Filename-Command">%0100dddd*</KBD> (where <KBD CLASS="Filename-Command">dddd</KBD> in the bits (b4-b1) denote the origin logical channel: 4-19) and INS=<KBD CLASS="Filename-Command">0xA4</KBD>.</P><P CLASS="ParaIndent1"><A NAME="pgfId-419029"></A>If the SELECT FILE command has non-zero secure messaging bits (b4,b3*) in the CLA byte when the origin logical channel is 0-3 or non-zero bit (b6*) when the origin logical channel is 4-19, it is deemed not to be an Applet SELECT FILE command. The Java Card RE simply forwards the command to the active applet on the specified logical channel.</P><UL><LI CLASS="Bullet1"><A NAME="pgfId-416734"></A>The Applet SELECT FILE command uses &quot;Selection by DF name&quot; with P1=<KBD CLASS="Filename-Command">0x04</KBD>.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-416741"></A>The Java Card RE shall support both of the following:</LI><P CLASS="Linebreak"></P><UL><LI CLASS="Bullet2"><A NAME="pgfId-419665"></A>Selection by &quot;exact DF name(AID)&quot; with P2=<KBD CLASS="Filename-Command">%b0000xx00</KBD> (b4,b3* are don't care) and</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet2"><A NAME="pgfId-419669"></A>The RFU variant described in ISO 7816-4 Specification with P2=<KBD CLASS="Filename-Command">%b0001xx00</KBD> (b4,b3* are don't care).</LI><P CLASS="Linebreak"></P></UL><LI CLASS="Bullet1"><A NAME="pgfId-413318"></A>All other partial DF name SELECT FILE options (b2,b1* variants) are Java Card RE implementation dependent.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-413319"></A>All file control information options codes (b4,b3*) of the P2 parameter shall be supported by the Java Card RE and interpreted and processed by the applet instance itself.</LI><P CLASS="Linebreak"></P></UL><P CLASS="List1-"><A NAME="pgfId-416748"></A>2. 	If resources for the specified logical channel (in bits <KBD CLASS="Filename-Command">cc</KBD> of the CLA) are not available, the Java Card RE responds with status code <KBD CLASS="Filename-Command">0x6881</KBD> (<KBD CLASS="Filename-Command">SW_LOGICAL_CHANNEL_NOT_SUPPORTED</KBD>).</P><P CLASS="List1-"><A NAME="pgfId-416775"></A>3. 	If the specified logical channel is not open on the I/O interface that received the SELECT FILE command, it is now opened and the Java Card RE state is set so that no applet is active on this new logical channel. The specified logical channel will be the assigned channel for the applet instance that will be active on it.</P><P CLASS="List1-"><A NAME="pgfId-416782"></A>4. 	The Java Card RE searches the internal applet table which lists all successfully installed applet instances on the card for an applet instance with a matching AID. If a matching applet instance is found, it is picked as the candidate applet instance. Otherwise, if no AID match is found:</P><UL><LI CLASS="Bullet1"><A NAME="pgfId-416793"></A>If there is no active applet instance on the specified logical channel, the Java Card RE responds with status code <KBD CLASS="Filename-Command">0x6999</KBD> (<KBD CLASS="Filename-Command">SW_APPLET_SELECT_FAILED</KBD>).</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-416808"></A>Otherwise, the active applet instance on this logical channel is set as the currently selected applet instance and the SELECT FILE command is forwarded to that applet instance's <KBD CLASS="Filename-Command">process</KBD> method. A context switch into the applet instance's context occurs at this point, see <A HREF="JCRESpec06firewall.html#69025" CLASS="XRef">Section 6.1.1, Firewall Protection</A>. Applets may use the SELECT FILE command for their own internal processing. Upon return from the applet's <KBD CLASS="Filename-Command">process</KBD> method, the Java Card RE sends the applet instance's response as the response to the SELECT FILE command.</LI><P CLASS="Linebreak"></P></UL><P CLASS="List1-"><A NAME="pgfId-416832"></A>5. 	If the candidate applet instance is not a multiselectable applet, and the candidate applet's context is active, the logical channel remains open and the Java Card RE records an error response status code of <KBD CLASS="Filename-Command">0x6985</KBD> (<KBD CLASS="Filename-Command">SW_CONDITIONS_NOT_SATISFIED</KBD>). Prior to sending the response code, if there is an active applet instance on the logical channel, then the Java Card RE may optionally deselect the applet instance, as described in <A HREF="JCRESpec04selection.html#11324" CLASS="XRef">Section 4.6, Applet Deselection</A>, and set the state so that no applet is active on the specified logical channel.</P><P CLASS="List1-"><A NAME="pgfId-413421"></A>6. 	Assign the <KBD CLASS="Filename-Command">CLEAR_ON_DESELECT</KBD> transient memory segment for the new logical channel in the following cases:</P><UL><LI CLASS="Bullet1"><A NAME="pgfId-416864"></A>If any applet instance from the same package as that of the candidate applet instance is active on another logical channel, assign the same <KBD CLASS="Filename-Command">CLEAR_ON_DESELECT</KBD> transient memory segment to this logical channel.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-413423"></A>Otherwise, assign a different (zero-filled) <KBD CLASS="Filename-Command">CLEAR_ON_DESELECT</KBD> transient memory segment to this new logical channel.</LI><P CLASS="Linebreak"></P></UL><P CLASS="List1-"><A NAME="pgfId-413424"></A>7. 	Check whether the candidate applet instance accepts selection:</P><UL><LI CLASS="Bullet1"><A NAME="pgfId-416877"></A>If the candidate applet's context is active, the Java Card RE shall set the candidate applet instance as the currently selected applet instance and call the <KBD CLASS="Filename-Command">MultiSelectable.select(appInstAlreadyActive)</KBD> method, where the parameter <KBD CLASS="Filename-Command">appInstAlreadyActive</KBD> is set to <KBD CLASS="Filename-Command">true</KBD> if the same applet instance is already active on another logical channel. A context switch into the candidate applet instance's context occurs at this point, see <A HREF="JCRESpec06firewall.html#43635" CLASS="XRef">Section 6.1.2, Contexts and Context Switching</A>.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-416909"></A>Otherwise, if the candidate applet's context is not active, the Java Card RE shall set the candidate applet instance as the currently selected applet instance and call the <KBD CLASS="Filename-Command">Applet.select</KBD> method. A context switch into the candidate applet instance's context occurs at this point.</LI><P CLASS="Linebreak"></P><LI CLASS="Bullet1"><A NAME="pgfId-416930"></A>If the applet instance's <KBD CLASS="Filename-Command">select</KBD> method throws an exception or returns <KBD CLASS="Filename-Command">false</KBD>, then the Java Card RE state is set so that no applet is active on the specified logical channel. The logical channel remains open, and the Java Card RE responds with status code <KBD CLASS="Filename-Command">0x6999</KBD> (<KBD CLASS="Filename-Command">SW_APPLET_SELECT_FAILED</KBD>).</LI><P CLASS="Linebreak"></P></UL><P CLASS="List1-"><A NAME="pgfId-416951"></A>8. 	The Java Card RE shall set the candidate applet instance as the currently selected applet instance and call the <KBD CLASS="Filename-Command">Applet.process</KBD> method with the SELECT FILE APDU as the input parameter. A context switch occurs into the applet instance's context at this point. Upon return from the applet instance's <KBD CLASS="Filename-Command">process</KBD> method, the Java Card RE sends the applet instance's response as the response to 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-413504"></A>If the SELECT FILE command does not conform to the exact format of an Applet SELECT FILE command described in item 1 above or if there is no matching AID, the SELECT FILE command is forwarded to the active applet instance (if any) on that logical channel for processing as a normal applet APDU command.<BR><BR>If there is a matching AID and the SELECT FILE command fails, the Java Card RE always sets the state in which no applet is active on that logical channel.<BR><BR>If the matching AID is the same as the active applet instance on the specified logical channel, the Java Card RE still goes through the process of deselecting the applet instance and then selecting it. Reselection could fail, leaving the card in a state in which no applet is active on that logical channel.</P></TD></TR></TABLE><HR NOSHADE SIZE=1><BR><H2 CLASS="Head1"><A NAME="pgfId-413485"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>4.6	<A NAME="11324"></A>Applet <A NAME="marker-419780"></A>Deselection</H2><P CLASS="Paragraph"><A NAME="pgfId-416971"></A>An applet instance is deselected either upon receipt of a

⌨️ 快捷键说明

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