Search in sources :

Example 21 with ConnectionHandleType

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

the class TinySAL method cardApplicationStartSession.

/**
 * This CardApplicationStartSession function starts a session between the client application and the card application.
 * See BSI-TR-03112-4, version 1.1.2, section 3.2.3.
 *
 * @param request CardApplicationStartSession
 * @return CardApplicationStartSessionResponse
 */
@Publish
@Override
public CardApplicationStartSessionResponse cardApplicationStartSession(CardApplicationStartSession request) {
    CardApplicationStartSessionResponse response = WSHelper.makeResponse(CardApplicationStartSessionResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
        byte[] cardApplicationID = connectionHandle.getCardApplication();
        String didName = SALUtils.getDIDName(request);
        Assert.assertIncorrectParameter(didName, "The parameter didName is empty.");
        DIDAuthenticationDataType didAuthenticationProtocolData = request.getAuthenticationProtocolData();
        Assert.assertIncorrectParameter(didAuthenticationProtocolData, "The parameter didAuthenticationProtocolData is empty.");
        DIDStructureType didStructure = cardStateEntry.getDIDStructure(didName, cardApplicationID);
        Assert.assertNamedEntityNotFound(didStructure, "The given DIDName cannot be found.");
        Assert.securityConditionApplication(cardStateEntry, cardApplicationID, ConnectionServiceActionName.CARD_APPLICATION_START_SESSION);
        String protocolURI = didStructure.getDIDMarker().getProtocol();
        SALProtocol protocol = getProtocol(connectionHandle, request.getDIDScope(), protocolURI);
        if (protocol.hasNextStep(FunctionType.CardApplicationStartSession)) {
            response = protocol.cardApplicationStartSession(request);
            removeFinishedProtocol(connectionHandle, protocolURI, protocol);
        } else {
            throw new InappropriateProtocolForActionException("CardApplicationStartSession", protocol.toString());
        }
    } 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) InappropriateProtocolForActionException(org.openecard.common.sal.exception.InappropriateProtocolForActionException) ECardException(org.openecard.common.ECardException) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) SALProtocol(org.openecard.addon.sal.SALProtocol) CardApplicationStartSessionResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationStartSessionResponse) DIDAuthenticationDataType(iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType) DIDStructureType(iso.std.iso_iec._24727.tech.schema.DIDStructureType) PrerequisitesNotSatisfiedException(org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException) NameExistsException(org.openecard.common.sal.exception.NameExistsException) AddonNotFoundException(org.openecard.addon.AddonNotFoundException) ThreadTerminateException(org.openecard.common.ThreadTerminateException) ECardException(org.openecard.common.ECardException) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) UnknownProtocolException(org.openecard.common.sal.exception.UnknownProtocolException) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) InappropriateProtocolForActionException(org.openecard.common.sal.exception.InappropriateProtocolForActionException) TLVException(org.openecard.common.tlv.TLVException) SecurityConditionNotSatisfiedException(org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException) UnknownConnectionHandleException(org.openecard.common.sal.exception.UnknownConnectionHandleException) Publish(org.openecard.common.interfaces.Publish)

Example 22 with ConnectionHandleType

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

the class TinySAL method didUpdate.

/**
 * The DIDUpdate function creates a new key (marker) for the DID addressed with DIDName.
 * See BSI-TR-03112-4, version 1.1.2, section 3.6.4.
 *
 * @param request DIDUpdate
 * @return DIDUpdateResponse
 */
// TODO: discuss whether we should publish this @Publish
@Override
public DIDUpdateResponse didUpdate(DIDUpdate request) {
    DIDUpdateResponse response = WSHelper.makeResponse(DIDUpdateResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        byte[] cardApplicationID = connectionHandle.getCardApplication();
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
        String didName = request.getDIDName();
        Assert.assertIncorrectParameter(didName, "The parameter DIDName is empty.");
        DIDUpdateDataType didUpdateData = request.getDIDUpdateData();
        Assert.assertIncorrectParameter(didUpdateData, "The parameter DIDUpdateData is empty.");
        DIDStructureType didStructure = cardStateEntry.getDIDStructure(didName, cardApplicationID);
        Assert.assertNamedEntityNotFound(didStructure, "The given DIDName cannot be found.");
        Assert.securityConditionDID(cardStateEntry, cardApplicationID, didName, DifferentialIdentityServiceActionName.DID_UPDATE);
        String protocolURI = didStructure.getDIDMarker().getProtocol();
        SALProtocol protocol = getProtocol(connectionHandle, null, protocolURI);
        if (protocol.hasNextStep(FunctionType.DIDUpdate)) {
            response = protocol.didUpdate(request);
            removeFinishedProtocol(connectionHandle, protocolURI, protocol);
        } else {
            throw new InappropriateProtocolForActionException("DIDUpdate", protocol.toString());
        }
    } 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) InappropriateProtocolForActionException(org.openecard.common.sal.exception.InappropriateProtocolForActionException) ECardException(org.openecard.common.ECardException) DIDUpdateResponse(iso.std.iso_iec._24727.tech.schema.DIDUpdateResponse) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) SALProtocol(org.openecard.addon.sal.SALProtocol) DIDStructureType(iso.std.iso_iec._24727.tech.schema.DIDStructureType) DIDUpdateDataType(iso.std.iso_iec._24727.tech.schema.DIDUpdateDataType) PrerequisitesNotSatisfiedException(org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException) NameExistsException(org.openecard.common.sal.exception.NameExistsException) AddonNotFoundException(org.openecard.addon.AddonNotFoundException) ThreadTerminateException(org.openecard.common.ThreadTerminateException) ECardException(org.openecard.common.ECardException) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) UnknownProtocolException(org.openecard.common.sal.exception.UnknownProtocolException) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) InappropriateProtocolForActionException(org.openecard.common.sal.exception.InappropriateProtocolForActionException) TLVException(org.openecard.common.tlv.TLVException) SecurityConditionNotSatisfiedException(org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException) UnknownConnectionHandleException(org.openecard.common.sal.exception.UnknownConnectionHandleException)

Example 23 with ConnectionHandleType

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

the class TinySAL method cardApplicationDelete.

/**
 * The CardApplicationDelete function deletes a card application as well as all corresponding
 * data sets, DSIs, DIDs and services.
 * See BSI-TR-03112-4, version 1.1.2, section 3.3.3.
 *
 * @param request CardApplicationDelete
 * @return CardApplicationDeleteResponse
 */
@Override
public CardApplicationDeleteResponse cardApplicationDelete(CardApplicationDelete request) {
    CardApplicationDeleteResponse response = WSHelper.makeResponse(CardApplicationDeleteResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
        byte[] cardApplicationName = request.getCardApplicationName();
        Assert.assertIncorrectParameter(cardApplicationName, "The parameter CardApplicationName is empty.");
        Assert.securityConditionApplication(cardStateEntry, connectionHandle.getCardApplication(), CardApplicationServiceActionName.CARD_APPLICATION_DELETE);
        // TODO: determine how the deletion have to be performed. A card don't have to support the Deletion by
        // application identifier. Necessary attributes should be available in the ATR or EF.ATR.
        DeleteFile delFile = new DeleteFile.Application(cardApplicationName);
        delFile.transmit(env.getDispatcher(), connectionHandle.getSlotHandle());
    } 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) CardApplicationDeleteResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationDeleteResponse) PrerequisitesNotSatisfiedException(org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException) NameExistsException(org.openecard.common.sal.exception.NameExistsException) AddonNotFoundException(org.openecard.addon.AddonNotFoundException) ThreadTerminateException(org.openecard.common.ThreadTerminateException) ECardException(org.openecard.common.ECardException) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) UnknownProtocolException(org.openecard.common.sal.exception.UnknownProtocolException) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) InappropriateProtocolForActionException(org.openecard.common.sal.exception.InappropriateProtocolForActionException) TLVException(org.openecard.common.tlv.TLVException) SecurityConditionNotSatisfiedException(org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException) UnknownConnectionHandleException(org.openecard.common.sal.exception.UnknownConnectionHandleException) DeleteFile(org.openecard.common.apdu.DeleteFile)

Example 24 with ConnectionHandleType

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

the class TinySAL method didDelete.

/**
 * The DIDDelete function deletes the DID addressed with DIDName.
 * See BSI-TR-03112-4, version 1.1.2, section 3.6.5.
 *
 * @param request DIDDelete
 * @return DIDDeleteResponse
 */
@Override
public DIDDeleteResponse didDelete(DIDDelete request) {
    DIDDeleteResponse response = WSHelper.makeResponse(DIDDeleteResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        byte[] cardApplicationID = connectionHandle.getCardApplication();
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
        String didName = request.getDIDName();
        Assert.assertIncorrectParameter(didName, "The parameter DIDName is empty.");
        DIDStructureType didStructure = cardStateEntry.getDIDStructure(didName, cardApplicationID);
        Assert.assertNamedEntityNotFound(didStructure, "The given DIDName cannot be found.");
        Assert.securityConditionDID(cardStateEntry, cardApplicationID, didName, DifferentialIdentityServiceActionName.DID_DELETE);
        String protocolURI = didStructure.getDIDMarker().getProtocol();
        SALProtocol protocol = getProtocol(connectionHandle, null, protocolURI);
        if (protocol.hasNextStep(FunctionType.DIDDelete)) {
            response = protocol.didDelete(request);
            removeFinishedProtocol(connectionHandle, protocolURI, protocol);
        } else {
            throw new InappropriateProtocolForActionException("DIDDelete", protocol.toString());
        }
    } 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) InappropriateProtocolForActionException(org.openecard.common.sal.exception.InappropriateProtocolForActionException) ECardException(org.openecard.common.ECardException) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) DIDDeleteResponse(iso.std.iso_iec._24727.tech.schema.DIDDeleteResponse) SALProtocol(org.openecard.addon.sal.SALProtocol) DIDStructureType(iso.std.iso_iec._24727.tech.schema.DIDStructureType) PrerequisitesNotSatisfiedException(org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException) NameExistsException(org.openecard.common.sal.exception.NameExistsException) AddonNotFoundException(org.openecard.addon.AddonNotFoundException) ThreadTerminateException(org.openecard.common.ThreadTerminateException) ECardException(org.openecard.common.ECardException) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) UnknownProtocolException(org.openecard.common.sal.exception.UnknownProtocolException) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) InappropriateProtocolForActionException(org.openecard.common.sal.exception.InappropriateProtocolForActionException) TLVException(org.openecard.common.tlv.TLVException) SecurityConditionNotSatisfiedException(org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException) UnknownConnectionHandleException(org.openecard.common.sal.exception.UnknownConnectionHandleException)

Example 25 with ConnectionHandleType

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

the class TinySAL method cardApplicationServiceList.

/**
 * The CardApplicationServiceList function returns a list of all available services of a card application.
 * See BSI-TR-03112-4, version 1.1.2, section 3.3.4.
 *
 * @param request CardApplicationServiceList
 * @return CardApplicationServiceListResponse
 */
@Publish
@Override
public CardApplicationServiceListResponse cardApplicationServiceList(CardApplicationServiceList request) {
    CardApplicationServiceListResponse response = WSHelper.makeResponse(CardApplicationServiceListResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
        byte[] cardApplicationID = connectionHandle.getCardApplication();
        // Assert.securityConditionApplication(cardStateEntry, cardApplicationID,
        // CardApplicationServiceActionName.CARD_APPLICATION_SERVICE_LIST);
        CardApplicationServiceNameList cardApplicationServiceNameList = new CardApplicationServiceNameList();
        CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
        Iterator<CardApplicationType> it = cardInfoWrapper.getApplicationCapabilities().getCardApplication().iterator();
        while (it.hasNext()) {
            CardApplicationType next = it.next();
            byte[] appName = next.getApplicationIdentifier();
            if (Arrays.equals(appName, cardApplicationID)) {
                Iterator<CardApplicationServiceType> itt = next.getCardApplicationServiceInfo().iterator();
                while (itt.hasNext()) {
                    CardApplicationServiceType nextt = itt.next();
                    cardApplicationServiceNameList.getCardApplicationServiceName().add(nextt.getCardApplicationServiceName());
                }
            }
        }
        response.setCardApplicationServiceNameList(cardApplicationServiceNameList);
    } 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) CardApplicationType(iso.std.iso_iec._24727.tech.schema.CardApplicationType) CardApplicationServiceListResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceListResponse) CardApplicationServiceType(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceType) CardInfoWrapper(org.openecard.common.sal.state.cif.CardInfoWrapper) PrerequisitesNotSatisfiedException(org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException) NameExistsException(org.openecard.common.sal.exception.NameExistsException) AddonNotFoundException(org.openecard.addon.AddonNotFoundException) ThreadTerminateException(org.openecard.common.ThreadTerminateException) ECardException(org.openecard.common.ECardException) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) UnknownProtocolException(org.openecard.common.sal.exception.UnknownProtocolException) IncorrectParameterException(org.openecard.common.sal.exception.IncorrectParameterException) InappropriateProtocolForActionException(org.openecard.common.sal.exception.InappropriateProtocolForActionException) TLVException(org.openecard.common.tlv.TLVException) SecurityConditionNotSatisfiedException(org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException) UnknownConnectionHandleException(org.openecard.common.sal.exception.UnknownConnectionHandleException) CardApplicationServiceNameList(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceListResponse.CardApplicationServiceNameList) Publish(org.openecard.common.interfaces.Publish)

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