📄 basicservice.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.5.0_02) on Wed Mar 22 19:19:07 PST 2006 --><TITLE>BasicService (Java Card API and Subsets)</TITLE><META NAME="keywords" CONTENT="javacard.framework.service.BasicService class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){ parent.document.title="BasicService (Java Card API and Subsets)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/BasicService.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java Card </b><br><font size="-1">v2.2.2</font></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> PREV CLASS <A HREF="../../../javacard/framework/service/CardRemoteObject.html" title="class in javacard.framework.service"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html?javacard/framework/service/BasicService.html" target="_top"><B>FRAMES</B></A> <A HREF="BasicService.html" target="_top"><B>NO FRAMES</B></A> <SCRIPT type="text/javascript"> <!-- if(window==top) { document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>'); } //--></SCRIPT><NOSCRIPT> <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javacard.framework.service</FONT><BR>Class BasicService</H2><PRE><A HREF="../../../java/lang/Object.html" title="class in java.lang">java.lang.Object</A> <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>javacard.framework.service.BasicService</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../javacard/framework/service/Service.html" title="interface in javacard.framework.service">Service</A></DD></DL><DL><DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../javacard/framework/service/RMIService.html" title="class in javacard.framework.service">RMIService</A></DD></DL><HR><DL><DT><PRE>public class <B>BasicService</B><DT>extends <A HREF="../../../java/lang/Object.html" title="class in java.lang">Object</A><DT>implements <A HREF="../../../javacard/framework/service/Service.html" title="interface in javacard.framework.service">Service</A></DL></PRE><P>This class should be used as the base class for implementing services. It provides a default implementation for the methods defined in the <CODE>Service</CODE> interface, and defines a set of helper methods that manage the APDU buffer to enable co-operation among different Services. <P>The <CODE>BasicService</CODE> class uses the state of APDU processing to enforce the validity of the various helper operations. It expects and maintains the following Common Service Format (CSF) of data in the APDU Buffer corresponding to the various APDU processing states (See <A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework"><CODE>APDU</CODE></A> ): <P><PRE> Init State format of APDU Buffer. This format corresponds to the APDU processing state - <CODE>STATE_INITIAL</CODE> : 0 1 2 3 4 5 <- offset +------------------------------------------------------------+ | CLA | INS | P1 | P2 | P3 | ... Implementation dependent ...| +------------------------------------------------------------+ Input Ready format of APDU Buffer. This format corresponds to the APDU processing state - <CODE>STATE_FULL_INCOMING</CODE>. 0 1 2 3 4 5 <- offset +------------------------------------------------------------+ | CLA | INS | P1 | P2 | Lc | Incoming Data( Lc bytes ) | +------------------------------------------------------------+ Output Ready format of APDU Buffer. This format corresponds to the APDU processing status - <CODE>STATE_OUTGOING</CODE> .. <CODE>STATE_FULL_OUTGOING</CODE> 0 1 2 3 4 5 <- offset +------------------------------------------------------------+ | CLA | INS | SW1 | SW2 | La | Outgoing Data( La bytes ) | +------------------------------------------------------------+ </PRE> <p>When the APDU buffer is in the Init and Input Ready formats, the helper methods allow input access methods but flag errors if output access is attempted. Conversely, when the APDU buffer is in the Output format, input access methods result in exceptions. <p> The Common Service Format (CSF) of the APDU Buffer is only defined for APDUs using the short length (normal semantics) of the ISO7816 protocol. When an implementation supports extended length APDU format (see <A HREF="../../../javacardx/apdu/ExtendedLength.html" title="interface in javacardx.apdu"><CODE>ExtendedLength</CODE></A>) and an APDU with more than 255 input or output data bytes is being processed, the behavior of <CODE>BasicService</CODE> class is undefined. <p> If the header areas maintained by the <CODE>BasicService</CODE> helper methods are modified directly in the APDU buffer and the format of the APDU buffer described above is not maintained, unexpected behavior might result. <p> In addition, both La=0 and La=256 are represented in the CSF format as La=0. The distinction is implementation dependent. The <CODE>getOutputLength</CODE> method must be used to avoid ambiguity. <p> Many of the helper methods also throw exceptions if the APDU object is in an error state ( processing status code < 0 ).<P><P><DL><DT><B>Version:</B></DT> <DD>1.0</DD><DT><B>See Also:</B><DD><A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework"><CODE>APDU</CODE></A>, <A HREF="../../../javacardx/apdu/ExtendedLength.html" title="interface in javacardx.apdu"><CODE>javacardx.apdu.ExtendedLength</CODE></A></DL><HR><P><!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../javacard/framework/service/BasicService.html#BasicService()">BasicService</A></B>()</CODE><BR> Creates new <CODE>BasicService</CODE>.</TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Method Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javacard/framework/service/BasicService.html#fail(javacard.framework.APDU, short)">fail</A></B>(<A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework">APDU</A> apdu, short sw)</CODE><BR> Sets the processing state for the command in the <CODE>APDU</CODE> object to <em>processed</em>, and indicates that the processing has failed.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> byte</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javacard/framework/service/BasicService.html#getCLA(javacard.framework.APDU)">getCLA</A></B>(<A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework">APDU</A> apdu)</CODE><BR> Returns the class byte for the command in the <CODE>APDU</CODE> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> byte</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javacard/framework/service/BasicService.html#getINS(javacard.framework.APDU)">getINS</A></B>(<A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework">APDU</A> apdu)</CODE><BR> Returns the instruction byte for the command in the <CODE>APDU</CODE> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> short</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javacard/framework/service/BasicService.html#getOutputLength(javacard.framework.APDU)">getOutputLength</A></B>(<A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework">APDU</A> apdu)</CODE><BR> Returns the output length for the command in the <CODE>APDU</CODE> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> byte</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javacard/framework/service/BasicService.html#getP1(javacard.framework.APDU)">getP1</A></B>(<A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework">APDU</A> apdu)</CODE><BR> Returns the first parameter byte for the command in the <CODE>APDU</CODE> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> byte</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javacard/framework/service/BasicService.html#getP2(javacard.framework.APDU)">getP2</A></B>(<A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework">APDU</A> apdu)</CODE><BR> Returns the second parameter byte for the command in the <CODE>APDU</CODE> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> short</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javacard/framework/service/BasicService.html#getStatusWord(javacard.framework.APDU)">getStatusWord</A></B>(<A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework">APDU</A> apdu)</CODE><BR> Returns the response status word for the command in the <CODE>APDU</CODE> object.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javacard/framework/service/BasicService.html#isProcessed(javacard.framework.APDU)">isProcessed</A></B>(<A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework">APDU</A> apdu)</CODE><BR> Checks if the command in the <CODE>APDU</CODE> object has already been <em>processed</em>.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javacard/framework/service/BasicService.html#processCommand(javacard.framework.APDU)">processCommand</A></B>(<A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework">APDU</A> apdu)</CODE><BR> This <CODE>BasicService</CODE> method is a default implementation and simply returns false without performing any processing.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javacard/framework/service/BasicService.html#processDataIn(javacard.framework.APDU)">processDataIn</A></B>(<A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework">APDU</A> apdu)</CODE><BR> This <CODE>BasicService</CODE> method is a default implementation and simply returns false without performing any processing.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../javacard/framework/service/BasicService.html#processDataOut(javacard.framework.APDU)">processDataOut</A></B>(<A HREF="../../../javacard/framework/APDU.html" title="class in javacard.framework">APDU</A> apdu)</CODE><BR> This <CODE>BasicService</CODE> method is a default implementation and simply returns false without performing any processing.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE> short</CODE></FONT></TD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -