Search in sources :

Example 21 with CardApplicationPath

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

the class TinySALTest method testCardApplicationServiceDescribe.

/**
 * Test of cardApplicationServiceDescribe method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationServiceDescribe() {
    System.out.println("cardApplicationServiceDescribe");
    CardApplicationServiceDescribe parameters = new CardApplicationServiceDescribe();
    // get path to esign
    CardApplicationPath cardApplicationPath = new CardApplicationPath();
    CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
    cardApplicationPathType.setCardApplication(appIdentifier_ESIGN);
    cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
    CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
    assertTrue(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().size() > 0);
    assertEquals(cardApplicationPathResponse.getResult().getResultMajor(), ECardConstants.Major.OK);
    // 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());
    assertEquals(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
    parameters.setConnectionHandle(result.getConnectionHandle());
    parameters.setCardApplicationServiceName("testService");
    CardApplicationServiceDescribeResponse resultServiceDescribe = instance.cardApplicationServiceDescribe(parameters);
    assertEquals(ECardConstants.Major.OK, resultServiceDescribe.getResult().getResultMajor());
}
Also used : CardApplicationServiceDescribe(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceDescribe) CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) CardApplicationServiceDescribeResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceDescribeResponse) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) Test(org.testng.annotations.Test)

Example 22 with CardApplicationPath

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

the class TinySALTest method testDsiRead.

/**
 * Test of dsiRead method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testDsiRead() {
    System.out.println("dsiRead");
    // test normal case
    // get esign path
    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());
    assertEquals(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
    // read EF.C.CH.AUT
    DSIRead dsiRead = new DSIRead();
    dsiRead.setConnectionHandle(result.getConnectionHandle());
    dsiRead.setDSIName("EF.C.CH.AUT");
    DSIReadResponse dsiReadResponse = instance.dsiRead(dsiRead);
    System.out.println(dsiReadResponse.getResult().getResultMinor());
    assertEquals(ECardConstants.Major.OK, dsiReadResponse.getResult().getResultMajor());
    System.out.println(dsiReadResponse.getResult().getResultMinor());
    assertTrue(dsiReadResponse.getDSIContent().length > 0);
    // test connectionhandle == null
    dsiRead = new DSIRead();
    dsiRead.setConnectionHandle(null);
    dsiRead.setDSIName("EF.C.CH.AUT");
    dsiReadResponse = instance.dsiRead(dsiRead);
    assertEquals(ECardConstants.Major.ERROR, dsiReadResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dsiReadResponse.getResult().getResultMinor());
    // test dsiName == null
    dsiRead = new DSIRead();
    dsiRead.setConnectionHandle(result.getConnectionHandle());
    dsiRead.setDSIName(null);
    dsiReadResponse = instance.dsiRead(dsiRead);
    assertEquals(ECardConstants.Major.ERROR, dsiReadResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dsiReadResponse.getResult().getResultMinor());
    // test dsiName invalid
    dsiRead = new DSIRead();
    dsiRead.setConnectionHandle(result.getConnectionHandle());
    dsiRead.setDSIName("INVALID");
    dsiReadResponse = instance.dsiRead(dsiRead);
    assertEquals(ECardConstants.Major.ERROR, dsiReadResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.SAL.NAMED_ENTITY_NOT_FOUND, dsiReadResponse.getResult().getResultMinor());
    // test security condition not satisfied
    dsiRead = new DSIRead();
    dsiRead.setConnectionHandle(result.getConnectionHandle());
    dsiRead.setDSIName("EF.C.CH.AUTN");
    dsiReadResponse = instance.dsiRead(dsiRead);
    assertEquals(ECardConstants.Major.ERROR, dsiReadResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.SAL.SECURITY_CONDITION_NOT_SATISFIED, dsiReadResponse.getResult().getResultMinor());
    // test invalid connectionhandle
    dsiRead = new DSIRead();
    dsiRead.setConnectionHandle(result.getConnectionHandle());
    dsiRead.getConnectionHandle().setIFDName("invalid");
    dsiRead.setDSIName(null);
    dsiReadResponse = instance.dsiRead(dsiRead);
    assertEquals(ECardConstants.Major.ERROR, dsiReadResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, dsiReadResponse.getResult().getResultMinor());
}
Also used : CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) DSIRead(iso.std.iso_iec._24727.tech.schema.DSIRead) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) DSIReadResponse(iso.std.iso_iec._24727.tech.schema.DSIReadResponse) Test(org.testng.annotations.Test)

Example 23 with CardApplicationPath

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

Example 24 with CardApplicationPath

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

the class TinySALTest method testDidGet.

/**
 * Test of didGet method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testDidGet() {
    System.out.println("didGet");
    // 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());
    DIDList didList = new DIDList();
    didList.setConnectionHandle(result.getConnectionHandle());
    DIDQualifierType didQualifier = new DIDQualifierType();
    didQualifier.setApplicationIdentifier(appIdentifier_ESIGN);
    didQualifier.setObjectIdentifier("urn:oid:1.3.162.15480.3.0.25");
    didQualifier.setApplicationFunction("Compute-signature");
    didList.setFilter(didQualifier);
    DIDListResponse didListResponse = instance.didList(didList);
    Assert.assertTrue(didListResponse.getDIDNameList().getDIDName().size() > 0);
    assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
    String didName = didListResponse.getDIDNameList().getDIDName().get(0);
    DIDGet parameters = new DIDGet();
    parameters.setDIDName(didName);
    parameters.setConnectionHandle(result.getConnectionHandle());
    DIDGetResponse resultDIDGet = instance.didGet(parameters);
    assertEquals(ECardConstants.Major.OK, resultDIDGet.getResult().getResultMajor());
    assertTrue(resultDIDGet.getDIDStructure() != null);
}
Also used : CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) DIDList(iso.std.iso_iec._24727.tech.schema.DIDList) DIDQualifierType(iso.std.iso_iec._24727.tech.schema.DIDQualifierType) DIDGet(iso.std.iso_iec._24727.tech.schema.DIDGet) DIDGetResponse(iso.std.iso_iec._24727.tech.schema.DIDGetResponse) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) DIDListResponse(iso.std.iso_iec._24727.tech.schema.DIDListResponse) Test(org.testng.annotations.Test)

Example 25 with CardApplicationPath

use of iso.std.iso_iec._24727.tech.schema.CardApplicationPath 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());
}
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) 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) DataSetSelect(iso.std.iso_iec._24727.tech.schema.DataSetSelect) DataSetSelectResponse(iso.std.iso_iec._24727.tech.schema.DataSetSelectResponse) Test(org.testng.annotations.Test)

Aggregations

CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)35 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)35 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)34 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)33 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)33 Test (org.testng.annotations.Test)26 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)9 DIDAuthenticate (iso.std.iso_iec._24727.tech.schema.DIDAuthenticate)6 DIDAuthenticateResponse (iso.std.iso_iec._24727.tech.schema.DIDAuthenticateResponse)6 DIDGet (iso.std.iso_iec._24727.tech.schema.DIDGet)6 DIDGetResponse (iso.std.iso_iec._24727.tech.schema.DIDGetResponse)6 DIDList (iso.std.iso_iec._24727.tech.schema.DIDList)6 DIDListResponse (iso.std.iso_iec._24727.tech.schema.DIDListResponse)6 DIDQualifierType (iso.std.iso_iec._24727.tech.schema.DIDQualifierType)6 DataSetList (iso.std.iso_iec._24727.tech.schema.DataSetList)6 DataSetListResponse (iso.std.iso_iec._24727.tech.schema.DataSetListResponse)6 CardApplicationDisconnect (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnect)5 CardAppPathResultSet (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse.CardAppPathResultSet)5 CryptoMarkerType (iso.std.iso_iec._24727.tech.schema.CryptoMarkerType)4 CardApplicationDisconnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnectResponse)3