use of iso.std.iso_iec._24727.tech.schema.DataSetSelectResponse 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;
}
use of iso.std.iso_iec._24727.tech.schema.DataSetSelectResponse in project open-ecard by ecsec.
the class TinySAL method dataSetSelect.
/**
* The DataSetSelect function selects a data set in a card application.
* See BSI-TR-03112-4, version 1.1.2, section 3.4.3.
*
* @param request DataSetSelect
* @return DataSetSelectResponse
*/
@Publish
@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);
byte[] fileID = dataSetInfo.getDataSetPath().getEfIdOrPath();
byte[] slotHandle = connectionHandle.getSlotHandle();
CardResponseAPDU result = CardUtils.selectFileWithOptions(env.getDispatcher(), slotHandle, fileID, null, CardUtils.FCP_RESPONSE_DATA);
FCP fcp = null;
if (result != null && result.getData().length > 0) {
try {
fcp = new FCP(result.getData());
} catch (TLVException ex) {
LOG.warn("Invalid FCP received.");
}
}
if (fcp == null) {
LOG.info("Using fake FCP.");
fcp = new FCP(createFakeFCP(Arrays.copyOfRange(fileID, fileID.length - 2, fileID.length)));
}
cardStateEntry.setFCPOfSelectedEF(fcp);
} 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 iso.std.iso_iec._24727.tech.schema.DataSetSelectResponse in project open-ecard by ecsec.
the class DataSetInfo method select.
private void select() throws WSHelper.WSException {
DataSetSelect req = new DataSetSelect();
req.setConnectionHandle(didInfos.getHandle(application));
req.setDataSetName(datasetNameTarget.getDataSetName());
DataSetSelectResponse res = (DataSetSelectResponse) didInfos.getDispatcher().safeDeliver(req);
WSHelper.checkResult(res);
}
use of iso.std.iso_iec._24727.tech.schema.DataSetSelectResponse in project open-ecard by ecsec.
the class TinySALTest method testDataSetSelect.
/**
* Test of dataSetSelect method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testDataSetSelect() {
System.out.println("dataSetSelect");
CardApplicationPath cardApplicationPath = new CardApplicationPath();
CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
cardApplicationPathType.setCardApplication(appIdentifier_ESIGN);
cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
CardApplicationConnect parameters = new CardApplicationConnect();
parameters.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
CardApplicationConnectResponse result = instance.cardApplicationConnect(parameters);
assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
// test good case
DataSetSelect dataSetSelect = new DataSetSelect();
dataSetSelect.setConnectionHandle(result.getConnectionHandle());
dataSetSelect.setDataSetName("EF.C.CH.AUT");
DataSetSelectResponse dataSetSelectResponse = instance.dataSetSelect(dataSetSelect);
assertEquals(ECardConstants.Major.OK, dataSetSelectResponse.getResult().getResultMajor());
// test connectionhanle == null
dataSetSelect = new DataSetSelect();
dataSetSelect.setConnectionHandle(null);
dataSetSelect.setDataSetName("EF.C.CH.AUT");
dataSetSelectResponse = instance.dataSetSelect(dataSetSelect);
assertEquals(ECardConstants.Major.ERROR, dataSetSelectResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dataSetSelectResponse.getResult().getResultMinor());
// test datasetname == null
dataSetSelect = new DataSetSelect();
dataSetSelect.setConnectionHandle(result.getConnectionHandle());
dataSetSelect.setDataSetName(null);
dataSetSelectResponse = instance.dataSetSelect(dataSetSelect);
assertEquals(ECardConstants.Major.ERROR, dataSetSelectResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dataSetSelectResponse.getResult().getResultMinor());
// test datasetname not found
dataSetSelect = new DataSetSelect();
dataSetSelect.setConnectionHandle(result.getConnectionHandle());
dataSetSelect.setDataSetName("INVALID");
dataSetSelectResponse = instance.dataSetSelect(dataSetSelect);
assertEquals(ECardConstants.Major.ERROR, dataSetSelectResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.SAL.NAMED_ENTITY_NOT_FOUND, dataSetSelectResponse.getResult().getResultMinor());
// test invalid connectionhandle
dataSetSelect = new DataSetSelect();
ConnectionHandleType invalidConnectionHandle = result.getConnectionHandle();
invalidConnectionHandle.setIFDName(("invalid"));
dataSetSelect.setConnectionHandle(invalidConnectionHandle);
dataSetSelect.setDataSetName("EF.C.CH.AUT");
dataSetSelectResponse = instance.dataSetSelect(dataSetSelect);
assertEquals(ECardConstants.Major.ERROR, dataSetSelectResponse.getResult().getResultMajor());
assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dataSetSelectResponse.getResult().getResultMinor());
}
Aggregations