use of org.openecard.common.interfaces.Dispatcher 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.interfaces.Dispatcher in project open-ecard by ecsec.
the class CHATStepAction method perform.
@Override
public StepActionResult perform(Map<String, ExecutionResults> oldResults, StepResult result) {
if (result.isOK()) {
processResult(oldResults);
DynamicContext ctx = DynamicContext.getInstance(TR03112Keys.INSTANCE_KEY);
boolean nativePace = (boolean) ctx.get(EACProtocol.IS_NATIVE_PACE);
PACEMarkerType paceMarker = (PACEMarkerType) ctx.get(EACProtocol.PACE_MARKER);
EacPinStatus status = (EacPinStatus) ctx.get(EACProtocol.PIN_STATUS);
byte[] slotHandle = (byte[]) ctx.get(EACProtocol.SLOT_HANDLE);
Dispatcher dispatcher = (Dispatcher) ctx.get(EACProtocol.DISPATCHER);
Step pinStep;
assert (status != null);
switch(status) {
case BLOCKED:
ctx.put(EACProtocol.PIN_BLOCKED_STATUS, status);
pinStep = new ErrorStep(LANG.translationForKey("step_error_title_blocked", PIN), LANG.translationForKey("step_error_pin_blocked", PIN, PIN, PUK, PIN), WSHelper.createException(WSHelper.makeResultError(ECardConstants.Minor.IFD.PASSWORD_BLOCKED, "Password blocked.")));
break;
case DEACTIVATED:
ctx.put(EACProtocol.PIN_BLOCKED_STATUS, status);
pinStep = new ErrorStep(LANG.translationForKey("step_error_title_deactivated"), LANG.translationForKey("step_error_pin_deactivated"), WSHelper.createException(WSHelper.makeResultError(ECardConstants.Minor.IFD.PASSWORD_SUSPENDED, "Card deactivated.")));
break;
default:
pinStep = new PINStep(eacData, !nativePace, paceMarker, status);
pinStep.setBackgroundTask(bTask);
StepAction pinAction = new PINStepAction(eacData, !nativePace, slotHandle, dispatcher, (PINStep) pinStep, status);
pinStep.setAction(pinAction);
}
return new StepActionResult(StepActionResultStatus.NEXT, pinStep);
} else {
// cancel can not happen, so only back is left to be handled
return new StepActionResult(StepActionResultStatus.BACK);
}
}
use of org.openecard.common.interfaces.Dispatcher 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.interfaces.Dispatcher 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);
}
Aggregations