Search in sources :

Example 1 with CardApplicationPathResponse

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

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

the class TinySALTest method testCardApplicationCreate.

/**
 * Test of cardApplicationCreate method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationCreate() {
    System.out.println("cardApplicationCreate");
    Set<CardStateEntry> cHandles = states.getMatchingEntries(new ConnectionHandleType());
    byte[] appName = { (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74 };
    CardApplicationCreate parameters = new CardApplicationCreate();
    parameters.setConnectionHandle(cHandles.iterator().next().handleCopy());
    parameters.setCardApplicationName(appName);
    AccessControlListType cardApplicationACL = new AccessControlListType();
    parameters.setCardApplicationACL(cardApplicationACL);
    CardApplicationCreateResponse result = instance.cardApplicationCreate(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) AccessControlListType(iso.std.iso_iec._24727.tech.schema.AccessControlListType) CardApplicationCreateResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationCreateResponse) 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) 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) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) CardApplicationCreate(iso.std.iso_iec._24727.tech.schema.CardApplicationCreate) Test(org.testng.annotations.Test)

Example 3 with CardApplicationPathResponse

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

the class TinySALTest method testDidList.

/**
 * Test of didList method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testDidList() {
    System.out.println("didList");
    // 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());
    // get path to root
    cardApplicationPath = new CardApplicationPath();
    cardApplicationPathType = new CardApplicationPathType();
    cardApplicationPathType.setCardApplication(appIdentifier_ROOT);
    cardApplicationPath.setCardAppPathRequest(cardApplicationPathType);
    cardApplicationPathResponse = instance.cardApplicationPath(cardApplicationPath);
    // connect to root
    cardApplicationConnect = new CardApplicationConnect();
    cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
    cardApplicationConnect.getCardApplicationPath().setCardApplication(appIdentifier_ROOT);
    result = instance.cardApplicationConnect(cardApplicationConnect);
    assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
    didList = new DIDList();
    didList.setConnectionHandle(result.getConnectionHandle());
    didQualifier = new DIDQualifierType();
    didQualifier.setApplicationIdentifier(appIdentifier_ROOT);
    didQualifier.setObjectIdentifier("urn:oid:1.3.162.15480.3.0.25");
    didQualifier.setApplicationFunction("Compute-signature");
    didList.setFilter(didQualifier);
    didListResponse = instance.didList(didList);
    // we expect 0 because of the filter
    Assert.assertEquals(didListResponse.getDIDNameList().getDIDName().size(), 0);
    assertEquals(ECardConstants.Major.OK, didListResponse.getResult().getResultMajor());
    // test null connectionhandle
    didList = new DIDList();
    didList.setConnectionHandle(null);
    didListResponse = instance.didList(didList);
    assertEquals(ECardConstants.Major.ERROR, didListResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, didListResponse.getResult().getResultMinor());
    // test invalid connectionhandle
    didList = new DIDList();
    didList.setConnectionHandle(result.getConnectionHandle());
    didList.getConnectionHandle().setIFDName("invalid");
    didListResponse = instance.didList(didList);
    assertEquals(ECardConstants.Major.ERROR, didListResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, didListResponse.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) DIDList(iso.std.iso_iec._24727.tech.schema.DIDList) DIDQualifierType(iso.std.iso_iec._24727.tech.schema.DIDQualifierType) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) DIDListResponse(iso.std.iso_iec._24727.tech.schema.DIDListResponse) Test(org.testng.annotations.Test)

Example 4 with CardApplicationPathResponse

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

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

Aggregations

CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)35 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)34 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)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