use of iso.std.iso_iec._24727.tech.schema.DSIList in project open-ecard by ecsec.
the class TinySALTest method testDsiCreate.
/**
* Test of dsiCreate method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testDsiCreate() {
System.out.println("dsiCreate");
// 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());
// list datasets of esign
DataSetList dataSetList = new DataSetList();
dataSetList.setConnectionHandle(result.getConnectionHandle());
DataSetListResponse dataSetListResponse = instance.dataSetList(dataSetList);
Assert.assertTrue(dataSetListResponse.getDataSetNameList().getDataSetName().size() > 0);
assertEquals(ECardConstants.Major.OK, dataSetListResponse.getResult().getResultMajor());
String dataSetName = dataSetListResponse.getDataSetNameList().getDataSetName().get(0);
byte[] dsiContent = { (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74 };
String dsiName = "DsiTest";
PathType dsiPath = new PathType();
byte[] dsiEF = { (byte) 0x03, (byte) 0x00 };
dsiPath.setEfIdOrPath(dsiEF);
DSICreate parameters = new DSICreate();
parameters.setConnectionHandle(result.getConnectionHandle());
parameters.setDSIContent(dsiContent);
parameters.setDSIName(dsiName);
DSICreateResponse resultDSICreate = instance.dsiCreate(parameters);
assertEquals(ECardConstants.Major.OK, resultDSICreate.getResult().getResultMajor());
// list DSIs of DataSetName
DSIList parametersDSI = new DSIList();
parametersDSI.setConnectionHandle(result.getConnectionHandle());
DSIListResponse resultDSIList = instance.dsiList(parametersDSI);
assertEquals(ECardConstants.Major.OK, resultDSIList.getResult().getResultMajor());
// try to find new DSI
Iterator<String> it = resultDSIList.getDSINameList().getDSIName().iterator();
boolean dsiFound = false;
while (it.hasNext()) {
String val = it.next();
if (val.equals(dsiName)) {
dsiFound = true;
}
}
assertTrue(dsiFound);
}
use of iso.std.iso_iec._24727.tech.schema.DSIList in project open-ecard by ecsec.
the class TinySALTest method testDsiDelete.
/**
* Test of dsiDelete method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testDsiDelete() {
System.out.println("dsiDelete");
// 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());
// list datasets of esign
DataSetList dataSetList = new DataSetList();
dataSetList.setConnectionHandle(result.getConnectionHandle());
DataSetListResponse dataSetListResponse = instance.dataSetList(dataSetList);
Assert.assertTrue(dataSetListResponse.getDataSetNameList().getDataSetName().size() > 0);
assertEquals(ECardConstants.Major.OK, dataSetListResponse.getResult().getResultMajor());
String dataSetName = dataSetListResponse.getDataSetNameList().getDataSetName().get(0);
String dsiName = "dsiTest";
DSIDelete parameters = new DSIDelete();
parameters.setConnectionHandle(result.getConnectionHandle());
parameters.setDSIName(dsiName);
DSIDeleteResponse resultDSIDelete = instance.dsiDelete(parameters);
assertEquals(ECardConstants.Major.OK, resultDSIDelete.getResult().getResultMajor());
// try to find dsiName under dataSetName
DSIList parametersDSI = new DSIList();
parametersDSI.setConnectionHandle(result.getConnectionHandle());
DSIListResponse resultDSIList = instance.dsiList(parametersDSI);
assertEquals(ECardConstants.Major.OK, resultDSIList.getResult().getResultMajor());
// try to find new DSI
Iterator<String> it = resultDSIList.getDSINameList().getDSIName().iterator();
boolean dsiFound = false;
while (it.hasNext()) {
String val = it.next();
if (val.equals(dsiName)) {
dsiFound = true;
}
}
assertTrue(!dsiFound);
}
use of iso.std.iso_iec._24727.tech.schema.DSIList in project open-ecard by ecsec.
the class TinySAL method dsiList.
/**
* The function DSIList supplies the list of the DSI (Data Structure for Interoperability) which exist in the
* selected data set.
* See BSI-TR-03112-4, version 1.1.2, section 3.4.5. <br>
* <br>
* Prerequisites: <br>
* - a connection to a card application has been established <br>
* - a data set has been selected <br>
*
* @param request DSIList
* @return DSIListResponse
*/
@Publish
@Override
public DSIListResponse dsiList(DSIList request) {
DSIListResponse response = WSHelper.makeResponse(DSIListResponse.class, WSHelper.makeResultOK());
try {
ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
byte[] cardApplicationID = connectionHandle.getCardApplication();
if (cardStateEntry.getFCPOfSelectedEF() == null) {
throw new PrerequisitesNotSatisfiedException("No EF selected.");
}
DataSetInfoType dataSet = cardInfoWrapper.getDataSetByFid(cardStateEntry.getFCPOfSelectedEF().getFileIdentifiers().get(0));
Assert.securityConditionDataSet(cardStateEntry, cardApplicationID, dataSet.getDataSetName(), NamedDataServiceActionName.DSI_LIST);
DSINameListType dsiNameList = new DSINameListType();
for (DSIType dsi : dataSet.getDSI()) {
dsiNameList.getDSIName().add(dsi.getDSIName());
}
response.setDSINameList(dsiNameList);
} 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.DSIList in project open-ecard by ecsec.
the class TinySALTest method testDsiList.
/**
* Test of dsiList method, of class TinySAL.
*/
@Test(enabled = TESTS_ENABLED)
public void testDsiList() {
System.out.println("dsiList");
// 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());
// list datasets of esign
DataSetList dataSetList = new DataSetList();
dataSetList.setConnectionHandle(result.getConnectionHandle());
DataSetListResponse dataSetListResponse = instance.dataSetList(dataSetList);
Assert.assertTrue(dataSetListResponse.getDataSetNameList().getDataSetName().size() > 0);
assertEquals(ECardConstants.Major.OK, dataSetListResponse.getResult().getResultMajor());
String dataSetName = dataSetListResponse.getDataSetNameList().getDataSetName().get(0);
DSIList parameters = new DSIList();
parameters.setConnectionHandle(result.getConnectionHandle());
DSIListResponse resultDSIList = instance.dsiList(parameters);
assertEquals(ECardConstants.Major.OK, resultDSIList.getResult().getResultMajor());
assertTrue(resultDSIList.getDSINameList().getDSIName().isEmpty());
}
Aggregations