Search in sources :

Example 11 with ConnectionHandleType

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

the class MiddlewareSAL method dataSetSelect.

@Override
public DataSetSelectResponse dataSetSelect(DataSetSelect request) {
    DataSetSelectResponse response = WSHelper.makeResponse(DataSetSelectResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
        byte[] applicationID = connectionHandle.getCardApplication();
        String dataSetName = request.getDataSetName();
        Assert.assertIncorrectParameter(dataSetName, "The parameter DataSetName is empty.");
        CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
        DataSetInfoType dataSetInfo = cardInfoWrapper.getDataSet(dataSetName, applicationID);
        Assert.assertNamedEntityNotFound(dataSetInfo, "The given DataSet cannot be found.");
        Assert.securityConditionDataSet(cardStateEntry, applicationID, dataSetName, NamedDataServiceActionName.DATA_SET_SELECT);
    // nothing else to do, DSI Read works for itself
    } catch (ECardException e) {
        response.setResult(e.getResult());
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        throwThreadKillException(e);
        response.setResult(WSHelper.makeResult(e));
    }
    return response;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) ECardException(org.openecard.common.ECardException) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CardInfoWrapper(org.openecard.common.sal.state.cif.CardInfoWrapper) DataSetInfoType(iso.std.iso_iec._24727.tech.schema.DataSetInfoType) ThreadTerminateException(org.openecard.common.ThreadTerminateException) InitializationException(org.openecard.mdlw.sal.exceptions.InitializationException) ECardException(org.openecard.common.ECardException) FinalizationException(org.openecard.mdlw.sal.exceptions.FinalizationException) PinBlockedException(org.openecard.mdlw.sal.exceptions.PinBlockedException) CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) UnknownProtocolException(org.openecard.common.sal.exception.UnknownProtocolException) TokenException(org.openecard.mdlw.sal.exceptions.TokenException) WSMarshallerException(org.openecard.ws.marshal.WSMarshallerException) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) UnsupportedAlgorithmException(org.openecard.crypto.common.UnsupportedAlgorithmException) PinIncorrectException(org.openecard.mdlw.sal.exceptions.PinIncorrectException) DataSetSelectResponse(iso.std.iso_iec._24727.tech.schema.DataSetSelectResponse)

Example 12 with ConnectionHandleType

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

the class MiddlewareSAL method cardApplicationConnect.

@Override
public CardApplicationConnectResponse cardApplicationConnect(CardApplicationConnect request) {
    CardApplicationConnectResponse response = WSHelper.makeResponse(CardApplicationConnectResponse.class, WSHelper.makeResultOK());
    try {
        CardApplicationPathType cardAppPath = request.getCardApplicationPath();
        Assert.assertIncorrectParameter(cardAppPath, "The parameter CardAppPathRequest is empty.");
        Set<CardStateEntry> cardStateEntrySet = states.getMatchingEntries(cardAppPath, false);
        Assert.assertIncorrectParameter(cardStateEntrySet, "The given ConnectionHandle is invalid.");
        /*
	     * [TR-03112-4] If the provided path fragments are valid for more than one card application
	     * the eCard-API-Framework SHALL return any of the possible choices.
             */
        CardStateEntry cardStateEntry = cardStateEntrySet.iterator().next();
        ConnectionHandleType handle = cardStateEntry.handleCopy();
        cardStateEntry = cardStateEntry.derive(handle);
        byte[] applicationID = cardStateEntry.getImplicitlySelectedApplicationIdentifier();
        Assert.securityConditionApplication(cardStateEntry, applicationID, ConnectionServiceActionName.CARD_APPLICATION_CONNECT);
        // find matching slot and associate it with the slotHandle
        MwSlot slot = getMatchingSlot(handle.getIFDName(), handle.getSlotIndex());
        if (slot != null) {
            // open session
            MwSession session = slot.openSession();
            // save values in maps
            byte[] slotHandle = ValueGenerators.generateRandom(64);
            handle.setSlotHandle(slotHandle);
            managedSlots.put(slotHandle, slot);
            managedSessions.put(slotHandle, session);
        } else {
            throw new IncorrectParameterException("No slot found for requestet handle.");
        }
        cardStateEntry.setSlotHandle(handle.getSlotHandle());
        // reset the ef FCP
        cardStateEntry.unsetFCPOfSelectedEF();
        states.addEntry(cardStateEntry);
        response.setConnectionHandle(cardStateEntry.handleCopy());
        response.getConnectionHandle().setCardApplication(applicationID);
    } catch (ECardException e) {
        response.setResult(e.getResult());
    } catch (CryptokiException ex) {
        String msg = "Error in Middleware.";
        LOG.error(msg, ex);
        response.setResult(WSHelper.makeResultError(ECardConstants.Minor.Disp.COMM_ERROR, msg));
    }
    return response;
}
Also used : CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) ECardException(org.openecard.common.ECardException) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CryptokiException(org.openecard.mdlw.sal.exceptions.CryptokiException) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)

Example 13 with ConnectionHandleType

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

the class MwEventObject method toString.

@Override
public String toString() {
    ConnectionHandleType handle = getHandle();
    String ifdName = handle.getIFDName();
    String slotHandle = ByteUtils.toHexString(handle.getSlotHandle());
    ConnectionHandleType.RecognitionInfo recInfo = handle.getRecognitionInfo();
    String cardType = recInfo != null ? recInfo.getCardType() : null;
    return String.format("MwEventObject={ifdName=%s, slot=%s, cardType=%s}", ifdName, slotHandle, cardType);
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)

Example 14 with ConnectionHandleType

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

the class MwEventRunner method sendCardInserted.

private void sendCardInserted(MwSlot slot) {
    // Add new Terminal to cache if needed
    this.sendTerminalAdded(slot);
    if (slots.get(slot.getSlotInfo().getSlotID()).isCardPresent) {
        // Event already sended
        return;
    }
    CkSlot ckSlot = slot.getSlotInfo();
    // send card inserted
    ConnectionHandleType insertHandle = makeUnknownCardHandle(ckSlot.getSlotDescription(), ckSlot.getSlotID());
    MwEventObject insertEvent = new MwEventObject(insertHandle, slot);
    notify(EventType.CARD_INSERTED, insertEvent);
    // For Cache
    slots.get(slot.getSlotInfo().getSlotID()).isCardPresent = true;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) CkSlot(org.openecard.mdlw.sal.struct.CkSlot)

Example 15 with ConnectionHandleType

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

the class MwEventRunner method makeKnownCardHandle.

private ConnectionHandleType makeKnownCardHandle(String ifdName, long slotIdx, String cardType, boolean isProtectedAuthPath) {
    ConnectionHandleType.RecognitionInfo rInfo = new ConnectionHandleType.RecognitionInfo();
    rInfo.setCardType(cardType);
    rInfo.setCaptureTime(dataFactory.newXMLGregorianCalendar(new GregorianCalendar()));
    ConnectionHandleType h = builder.setIfdName(ifdName).setSlotIdx(BigInteger.valueOf(slotIdx)).setRecognitionInfo(rInfo).setProtectedAuthPath(isProtectedAuthPath).buildConnectionHandle();
    return h;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) GregorianCalendar(java.util.GregorianCalendar)

Aggregations

ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)110 CardStateEntry (org.openecard.common.sal.state.CardStateEntry)47 ECardException (org.openecard.common.ECardException)43 IncorrectParameterException (org.openecard.common.sal.exception.IncorrectParameterException)37 ThreadTerminateException (org.openecard.common.ThreadTerminateException)36 NamedEntityNotFoundException (org.openecard.common.sal.exception.NamedEntityNotFoundException)34 UnknownProtocolException (org.openecard.common.sal.exception.UnknownProtocolException)34 TLVException (org.openecard.common.tlv.TLVException)29 AddonNotFoundException (org.openecard.addon.AddonNotFoundException)28 InappropriateProtocolForActionException (org.openecard.common.sal.exception.InappropriateProtocolForActionException)28 NameExistsException (org.openecard.common.sal.exception.NameExistsException)28 PrerequisitesNotSatisfiedException (org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException)28 SecurityConditionNotSatisfiedException (org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException)28 UnknownConnectionHandleException (org.openecard.common.sal.exception.UnknownConnectionHandleException)28 DIDStructureType (iso.std.iso_iec._24727.tech.schema.DIDStructureType)22 Publish (org.openecard.common.interfaces.Publish)17 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)15 ArrayList (java.util.ArrayList)15 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)14 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)14