Search in sources :

Example 1 with Initialize

use of iso.std.iso_iec._24727.tech.schema.Initialize in project open-ecard by ecsec.

the class SelectorSAL method initialize.

@Override
public InitializeResponse initialize(Initialize init) {
    InitializeResponse response = WSHelper.makeResponse(InitializeResponse.class, WSHelper.makeResultOK());
    // only initialize one time
    if (initializedSals.isEmpty()) {
        LinkedList<SAL> sals = new LinkedList<>();
        sals.add(main);
        sals.addAll(special);
        for (SAL next : sals) {
            try {
                InitializeResponse res = next.initialize(init);
                WSHelper.checkResult(res);
                if (!WSHelper.resultsInWarn(res)) {
                    if (next instanceof SpecializedSAL) {
                        initializedSpecializedSals.add((SpecializedSAL) next);
                    } else {
                        initializedSals.add(next);
                    }
                }
            } catch (WSHelper.WSException ex) {
                String msg = "One of the SAL instances failed to initialize:\n" + ex.getMessage();
                terminate(new Terminate());
                response.setResult(WSHelper.makeResultError(ECardConstants.Minor.Disp.COMM_ERROR, msg));
                return response;
            }
        }
    }
    return response;
}
Also used : WSHelper(org.openecard.common.WSHelper) InitializeResponse(iso.std.iso_iec._24727.tech.schema.InitializeResponse) Terminate(iso.std.iso_iec._24727.tech.schema.Terminate) LinkedList(java.util.LinkedList) SAL(org.openecard.ws.SAL) SpecializedSAL(org.openecard.common.sal.SpecializedSAL) SpecializedSAL(org.openecard.common.sal.SpecializedSAL)

Example 2 with Initialize

use of iso.std.iso_iec._24727.tech.schema.Initialize in project open-ecard by ecsec.

the class TinySALTest method testInitialize.

/**
 * Test of initialize method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testInitialize() {
    System.out.println("initialize");
    Initialize parameters = new Initialize();
    InitializeResponse result = instance.initialize(parameters);
    assertEquals(ECardConstants.Major.ERROR, result.getResult().getResultMajor());
}
Also used : InitializeResponse(iso.std.iso_iec._24727.tech.schema.InitializeResponse) Initialize(iso.std.iso_iec._24727.tech.schema.Initialize) Test(org.testng.annotations.Test)

Example 3 with Initialize

use of iso.std.iso_iec._24727.tech.schema.Initialize 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();
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) SALStateCallback(org.openecard.common.sal.state.SALStateCallback) TinySAL(org.openecard.sal.TinySAL) EventDispatcherImpl(org.openecard.common.event.EventDispatcherImpl) IFD(org.openecard.ifd.scio.IFD) InputStream(java.io.InputStream) CardRecognitionImpl(org.openecard.recognition.CardRecognitionImpl) 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) SwingDialogWrapper(org.openecard.gui.swing.SwingDialogWrapper) CardInfoType(iso.std.iso_iec._24727.tech.schema.CardInfoType) EventDispatcher(org.openecard.common.interfaces.EventDispatcher) SwingUserConsent(org.openecard.gui.swing.SwingUserConsent) TinyManagement(org.openecard.management.TinyManagement) CardStateMap(org.openecard.common.sal.state.CardStateMap) EstablishContext(iso.std.iso_iec._24727.tech.schema.EstablishContext) AddonManager(org.openecard.addon.AddonManager)

Example 4 with Initialize

use of iso.std.iso_iec._24727.tech.schema.Initialize 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);
}
Also used : ClientEnv(org.openecard.common.ClientEnv) EventDispatcherImpl(org.openecard.common.event.EventDispatcherImpl) EventDispatcher(org.openecard.common.interfaces.EventDispatcher) Environment(org.openecard.common.interfaces.Environment) Initialize(iso.std.iso_iec._24727.tech.schema.Initialize) Test(org.testng.annotations.Test)

Example 5 with Initialize

use of iso.std.iso_iec._24727.tech.schema.Initialize in project open-ecard by ecsec.

the class MiddlewareSAL method initialize.

@Override
public InitializeResponse initialize(Initialize parameters) {
    InitializeResponse resp = WSHelper.makeResponse(InitializeResponse.class, WSHelper.makeResultOK());
    try {
        mwModule.initialize();
        eventMan.initialize();
        if (gui == null) {
            throw new InternalAppError("GUI is not initialized.");
        }
    } catch (UnsatisfiedLinkError | InitializationException ex) {
        String mwSALName = mwSALConfig.getMiddlewareName();
        String msg = String.format("Failed to initialize Middleware for '%s'-SAL.", mwSALName);
        if (mwSALConfig.isSALRequired()) {
            LOG.error(msg, ex);
            resp.setResult(WSHelper.makeResultError(ECardConstants.Minor.Disp.COMM_ERROR, msg));
        } else {
            LOG.warn(msg, ex);
            resp.setResult(WSHelper.makeResult(ECardConstants.Major.WARN, ECardConstants.Minor.App.NOT_INITIALIZED, msg));
        }
    } catch (InternalAppError ex) {
        LOG.error(ex.getMessage());
        resp.setResult(ex.getResult());
    }
    return resp;
}
Also used : InitializeResponse(iso.std.iso_iec._24727.tech.schema.InitializeResponse) InitializationException(org.openecard.mdlw.sal.exceptions.InitializationException) InternalAppError(org.openecard.common.sal.exception.InternalAppError)

Aggregations

Initialize (iso.std.iso_iec._24727.tech.schema.Initialize)4 ClientEnv (org.openecard.common.ClientEnv)4 EventDispatcherImpl (org.openecard.common.event.EventDispatcherImpl)4 EstablishContext (iso.std.iso_iec._24727.tech.schema.EstablishContext)3 EstablishContextResponse (iso.std.iso_iec._24727.tech.schema.EstablishContextResponse)3 InitializeResponse (iso.std.iso_iec._24727.tech.schema.InitializeResponse)3 AddonManager (org.openecard.addon.AddonManager)3 WSHelper (org.openecard.common.WSHelper)3 CardStateMap (org.openecard.common.sal.state.CardStateMap)3 SALStateCallback (org.openecard.common.sal.state.SALStateCallback)3 IFD (org.openecard.ifd.scio.IFD)3 TinyManagement (org.openecard.management.TinyManagement)3 CardRecognitionImpl (org.openecard.recognition.CardRecognitionImpl)3 TinySAL (org.openecard.sal.TinySAL)3 MessageDispatcher (org.openecard.transport.dispatcher.MessageDispatcher)3 EventDispatcher (org.openecard.common.interfaces.EventDispatcher)2 PACEProtocolFactory (org.openecard.ifd.protocol.pace.PACEProtocolFactory)2 SelectorSAL (org.openecard.sal.SelectorSAL)2 JoranException (ch.qos.logback.core.joran.spi.JoranException)1 Win32Exception (com.sun.jna.platform.win32.Win32Exception)1