Search in sources :

Example 6 with Disconnect

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

the class CardSelectionAction method updateCards.

/**
 * Update the list of available and fitting cards.
 */
private void updateCards() {
    avCard.clear();
    CardApplicationPath cap = new CardApplicationPath();
    cap.setCardAppPathRequest(new CardApplicationPathType());
    CardApplicationPathResponse resp = (CardApplicationPathResponse) ctx.getDispatcher().safeDeliver(cap);
    List<CardApplicationPathType> cards = resp.getCardAppPathResultSet().getCardApplicationPathResult();
    for (CardApplicationPathType path : cards) {
        CardApplicationConnect connect = new CardApplicationConnect();
        connect.setCardApplicationPath(path);
        CardApplicationConnectResponse conResp = (CardApplicationConnectResponse) ctx.getDispatcher().safeDeliver(connect);
        if (types.contains(conResp.getConnectionHandle().getRecognitionInfo().getCardType())) {
            avCard.add(conResp.getConnectionHandle());
        } else {
            CardApplicationDisconnect disconnect = new CardApplicationDisconnect();
            disconnect.setConnectionHandle(conResp.getConnectionHandle());
            ctx.getDispatcher().safeDeliver(disconnect);
        }
    }
}
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) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)

Example 7 with Disconnect

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

the class GetCardsAndPINStatusAction method execute.

@Override
public void execute() {
    // check if a german identity card is inserted, if not wait for it
    ConnectionHandleType cHandle = waitForCardType(GERMAN_IDENTITY_CARD);
    if (cHandle == null) {
        LOG.debug("User cancelled card insertion.");
        return;
    }
    cHandle = connectToRootApplication(cHandle);
    RecognizedState pinState = recognizeState(cHandle);
    boolean nativePace;
    try {
        nativePace = genericPACESupport(cHandle);
    } catch (WSException e) {
        LOG.error("Could not get capabilities from reader.");
        return;
    }
    PINDialog uc = new PINDialog(gui, dispatcher, cHandle, pinState, !nativePace);
    uc.show();
    Disconnect d = new Disconnect();
    d.setSlotHandle(cHandle.getSlotHandle());
    dispatcher.safeDeliver(d);
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) PINDialog(org.openecard.plugins.pinplugin.gui.PINDialog) Disconnect(iso.std.iso_iec._24727.tech.schema.Disconnect) WSException(org.openecard.common.WSHelper.WSException)

Example 8 with Disconnect

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

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

the class AndroidMarshallerTest method testConversionOfDisconnect.

@Test
public void testConversionOfDisconnect() throws Exception {
    WSMarshaller m = new AndroidMarshaller();
    Object o = m.unmarshal(m.str2doc(DISCONNECT));
    if (!(o instanceof Disconnect)) {
        throw new Exception("Object should be an instace of EstablishContext");
    }
    Disconnect d = (Disconnect) o;
    assertEquals(d.getSlotHandle(), StringUtils.toByteArray("1D8EFC10F063FB6FE8A3BBF8D2E0CA5C"));
    assertEquals(d.getAction(), ActionType.EJECT);
}
Also used : Disconnect(iso.std.iso_iec._24727.tech.schema.Disconnect) WSMarshaller(org.openecard.ws.marshal.WSMarshaller) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 10 with Disconnect

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

the class CardRecognitionImpl method recognizeCard.

/**
 * Recognizes the card in the defined reader.
 *
 * @param ctx Context handle of the IFD.
 * @param ifdName Name of the card reader.
 * @param slot Index of the slot in the reader.
 * @return RecognitionInfo structure containing the card type of the detected card or {@code null} if no card could
 *   be detected.
 * @throws RecognitionException Thrown in case there was an error in the recognition.
 */
@Nullable
@Override
public RecognitionInfo recognizeCard(byte[] ctx, String ifdName, BigInteger slot) throws RecognitionException {
    // connect card
    byte[] slotHandle = connect(ctx, ifdName, slot);
    // recognise card
    String type = treeCalls(slotHandle, getTree().getCardCall());
    // disconnect and return
    disconnect(slotHandle);
    // build result or throw exception if it is null or unsupported
    if (type == null || !isSupportedCard(type)) {
        return null;
    }
    RecognitionInfo info = new RecognitionInfo();
    info.setCardType(type);
    return info;
}
Also used : RecognitionInfo(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType.RecognitionInfo) Nullable(javax.annotation.Nullable)

Aggregations

CardApplicationDisconnect (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnect)10 Disconnect (iso.std.iso_iec._24727.tech.schema.Disconnect)10 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)9 CardApplicationConnect (iso.std.iso_iec._24727.tech.schema.CardApplicationConnect)5 CardApplicationConnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)5 CardApplicationPath (iso.std.iso_iec._24727.tech.schema.CardApplicationPath)5 CardApplicationPathResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationPathResponse)5 CardApplicationPathType (iso.std.iso_iec._24727.tech.schema.CardApplicationPathType)5 DisconnectResponse (iso.std.iso_iec._24727.tech.schema.DisconnectResponse)5 CardApplicationDisconnectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationDisconnectResponse)4 DestroyChannel (iso.std.iso_iec._24727.tech.schema.DestroyChannel)4 EstablishChannelResponse (iso.std.iso_iec._24727.tech.schema.EstablishChannelResponse)4 IOException (java.io.IOException)4 EndTransaction (iso.std.iso_iec._24727.tech.schema.EndTransaction)3 EndTransactionResponse (iso.std.iso_iec._24727.tech.schema.EndTransactionResponse)3 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)3 ThreadTerminateException (org.openecard.common.ThreadTerminateException)3 BeginTransaction (iso.std.iso_iec._24727.tech.schema.BeginTransaction)2 BeginTransactionResponse (iso.std.iso_iec._24727.tech.schema.BeginTransactionResponse)2 ChannelHandleType (iso.std.iso_iec._24727.tech.schema.ChannelHandleType)2