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);
}
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();
}
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);
}
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));
}
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));
}
Aggregations