Search in sources :

Example 1 with DeleteFile

use of org.openecard.common.apdu.DeleteFile 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 2 with DeleteFile

use of org.openecard.common.apdu.DeleteFile in project open-ecard by ecsec.

the class TinySAL method dataSetDelete.

/**
 * The DataSetDelete function deletes a data set of a card application on an eCard.
 * See BSI-TR-03112-4, version 1.1.2, section 3.4.4.
 *
 * @param request DataSetDelete
 * @return DataSetDeleteResponse
 */
@Override
public DataSetDeleteResponse dataSetDelete(DataSetDelete request) {
    DataSetDeleteResponse response = WSHelper.makeResponse(DataSetDeleteResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
        byte[] cardApplicationID = connectionHandle.getCardApplication();
        CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
        String dataSetName = request.getDataSetName();
        Assert.assertIncorrectParameter(dataSetName, "The parameter DataSetName is empty.");
        Assert.securityConditionDataSet(cardStateEntry, cardApplicationID, dataSetName, NamedDataServiceActionName.DATA_SET_DELETE);
        DataSetInfoType dataSet = cardInfoWrapper.getDataSet(dataSetName, cardApplicationID);
        if (dataSet == null) {
            throw new NamedEntityNotFoundException("The data set " + dataSetName + " does not exist.");
        }
        byte[] path = dataSet.getDataSetPath().getEfIdOrPath();
        int len = path.length;
        byte[] fid = new byte[] { path[len - 2], path[len - 1] };
        DeleteFile delFile = new DeleteFile.ChildFile(fid);
        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) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) 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) ECardException(org.openecard.common.ECardException) NamedEntityNotFoundException(org.openecard.common.sal.exception.NamedEntityNotFoundException) DataSetInfoType(iso.std.iso_iec._24727.tech.schema.DataSetInfoType) DataSetDeleteResponse(iso.std.iso_iec._24727.tech.schema.DataSetDeleteResponse) DeleteFile(org.openecard.common.apdu.DeleteFile)

Aggregations

ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)2 AddonNotFoundException (org.openecard.addon.AddonNotFoundException)2 ECardException (org.openecard.common.ECardException)2 ThreadTerminateException (org.openecard.common.ThreadTerminateException)2 DeleteFile (org.openecard.common.apdu.DeleteFile)2 InappropriateProtocolForActionException (org.openecard.common.sal.exception.InappropriateProtocolForActionException)2 IncorrectParameterException (org.openecard.common.sal.exception.IncorrectParameterException)2 NameExistsException (org.openecard.common.sal.exception.NameExistsException)2 NamedEntityNotFoundException (org.openecard.common.sal.exception.NamedEntityNotFoundException)2 PrerequisitesNotSatisfiedException (org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException)2 SecurityConditionNotSatisfiedException (org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException)2 UnknownConnectionHandleException (org.openecard.common.sal.exception.UnknownConnectionHandleException)2 UnknownProtocolException (org.openecard.common.sal.exception.UnknownProtocolException)2 CardStateEntry (org.openecard.common.sal.state.CardStateEntry)2 TLVException (org.openecard.common.tlv.TLVException)2 CardApplicationDeleteResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationDeleteResponse)1 DataSetDeleteResponse (iso.std.iso_iec._24727.tech.schema.DataSetDeleteResponse)1 DataSetInfoType (iso.std.iso_iec._24727.tech.schema.DataSetInfoType)1 CardInfoWrapper (org.openecard.common.sal.state.cif.CardInfoWrapper)1