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;
}
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;
}
Aggregations