Search in sources :

Example 6 with DataSetListResponse

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

Example 7 with DataSetListResponse

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

the class TinySALTest method testDataSetList.

/**
 * Test of dataSetList method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testDataSetList() {
    System.out.println("dataSetList");
    // 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);
    System.out.println(ByteUtils.toHexString(result.getConnectionHandle().getSlotHandle()));
    Assert.assertTrue(dataSetListResponse.getDataSetNameList().getDataSetName().size() > 0);
    assertEquals(ECardConstants.Major.OK, dataSetListResponse.getResult().getResultMajor());
    // test invalid connectionhandle
    dataSetList = new DataSetList();
    ConnectionHandleType wrongConnectionHandle = result.getConnectionHandle();
    wrongConnectionHandle.setCardApplication(new byte[] { 0x0, 0x0, 0x0 });
    dataSetList.setConnectionHandle(wrongConnectionHandle);
    dataSetListResponse = instance.dataSetList(dataSetList);
    assertEquals(ECardConstants.Major.ERROR, dataSetListResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dataSetListResponse.getResult().getResultMinor());
    // test null connectionhandle
    dataSetList = new DataSetList();
    dataSetList.setConnectionHandle(null);
    dataSetListResponse = instance.dataSetList(dataSetList);
    assertEquals(ECardConstants.Major.ERROR, dataSetListResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dataSetListResponse.getResult().getResultMinor());
// TODO test for unsatisfied security condition
}
Also used : CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) DataSetListResponse(iso.std.iso_iec._24727.tech.schema.DataSetListResponse) 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) Test(org.testng.annotations.Test)

Example 8 with DataSetListResponse

use of iso.std.iso_iec._24727.tech.schema.DataSetListResponse 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());
}
Also used : CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) DSIListResponse(iso.std.iso_iec._24727.tech.schema.DSIListResponse) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) DataSetListResponse(iso.std.iso_iec._24727.tech.schema.DataSetListResponse) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) DSIList(iso.std.iso_iec._24727.tech.schema.DSIList) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) DataSetList(iso.std.iso_iec._24727.tech.schema.DataSetList) Test(org.testng.annotations.Test)

Example 9 with DataSetListResponse

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

the class SALFileUtils method selectAppByDataSet.

/**
 * The method connects the given card to the CardApplication containing the requested DataSet.
 *
 * @param dataSetName Name of the DataSet which should be contained in the application to connect.
 * @param handle ConnectionHandle which identifies the card and terminal.
 * @return The handle describing the new state of the card.
 * @throws WSException Thrown in case any of the requested eCard API methods returned an error, or no application of
 *   the specified card contains the requested data set.
 */
@Nonnull
public ConnectionHandleType selectAppByDataSet(@Nonnull String dataSetName, @Nonnull ConnectionHandleType handle) throws WSException {
    // copy handle so that the given handle is not damaged
    handle = HandlerUtils.copyHandle(handle);
    // get all card applications
    CardApplicationList cardApps = new CardApplicationList();
    cardApps.setConnectionHandle(handle);
    CardApplicationListResponse cardAppsResp = (CardApplicationListResponse) dispatcher.safeDeliver(cardApps);
    WSHelper.checkResult(cardAppsResp);
    List<byte[]> cardApplications = cardAppsResp.getCardApplicationNameList().getCardApplicationName();
    // check if our data set is in any of the applications
    for (byte[] app : cardApplications) {
        DataSetList dataSetListReq = new DataSetList();
        handle.setCardApplication(app);
        dataSetListReq.setConnectionHandle(handle);
        DataSetListResponse dataSetListResp = (DataSetListResponse) dispatcher.safeDeliver(dataSetListReq);
        WSHelper.checkResult(dataSetListResp);
        if (dataSetListResp.getDataSetNameList().getDataSetName().contains(dataSetName)) {
            handle = selectApplication(app, handle);
            return handle;
        }
    }
    // data set not found
    String msg = "Failed to find the requested data set (%s) in any of the applications of the specified card.";
    msg = String.format(msg, dataSetName);
    Result r = WSHelper.makeResultError(ECardConstants.Minor.SAL.FILE_NOT_FOUND, msg);
    throw WSHelper.createException(r);
}
Also used : CardApplicationListResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationListResponse) DataSetListResponse(iso.std.iso_iec._24727.tech.schema.DataSetListResponse) CardApplicationList(iso.std.iso_iec._24727.tech.schema.CardApplicationList) DataSetList(iso.std.iso_iec._24727.tech.schema.DataSetList) Result(oasis.names.tc.dss._1_0.core.schema.Result) Nonnull(javax.annotation.Nonnull)

Aggregations

DataSetListResponse (iso.std.iso_iec._24727.tech.schema.DataSetListResponse)9 DataSetList (iso.std.iso_iec._24727.tech.schema.DataSetList)8 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)6 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)6 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)6 CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)6 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)6 Test (org.testng.annotations.Test)6 DSIList (iso.std.iso_iec._24727.tech.schema.DSIList)3 DSIListResponse (iso.std.iso_iec._24727.tech.schema.DSIListResponse)3 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)2 DataSetNameListType (iso.std.iso_iec._24727.tech.schema.DataSetNameListType)2 AccessControlListType (iso.std.iso_iec._24727.tech.schema.AccessControlListType)1 CardApplicationList (iso.std.iso_iec._24727.tech.schema.CardApplicationList)1 CardApplicationListResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationListResponse)1 DSICreate (iso.std.iso_iec._24727.tech.schema.DSICreate)1 DSICreateResponse (iso.std.iso_iec._24727.tech.schema.DSICreateResponse)1 DSIDelete (iso.std.iso_iec._24727.tech.schema.DSIDelete)1 DSIDeleteResponse (iso.std.iso_iec._24727.tech.schema.DSIDeleteResponse)1 DataSetCreate (iso.std.iso_iec._24727.tech.schema.DataSetCreate)1