use of org.openecard.gui.swing.SwingUserConsent 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.gui.swing.SwingUserConsent 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.gui.swing.SwingUserConsent in project open-ecard by ecsec.
the class TestGui method testPinEntry.
@Test
public void testPinEntry() throws Exception {
SwingDialogWrapper wrapper = new SwingDialogWrapper();
SwingUserConsent uc = new SwingUserConsent(wrapper);
new Expectations() {
{
token.containsFlag(Flag.CKF_USER_PIN_INITIALIZED);
result = true;
session.login(UserType.User, null);
}
};
PinEntryDialog d = new PinEntryDialog(uc, false, marker, session);
d.show();
}
use of org.openecard.gui.swing.SwingUserConsent in project open-ecard by ecsec.
the class TestGui method testPinBlocked.
@Test
public void testPinBlocked() throws Exception {
SwingDialogWrapper wrapper = new SwingDialogWrapper();
SwingUserConsent uc = new SwingUserConsent(wrapper);
new Expectations() {
{
token.containsFlag(Flag.CKF_USER_PIN_INITIALIZED);
result = true;
token.containsFlag(Flag.CKF_USER_PIN_LOCKED);
result = true;
session.login(UserType.User, null);
}
};
PinEntryDialog d = new PinEntryDialog(uc, false, marker, session);
d.show();
}
use of org.openecard.gui.swing.SwingUserConsent in project open-ecard by ecsec.
the class TestGui method testPinEntryFailedFinalTry.
@Test
public void testPinEntryFailedFinalTry() throws Exception {
SwingDialogWrapper wrapper = new SwingDialogWrapper();
SwingUserConsent uc = new SwingUserConsent(wrapper);
new Expectations() {
{
token.containsFlag(Flag.CKF_USER_PIN_INITIALIZED);
result = true;
token.containsFlag(Flag.CKF_USER_PIN_COUNT_LOW);
returns(true, false);
token.containsFlag(Flag.CKF_USER_PIN_FINAL_TRY);
result = true;
session.login(UserType.User, null);
result = new PinIncorrectException("PIN entry failed.", 0);
result = null;
}
};
PinEntryDialog d = new PinEntryDialog(uc, false, marker, session);
d.show();
}
Aggregations