Search in sources :

Example 11 with Connect

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

the class TinySALTest method testCardApplicationList.

/**
 * Test of cardApplicationList method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationList() {
    System.out.println("cardApplicationList");
    // get path to root
    CardApplicationPath cardApplicationPath = new CardApplicationPath();
    CardApplicationPathType cardApplicationPathType = new CardApplicationPathType();
    cardApplicationPathType.setCardApplication(appIdentifier_ROOT);
    cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
    CardApplicationPathResponse cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
    // connect to root
    CardApplicationConnect cardApplicationConnect = new CardApplicationConnect();
    cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
    CardApplicationConnectResponse result = instance.cardApplicationConnect(cardApplicationConnect);
    assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
    CardApplicationList cardApplicationList = new CardApplicationList();
    cardApplicationList.setConnectionHandle(result.getConnectionHandle());
    CardApplicationListResponse cardApplicationListResponse = instance.cardApplicationList(cardApplicationList);
    System.out.println(cardApplicationListResponse.getResult().getResultMinor());
    assertEquals(ECardConstants.Major.OK, cardApplicationListResponse.getResult().getResultMajor());
    assertTrue(cardApplicationListResponse.getCardApplicationNameList().getCardApplicationName().size() > 0);
    // test non existent connectionhandle
    cardApplicationList = new CardApplicationList();
    cardApplicationList.setConnectionHandle(result.getConnectionHandle());
    cardApplicationList.getConnectionHandle().setIFDName("invalid");
    cardApplicationListResponse = instance.cardApplicationList(cardApplicationList);
    assertEquals(ECardConstants.Major.ERROR, cardApplicationListResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, cardApplicationListResponse.getResult().getResultMinor());
    // test nullpointer
    cardApplicationList = new CardApplicationList();
    cardApplicationList.setConnectionHandle(null);
    cardApplicationListResponse = instance.cardApplicationList(cardApplicationList);
    assertEquals(ECardConstants.Major.ERROR, cardApplicationListResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, cardApplicationListResponse.getResult().getResultMinor());
}
Also used : CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) CardApplicationListResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationListResponse) 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) CardApplicationList(iso.std.iso_iec._24727.tech.schema.CardApplicationList) Test(org.testng.annotations.Test)

Example 12 with Connect

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

the class TinySALTest method testCardApplicationServiceList.

/**
 * Test of cardApplicationServiceList method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationServiceList() {
    System.out.println("cardApplicationServiceList");
    CardApplicationServiceList parameters = new CardApplicationServiceList();
    // 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());
    CardApplicationServiceListResponse resultServiceList = instance.cardApplicationServiceList(parameters);
    CardApplicationServiceNameList cardApplicationServiceNameList = resultServiceList.getCardApplicationServiceNameList();
    assertEquals(ECardConstants.Major.OK, resultServiceList.getResult().getResultMajor());
    assertTrue(cardApplicationServiceNameList.getCardApplicationServiceName().isEmpty());
}
Also used : CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) CardApplicationServiceList(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceList) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) CardApplicationServiceListResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceListResponse) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) CardApplicationServiceNameList(iso.std.iso_iec._24727.tech.schema.CardApplicationServiceListResponse.CardApplicationServiceNameList) Test(org.testng.annotations.Test)

Example 13 with Connect

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

the class TinySALTest method testCardApplicationConnect.

/**
 * Test of cardApplicationConnect method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationConnect() {
    System.out.println("cardApplicationConnect");
    // 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());
    // test non existent card application path
    cardApplicationConnect = new CardApplicationConnect();
    CardApplicationPathType wrongCardApplicationPath = cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0);
    wrongCardApplicationPath.setCardApplication(new byte[] { 0x12, 0x23, 0x34 });
    cardApplicationConnect.setCardApplicationPath(wrongCardApplicationPath);
    result = instance.cardApplicationConnect(cardApplicationConnect);
    assertEquals(ECardConstants.Major.ERROR, result.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, result.getResult().getResultMinor());
    // test nullpointer
    cardApplicationConnect = new CardApplicationConnect();
    cardApplicationConnect.setCardApplicationPath(null);
    result = instance.cardApplicationConnect(cardApplicationConnect);
    assertEquals(ECardConstants.Major.ERROR, result.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, result.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) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) Test(org.testng.annotations.Test)

Example 14 with Connect

use of iso.std.iso_iec._24727.tech.schema.Connect 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 15 with Connect

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

the class TinySALTest method testCardApplicationDelete.

/**
 * Test of cardApplicationDelete method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationDelete() {
    System.out.println("cardApplicationDelete");
    Set<CardStateEntry> cHandles = states.getMatchingEntries(new ConnectionHandleType());
    byte[] appName = { (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74 };
    CardApplicationDelete parameters = new CardApplicationDelete();
    parameters.setConnectionHandle(cHandles.iterator().next().handleCopy());
    parameters.setCardApplicationName(appName);
    CardApplicationDeleteResponse result = instance.cardApplicationDelete(parameters);
    assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
    // 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 resultConnect = instance.cardApplicationConnect(cardApplicationConnect);
    assertEquals(ECardConstants.Major.OK, resultConnect.getResult().getResultMajor());
    CardApplicationList cardApplicationList = new CardApplicationList();
    cardApplicationList.setConnectionHandle(cHandles.iterator().next().handleCopy());
    CardApplicationListResponse cardApplicationListResponse = instance.cardApplicationList(cardApplicationList);
    Iterator<byte[]> it = cardApplicationListResponse.getCardApplicationNameList().getCardApplicationName().iterator();
    boolean appFound = false;
    try {
        while (it.hasNext()) {
            byte[] val = it.next();
            if (Arrays.equals(val, appName)) {
                appFound = true;
            }
        }
        assertTrue(!appFound);
    } catch (Exception e) {
        assertTrue(!appFound);
        System.out.println(e);
    }
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) CardApplicationList(iso.std.iso_iec._24727.tech.schema.CardApplicationList) SkipException(org.testng.SkipException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) CardApplicationDelete(iso.std.iso_iec._24727.tech.schema.CardApplicationDelete) CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) CardApplicationListResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationListResponse) CardApplicationDeleteResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationDeleteResponse) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) Test(org.testng.annotations.Test)

Aggregations

CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)27 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)27 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)25 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)24 CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)24 Test (org.testng.annotations.Test)23 Connect (iso.std.iso_iec._24727.tech.schema.Connect)11 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)10 DataSetList (iso.std.iso_iec._24727.tech.schema.DataSetList)7 DataSetListResponse (iso.std.iso_iec._24727.tech.schema.DataSetListResponse)7 EstablishContext (iso.std.iso_iec._24727.tech.schema.EstablishContext)7 ListIFDs (iso.std.iso_iec._24727.tech.schema.ListIFDs)7 ConnectResponse (iso.std.iso_iec._24727.tech.schema.ConnectResponse)6 CardApplicationList (iso.std.iso_iec._24727.tech.schema.CardApplicationList)5 CardApplicationListResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationListResponse)5 CardApplicationDisconnect (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnect)4 EstablishChannel (iso.std.iso_iec._24727.tech.schema.EstablishChannel)4 EstablishChannelResponse (iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse)4 BeginTransaction (iso.std.iso_iec._24727.tech.schema.BeginTransaction)3 BeginTransactionResponse (iso.std.iso_iec._24727.tech.schema.BeginTransactionResponse)3