Java源码示例:javacard.framework.AID

示例1
/**
 * Attempt to connect to the backend service
 */
private void connectService() {
    NdefService service = null;
    // get AID object for service
    AID aid = JCSystem.lookupAID(serviceAID, (short)0, (byte)serviceAID.length);
    if(aid != null) {
        // get service object
        Shareable share = JCSystem.getAppletShareableInterfaceObject(aid, serviceID);
        // cast the service object
        if(share instanceof NdefService) {
            service = (NdefService)share;
        }
    }
    // check that we got a valid object
    if(service == null) {
        ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
    }
    // retrieve the data array
    byte[] data = service.getData();
    if(data == null) {
        ISOException.throwIt(ISO7816.SW_CONDITIONS_NOT_SATISFIED);
    }
    // remember both references
    refs[REF_SERVICE] = service;
    refs[REF_DATA] = data;
}
 
示例2
private CardChannel ConnectJCardSimLocalSimulator(Class appletClass) throws Exception {
    System.setProperty("com.licel.jcardsim.terminal.type", "2");
    CAD cad = new CAD(System.getProperties());
    JavaxSmartCardInterface simulator = (JavaxSmartCardInterface) cad.getCardInterface();
    byte[] installData = new byte[0];
    AID appletAID = new AID(m_APPLET_AID, (short) 0, (byte) m_APPLET_AID.length);

    AID appletAIDRes = simulator.installApplet(appletAID, appletClass, installData, (short) 0, (byte) installData.length);
    simulator.selectApplet(appletAID);

    return new SimulatedCardChannelLocal(simulator);
}
 
示例3
private CardChannel ConnectJCardSimLocalSimulator(Class appletClass) throws Exception {
System.out.print("Setting up Javacard simulator...");
//CardSimulator simulator = new CardSimulator();
System.setProperty("com.licel.jcardsim.terminal.type", "2");
      CAD cad = new CAD(System.getProperties());
      JavaxSmartCardInterface simulator = (JavaxSmartCardInterface) cad.getCardInterface();	
byte[] installData = new byte[0];
AID appletAID = new AID(m_APPLET_AID, (short) 0, (byte) m_APPLET_AID.length);
AID appletAIDRes = simulator.installApplet(appletAID, appletClass, installData, (short) 0, (byte) installData.length);
simulator.selectApplet(appletAID);		
      return new SimulatedCardChannelLocal(simulator);
  }
 
示例4
private static void openSimulatorChannel() throws Exception {
  simulator = new CardSimulator();

  // Install KeycardApplet
  AID aid = AIDUtil.create(Identifiers.KEYCARD_AID);
  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  bos.write(Identifiers.getKeycardInstanceAID().length);
  bos.write(Identifiers.getKeycardInstanceAID());

  simulator.installApplet(aid, KeycardApplet.class, bos.toByteArray(), (short) 0, (byte) bos.size());
  bos.reset();

  // Install NDEFApplet
  aid = AIDUtil.create(Identifiers.NDEF_AID);
  bos.write(Identifiers.NDEF_INSTANCE_AID.length);
  bos.write(Identifiers.NDEF_INSTANCE_AID);
  bos.write(new byte[] {0x01, 0x00, 0x02, (byte) 0xC9, 0x00});

  simulator.installApplet(aid, NDEFApplet.class, bos.toByteArray(), (short) 0, (byte) bos.size());
  bos.reset();

  // Install CashApplet
  aid = AIDUtil.create(Identifiers.CASH_AID);
  bos.write(Identifiers.CASH_INSTANCE_AID.length);
  bos.write(Identifiers.CASH_INSTANCE_AID);
  bos.write(new byte[] {0x01, 0x00, 0x02, (byte) 0xC9, 0x00});

  simulator.installApplet(aid, CashApplet.class, bos.toByteArray(), (short) 0, (byte) bos.size());
  bos.reset();

  cardTerminal = CardTerminalSimulator.terminal(simulator);

  openPCSCChannel();
}
 
示例5
@Before
public void setUp() throws Exception {
    // 1. Create simulator
    byte[] TEST_APPLET_AID_BYTES = new byte[] {(byte) 0xA0,0x00,0x00,0x03,(byte) 0x97,0x42,0x54,0x46,0x59};
    AID TEST_APPLET_AID = new AID(TEST_APPLET_AID_BYTES, (short)0, (byte) TEST_APPLET_AID_BYTES.length);



    simulator = new JavaxSmartCardInterface ();

    // 2. Install applet
    simulator.installApplet(TEST_APPLET_AID, GidsApplet.class);
    simulator.selectApplet(TEST_APPLET_AID);
    // 3. Select applet
}
 
示例6
public boolean prepareLocalSimulatorApplet(byte[] appletAIDArray, byte[] installData, Class<? extends Applet> appletClass) {
    simulator = new JavaxSmartCardInterface();
    AID appletAID = new AID(appletAIDArray, (short) 0, (byte) appletAIDArray.length);

    simulator.installApplet(appletAID, appletClass, installData, (short) 0, (byte) installData.length);
    return simulator.selectApplet(appletAID);
}