Search in sources :

Example 1 with ReleaseContext

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

the class IFD method releaseContext.

@Override
public synchronized ReleaseContextResponse releaseContext(ReleaseContext parameters) {
    ReleaseContextResponse response;
    if (ByteUtils.compare(ctxHandle, parameters.getContextHandle())) {
        if (numClients.decrementAndGet() == 0) {
            // last client detaches
            env.removeIFDCtx(ctxHandle);
            ctxHandle = null;
            numClients = null;
            // terminate thread pool
            // wait for threads to die and block new requests
            threadPool.shutdownNow();
            // just assume it worked ... and don't wait
            threadPool = null;
            asyncWaitThreads = null;
        }
        evManager.terminate();
        response = WSHelper.makeResponse(ReleaseContextResponse.class, WSHelper.makeResultOK());
        return response;
    } else {
        String msg = "Invalid context handle specified.";
        Result r = WSHelper.makeResultError(ECardConstants.Minor.IFD.INVALID_CONTEXT_HANDLE, msg);
        response = WSHelper.makeResponse(ReleaseContextResponse.class, r);
        return response;
    }
}
Also used : ReleaseContextResponse(iso.std.iso_iec._24727.tech.schema.ReleaseContextResponse) Result(oasis.names.tc.dss._1_0.core.schema.Result)

Example 2 with ReleaseContext

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

the class TerminalTest method kill.

@AfterTest
public void kill() {
    if (ifd != null) {
        ReleaseContext rCtx = new ReleaseContext();
        rCtx.setContextHandle(ctxHandle);
        ifd.releaseContext(rCtx);
    }
    ifd = null;
}
Also used : ReleaseContext(iso.std.iso_iec._24727.tech.schema.ReleaseContext) AfterTest(org.testng.annotations.AfterTest)

Example 3 with ReleaseContext

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

the class RichClient method teardown.

public void teardown() {
    try {
        if (eventDispatcher != null) {
            eventDispatcher.terminate();
        }
        // TODO: shutdown addon manager and related components?
        if (manager != null) {
            manager.shutdown();
        }
        // shutdown control modules
        if (httpBinding != null) {
            httpBinding.stop();
        }
        // shutdown SAL
        if (sal != null) {
            Terminate terminate = new Terminate();
            sal.terminate(terminate);
        }
        // shutdown IFD
        if (ifd != null && contextHandle != null) {
            ReleaseContext releaseContext = new ReleaseContext();
            releaseContext.setContextHandle(contextHandle);
            ifd.releaseContext(releaseContext);
        }
    } catch (Exception ex) {
        LOG.error("Failed to stop Richclient.", ex);
    }
    System.exit(0);
}
Also used : ReleaseContext(iso.std.iso_iec._24727.tech.schema.ReleaseContext) Terminate(iso.std.iso_iec._24727.tech.schema.Terminate) UnsupportedCharsetException(java.nio.charset.UnsupportedCharsetException) Win32Exception(com.sun.jna.platform.win32.Win32Exception) BindException(java.net.BindException) HttpException(org.openecard.apache.http.HttpException) IOException(java.io.IOException) JoranException(ch.qos.logback.core.joran.spi.JoranException)

Example 4 with ReleaseContext

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

the class OpeneCardContext method shutdown.

String shutdown() {
    initialized = false;
    try {
        if (ifd != null && contextHandle != null) {
            ReleaseContext releaseContext = new ReleaseContext();
            releaseContext.setContextHandle(contextHandle);
            ifd.releaseContext(releaseContext);
        }
        if (eventDispatcher != null) {
            eventDispatcher.terminate();
        }
        if (manager != null) {
            manager.shutdown();
        }
        if (sal != null) {
            Terminate terminate = new Terminate();
            sal.terminate(terminate);
        }
        return SUCCESS;
    } catch (Exception ex) {
        LOG.error("Failed to terminate Open eCard instances...", ex);
        return FAILURE;
    }
}
Also used : ReleaseContext(iso.std.iso_iec._24727.tech.schema.ReleaseContext) Terminate(iso.std.iso_iec._24727.tech.schema.Terminate) IFDException(org.openecard.ifd.scio.IFDException)

Aggregations

ReleaseContext (iso.std.iso_iec._24727.tech.schema.ReleaseContext)3 Terminate (iso.std.iso_iec._24727.tech.schema.Terminate)2 JoranException (ch.qos.logback.core.joran.spi.JoranException)1 Win32Exception (com.sun.jna.platform.win32.Win32Exception)1 ReleaseContextResponse (iso.std.iso_iec._24727.tech.schema.ReleaseContextResponse)1 IOException (java.io.IOException)1 BindException (java.net.BindException)1 UnsupportedCharsetException (java.nio.charset.UnsupportedCharsetException)1 Result (oasis.names.tc.dss._1_0.core.schema.Result)1 HttpException (org.openecard.apache.http.HttpException)1 IFDException (org.openecard.ifd.scio.IFDException)1 AfterTest (org.testng.annotations.AfterTest)1