Search in sources :

Example 1 with Environment

use of org.openecard.common.interfaces.Environment in project open-ecard by ecsec.

the class ManagerTest method runManager.

@Test(enabled = false)
public void runManager() throws InterruptedException, IFDException {
    IFD ifd = new IFD();
    EstablishContext ctx = new EstablishContext();
    EstablishContextResponse ctxR = ifd.establishContext(ctx);
    Environment env = new ClientEnv();
    env.setIFD(ifd);
    IfdEventManager evt = new IfdEventManager(env, new ChannelManager(), ctxR.getContextHandle());
    evt.initialize();
    Thread.sleep(1000);
    // evt.terminate();
    Thread.sleep(1000000);
}
Also used : ClientEnv(org.openecard.common.ClientEnv) ChannelManager(org.openecard.ifd.scio.wrapper.ChannelManager) IFD(org.openecard.ifd.scio.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 2 with Environment

use of org.openecard.common.interfaces.Environment 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 3 with Environment

use of org.openecard.common.interfaces.Environment 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 4 with Environment

use of org.openecard.common.interfaces.Environment in project open-ecard by ecsec.

the class CardApplicationWrapperTest method test.

/**
 * Simple test for CardApplicationWrapper-class. After getting the CardApplicationWrapper for the root application
 * we check if the get-methods return the expected values.
 *
 * @throws Exception when something in this test went unexpectedly wrong
 */
@Test
public void test() throws Exception {
    new Expectations() {

        {
            cifp.getCardInfo(anyString);
            result = null;
        }
    };
    Environment env = new ClientEnv();
    env.setCIFProvider(cifp);
    CardRecognitionImpl recognition = new CardRecognitionImpl(env);
    CardInfoType cardInfo = recognition.getCardInfo("http://bsi.bund.de/cif/npa.xml");
    CardInfoWrapper cardInfoWrapper = new CardInfoWrapper(cardInfo, null);
    CardApplicationWrapper cardAppWrapper = cardInfoWrapper.getCardApplication(rootApplication);
    assertEquals(cardAppWrapper.getApplicationIdentifier(), rootApplication);
    assertEquals(cardAppWrapper.getDataSetNameList().getDataSetName().size(), 5);
    assertEquals(cardAppWrapper.getDIDInfoList().size(), 9);
    assertEquals(cardAppWrapper.getCardApplicationACL().getAccessRule().size(), 40);
    assertNotNull(cardAppWrapper.getSecurityCondition(CardApplicationServiceActionName.CARD_APPLICATION_LIST));
}
Also used : Expectations(mockit.Expectations) ClientEnv(org.openecard.common.ClientEnv) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) Environment(org.openecard.common.interfaces.Environment) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) Test(org.testng.annotations.Test)

Example 5 with Environment

use of org.openecard.common.interfaces.Environment in project open-ecard by ecsec.

the class DIDInfoWrapperTest method test.

/**
 * Simple test for DIDInfoWrapper-class. After getting the DIDInfoWrapper for the CAN DID in the
 * root applicaton of the npa we check if the get-methods return the expected values.
 *
 * @throws Exception when something in this test went unexpectedly wrong
 */
@Test
public void test() throws Exception {
    new Expectations() {

        {
            cifp.getCardInfo(anyString);
            result = null;
        }
    };
    Environment env = new ClientEnv();
    env.setCIFProvider(cifp);
    CardRecognitionImpl recognition = new CardRecognitionImpl(env);
    CardInfoType cardInfo = recognition.getCardInfo("http://bsi.bund.de/cif/npa.xml");
    CardInfoWrapper cardInfoWrapper = new CardInfoWrapper(cardInfo, null);
    CardApplicationWrapper cardApplicationWrapper = cardInfoWrapper.getCardApplication(rootApplication);
    DIDInfoWrapper didInfoWrapper = cardApplicationWrapper.getDIDInfo("CAN");
    assertSame(didInfoWrapper, cardApplicationWrapper.getDIDInfo("CAN"));
    assertNotNull(didInfoWrapper.getDIDInfo());
    assertNotNull(didInfoWrapper.getSecurityCondition(DifferentialIdentityServiceActionName.DID_GET));
}
Also used : Expectations(mockit.Expectations) ClientEnv(org.openecard.common.ClientEnv) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) Environment(org.openecard.common.interfaces.Environment) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) Test(org.testng.annotations.Test)

Aggregations

Environment (org.openecard.common.interfaces.Environment)10 Test (org.testng.annotations.Test)10 ClientEnv (org.openecard.common.ClientEnv)8 EstablishContext (iso.std.iso_iec._24727.tech.schema.EstablishContext)5 EstablishContextResponse (iso.std.iso_iec._24727.tech.schema.EstablishContextResponse)5 CardInfoType (iso.std.iso_iec._24727.tech.schema.CardInfoType)4 Expectations (mockit.Expectations)4 CardRecognitionImpl (org.openecard.recognition.CardRecognitionImpl)4 IFD (org.openecard.ws.IFD)4 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 Initialize (iso.std.iso_iec._24727.tech.schema.Initialize)1 ListIFDs (iso.std.iso_iec._24727.tech.schema.ListIFDs)1 ListIFDsResponse (iso.std.iso_iec._24727.tech.schema.ListIFDsResponse)1 EventDispatcherImpl (org.openecard.common.event.EventDispatcherImpl)1 EventDispatcher (org.openecard.common.interfaces.EventDispatcher)1 SwingDialogWrapper (org.openecard.gui.swing.SwingDialogWrapper)1 SwingUserConsent (org.openecard.gui.swing.SwingUserConsent)1