Code Sample: cardinfo for JCOP41V22 Card

Listed below is the code sample, cardinfo.java, deduced from loader.java for JCOP41V22 card:
import java.io.*;
import com.ibm.jc.*;
import com.ibm.jc.terminal.*;
* Sample cardinfo. Demonstrates how to use the offcard API to list applets informatoin,
* JCOP41V22 by shrinking the loader.java code.
* Modified by: freiheit / 13/10/2005
public class cardinfo{
     protected static final byte[] JCOP_CARD_MANAGER_AID = { (byte) 0xa0, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00};
     protected static final byte defaultInstallParam[] = { -55, 0 }; // don't know what it's for
     public static void main(String[] args){
     if (args.length == 0){
     System.out.println("cardinfo.main(): missing cap-file argument");
     System.exit(1);
     try{
     cardinfo l = new cardinfo();
     //l.load(args[0]);
     l.getcardinfo();
     }catch(Exception e){
     System.err.println("EX: msg " + e.getMessage() + ", class " + e.getClass());
     e.printStackTrace(System.err);
     System.exit(0);
private cardinfo(){}
//private void load(String capFileName) throws Exception{
private void getcardinfo() throws Exception{
     //CapFile capFile = new CapFile(capFileName, null);
/*CapFile capFile = new CapFile("C:\\Documents and Settings\\Seah Peng Chew\\workspace\\Helloworld\\bin\\com\\acme\\helloworld\\javacard\\helloworld.cap", null);
     System.out.println("Package name: " + capFile.pkg);
     byte[][] applets = capFile.aids;
     if ((applets == null) || (applets.length == 0)){
     throw new RuntimeException("no applets in cap file");
     // Get connection to terminal, we look for the simulation.
     // As you might want to use "pcsc", "4" or "tcl", "10" in case of
     // Windows or "PCSC", null in case of Linux, you should pass the name
     // of the terminal on the command line or in a properties file
     System.out.println("Open terminal ...");     
     //Make sure the simulator jcop.exe is activated before unmark this satement
     //before running
     //Issue /close command at "cm" prompt if the card is in use,, ie it should
     //have "-" prompt.
     JCTerminal term = JCTerminal.getInstance("Remote", null);
     //For real JCOP41V22 card, please unmark this statement before running
     //Issue /close command at "cm" prompt if the card is in use,, ie it should
     //have "-" prompt.
     //JCTerminal term = JCTerminal.getInstance("pcsc:4", null);
     term.open();
     term.waitForCard(5000);
     TraceJCTerminal _term = new TraceJCTerminal();
     _term.setLog(new PrintWriter(System.out));
     _term.init(term);
     term = _term;
     System.out.println("Get card ...");
     JCard card = new JCard(term, null, 2000);
     System.out.println("Select card manager ...");
     CardManager cardManager = new CardManager(card, CardManager.daid);     
     cardManager.select();
     byte[] dfltKey = c2b("404142434445464748494a4b4c4d4e4f");
     cardManager.setKey(new OPKey(255, 1, OPKey.DES_ECB, dfltKey));
     cardManager.setKey(new OPKey(255, 2, OPKey.DES_ECB, dfltKey));
     cardManager.setKey(new OPKey(255, 3, OPKey.DES_ECB, dfltKey));
     System.out.println("Authenticate to card manager ...");
     cardManager.initializeUpdate(255, 0, CardManager.SCP_UNDEFINED);
     cardManager.externalAuthenticate(OPApplet.APDU_CLR);
     cardManager.update();
     JCInfo info = JCInfo.INFO;
     System.out.println("\nCardManager AID : " + JCInfo.dataToString(cardManager.getAID()));
     System.out.println("CardManager state : " + info.toString("card.status", (byte) cardManager.getState()) + "\n");
     Object[] app = cardManager.getApplets(1, 0, true);
     if (app == null) {
     System.out.println("No applets installed on-card");
     } else {
     System.out.println("Applets:");
     for (int i = 0; i < app.length; i++) {
          System.out.println(info.toString("applet.status", (byte) ((OPApplet) app).getState()) + " " + JCInfo.dataToString(((OPApplet) app[i]).getAID()));
     Object[] lf = cardManager.getLoadFiles(0, true);
     if (lf == null) {
     System.out.println("No packages installed on-card");
     } else {
     System.out.println("Packages:");
     for (int i = 0; i < lf.length; i++) {
          System.out.println(info.toString("loadfile.status", (byte)((LoadFile) lf[i]).getState()) + " " + JCInfo.dataToString(((LoadFile) lf[i]).getAID()));
     term.close();
static String numbers = "0123456789abcdef";
private byte[] c2b(String s) {
     if (s == null) return null;
     if (s.length() % 2 != 0) throw new RuntimeException("invalid length");
     byte[] result = new byte[s.length() / 2];
     for (int i = 0; i < s.length(); i += 2) {
     int i1 = numbers.indexOf(s.charAt(i));
     if (i1 == -1) throw new RuntimeException("invalid number");
     int i2 = numbers.indexOf(s.charAt(i + 1));
     if (i2 == -1) throw new RuntimeException("invalid number");
     result[i / 2] = (byte) ((i1 << 4) | i2);
     return result;
I have tested the code with JCOP Plug-in 3.1.1a in Windows environment.
Please give your comments and feedback.

The posted code had some errors in the part which enumerate the installed applets and packages. I corrected that.
Second I changed the class name from "cardinfo" to "CardInfo", because of java code style.
import java.io.PrintWriter;
import com.ibm.jc.CardManager;
import com.ibm.jc.JCInfo;
import com.ibm.jc.JCTerminal;
import com.ibm.jc.JCard;
import com.ibm.jc.LoadFile;
import com.ibm.jc.OPApplet;
import com.ibm.jc.OPKey;
import com.ibm.jc.terminal.TraceJCTerminal;
* Sample cardinfo. Demonstrates how to use the offcard API to list applets informatoin, JCOP41V22
* by shrinking the loader.java code. Modified by: freiheit / 13/10/2005
public class CardInfo {
    protected static final byte[] JCOP_CARD_MANAGER_AID = { (byte) 0xa0, 0x00, 0x00, 0x00, 0x03,
            0x00, 0x00, 0x00 };
    protected static final byte defaultInstallParam[] = { -55, 0 }; // don't know what it's for
    public static void main(String[] args) {
         * if (args.length == 0){ System.out.println("cardinfo.main(): missing cap-file argument");
         * System.exit(1); }
        try {
            CardInfo l = new CardInfo();
            // l.load(args[0]);
            l.getcardinfo();
        } catch (Exception e) {
            System.err.println("EX: msg " + e.getMessage() + ", class " + e.getClass());
            e.printStackTrace(System.err);
        System.exit(0);
    private CardInfo() {
    // private void load(String capFileName) throws Exception{
    private void getcardinfo() throws Exception {
        // CapFile capFile = new CapFile(capFileName, null);
         * CapFile capFile = new CapFile("C:\\Documents and Settings\\Seah Peng
         * Chew\\workspace\\Helloworld\\bin\\com\\acme\\helloworld\\javacard\\helloworld.cap",
         * null); System.out.println("Package name: " + capFile.pkg); byte[][] applets =
         * capFile.aids; if ((applets == null) || (applets.length == 0)){ throw new
         * RuntimeException("no applets in cap file"); }
        // Get connection to terminal, we look for the simulation.
        // As you might want to use "pcsc", "4" or "tcl", "10" in case of
        // Windows or "PCSC", null in case of Linux, you should pass the name
        // of the terminal on the command line or in a properties file
        System.out.println("Open terminal ...");
        // Make sure the simulator jcop.exe is activated before unmark this satement
        // before running
        // Issue /close command at "cm" prompt if the card is in use,, ie it should
        // have "-" prompt.
        JCTerminal term = JCTerminal.getInstance("Remote", null);
        // For real JCOP41V22 card, please unmark this statement before running
        // Issue /close command at "cm" prompt if the card is in use,, ie it should
        // have "-" prompt.
        // JCTerminal term = JCTerminal.getInstance("pcsc:4", null);
        term.open();
        term.waitForCard(5000);
        TraceJCTerminal _term = new TraceJCTerminal();
        _term.setLog(new PrintWriter(System.out));
        _term.init(term);
        term = _term;
        System.out.println("Get card ...");
        JCard card = new JCard(term, null, 2000);
        System.out.println("Select card manager ...");
        CardManager cardManager = new CardManager(card, CardManager.daid);
        cardManager.select();
        byte[] dfltKey = c2b("404142434445464748494a4b4c4d4e4f");
        cardManager.setKey(new OPKey(255, 1, OPKey.DES_ECB, dfltKey));
        cardManager.setKey(new OPKey(255, 2, OPKey.DES_ECB, dfltKey));
        cardManager.setKey(new OPKey(255, 3, OPKey.DES_ECB, dfltKey));
        System.out.println("Authenticate to card manager ...");
        cardManager.initializeUpdate(255, 0, CardManager.SCP_UNDEFINED);
        cardManager.externalAuthenticate(OPApplet.APDU_CLR);
        cardManager.update();
        JCInfo info = JCInfo.INFO;
        System.out.println("\nCardManager AID : " + JCInfo.dataToString(cardManager.getAID()));
        System.out.println("CardManager state : "
                + info.toString("card.status", (byte) cardManager.getState()) + "\n");
        OPApplet[] app = (OPApplet[]) cardManager.getApplets(1, 0, true);
        if (app == null) {
            System.out.println("No applets installed on-card");
        } else {
            System.out.println("Applets:");
            for (int i = 0; i < app.length; i++) {
                System.out.println(info.toString("applet.status", (byte) app.getState()) + " "
+ JCInfo.dataToString(app[i].getAID()));
LoadFile[] lf = cardManager.getLoadFiles(0, true);
if (lf == null) {
System.out.println("No packages installed on-card");
} else {
System.out.println("Packages:");
for (int i = 0; i < lf.length; i++) {
System.out.println(info.toString("loadfile.status", (byte) lf[i].getState()) + " "
+ JCInfo.dataToString(lf[i].getAID()));
term.close();
static String numbers = "0123456789abcdef";
private byte[] c2b(String s) {
if (s == null)
return null;
if (s.length() % 2 != 0)
throw new RuntimeException("invalid length");
byte[] result = new byte[s.length() / 2];
for (int i = 0; i < s.length(); i += 2) {
int i1 = numbers.indexOf(s.charAt(i));
if (i1 == -1)
throw new RuntimeException("invalid number");
int i2 = numbers.indexOf(s.charAt(i + 1));
if (i2 == -1)
throw new RuntimeException("invalid number");
result[i / 2] = (byte) ((i1 << 4) | i2);
return result;

Similar Messages

  • Apple store worked great, now it keeps telling me that I need to verify payment info and my security code is invalid for my card... The card is current? What's going on?

    Apple store worked great, now it keeps telling me that I need to verify payment info and my security code is invalid for my card... The card is current? What's going on?

    Did you enter the last three digits on the back of the card for Visa or Master or the 4 digit # on the front of Amex?

  • Java code coverage tool for Java Card?

    Hello,
    I am looking for "Java code coverage tool" that can be used for testing Java Card Applets.
    Has anyone tried EMMA<http://emma.sourceforge.net/> with JCWDE, or other tools?
    Any information appreciated.
    ichara

    JCOP Tools 3.0 for Eclipse 2.1 support code coverage with the JCOP simulations for Java Card 2.1. The newest JCOP41 simulation for Java Card 2.2.1 does not yet have this feature.
    Code coverage information is shown in the Profiling view, when it is enabled in the Launch Configuration. The editor also shows colored bars next to source lines to quickly identify dead code.

  • Bar Code Sample Example for Usage in Smarform

    Dear Experts,
    We are trying to print the barcode on the Manufacturing Sheet and should contain the PART code, Serial Number and the Mfg. Date embeded in the bar code.
    Can somebody share the sample  Bar Code Example for Usage in Smarforms.
    I never got a chance to work on such development. We are getting different answers from our development partner and sould like to excersize this on my own.
    Appreciate your help
    Regards,
    Ravati

    Hi Ravati,  It's simple!!
    Follow the example below for printing barcode in smartform .
    There are some SAP standard barcodes(for ex.ARTNR,AUFNR ..etc) and also we can create our own barcode for it by using transaction code SE73.
    1. Steps for using existing barcode in Smartform
    For Printing Barcode in Smartform, you need to have the style with barcode active in it. So define new style where the standard settings should define the barcode that you want to use in the smartform.
    For example, For product information display I use the Style as ZMFG_BARCODE.
    Create paragraph & character format as "P1 - Product Description". In standard setting of character format P1, select the standard or custom defined barcode. This will ensure the printing of Product Information in Barcode format.
    Now Create Smartform with output options specifying style name which you have created with Barcode active.
    Complete your smartform coding, and when you want to display the information in barcode, concatinate all the required information and enclose that text in character format like,
    for Product Code assuming the technical field name as mara-matnr, it should be printed as below:
    <P1>&mara-matnr&</>
    2. Steps to create new barcode using SE73 - SAPScript Font Maintenance.
    In SE73, Select radio button "System barcode" to create new barcode.  While creation of this barcode, you have to describe the new barcode, select technology new, barcode symbology and barcode alignment.
    You may also chage the barcode parameter if required.
    Now follow the same steps to implement this new barcode.
    Hope this will help you.
    Regards,
    Pravin

  • Help:  Problem in Uploading Cap File to JCOP41v22  Card

    Hi,
    I am new in Java Card development.
    Having successfully tested the simulation with HelloWorld Applet using JCOP Tools 3.1 on Eclipse, I tried to excecute the code using the real JCOP41V22 card, I encountered the following error message after the Cap File is uploaded:
    jcshell: Error code: 45d (0x045D)
    jcshell: Command failed: SCardTransmit(): 0x45d, PCSC failed with 0x45D: 0x45D (OK,--,(System))
    Unexpected error; aborting execution
    What could go wrong?
    Please endlighten.

    Finally, I got the answer from IBM Zurich Research Lab after sending 4 emails to three different email addresses there within a week.
    It boils down to the Gemplus USB GemPC430 smart card reader which is not fully ISO-compliant.
    After switching to Sclumberger Refelx USB reader, it works perfectly.
    CrreativeMan,
    I strongly recommend JCOP java card if you are keen to embark on the development. You need to install Eclispse Java IDE first, download the JCOP Tools and;
    - Buy an activation code at CHF 40 to make use of the Java Card Simulator
    - or buy a JCOP Engineering Sample Card at CHF 75. The activation code is bundled with the card. It will be activated automatically when you click Run Java Card Application the first time. Once activated, you can either work in simulation or real card condition.
    - As for the reader, I have just replied that Schlumberger Relext USB reader works fine.
    JCOP ordering information is at
    http://www.zurich.ibm.com/jcop/order/tools.html
    The delivery by Federal Express is very fast . Mine took three days only..
    I hope the above informatio will help.

  • Is there a RH standard for formatting code samples?

    In the RH default style sheet, I do not see a pre HTML tag or other tag that will display code samples in a monospaced font.
    I created custom styles for a single line code sample and another style for multiline samples.
    We want our code samples to be shaded. If I shade multiple lines, each line being separated with a paragraph, there is a small amount of
    white space between each line. We do not like this either.
    I then created a custom table style with a single shaded cell. I add my multiline sample code, then I apply the custom paragraph style to get
    the font and spacing between lines that I want.
    Is there a different best practice for this, so that the code sample would be rendered correctly if viewed from other devices that read the HTML and
    may look for the pre HTML tag?
    I am using RoboHelp 9 and I provide the output as Eclipse help. Our help files are integrated into Eclipse help in the Eclipse IDE.
    Thank you.
    Cynthia

    Hi Cynthia
    As much as it pains me to say it, this is one case where using a Form element might be your best bet. I say this because often code samples are used or presented with the intent of copying and pasting into something like Windows Notepad. And if you used the TextArea form element, you can place the code there and make it pretty easy for folks to copy it for use elsewhere.
    I stand to be corrected on this because I am not a "power CSS" person. (meaning I am aware there are complete two and three day classes one might attend on all the nuances of CSS) But RoboHelp won't really do anything to help you a great deal in formatting things. But it might be possible, somehow, to configure CSS to accomplish your goal of making the code look as you want.
    Cheers... Rick

  • HT203905 I have changed my family sharing organizer payment method but when asked to add members it keeps asking for information for a card I no longer have so I do not have the security code.

    I have changed my family sharing organizer payment method but when asked to add members it keeps asking for information for a card I no longer have so I do not have the security code.  My current shows in all the correct places but when asked to verify, the old card is referenced.  I changed the card in itunes and on my phone and ipad.

    I have changed my family sharing organizer payment method but when asked to add members it keeps asking for information for a card I no longer have so I do not have the security code.  My current shows in all the correct places but when asked to verify, the old card is referenced.  I changed the card in itunes and on my phone and ipad.

  • TS1646 I have a $15 credit and I no longer have the iTunes card, and it's asking me for the card code. How do I get my credit credited?

    I have a &amp;25 iTunes credit but no longer have the card. What should I do?

    It's probably asking for the security code on your credit card, not for the code from your iTunes prepaid card which if you correctly redeemed is no longer needed.
    Regards.

  • I'm trying to update my apps on my third generation Ipod but, I'm having some difficulty. I can't update my Ipod of apps via my laptop because it's broken. Itunes keeps saying that my code for my card is wrong. I can't update my apps now. What do I do???

    I'm trying to update my apps on my third generation Ipod but, I'm having some difficulty. I can't update my Ipod or apps via my laptop because it's broken. Itunes keeps saying that my security code for my card is wrong. I can't update my apps now or continue to play games. What do I do???

    Perhaps this article can be of assistance.
    iTunes Store: My credit card's security code or zip code does not match my bank's records
    B-rock

  • How to purchase apps in App Store? When I am trying to buy those apps, it is asking for my card details. I have entered my debit card number and then it asked for 3 digit security code. I have entered cvv secure code but it is showing an invalid security

    How to purchase apps in App Store? When I am trying to buy those apps, it is asking for my card details. I have entered my debit card number and then it asked for 3 digit security code. I have entered cvv secure code but it is showing an invalid security

    Debit cards are no longer accepted in the iTunes Store, it seems. The current valid payment methods are listed here:
    http://support.apple.com/kb/HT5552
    You can try contacting the iTunes Store and asking if there is any way to use your card, but they probably will tell you that it's not possible.
    http://www.apple.com/emea/support/itunes/contact.html
    Using a debit card in any online service where it stores your card is a bad idea in any case since if someone gains access to your account in the service, they can quickly drain your bank account. Credit cards limit your liability, as do prepaid iTunes cards.
    Regards.

  • TS1646 I'v tried many times to update my applications however, my account can't do it because security code for my card is incorrect note that I'm sure my card details are correct completely so i need help to fix it as much as you can plz. Thnks

    Hi
    I'v tried many times to update my applications however, my account can't do it because security code for my card is incorrect note that I'm sure my card details are correct completely so i need help to fix it as much as you can plz. Thnks

    Look, I understand I still need a card attached to the account. The problem is, it won't accept my card because I only have 87 cents in my bank account right now.
    If I had known there would be so much trouble with the iTunes card, I would have just put the cash in my bank account in the morning instead of buying an iTunes card (I didn't expect the banks to be open on Thanksgiving of course).
    Apple will only accept cards that have a balance. The balance is so small in my account that it won't accept it as a valid card.
    I'm going to have to contact Apple anyway to reset the security questions. That's obvious. Your answers were not exactly helpful. You didn't tell me anything I don't already know, but thanks for trying to be helpful.

  • ABAP Sample Program for T Code FFB4

    Hi guys: I have the structure that t code FFB4 requires, but now I need to code a program for SAP to read the csv or text file and convert it automatically to match the structures required by FFB4 to post successfully. Does anyone please have a sample program that they have written for this purpose? The CSV/txt file is being generated by an external system but now SAP needs to make sense of it.
    The structures are:
    Header record  (record type 0, structure FEBSCSA).
    Memo record    (record type 1, structure FEBSCSB).
    Clearing record (record type 2, structure FEBSCSC).
    Please provide a sample code so I can debug & tweak it.
    Thanks so much
    Full points will be rewarded.
    Brian

    No.  However, you just have to write a custom program to do the following.
      data : gi_filename like rlgrap-filename,
             gi_name     like thead-tdname," You image name
             gi_spras    like thead-tdspras,
             gi_object   like thead-tdobject value 'GRAPHICS',
             gi_id       like thead-tdid value 'BMAP',
             l_extension like rlgrap-filename  value 'BMP',
             gi_title    like bapisignat-prop_value,
             gi_resident like rsscg-resident,
             gi_btype    like stxbitmaps-tdbtype value 'BMON',
             gi_autoheight like rsscg-autoheight value ' ',
             gi_resolution like stxbitmaps-resolution value '600',
             l_stxbitmaps like stxbitmaps.
    For each image do the following perform.
      perform import_bitmap_bds(saplstxbitmaps)
                                using    gi_filename
                                         gi_name
                                         gi_object
                                         gi_id
                                         gi_btype
                                         l_extension
                                         gi_title
                                         gi_resident
                                         gi_autoheight
                           changing l_docid
                                         gi_resolution.

  • I scratched the label off on a £25 gift card and it removed the code. How can I get the code for the card?

    I scratched the label off on a £25 gift card and it removed the code. How can I get the code for the card?

    Click here and request assistance. Gift cards are usually if not always final sale because it would be easy enough for someone dishonest to abuse returns or replacements of them.
    (58640)

  • Code Samples for SDK programming in Java

    I need a complete set of Code Samples for SDK programming in Java, like the one that is available in VB and .Net.
    For Example, if you look at the following directory of machine where SDK is installed,
    C:\ProgramFiles\SAP\SAP Business One SDK\Samples\COM DI\VB.NET
    we have following Sample programs in C Sharp, VB6, VB.Net
    01.BasicOperations
    02.MetaDataOperations
    03.UsingSBObob
    04.SerialAndBatch
    05.OrderAndInvoice
    06.ObjectsSchemas
    07.Permissions
    08.LoadFromXML
    09.BudgetEditor
    10.Messages Service
    11.Basic Company Settings
    12. Report Layout Service
    13.SaveXML
    14.ItemCycleCount
    15.ApprovalStagesAndTemplateServices
    16.Alert Management Service
    Iam looking for Samples like what is available above so that we can understand JCO better.

    Hi Sridharan,
    The only JCO samples I know of are posted in the [thread|;.
    Regards,
    Vítor Vieira

  • Hi basically when i try download a app its saying sign in required ask for sercurity code for bank card and i put the correct details in and still saying its invalid? Can anyone help

    Hi basically when i try download a app its saying sign in required ask for sercurity code for bank card and i put the correct details in and still saying its invalid? Can anyone help

    Refusal of a card is based on information provided matching what is on file from your credit card provider. If it is refused, it generally means something is not matching. That can inclue the name, the address or other information. It has to be exact to match. If you check your credit card bill to make sure you are spelling the name correctly, the address is listed correctly, and yes, ST is different than Street, and it still does not work, contact iTunes support. http://www.apple.com/emea/support/itunes/contact.html

Maybe you are looking for

  • Java (.jar) applications and games on 5530XM

    Hello I have used the search option before asking, and I have manually searched some of the sub-forums (or boards) I thought could and would be relevant to my issue, and have seen no similar questions being asked. I have also worked with my good frie

  • Web Services Reliable Messaging

    Does Oracle BPEL PM has WSRM implemented 1.As Server to expose WSRM based service ? 2.To consume other WSRM services ? If so, what other app servers the interoperability is tested ? regards, Arun

  • Next/Previous Track multimedia buttons stopped working in 2.18

    After upgrading to 2.18, when I use Banshee the keys that are mapped to next/previous track have stopped working. However, volume change and mute buttons still work. I checked the Gnome configuration (preferences -> keyboard shortcuts) and those keys

  • Planning WISM to WISM2

    Hello, I hope my english is comprehensible. I have an environment with 2 WISM (4 logical controller) and about 450 APs. Both WISMs have the same configuration. Now I want to migrate the whole thing on 2 WISM-2. I've designed the following scheme and

  • Nvidia Shield 16GB Shield TV - Haven't received promotion codes

    I placed an in store order for the Nvidia Shield 16GB Shield TV (SKU: 8526126) on 06/19/2015. It shipped on 06/22/2015, and I have yet to receive an email with the promotion codes ($30 Google Play credit). The email address is the same one used when