Search in sources :

Example 1 with IFD

use of org.openecard.ws.IFD in project open-ecard by ecsec.

the class TestTransactions method testExecute.

/**
 * Manual test to ensure the card recognition with transactions is working as expected. This test starts two
 * Threads. The first one blocks the card for 15 seconds. The second one attempts to recognize the card. This will
 * obviously fail within the 15 seconds and a MessageDialog will be displayed. After the 15 seconds the recognition
 * will succeed.
 *
 * @throws Exception
 */
// a reader with an inserted card is needed
@Test(enabled = false)
public void testExecute() throws Exception {
    // set up ifd and establish context
    Environment env = new ClientEnv();
    final IFD ifd = new org.openecard.ifd.scio.IFD();
    env.setIFD(ifd);
    EstablishContext eCtx = new EstablishContext();
    EstablishContextResponse eCtxR = ifd.establishContext(eCtx);
    final byte[] ctx = eCtxR.getContextHandle();
    // Set up GUI and card recognition
    SwingUserConsent gui = new SwingUserConsent(new SwingDialogWrapper());
    final CardRecognitionImpl recog = new CardRecognitionImpl(env);
    recog.setGUI(gui);
    // get the first reader
    ListIFDs listIFDs = new ListIFDs();
    listIFDs.setContextHandle(ctx);
    ListIFDsResponse listIFDsResponse = ifd.listIFDs(listIFDs);
    final String ifdName = listIFDsResponse.getIFDName().get(0);
    Thread t1 = new Thread(new BlockingRunnable(ctx, ifdName, ifd));
    t1.start();
    Thread t2 = new Thread(new RecognizeRunnable(ctx, ifdName, recog));
    t2.start();
    t2.join();
}
Also used : ListIFDs(iso.std.iso_iec._24727.tech.schema.ListIFDs) ListIFDsResponse(iso.std.iso_iec._24727.tech.schema.ListIFDsResponse) IFD(org.openecard.ws.IFD) EstablishContextResponse(iso.std.iso_iec._24727.tech.schema.EstablishContextResponse) ClientEnv(org.openecard.common.ClientEnv) SwingDialogWrapper(org.openecard.gui.swing.SwingDialogWrapper) SwingUserConsent(org.openecard.gui.swing.SwingUserConsent) Environment(org.openecard.common.interfaces.Environment) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) Test(org.testng.annotations.Test)

Example 2 with IFD

use of org.openecard.ws.IFD in project open-ecard by ecsec.

the class TestDispatcher method testDispatcher2.

/**
 * Test instance of TestEnv2.
 *
 * @throws Exception If the test is a failure.
 */
@Test
public void testDispatcher2() throws Exception {
    // test with inherited annotation without explicit class specification
    IFD ifd = new TestIFD();
    Environment env = new TestEnv2();
    MessageDispatcher disp = new MessageDispatcher(env);
    env.setIFD(ifd);
    Object req = new EstablishContext();
    Object res = disp.deliver(req);
    assertTrue(res instanceof EstablishContextResponse);
}
Also used : IFD(org.openecard.ws.IFD) Environment(org.openecard.common.interfaces.Environment) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) EstablishContextResponse(iso.std.iso_iec._24727.tech.schema.EstablishContextResponse) Test(org.testng.annotations.Test)

Example 3 with IFD

use of org.openecard.ws.IFD in project open-ecard by ecsec.

the class TestDispatcher method testDispatcher1.

/**
 * Test instance of TestEnv1.
 *
 * @throws Exception If the test is a failure.
 */
@Test
public void testDispatcher1() throws Exception {
    // test with direct annotation with explicit class specification
    IFD ifd = new TestIFD();
    Environment env = new TestEnv1();
    MessageDispatcher disp = new MessageDispatcher(env);
    env.setIFD(ifd);
    Object req = new EstablishContext();
    Object res = disp.deliver(req);
    assertTrue(res instanceof EstablishContextResponse);
}
Also used : IFD(org.openecard.ws.IFD) Environment(org.openecard.common.interfaces.Environment) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) EstablishContextResponse(iso.std.iso_iec._24727.tech.schema.EstablishContextResponse) Test(org.testng.annotations.Test)

Example 4 with IFD

use of org.openecard.ws.IFD in project open-ecard by ecsec.

the class ExecuteRecognition method testExecute.

@Test(enabled = false)
public void testExecute() throws Exception {
    Environment env = new ClientEnv();
    IFD ifd = new org.openecard.ifd.scio.IFD();
    env.setIFD(ifd);
    byte[] ctx;
    // establish context
    EstablishContext eCtx = new EstablishContext();
    EstablishContextResponse eCtxR = ifd.establishContext(eCtx);
    ctx = eCtxR.getContextHandle();
    // get status to see if we can execute the recognition
    GetStatus status = new GetStatus();
    status.setContextHandle(ctx);
    GetStatusResponse statusR = ifd.getStatus(status);
    if (statusR.getIFDStatus().size() > 0 && statusR.getIFDStatus().get(0).getSlotStatus().get(0).isCardAvailable()) {
        CardRecognitionImpl recog = new CardRecognitionImpl(env);
        IFDStatusType stat = statusR.getIFDStatus().get(0);
        RecognitionInfo info = recog.recognizeCard(ctx, stat.getIFDName(), BigInteger.ZERO);
        if (info == null) {
            System.out.println("Card not recognized.");
        } else {
            System.out.println(info.getCardType());
        }
    }
}
Also used : GetStatusResponse(iso.std.iso_iec._24727.tech.schema.GetStatusResponse) IFD(org.openecard.ws.IFD) EstablishContextResponse(iso.std.iso_iec._24727.tech.schema.EstablishContextResponse) ClientEnv(org.openecard.common.ClientEnv) RecognitionInfo(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo) Environment(org.openecard.common.interfaces.Environment) IFDStatusType(iso.std.iso_iec._24727.tech.schema.IFDStatusType) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) GetStatus(iso.std.iso_iec._24727.tech.schema.GetStatus) Test(org.testng.annotations.Test)

Aggregations

EstablishContext (iso.std.iso_iec._24727.tech.schema.EstablishContext)4 EstablishContextResponse (iso.std.iso_iec._24727.tech.schema.EstablishContextResponse)4 Environment (org.openecard.common.interfaces.Environment)4 IFD (org.openecard.ws.IFD)4 Test (org.testng.annotations.Test)4 ClientEnv (org.openecard.common.ClientEnv)2 RecognitionInfo (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo)1 GetStatus (iso.std.iso_iec._24727.tech.schema.GetStatus)1 GetStatusResponse (iso.std.iso_iec._24727.tech.schema.GetStatusResponse)1 IFDStatusType (iso.std.iso_iec._24727.tech.schema.IFDStatusType)1 ListIFDs (iso.std.iso_iec._24727.tech.schema.ListIFDs)1 ListIFDsResponse (iso.std.iso_iec._24727.tech.schema.ListIFDsResponse)1 SwingDialogWrapper (org.openecard.gui.swing.SwingDialogWrapper)1 SwingUserConsent (org.openecard.gui.swing.SwingUserConsent)1