Search in sources :

Example 26 with Connect

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

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

the class TinySALTest method testAclList.

/**
 * Test of aclList method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testAclList() {
    System.out.println("aclList");
    // 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());
    ACLList aclList = new ACLList();
    aclList.setConnectionHandle(result.getConnectionHandle());
    TargetNameType targetName = new TargetNameType();
    targetName.setCardApplicationName(appIdentifier_ESIGN);
    aclList.setTargetName(targetName);
    ACLListResponse aclListResponse = instance.aclList(aclList);
    assertEquals(aclListResponse.getResult().getResultMajor(), ECardConstants.Major.OK);
    assertTrue(aclListResponse.getTargetACL().getAccessRule().size() > 0);
    // test null connectionhandle
    aclList = new ACLList();
    aclList.setConnectionHandle(null);
    targetName = new TargetNameType();
    targetName.setCardApplicationName(appIdentifier_ESIGN);
    aclList.setTargetName(targetName);
    aclListResponse = instance.aclList(aclList);
    assertEquals(ECardConstants.Major.ERROR, aclListResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, aclListResponse.getResult().getResultMinor());
    // test missing targetname
    aclList = new ACLList();
    aclList.setConnectionHandle(null);
    targetName = new TargetNameType();
    aclList.setTargetName(targetName);
    aclListResponse = instance.aclList(aclList);
    assertEquals(ECardConstants.Major.ERROR, aclListResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, aclListResponse.getResult().getResultMinor());
    // test invalid applicationIdentifier
    aclList = new ACLList();
    aclList.setConnectionHandle(result.getConnectionHandle());
    targetName = new TargetNameType();
    targetName.setCardApplicationName(new byte[] { 0x0, 0x0, 0x0 });
    aclList.setTargetName(targetName);
    aclListResponse = instance.aclList(aclList);
    assertEquals(ECardConstants.Major.ERROR, aclListResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.SAL.NAMED_ENTITY_NOT_FOUND, aclListResponse.getResult().getResultMinor());
    // test invalid connectionhandle
    aclList = new ACLList();
    aclList.setConnectionHandle(result.getConnectionHandle());
    aclList.getConnectionHandle().setIFDName("invalid");
    targetName = new TargetNameType();
    targetName.setCardApplicationName(appIdentifier_ESIGN);
    aclList.setTargetName(targetName);
    aclListResponse = instance.aclList(aclList);
    assertEquals(ECardConstants.Major.ERROR, aclListResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, aclListResponse.getResult().getResultMinor());
}
Also used : CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) TargetNameType(iso.std.iso_iec._24727.tech.schema.TargetNameType) CardApplicationPath(iso.std.iso_iec._24727.tech.schema.CardApplicationPath) CardApplicationPathResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse) ACLList(iso.std.iso_iec._24727.tech.schema.ACLList) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) ACLListResponse(iso.std.iso_iec._24727.tech.schema.ACLListResponse) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) Test(org.testng.annotations.Test)

Example 28 with Connect

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

the class TinySALTest method testCardApplicationDisconnect.

/**
 * Test of cardApplicationDisconnect method, of class TinySAL.
 */
@Test(enabled = TESTS_ENABLED)
public void testCardApplicationDisconnect() {
    System.out.println("cardApplicationDisconnect");
    // 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(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
    assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
    // disconnect
    CardApplicationDisconnect cardApplicationDisconnect = new CardApplicationDisconnect();
    cardApplicationDisconnect.setConnectionHandle(result.getConnectionHandle());
    instance.cardApplicationDisconnect(cardApplicationDisconnect);
    assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
    // test invalid connectionhandle
    // connect to esign
    cardApplicationConnect = new CardApplicationConnect();
    cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
    result = instance.cardApplicationConnect(cardApplicationConnect);
    assertEquals(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
    assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
    // disconnect
    cardApplicationDisconnect = new CardApplicationDisconnect();
    cardApplicationDisconnect.setConnectionHandle(result.getConnectionHandle());
    cardApplicationDisconnect.getConnectionHandle().setSlotHandle(new byte[] { 0x0, 0x0, 0x0 });
    CardApplicationDisconnectResponse cardApplicationDisconnectResponse = instance.cardApplicationDisconnect(cardApplicationDisconnect);
    assertEquals(ECardConstants.Major.ERROR, cardApplicationDisconnectResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, cardApplicationDisconnectResponse.getResult().getResultMinor());
    // test nullpointer
    // connect to esign
    cardApplicationConnect = new CardApplicationConnect();
    cardApplicationConnect.setCardApplicationPath(cardApplicationPathResponse.getCardAppPathResultSet().getCardApplicationPathResult().get(0));
    result = instance.cardApplicationConnect(cardApplicationConnect);
    assertEquals(appIdentifier_ESIGN, result.getConnectionHandle().getCardApplication());
    assertEquals(ECardConstants.Major.OK, result.getResult().getResultMajor());
    // disconnect
    cardApplicationDisconnect = new CardApplicationDisconnect();
    cardApplicationDisconnect.setConnectionHandle(null);
    cardApplicationDisconnectResponse = instance.cardApplicationDisconnect(cardApplicationDisconnect);
    assertEquals(ECardConstants.Major.ERROR, cardApplicationDisconnectResponse.getResult().getResultMajor());
    assertEquals(ECardConstants.Minor.App.INCORRECT_PARM, cardApplicationDisconnectResponse.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) CardApplicationDisconnect(iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnect) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) CardApplicationDisconnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnectResponse) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse) Test(org.testng.annotations.Test)

Example 29 with Connect

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

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

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