com.ibm.jc.tools
Class JCRMIClient

java.lang.Object
  extended bycom.ibm.jc.tools.JCRMIClient

public class JCRMIClient
extends java.lang.Object


Field Summary
static java.lang.String CMD_AUTH
           
static java.lang.String CMD_CARD
           
static java.lang.String CMD_CLOSE
           
static java.lang.String CMD_ECHO
           
static java.lang.String CMD_INFO
           
static java.lang.String CMD_INVOKE
           
static java.lang.String CMD_METH
           
static java.lang.String CMD_SEL
           
static java.lang.String CMD_TERM
           
static java.lang.String METH_NAME_SAMPLE
           
static java.lang.String MTH_SAMPLE
           
static java.lang.String SPACE
           
static java.lang.String TERM_REMOTE
           
static java.lang.String VAR_METH_PREF
           
 
Constructor Summary
JCRMIClient()
          Constructor JCRMIClient without parameters.
JCRMIClient(java.io.PrintStream out, java.lang.String term)
          Constructor JCRMIClient with parameters: output device and terminal.
JCRMIClient(java.lang.String term)
          Constructor JCRMIClient with parameters: terminal.
 
Method Summary
 boolean close()
          close the terminal connection without response display
 java.lang.String executeMethod(java.lang.String methodName, java.lang.String params)
          Execute the given method with the given params and return the execution result.
 java.lang.String getFirstSelectableApplet(java.lang.String lastResponse)
          Return the name of the first applet in the applet list of the card.
 java.util.HashMap getRmiMethods()
           
 void initShell(java.lang.String[] args)
          initialize the JCShell arguments for initialization are possible in convinience with the JCShell
 boolean isWithEcho()
           
 boolean isWithResponse()
           
 java.util.HashMap prepareMethod(java.lang.String[] methods)
          Declare methods for the interface and save the method-id for later use in the hashmap.
 void selectApplet(java.lang.String selectedApplet)
          select the given applet and extracts the objId for this applet from card response
 void setRmiMethods(java.util.HashMap rmiMethods)
           
 void setWithEcho(boolean withEcho)
           
 void setWithResponse(boolean withResponse)
           
 void startSession()
          init the jcshell session Execution of the following commands: - select terminal - select card manager plugin - authenticate - receive info from card (card-info)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TERM_REMOTE

public static final java.lang.String TERM_REMOTE
See Also:
Constant Field Values

CMD_ECHO

public static final java.lang.String CMD_ECHO
See Also:
Constant Field Values

CMD_TERM

public static final java.lang.String CMD_TERM
See Also:
Constant Field Values

CMD_CARD

public static final java.lang.String CMD_CARD
See Also:
Constant Field Values

CMD_CLOSE

public static final java.lang.String CMD_CLOSE
See Also:
Constant Field Values

CMD_SEL

public static final java.lang.String CMD_SEL
See Also:
Constant Field Values

CMD_AUTH

public static final java.lang.String CMD_AUTH
See Also:
Constant Field Values

CMD_INFO

public static final java.lang.String CMD_INFO
See Also:
Constant Field Values

CMD_METH

public static final java.lang.String CMD_METH
See Also:
Constant Field Values

CMD_INVOKE

public static final java.lang.String CMD_INVOKE
See Also:
Constant Field Values

SPACE

public static final java.lang.String SPACE
See Also:
Constant Field Values

METH_NAME_SAMPLE

public static final java.lang.String METH_NAME_SAMPLE
See Also:
Constant Field Values

VAR_METH_PREF

public static final java.lang.String VAR_METH_PREF
See Also:
Constant Field Values

MTH_SAMPLE

public static final java.lang.String MTH_SAMPLE
See Also:
Constant Field Values
Constructor Detail

JCRMIClient

public JCRMIClient(java.io.PrintStream out,
                   java.lang.String term)
Constructor JCRMIClient with parameters: output device and terminal. Use this class for easy communication with an JCOP RMI applet
For a active JCOP simulation with installed JCOP sampleRmiApplet (created with the new Javacard Applet wizard ) a simple session could have the following content:
                RmiClient tester = null;
                PrintStream cout = null;
                try {
                        cout = new PrintStream( new FileOutputStream( "c:/tmp/test_rmi_result.txt" ) );
                        tester = new RmiClient( cout, RmiClient.TERM_REMOTE );
                        tester.setWithResponse( true );
                        tester.setWithEcho( true );
                        tester.initShell( new String[] {} );
                        tester.startSession();
                        tester.selectApplet( tester.getFirstSelectableApplet( JCShell.getLastResponse() ) );

                        // prepare methods
                        String[] methods = new String[] { RmiClient.MTH_SAMPLE };
                        tester.setRmiMethods( tester.prepareMethod( methods ) );
                        String result = tester.executeMethod( RmiClient.METH_NAME_SAMPLE, "1000" );
                        cout.println( "Execution result: " + result );
                } catch ( JCException e ) {
                        cout.println( "Error occured during JCShell command processing:\n" );
                        e.printStackTrace();
                } catch ( IOException e ) {
                        cout.println( "Error occured during JCShell initialization:\n" );
                        e.printStackTrace();
                } finally {
                        tester.close();
                        cout.close();
                }
 

Parameters:
out - device for output (default is System.out)
term - declare the used card terminal

JCRMIClient

public JCRMIClient(java.lang.String term)
Constructor JCRMIClient with parameters: terminal. Set output device to stdout

Parameters:
term -

JCRMIClient

public JCRMIClient()
Constructor JCRMIClient without parameters. Set output device to stdout
use the default remote terminal (JCOP simulation with port 8050)

Method Detail

executeMethod

public java.lang.String executeMethod(java.lang.String methodName,
                                      java.lang.String params)
                               throws JCException
Execute the given method with the given params and return the execution result.
command: invoke -r ${}
precondition: method must be prepared before

Parameters:
methodName -
params -
Returns:
String with the response of the command execution
Throws:
JCException

prepareMethod

public java.util.HashMap prepareMethod(java.lang.String[] methods)
                                throws JCException
Declare methods for the interface and save the method-id for later use in the hashmap.
objId = pos 20, len 4 of response data
method = -m meth_sample sampleMethod "short(short)"

Parameters:
methods - --> Array where each string describe a method with name and it's signature
Throws:
JCException

selectApplet

public void selectApplet(java.lang.String selectedApplet)
                  throws JCException
select the given applet and extracts the objId for this applet from card response

Parameters:
selectedApplet -
Throws:
JCException

startSession

public void startSession()
                  throws JCException
init the jcshell session Execution of the following commands: - select terminal - select card manager plugin - authenticate - receive info from card (card-info)

Throws:
JCException

initShell

public void initShell(java.lang.String[] args)
               throws java.io.IOException
initialize the JCShell arguments for initialization are possible in convinience with the JCShell

Parameters:
args -
Throws:
java.io.IOException

close

public boolean close()
close the terminal connection without response display

Returns:
boolean

getFirstSelectableApplet

public java.lang.String getFirstSelectableApplet(java.lang.String lastResponse)
Return the name of the first applet in the applet list of the card. precondition: This method should evaluate the response for previous executed method "startSession"

Parameters:
lastResponse -
Returns:
String with the name of the first found applet or null

getRmiMethods

public java.util.HashMap getRmiMethods()

setRmiMethods

public void setRmiMethods(java.util.HashMap rmiMethods)

isWithResponse

public boolean isWithResponse()

setWithResponse

public void setWithResponse(boolean withResponse)

isWithEcho

public boolean isWithEcho()

setWithEcho

public void setWithEcho(boolean withEcho)


Copyright (c) 2004, 2006 International Business Machines Corporation. All Rights Reserved.