Search in sources :

Example 1 with DataSetList

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

Example 2 with DataSetList

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

Example 3 with DataSetList

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

the class DidInfos method getDataSetNames.

List<String> getDataSetNames(byte[] application) throws WSHelper.WSException {
    DataSetList req = new DataSetList();
    req.setConnectionHandle(getHandle(application));
    DataSetListResponse res = (DataSetListResponse) dispatcher.safeDeliver(req);
    WSHelper.checkResult(res);
    DataSetNameListType listWrapper = res.getDataSetNameList();
    List<String> datasetNames;
    if (listWrapper != null && listWrapper.getDataSetName() != null) {
        datasetNames = Collections.unmodifiableList(listWrapper.getDataSetName());
    } else {
        datasetNames = Collections.emptyList();
    }
    return datasetNames;
}
Also used : DataSetListResponse(iso.std.iso_iec._24727.tech.schema.DataSetListResponse) DataSetList(iso.std.iso_iec._24727.tech.schema.DataSetList) DataSetNameListType(iso.std.iso_iec._24727.tech.schema.DataSetNameListType)

Example 4 with DataSetList

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

the class TinySAL method dataSetList.

/**
 * The DataSetList function returns the list of the data sets in the card application addressed with the
 * ConnectionHandle.
 * See BSI-TR-03112-4, version 1.1.2, section 3.4.1.
 *
 * @param request DataSetList
 * @return DataSetListResponse
 */
@Publish
@Override
public DataSetListResponse dataSetList(DataSetList request) {
    DataSetListResponse response = WSHelper.makeResponse(DataSetListResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType connectionHandle = SALUtils.getConnectionHandle(request);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle, false);
        byte[] cardApplicationID = connectionHandle.getCardApplication();
        Assert.securityConditionApplication(cardStateEntry, cardApplicationID, NamedDataServiceActionName.DATA_SET_LIST);
        CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
        DataSetNameListType dataSetNameList = cardInfoWrapper.getDataSetNameList(cardApplicationID);
        response.setDataSetNameList(dataSetNameList);
    } 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) ECardException(org.openecard.common.ECardException) DataSetListResponse(iso.std.iso_iec._24727.tech.schema.DataSetListResponse) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CardInfoWrapper(org.openecard.common.sal.state.cif.CardInfoWrapper) DataSetNameListType(iso.std.iso_iec._24727.tech.schema.DataSetNameListType) 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) Publish(org.openecard.common.interfaces.Publish)

Example 5 with DataSetList

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

the class TinySALTest method testDataSetCreate.

/**
 * Test of dataSetCreate method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testDataSetCreate() {
    System.out.println("dataSetCreate");
    DataSetCreate parameters = new DataSetCreate();
    // 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());
    AccessControlListType accessControlList = new AccessControlListType();
    parameters.setConnectionHandle(result.getConnectionHandle());
    String dataSetName = "DataSetTest";
    parameters.setDataSetName(dataSetName);
    parameters.setDataSetACL(accessControlList);
    DataSetCreateResponse resultDataSetCreate = instance.dataSetCreate(parameters);
    assertEquals(ECardConstants.Major.OK, resultDataSetCreate.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 : DataSetCreateResponse(iso.std.iso_iec._24727.tech.schema.DataSetCreateResponse) DataSetCreate(iso.std.iso_iec._24727.tech.schema.DataSetCreate) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) AccessControlListType(iso.std.iso_iec._24727.tech.schema.AccessControlListType) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) 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) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) DataSetList(iso.std.iso_iec._24727.tech.schema.DataSetList) Test(org.testng.annotations.Test)

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