Search in sources :

Example 91 with ConnectionHandleType

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

Example 92 with ConnectionHandleType

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

Example 93 with ConnectionHandleType

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

the class AndroidMarshallerTest method testConversionOfStartPAOS.

@Test
public void testConversionOfStartPAOS() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    StartPAOS startP = new StartPAOS();
    startP.setSessionIdentifier("5ec5ebb1dd254f392e6ca33cf5bf");
    ConnectionHandleType connectionHandleType = new ConnectionHandleType();
    connectionHandleType.setContextHandle(new BigInteger("94D7439CE657561E7AE3D491FD71AC21F8BCBB5608BA61F5A0EA52269BC01250", 16).toByteArray());
    connectionHandleType.setSlotHandle(new BigInteger("EEB49368C1152BEC379DA59356D59039CA7757AC3EAF9430285F2CBB3DD6EDDD", 16).toByteArray());
    connectionHandleType.setIFDName("Name of IFD");
    connectionHandleType.setSlotIndex(new BigInteger("0"));
    connectionHandleType.setCardApplication(new byte[] { 0x0, 0x0, 0x0 });
    ChannelHandleType channelHandle = new ChannelHandleType();
    channelHandle.setSessionIdentifier("sessionID");
    connectionHandleType.setChannelHandle(channelHandle);
    RecognitionInfo recognitionInfo = new RecognitionInfo();
    recognitionInfo.setCardType("nPA_1-0-0.xml");
    connectionHandleType.setRecognitionInfo(recognitionInfo);
    startP.getConnectionHandle().add(connectionHandleType);
    Document d = m.marshal(startP);
    assertEquals(m.doc2str(d), START_PAOS);
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) StartPAOS(iso.std.iso_iec._24727.tech.schema.StartPAOS) RecognitionInfo(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) BigInteger(java.math.BigInteger) ChannelHandleType(iso.std.iso_iec._24727.tech.schema.ChannelHandleType) Document(org.w3c.dom.Document) Test(org.testng.annotations.Test)

Example 94 with ConnectionHandleType

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

the class InsertCardDialog method show.

/**
 * Shows this InsertCardDialog dialog.
 *
 * @return The ConnectionHandle of the inserted card or null if no card was inserted.
 */
public List<ConnectionHandleType> show() {
    List<ConnectionHandleType> availableCards = checkAlreadyAvailable();
    if (!availableCards.isEmpty()) {
        return availableCards;
    } else {
        InsertCardStepAction insertCardAction = new InsertCardStepAction(STEP_ID, cardStates, cardNameAndType.values());
        evDispatcher.add(insertCardAction, EventType.CARD_RECOGNIZED);
        UserConsentNavigator ucr = gui.obtainNavigator(createInsertCardUserConsent(insertCardAction));
        ExecutionEngine exec = new ExecutionEngine(ucr);
        // run gui
        ResultStatus status = exec.process();
        if (status == ResultStatus.CANCEL) {
            return null;
        }
        evDispatcher.del(insertCardAction);
        return insertCardAction.getResponse();
    }
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) ExecutionEngine(org.openecard.gui.executor.ExecutionEngine) ResultStatus(org.openecard.gui.ResultStatus) UserConsentNavigator(org.openecard.gui.UserConsentNavigator)

Example 95 with ConnectionHandleType

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

the class InsertCardDialog method checkAlreadyAvailable.

/**
 * Check whether there are already cards with the required type(s) are available.
 *
 * @return A list containing {@link ConnectionHandleType} objects referencing the cards which fit the requirements or
 * an empty list if there are no cards which met the requirements are present.
 */
private List<ConnectionHandleType> checkAlreadyAvailable() {
    List<ConnectionHandleType> handlesList = new ArrayList<>();
    for (String type : cardNameAndType.values()) {
        ConnectionHandleType conHandle = new ConnectionHandleType();
        ConnectionHandleType.RecognitionInfo recInfo = new ConnectionHandleType.RecognitionInfo();
        recInfo.setCardType(type);
        conHandle.setRecognitionInfo(recInfo);
        Set<CardStateEntry> entries = cardStates.getMatchingEntries(conHandle);
        if (!entries.isEmpty()) {
            handlesList.add(entries.iterator().next().handleCopy());
        }
    }
    return handlesList;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) ArrayList(java.util.ArrayList)

Aggregations

ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)110 CardStateEntry (org.openecard.common.sal.state.CardStateEntry)47 ECardException (org.openecard.common.ECardException)43 IncorrectParameterException (org.openecard.common.sal.exception.IncorrectParameterException)37 ThreadTerminateException (org.openecard.common.ThreadTerminateException)36 NamedEntityNotFoundException (org.openecard.common.sal.exception.NamedEntityNotFoundException)34 UnknownProtocolException (org.openecard.common.sal.exception.UnknownProtocolException)34 TLVException (org.openecard.common.tlv.TLVException)29 AddonNotFoundException (org.openecard.addon.AddonNotFoundException)28 InappropriateProtocolForActionException (org.openecard.common.sal.exception.InappropriateProtocolForActionException)28 NameExistsException (org.openecard.common.sal.exception.NameExistsException)28 PrerequisitesNotSatisfiedException (org.openecard.common.sal.exception.PrerequisitesNotSatisfiedException)28 SecurityConditionNotSatisfiedException (org.openecard.common.sal.exception.SecurityConditionNotSatisfiedException)28 UnknownConnectionHandleException (org.openecard.common.sal.exception.UnknownConnectionHandleException)28 DIDStructureType (iso.std.iso_iec._24727.tech.schema.DIDStructureType)22 Publish (org.openecard.common.interfaces.Publish)17 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)15 ArrayList (java.util.ArrayList)15 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)14 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)14