use of iso.std.iso_iec._24727.tech.schema.EstablishContext 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 iso.std.iso_iec._24727.tech.schema.EstablishContext 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 iso.std.iso_iec._24727.tech.schema.EstablishContext 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 iso.std.iso_iec._24727.tech.schema.EstablishContext in project open-ecard by ecsec.
the class AndroidMarshallerTest method testConversionOfDisconnect.
@Test
public void testConversionOfDisconnect() throws Exception {
WSMarshaller m = new AndroidMarshaller();
Object o = m.unmarshal(m.str2doc(DISCONNECT));
if (!(o instanceof Disconnect)) {
throw new Exception("Object should be an instace of EstablishContext");
}
Disconnect d = (Disconnect) o;
assertEquals(d.getSlotHandle(), StringUtils.toByteArray("1D8EFC10F063FB6FE8A3BBF8D2E0CA5C"));
assertEquals(d.getAction(), ActionType.EJECT);
}
use of iso.std.iso_iec._24727.tech.schema.EstablishContext 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);
}
Aggregations