use of org.openecard.common.ClientEnv 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.ClientEnv 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.ClientEnv in project open-ecard by ecsec.
the class PINCompareProtocolTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
env = new ClientEnv();
Dispatcher d = new MessageDispatcher(env);
env.setDispatcher(d);
IFD ifd = new IFD();
ifd.setGUI(uc);
env.setIFD(ifd);
states = new CardStateMap();
EstablishContextResponse ecr = env.getIFD().establishContext(new EstablishContext());
final CardRecognitionImpl cr = new CardRecognitionImpl(env);
ListIFDs listIFDs = new ListIFDs();
CIFProvider cp = new CIFProvider() {
@Override
public CardInfoType getCardInfo(ConnectionHandleType type, String cardType) {
return cr.getCardInfo(cardType);
}
@Override
public boolean needsRecognition(byte[] atr) {
return true;
}
@Override
public CardInfoType getCardInfo(String cardType) throws RuntimeException {
return cr.getCardInfo(cardType);
}
@Override
public InputStream getCardImage(String cardType) {
return cr.getCardImage(cardType);
}
};
env.setCIFProvider(cp);
listIFDs.setContextHandle(ecr.getContextHandle());
ListIFDsResponse listIFDsResponse = ifd.listIFDs(listIFDs);
RecognitionInfo recognitionInfo = cr.recognizeCard(ecr.getContextHandle(), listIFDsResponse.getIFDName().get(0), BigInteger.ZERO);
SALStateCallback salCallback = new SALStateCallback(env, states);
Connect c = new Connect();
c.setContextHandle(ecr.getContextHandle());
c.setIFDName(listIFDsResponse.getIFDName().get(0));
c.setSlot(BigInteger.ZERO);
ConnectResponse connectResponse = env.getIFD().connect(c);
ConnectionHandleType connectionHandleType = new ConnectionHandleType();
connectionHandleType.setContextHandle(ecr.getContextHandle());
connectionHandleType.setRecognitionInfo(recognitionInfo);
connectionHandleType.setIFDName(listIFDsResponse.getIFDName().get(0));
connectionHandleType.setSlotIndex(BigInteger.ZERO);
connectionHandleType.setSlotHandle(connectResponse.getSlotHandle());
salCallback.signalEvent(EventType.CARD_RECOGNIZED, new IfdEventObject(connectionHandleType));
instance = new TinySAL(env, states);
// init AddonManager
AddonManager manager = new AddonManager(env, uc, states, null);
instance.setAddonManager(manager);
}
use of org.openecard.common.ClientEnv in project open-ecard by ecsec.
the class GenericCryptographyProtocolTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
env = new ClientEnv();
Dispatcher d = new MessageDispatcher(env);
env.setDispatcher(d);
ifd = new IFD();
ifd.setGUI(new SwingUserConsent(new SwingDialogWrapper()));
env.setIFD(ifd);
states = new CardStateMap();
EstablishContextResponse ecr = env.getIFD().establishContext(new EstablishContext());
final CardRecognitionImpl cr = new CardRecognitionImpl(env);
ListIFDs listIFDs = new ListIFDs();
CIFProvider cp = new CIFProvider() {
@Override
public CardInfoType getCardInfo(ConnectionHandleType type, String cardType) {
return cr.getCardInfo(cardType);
}
@Override
public boolean needsRecognition(byte[] atr) {
return true;
}
@Override
public CardInfoType getCardInfo(String cardType) throws RuntimeException {
return cr.getCardInfo(cardType);
}
@Override
public InputStream getCardImage(String cardType) {
return cr.getCardImage(cardType);
}
};
env.setCIFProvider(cp);
listIFDs.setContextHandle(ecr.getContextHandle());
ListIFDsResponse listIFDsResponse = ifd.listIFDs(listIFDs);
RecognitionInfo recognitionInfo = cr.recognizeCard(ecr.getContextHandle(), listIFDsResponse.getIFDName().get(0), BigInteger.ZERO);
SALStateCallback salCallback = new SALStateCallback(env, states);
ConnectionHandleType connectionHandleType = new ConnectionHandleType();
connectionHandleType.setContextHandle(ecr.getContextHandle());
connectionHandleType.setRecognitionInfo(recognitionInfo);
connectionHandleType.setIFDName(listIFDsResponse.getIFDName().get(0));
connectionHandleType.setSlotIndex(new BigInteger("0"));
salCallback.signalEvent(EventType.CARD_RECOGNIZED, new IfdEventObject(connectionHandleType));
instance = new TinySAL(env, states);
env.setSAL(instance);
// init AddonManager
UserConsent uc = new SwingUserConsent(new SwingDialogWrapper());
AddonManager manager = new AddonManager(env, uc, states, null);
instance.setAddonManager(manager);
}
use of org.openecard.common.ClientEnv 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));
}
Aggregations