use of org.openecard.common.ClientEnv 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));
}
use of org.openecard.common.ClientEnv in project open-ecard by ecsec.
the class DataSetInfoWrapperTest method test.
/**
* Simple test for DataSetInfoWrapper-class. After getting the DataSetInfoWrapper for the EF.DIR data set 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);
DataSetInfoWrapper dataSetInfoWrapper = cardApplicationWrapper.getDataSetInfo("EF.DIR");
assertSame(dataSetInfoWrapper, cardApplicationWrapper.getDataSetInfo("EF.DIR"));
assertNotNull(dataSetInfoWrapper.getDataSetInfo());
assertNotNull(dataSetInfoWrapper.getSecurityCondition(NamedDataServiceActionName.DSI_READ));
}
use of org.openecard.common.ClientEnv in project open-ecard by ecsec.
the class TestClient method setup.
private void setup() throws Exception {
// Set up client environment
ClientEnv env = new ClientEnv();
// Set up the IFD
IFD ifd = new IFD();
env.setIFD(ifd);
// Set up Management
TinyManagement management = new TinyManagement(env);
env.setManagement(management);
// Set up the Dispatcher
MessageDispatcher dispatcher = new MessageDispatcher(env);
env.setDispatcher(dispatcher);
// Perform an EstablishContext to get a ContextHandle
EstablishContext establishContext = new EstablishContext();
EstablishContextResponse establishContextResponse = ifd.establishContext(establishContext);
byte[] contextHandle = ifd.establishContext(establishContext).getContextHandle();
final CardRecognitionImpl recognition = new CardRecognitionImpl(env);
env.setRecognition(recognition);
env.setCIFProvider(new CIFProvider() {
@Override
public CardInfoType getCardInfo(ConnectionHandleType type, String cardType) {
return recognition.getCardInfo(cardType);
}
@Override
public boolean needsRecognition(byte[] atr) {
return true;
}
@Override
public CardInfoType getCardInfo(String cardType) throws RuntimeException {
return recognition.getCardInfo(cardType);
}
@Override
public InputStream getCardImage(String cardType) {
return recognition.getCardImage(cardType);
}
});
// Set up EventManager
EventDispatcher ed = new EventDispatcherImpl();
env.setEventDispatcher(ed);
// Set up SALStateCallback
cardStates = new CardStateMap();
SALStateCallback salCallback = new SALStateCallback(env, cardStates);
ed.add(salCallback);
// Set up SAL
sal = new TinySAL(env, cardStates);
env.setSAL(sal);
// Set up GUI
SwingUserConsent gui = new SwingUserConsent(new SwingDialogWrapper());
sal.setGUI(gui);
ifd.setGUI(gui);
// Initialize the EventManager
ed.start();
AddonManager manager = new AddonManager(env, gui, cardStates, null);
sal.setAddonManager(manager);
HttpBinding binding = new HttpBinding(24727);
binding.setAddonManager(manager);
binding.start();
}
use of org.openecard.common.ClientEnv in project open-ecard by ecsec.
the class TinySALTest method setUp.
@BeforeMethod()
public void setUp() throws Exception {
env = new ClientEnv();
Dispatcher dispatcher = new MessageDispatcher(env);
env.setDispatcher(dispatcher);
IFD ifd = new IFD();
ifd.setEnvironment(env);
env.setIFD(ifd);
states = new CardStateMap();
EstablishContextResponse ecr = env.getIFD().establishContext(new EstablishContext());
final CardRecognitionImpl cr = new CardRecognitionImpl(env);
ListIFDs listIFDs = new ListIFDs();
contextHandle = ecr.getContextHandle();
listIFDs.setContextHandle(ecr.getContextHandle());
ListIFDsResponse listIFDsResponse = ifd.listIFDs(listIFDs);
RecognitionInfo recognitionInfo = cr.recognizeCard(contextHandle, listIFDsResponse.getIFDName().get(0), BigInteger.ZERO);
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 null;
}
};
env.setCIFProvider(cp);
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);
}
use of org.openecard.common.ClientEnv in project open-ecard by ecsec.
the class TestEventManager method test.
@Test(enabled = false)
public void test() throws InterruptedException, InitializationException {
Environment env = new ClientEnv();
MiddlewareSAL mwSAL = new MiddlewareSAL(env, null, mwConfig, cb);
env.setSAL(mwSAL);
EventDispatcher ed = new EventDispatcherImpl();
env.setEventDispatcher(ed);
mwSAL.initialize(new Initialize());
ed.start();
Thread.sleep(10000);
}
Aggregations