package com.silentmission.ewallet.cardservices; import opencard.core.service.CardType; import opencard.core.service.CardServiceScheduler; import opencard.core.terminal.CardID; import opencard.core.util.HexString; import opencard.core.service.CardServiceFactory; import java.util.Enumeration; import java.util.Vector; import com.silentmission.ewallet.cardservices.TestWalletCardService; public class TestWalletCardServiceFactory extends CardServiceFactory { Vector services = null; static byte[] atr = HexString.parseHexString("3BEE00008131FE45003180718665016702A00A8390001B"); /** * DemoCardServiceFactory constructor comment. */ public TestWalletCardServiceFactory() { super(); } /** Indicate whether this CardServiceFactory "knows" the smart card OS * and/or installed card applications * and might be able to instantiate CardServices for it. *

* This method replaces the former knows() method. * Note: OCF 1.1 style card service factories should instead derive from * opencard.opt.service.OCF11CardServiceFactory which still * offers the knows() and cardServiceClasses() methods. *

* Should return a CardType that contains enough information to answer * the getClassFor() method. *

* The factory can inspect the card (communicate with the card) using * the provided CardServiceScheduler if the CardID information is insufficient * to classify the card. * * * @param cid * A CardID received from a Slot. * @param scheduler * A CardServiceScheduler that can be used to communicate with * the card to determine its type. * * @return A valid CardType if the factory can instantiate services for this * card. * CardType.UNSUPPORTED if the factory does not know the card. * * @see #getClasses * */ protected opencard.core.service.CardType getCardType(opencard.core.terminal.CardID cid, opencard.core.service.CardServiceScheduler scheduler) throws opencard.core.terminal.CardTerminalException { // return anything for now System.out.println("ATR:: "); byte[] tempATR = cid.getATR(); //for(int i=0; i < atr.length; i++) //{ //if (atr[i] != tempATR[i]) return CardType.UNSUPPORTED; //} String atrString = new String(tempATR); JCOPAppletLoadingService.setIsTestCard(atrString.indexOf("JCOP") > 0); System.out.println(HexString.dump(cid.getATR())); return new CardType(42); } /** * This method was created in VisualAge. * @return Enumeration * @param type CardType */ protected Enumeration getClasses(CardType type) { if (services == null) { services = new Vector(); services.addElement(JCOPAppletLoadingService.class); services.addElement(TestWalletCardService.class); //services.addElement(RDSDemoService.class); } return services.elements(); } }