Search in sources :

Example 1 with Dispatcher

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);
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) SALStateCallback(org.openecard.common.sal.state.SALStateCallback) TinySAL(org.openecard.sal.TinySAL) ListIFDs(iso.std.iso_iec._24727.tech.schema.ListIFDs) ListIFDsResponse(iso.std.iso_iec._24727.tech.schema.ListIFDsResponse) ConnectResponse(iso.std.iso_iec._24727.tech.schema.ConnectResponse) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) IFD(org.openecard.ifd.scio.IFD) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) Connect(iso.std.iso_iec._24727.tech.schema.Connect) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) Dispatcher(org.openecard.common.interfaces.Dispatcher) MessageDispatcher(org.openecard.transport.dispatcher.MessageDispatcher) EstablishContextResponse(iso.std.iso_iec._24727.tech.schema.EstablishContextResponse) ClientEnv(org.openecard.common.ClientEnv) CIFProvider(org.openecard.common.interfaces.CIFProvider) MessageDispatcher(org.openecard.transport.dispatcher.MessageDispatcher) RecognitionInfo(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo) CardStateMap(org.openecard.common.sal.state.CardStateMap) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) IfdEventObject(org.openecard.common.event.IfdEventObject) AddonManager(org.openecard.addon.AddonManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with Dispatcher

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);
    }
}
Also used : PACEMarkerType(org.openecard.sal.protocol.eac.anytype.PACEMarkerType) StepAction(org.openecard.gui.executor.StepAction) Step(org.openecard.gui.definition.Step) Dispatcher(org.openecard.common.interfaces.Dispatcher) StepActionResult(org.openecard.gui.executor.StepActionResult) DynamicContext(org.openecard.common.DynamicContext)

Example 3 with Dispatcher

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);
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) SALStateCallback(org.openecard.common.sal.state.SALStateCallback) TinySAL(org.openecard.sal.TinySAL) ListIFDs(iso.std.iso_iec._24727.tech.schema.ListIFDs) ListIFDsResponse(iso.std.iso_iec._24727.tech.schema.ListIFDsResponse) IFD(org.openecard.ifd.scio.IFD) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) Dispatcher(org.openecard.common.interfaces.Dispatcher) MessageDispatcher(org.openecard.transport.dispatcher.MessageDispatcher) EstablishContextResponse(iso.std.iso_iec._24727.tech.schema.EstablishContextResponse) SwingUserConsent(org.openecard.gui.swing.SwingUserConsent) UserConsent(org.openecard.gui.UserConsent) ClientEnv(org.openecard.common.ClientEnv) CIFProvider(org.openecard.common.interfaces.CIFProvider) MessageDispatcher(org.openecard.transport.dispatcher.MessageDispatcher) SwingDialogWrapper(org.openecard.gui.swing.SwingDialogWrapper) RecognitionInfo(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo) SwingUserConsent(org.openecard.gui.swing.SwingUserConsent) BigInteger(java.math.BigInteger) CardStateMap(org.openecard.common.sal.state.CardStateMap) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) IfdEventObject(org.openecard.common.event.IfdEventObject) AddonManager(org.openecard.addon.AddonManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with Dispatcher

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);
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) SALStateCallback(org.openecard.common.sal.state.SALStateCallback) ListIFDs(iso.std.iso_iec._24727.tech.schema.ListIFDs) ListIFDsResponse(iso.std.iso_iec._24727.tech.schema.ListIFDsResponse) IFD(org.openecard.ifd.scio.IFD) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) Dispatcher(org.openecard.common.interfaces.Dispatcher) MessageDispatcher(org.openecard.transport.dispatcher.MessageDispatcher) EstablishContextResponse(iso.std.iso_iec._24727.tech.schema.EstablishContextResponse) ClientEnv(org.openecard.common.ClientEnv) CIFProvider(org.openecard.common.interfaces.CIFProvider) MessageDispatcher(org.openecard.transport.dispatcher.MessageDispatcher) RecognitionInfo(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo) BigInteger(java.math.BigInteger) CardStateMap(org.openecard.common.sal.state.CardStateMap) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) IfdEventObject(org.openecard.common.event.IfdEventObject) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Dispatcher (org.openecard.common.interfaces.Dispatcher)4 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)3 RecognitionInfo (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo)3 EstablishContext (iso.std.iso_iec._24727.tech.schema.EstablishContext)3 EstablishContextResponse (iso.std.iso_iec._24727.tech.schema.EstablishContextResponse)3 ListIFDs (iso.std.iso_iec._24727.tech.schema.ListIFDs)3 ListIFDsResponse (iso.std.iso_iec._24727.tech.schema.ListIFDsResponse)3 ClientEnv (org.openecard.common.ClientEnv)3 IfdEventObject (org.openecard.common.event.IfdEventObject)3 CIFProvider (org.openecard.common.interfaces.CIFProvider)3 CardStateMap (org.openecard.common.sal.state.CardStateMap)3 SALStateCallback (org.openecard.common.sal.state.SALStateCallback)3 IFD (org.openecard.ifd.scio.IFD)3 CardRecognitionImpl (org.openecard.recognition.CardRecognitionImpl)3 MessageDispatcher (org.openecard.transport.dispatcher.MessageDispatcher)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 BigInteger (java.math.BigInteger)2 AddonManager (org.openecard.addon.AddonManager)2 TinySAL (org.openecard.sal.TinySAL)2 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)1