Search in sources :

Example 1 with CardApplicationSelectResponse

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

the class MiddlewareSAL method cardApplicationSelect.

@Override
public CardApplicationSelectResponse cardApplicationSelect(CardApplicationSelect parameters) {
    CardApplicationSelectResponse response = WSHelper.makeResponse(CardApplicationSelectResponse.class, WSHelper.makeResultOK());
    try {
        ConnectionHandleType handle = SALUtils.createConnectionHandle(parameters.getSlotHandle());
        CardStateEntry entry = states.getEntry(handle);
        Assert.assertConnectionHandle(entry, handle);
        // get fully filled handle
        handle = entry.handleCopy();
        response.setConnectionHandle(handle);
        return response;
    } catch (ECardException ex) {
        response.setResult(ex.getResult());
    }
    return response;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) ECardException(org.openecard.common.ECardException) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CardApplicationSelectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationSelectResponse)

Example 2 with CardApplicationSelectResponse

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

the class TinySAL method cardApplicationSelect.

@Override
public CardApplicationSelectResponse cardApplicationSelect(CardApplicationSelect request) {
    CardApplicationSelectResponse response = WSHelper.makeResponse(CardApplicationSelectResponse.class, WSHelper.makeResultOK());
    try {
        byte[] slotHandle = request.getSlotHandle();
        ConnectionHandleType connectionHandle = SALUtils.createConnectionHandle(slotHandle);
        CardStateEntry cardStateEntry = SALUtils.getCardStateEntry(states, connectionHandle);
        byte[] reqApplicationID = request.getCardApplication();
        Assert.assertIncorrectParameter(reqApplicationID, "The parameter CardApplication is empty.");
        CardInfoWrapper cardInfoWrapper = cardStateEntry.getInfo();
        CardApplicationWrapper appInfo = cardInfoWrapper.getCardApplication(reqApplicationID);
        Assert.assertNamedEntityNotFound(appInfo, "The given Application cannot be found.");
        Assert.securityConditionApplication(cardStateEntry, reqApplicationID, ConnectionServiceActionName.CARD_APPLICATION_CONNECT);
        // check if the currently selected application is already what the caller wants
        byte[] curApplicationID = cardStateEntry.getCurrentCardApplication().getApplicationIdentifier();
        if (!ByteUtils.compare(reqApplicationID, curApplicationID)) {
            // Select the card application
            CardCommandAPDU select;
            // TODO: proper determination of path, file and app id
            if (reqApplicationID.length == 2) {
                select = new Select.File(reqApplicationID);
                List<byte[]> responses = new ArrayList<>();
                responses.add(TrailerConstants.Success.OK());
                responses.add(TrailerConstants.Error.WRONG_P1_P2());
                CardResponseAPDU resp = select.transmit(env.getDispatcher(), slotHandle, responses);
                if (Arrays.equals(resp.getTrailer(), TrailerConstants.Error.WRONG_P1_P2())) {
                    select = new Select.AbsolutePath(reqApplicationID);
                    select.transmit(env.getDispatcher(), slotHandle);
                }
            } else {
                select = new Select.Application(reqApplicationID);
                select.transmit(env.getDispatcher(), slotHandle);
            }
            cardStateEntry.setCurrentCardApplication(reqApplicationID);
            // reset the ef FCP
            cardStateEntry.unsetFCPOfSelectedEF();
        }
        response.setConnectionHandle(cardStateEntry.handleCopy());
    } catch (ECardException e) {
        response.setResult(e.getResult());
    }
    return response;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) CardCommandAPDU(org.openecard.common.apdu.common.CardCommandAPDU) CardStateEntry(org.openecard.common.sal.state.CardStateEntry) CardApplicationSelectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationSelectResponse) CardInfoWrapper(org.openecard.common.sal.state.cif.CardInfoWrapper) ArrayList(java.util.ArrayList) ECardException(org.openecard.common.ECardException) CardApplicationWrapper(org.openecard.common.sal.state.cif.CardApplicationWrapper) Select(org.openecard.common.apdu.Select) CardApplicationSelect(iso.std.iso_iec._24727.tech.schema.CardApplicationSelect) DataSetSelect(iso.std.iso_iec._24727.tech.schema.DataSetSelect) CardResponseAPDU(org.openecard.common.apdu.common.CardResponseAPDU)

Example 3 with CardApplicationSelectResponse

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

the class DidInfos method connectApplication.

public void connectApplication(byte[] application) throws WSHelper.WSException {
    CardApplicationSelect req = new CardApplicationSelect();
    req.setCardApplication(application);
    req.setSlotHandle(handle.getSlotHandle());
    CardApplicationSelectResponse res = (CardApplicationSelectResponse) dispatcher.safeDeliver(req);
    WSHelper.checkResult(res);
}
Also used : CardApplicationSelect(iso.std.iso_iec._24727.tech.schema.CardApplicationSelect) CardApplicationSelectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationSelectResponse)

Aggregations

CardApplicationSelectResponse (iso.std.iso_iec._24727.tech.schema.CardApplicationSelectResponse)3 CardApplicationSelect (iso.std.iso_iec._24727.tech.schema.CardApplicationSelect)2 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)2 ECardException (org.openecard.common.ECardException)2 CardStateEntry (org.openecard.common.sal.state.CardStateEntry)2 DataSetSelect (iso.std.iso_iec._24727.tech.schema.DataSetSelect)1 ArrayList (java.util.ArrayList)1 Select (org.openecard.common.apdu.Select)1 CardCommandAPDU (org.openecard.common.apdu.common.CardCommandAPDU)1 CardResponseAPDU (org.openecard.common.apdu.common.CardResponseAPDU)1 CardApplicationWrapper (org.openecard.common.sal.state.cif.CardApplicationWrapper)1 CardInfoWrapper (org.openecard.common.sal.state.cif.CardInfoWrapper)1