Search in sources :

Example 1 with CancelResponse

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

the class IFD method cancel.

@Override
public CancelResponse cancel(Cancel parameters) {
    CancelResponse response;
    // you thought of a different IFD obviously
    if (!ByteUtils.compare(ctxHandle, parameters.getContextHandle())) {
        String msg = "Invalid context handle specified.";
        Result r = WSHelper.makeResultError(ECardConstants.Minor.IFD.INVALID_CONTEXT_HANDLE, msg);
        response = WSHelper.makeResponse(CancelResponse.class, r);
        return response;
    }
    String ifdName = parameters.getIFDName();
    String session = parameters.getSessionIdentifier();
    if (session != null) {
        // async wait
        Future<List<IFDStatusType>> f = this.asyncWaitThreads.get(session);
        if (f != null) {
            f.cancel(true);
            response = WSHelper.makeResponse(CancelResponse.class, WSHelper.makeResultOK());
        } else {
            String msg = "No matching Wait call exists for the given session.";
            Result r = WSHelper.makeResultError(ECardConstants.Minor.IFD.IO.CANCEL_NOT_POSSIBLE, msg);
            response = WSHelper.makeResponse(CancelResponse.class, r);
        }
    } else if (ifdName != null) {
        // sync wait
        synchronized (this) {
            if (syncWaitThread != null) {
                syncWaitThread.cancel(true);
                // not really needed but seems cleaner
                syncWaitThread = null;
                response = WSHelper.makeResponse(CancelResponse.class, WSHelper.makeResultOK());
            } else {
                String msg = "No synchronous Wait to cancel.";
                Result r = WSHelper.makeResultError(ECardConstants.Minor.IFD.IO.CANCEL_NOT_POSSIBLE, msg);
                response = WSHelper.makeResponse(CancelResponse.class, r);
            }
        }
    } else {
        // nothing to cancel
        String msg = "Invalid parameters given.";
        response = WSHelper.makeResponse(CancelResponse.class, WSHelper.makeResultUnknownError(msg));
    }
    return response;
}
Also used : CancelResponse(iso.std.iso_iec._24727.tech.schema.CancelResponse) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Result(oasis.names.tc.dss._1_0.core.schema.Result)

Aggregations

CancelResponse (iso.std.iso_iec._24727.tech.schema.CancelResponse)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Result (oasis.names.tc.dss._1_0.core.schema.Result)1