Search in sources :

Example 1 with DataSetDeleteResponse

use of iso.std.iso_iec._24727.tech.schema.DataSetDeleteResponse 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)

Example 2 with DataSetDeleteResponse

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

the class TinySALTest method testDataSetDelete.

/**
 * Test of dataSetDelete method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testDataSetDelete() {
    System.out.println("dataSetDelete");
    DataSetDelete parameters = new DataSetDelete();
    // get path to esign
    CardApplicationPath cardApplicationPath = new CardApplicationPath();
    CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
    cardApplicationPathType.setCardApplication(appIdentifier_ESIGN);
    cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
    CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
    // connect to esign
    CardApplicationConnect cardApplicationConnect = new CardApplicationConnect();
    cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
    CardApplicationConnectResponse result = instance.cardApplicationConnect(cardApplicationConnect);
    assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
    parameters.setConnectionHandle(result.getConnectionHandle());
    String dataSetName = "DataSetTest";
    parameters.setDataSetName(dataSetName);
    DataSetDeleteResponse resultDataSetDelete = instance.dataSetDelete(parameters);
    assertEquals(ECardConstants.Major.OK, resultDataSetDelete.getResult().getResultMajor());
    // list datasets of esign
    DataSetList dataSetList = new DataSetList();
    dataSetList.setConnectionHandle(result.getConnectionHandle());
    DataSetListResponse dataSetListResponse = instance.dataSetList(dataSetList);
    Iterator<String> it = dataSetListResponse.getDataSetNameList().getDataSetName().iterator();
    boolean appFound = false;
    while (it.hasNext()) {
        String val = it.next();
        if (val.equals(dataSetName)) {
            appFound = true;
        }
    }
    assertTrue(!appFound);
    assertEquals(ECardConstants.Major.OK, dataSetListResponse.getResult().getResultMajor());
}
Also used : CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) DataSetListResponse(iso.std.iso_iec._24727.tech.schema.DataSetListResponse) DataSetDelete(iso.std.iso_iec._24727.tech.schema.DataSetDelete) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) DataSetList(iso.std.iso_iec._24727.tech.schema.DataSetList) DataSetDeleteResponse(iso.std.iso_iec._24727.tech.schema.DataSetDeleteResponse) Test(org.testng.annotations.Test)

Aggregations

DataSetDeleteResponse (iso.std.iso_iec._24727.tech.schema.DataSetDeleteResponse)2 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)1 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)1 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)1 CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)1 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)1 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)1 DataSetDelete (iso.std.iso_iec._24727.tech.schema.DataSetDelete)1 DataSetInfoType (iso.std.iso_iec._24727.tech.schema.DataSetInfoType)1 DataSetList (iso.std.iso_iec._24727.tech.schema.DataSetList)1 DataSetListResponse (iso.std.iso_iec._24727.tech.schema.DataSetListResponse)1 AddonNotFoundException (org.openecard.addon.AddonNotFoundException)1 ECardException (org.openecard.common.ECardException)1 ThreadTerminateException (org.openecard.common.ThreadTerminateException)1 DeleteFile (org.openecard.common.apdu.DeleteFile)1 InappropriateProtocolForActionException (org.openecard.common.sal.exception.InappropriateProtocolForActionException)1 IncorrectParameterException (org.openecard.common.sal.exception.IncorrectParameterException)1 NameExistsException (org.openecard.common.sal.exception.NameExistsException)1 NamedEntityNotFoundException (org.openecard.common.sal.exception.NamedEntityNotFoundException)1 PrerequisitesNotSatisfiedException (org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException)1