Search in sources :

Example 1 with SlotCapabilityType

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

the class IFD method getIFDCapabilities.

@Override
public GetIFDCapabilitiesResponse getIFDCapabilities(GetIFDCapabilities parameters) {
    GetIFDCapabilitiesResponse response;
    // you thought of a different IFD obviously
    if (!ByteUtils.compare(ctxHandle, parameters.getContextHandle())) {
        String msg = "Invalid context handle specified.";
        Result r = WSHelper.makeResultError(ECardConstants.Minor.IFD.INVALID_CONTEXT_HANDLE, msg);
        response = WSHelper.makeResponse(GetIFDCapabilitiesResponse.class, r);
        return response;
    }
    try {
        TerminalInfo info;
        String ifdName = parameters.getIFDName();
        try {
            SingleThreadChannel channel = cm.openMasterChannel(ifdName);
            info = new TerminalInfo(cm, channel);
        } catch (NoSuchTerminal ex) {
            // continue without a channel
            SCIOTerminal term = cm.getTerminals().getTerminal(ifdName);
            info = new TerminalInfo(cm, term);
        }
        IFDCapabilitiesType cap = new IFDCapabilitiesType();
        // slot capability
        SlotCapabilityType slotCap = info.getSlotCapability();
        cap.getSlotCapability().add(slotCap);
        // ask protocol factory which types it supports
        List<String> protocols = slotCap.getProtocol();
        for (String proto : protocolFactories.protocols()) {
            if (!protocols.contains(proto)) {
                protocols.add(proto);
            }
        }
        // TODO: PIN Compare should be a part of establishChannel and thus just appear in the software protocol list
        if (!protocols.contains(ECardConstants.Protocol.PIN_COMPARE)) {
            protocols.add(ECardConstants.Protocol.PIN_COMPARE);
        }
        // display capability
        DisplayCapabilityType dispCap = info.getDisplayCapability();
        if (dispCap != null) {
            cap.getDisplayCapability().add(dispCap);
        }
        // keypad capability
        KeyPadCapabilityType keyCap = info.getKeypadCapability();
        if (keyCap != null) {
            cap.getKeyPadCapability().add(keyCap);
        }
        // biosensor capability
        BioSensorCapabilityType bioCap = info.getBiosensorCapability();
        if (bioCap != null) {
            cap.getBioSensorCapability().add(bioCap);
        }
        // acoustic and optical elements
        cap.setOpticalSignalUnit(info.isOpticalSignal());
        cap.setAcousticSignalUnit(info.isAcousticSignal());
        // prepare response
        response = WSHelper.makeResponse(GetIFDCapabilitiesResponse.class, WSHelper.makeResultOK());
        response.setIFDCapabilities(cap);
        return response;
    } catch (NullPointerException | NoSuchTerminal ex) {
        String msg = String.format("Requested terminal not found.");
        LOG.warn(msg, ex);
        Result r = WSHelper.makeResultError(ECardConstants.Minor.IFD.Terminal.UNKNOWN_IFD, msg);
        response = WSHelper.makeResponse(GetIFDCapabilitiesResponse.class, r);
        return response;
    } catch (SCIOException ex) {
        String msg = String.format("Failed to request status from terminal.");
        // use debug when card has been removed, as this happens all the time
        SCIOErrorCode code = ex.getCode();
        if (!(code == SCIOErrorCode.SCARD_E_NO_SMARTCARD || code == SCIOErrorCode.SCARD_W_REMOVED_CARD)) {
            LOG.warn(msg, ex);
        } else {
            LOG.debug(msg, ex);
        }
        Result r = WSHelper.makeResultUnknownError(msg);
        response = WSHelper.makeResponse(GetIFDCapabilitiesResponse.class, r);
        return response;
    }
}
Also used : SlotCapabilityType(iso.std.iso_iec._24727.tech.schema.SlotCapabilityType) NoSuchTerminal(org.openecard.common.ifd.scio.NoSuchTerminal) SingleThreadChannel(org.openecard.ifd.scio.wrapper.SingleThreadChannel) SCIOException(org.openecard.common.ifd.scio.SCIOException) SCIOTerminal(org.openecard.common.ifd.scio.SCIOTerminal) DisplayCapabilityType(iso.std.iso_iec._24727.tech.schema.DisplayCapabilityType) IFDCapabilitiesType(iso.std.iso_iec._24727.tech.schema.IFDCapabilitiesType) TerminalInfo(org.openecard.ifd.scio.wrapper.TerminalInfo) Result(oasis.names.tc.dss._1_0.core.schema.Result) KeyPadCapabilityType(iso.std.iso_iec._24727.tech.schema.KeyPadCapabilityType) SCIOErrorCode(org.openecard.common.ifd.scio.SCIOErrorCode) GetIFDCapabilitiesResponse(iso.std.iso_iec._24727.tech.schema.GetIFDCapabilitiesResponse) BioSensorCapabilityType(iso.std.iso_iec._24727.tech.schema.BioSensorCapabilityType)

Example 2 with SlotCapabilityType

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

the class AndroidMarshaller method parseSlotCapability.

private SlotCapabilityType parseSlotCapability(XmlPullParser parser) throws XmlPullParserException, IOException {
    SlotCapabilityType slotCapType = new SlotCapabilityType();
    int eventType;
    do {
        parser.next();
        eventType = parser.getEventType();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("Index")) {
                slotCapType.setIndex(new BigInteger(parser.nextText()));
            } else if (parser.getName().equals("Protocol")) {
                String protocol = parser.nextText();
                slotCapType.getProtocol().add(protocol);
            }
        }
    } while (!(eventType == XmlPullParser.END_TAG && parser.getName().equals("SlotCapabilityType")));
    return slotCapType;
}
Also used : SlotCapabilityType(iso.std.iso_iec._24727.tech.schema.SlotCapabilityType) BigInteger(java.math.BigInteger) LocalizedString(org.openecard.addon.manifest.LocalizedString)

Example 3 with SlotCapabilityType

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

the class PACEStep method genericPACESupport.

/**
 * Check if the selected card reader supports PACE.
 * In that case, the reader is a standard or comfort reader.
 *
 * @param connectionHandle Handle describing the IFD and reader.
 * @return true when card reader supports genericPACE, false otherwise.
 * @throws WSHelper.WSException
 */
private boolean genericPACESupport(ConnectionHandleType connectionHandle) throws WSHelper.WSException {
    // Request terminal capabilities
    GetIFDCapabilities capabilitiesRequest = new GetIFDCapabilities();
    capabilitiesRequest.setContextHandle(connectionHandle.getContextHandle());
    capabilitiesRequest.setIFDName(connectionHandle.getIFDName());
    GetIFDCapabilitiesResponse capabilitiesResponse = (GetIFDCapabilitiesResponse) dispatcher.safeDeliver(capabilitiesRequest);
    WSHelper.checkResult(capabilitiesResponse);
    if (capabilitiesResponse.getIFDCapabilities() != null) {
        List<SlotCapabilityType> capabilities = capabilitiesResponse.getIFDCapabilities().getSlotCapability();
        // Check all capabilities for generic PACE
        final String genericPACE = PACECapabilities.PACECapability.GenericPACE.getProtocol();
        for (SlotCapabilityType capability : capabilities) {
            if (capability.getIndex().equals(connectionHandle.getSlotIndex())) {
                for (String protocol : capability.getProtocol()) {
                    if (protocol.equals(genericPACE)) {
                        return true;
                    }
                }
            }
        }
    }
    // No PACE capability found
    return false;
}
Also used : GetIFDCapabilities(iso.std.iso_iec._24727.tech.schema.GetIFDCapabilities) SlotCapabilityType(iso.std.iso_iec._24727.tech.schema.SlotCapabilityType) GetIFDCapabilitiesResponse(iso.std.iso_iec._24727.tech.schema.GetIFDCapabilitiesResponse)

Example 4 with SlotCapabilityType

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

the class AbstractPINAction method genericPACESupport.

/**
 * Check if the selected card reader supports PACE.
 * In that case, the reader is a standard or comfort reader.
 *
 * @param connectionHandle Handle describing the IFD and reader.
 * @return true when card reader supports genericPACE, false otherwise.
 * @throws WSException In case request for the terminal capabilities returned an error.
 */
protected boolean genericPACESupport(ConnectionHandleType connectionHandle) throws WSException {
    // Request terminal capabilities
    GetIFDCapabilities capabilitiesRequest = new GetIFDCapabilities();
    capabilitiesRequest.setContextHandle(connectionHandle.getContextHandle());
    capabilitiesRequest.setIFDName(connectionHandle.getIFDName());
    GetIFDCapabilitiesResponse capabilitiesResponse = (GetIFDCapabilitiesResponse) dispatcher.safeDeliver(capabilitiesRequest);
    WSHelper.checkResult(capabilitiesResponse);
    if (capabilitiesResponse.getIFDCapabilities() != null) {
        List<SlotCapabilityType> capabilities = capabilitiesResponse.getIFDCapabilities().getSlotCapability();
        // Check all capabilities for generic PACE
        final String genericPACE = PACECapabilities.PACECapability.GenericPACE.getProtocol();
        for (SlotCapabilityType capability : capabilities) {
            if (capability.getIndex().equals(connectionHandle.getSlotIndex())) {
                for (String protocol : capability.getProtocol()) {
                    if (protocol.equals(genericPACE)) {
                        return true;
                    }
                }
            }
        }
    }
    // No PACE capability found
    return false;
}
Also used : GetIFDCapabilities(iso.std.iso_iec._24727.tech.schema.GetIFDCapabilities) SlotCapabilityType(iso.std.iso_iec._24727.tech.schema.SlotCapabilityType) GetIFDCapabilitiesResponse(iso.std.iso_iec._24727.tech.schema.GetIFDCapabilitiesResponse)

Example 5 with SlotCapabilityType

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

the class AndroidMarshaller method marshalIFDCapabilities.

private Element marshalIFDCapabilities(IFDCapabilitiesType cap, Document document) {
    Element emIFDCaps = createElementIso(document, cap.getClass().getSimpleName());
    for (BioSensorCapabilityType bioCap : cap.getBioSensorCapability()) {
        Element emBioCap = createElementIso(document, "BioSensorCapability");
        Element emIndex = createElementIso(document, "Index");
        emIndex.appendChild(document.createTextNode(bioCap.getIndex().toString()));
        emBioCap.appendChild(emIndex);
        Element emBiometricType = createElementIso(document, "BiometricType");
        emBiometricType.appendChild(document.createTextNode(bioCap.getBiometricType().toString()));
        emBioCap.appendChild(emBiometricType);
        emIFDCaps.appendChild(emBioCap);
    }
    for (DisplayCapabilityType dispType : cap.getDisplayCapability()) {
        Element emDisp = createElementIso(document, "DisplayCapability");
        Element emIndex = createElementIso(document, "Index");
        emIndex.appendChild(document.createTextNode(dispType.getIndex().toString()));
        emDisp.appendChild(emIndex);
        Element emLines = createElementIso(document, "Lines");
        emLines.appendChild(document.createTextNode(dispType.getLines().toString()));
        emDisp.appendChild(emLines);
        Element emColumns = createElementIso(document, "Columns");
        emColumns.appendChild(document.createTextNode(dispType.getColumns().toString()));
        emDisp.appendChild(emColumns);
        Element emVirLines = createElementIso(document, "VirtualLines");
        emVirLines.appendChild(document.createTextNode(dispType.getVirtualLines().toString()));
        emDisp.appendChild(emVirLines);
        Element emVirColumns = createElementIso(document, "VirtualColumns");
        emVirColumns.appendChild(document.createTextNode(dispType.getVirtualColumns().toString()));
        emDisp.appendChild(emVirColumns);
        emIFDCaps.appendChild(emDisp);
    }
    for (KeyPadCapabilityType keyPadType : cap.getKeyPadCapability()) {
        Element emKP = createElementIso(document, "KeyPadCapability");
        Element emIndex = createElementIso(document, "Index");
        emIndex.appendChild(document.createTextNode(keyPadType.getIndex().toString()));
        emKP.appendChild(emIndex);
        Element emKeys = createElementIso(document, "Keys");
        emKeys.appendChild(document.createTextNode(keyPadType.getKeys().toString()));
        emKP.appendChild(emKeys);
        emIFDCaps.appendChild(emKP);
    }
    for (SlotCapabilityType slotType : cap.getSlotCapability()) {
        Element emSlot = createElementIso(document, "SlotCapability");
        Element emIndex = createElementIso(document, "Index");
        emIndex.appendChild(document.createTextNode(slotType.getIndex().toString()));
        emSlot.appendChild(emIndex);
        for (String protocol : slotType.getProtocol()) {
            Element emProtocol = createElementIso(document, "Protocol");
            emProtocol.appendChild(document.createTextNode(protocol));
            emSlot.appendChild(emProtocol);
        }
        emIFDCaps.appendChild(emSlot);
    }
    Element emOpticalSignalUnit = createElementIso(document, "OpticalSignalUnit");
    emOpticalSignalUnit.appendChild(document.createTextNode(Boolean.toString(cap.isOpticalSignalUnit())));
    emIFDCaps.appendChild(emOpticalSignalUnit);
    Element emAcousticSignalUnit = createElementIso(document, "AcousticSignalUnit");
    emAcousticSignalUnit.appendChild(document.createTextNode(Boolean.toString(cap.isAcousticSignalUnit())));
    emIFDCaps.appendChild(emAcousticSignalUnit);
    return emIFDCaps;
}
Also used : KeyPadCapabilityType(iso.std.iso_iec._24727.tech.schema.KeyPadCapabilityType) SlotCapabilityType(iso.std.iso_iec._24727.tech.schema.SlotCapabilityType) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) DisplayCapabilityType(iso.std.iso_iec._24727.tech.schema.DisplayCapabilityType) LocalizedString(org.openecard.addon.manifest.LocalizedString) BioSensorCapabilityType(iso.std.iso_iec._24727.tech.schema.BioSensorCapabilityType)

Aggregations

SlotCapabilityType (iso.std.iso_iec._24727.tech.schema.SlotCapabilityType)6 GetIFDCapabilitiesResponse (iso.std.iso_iec._24727.tech.schema.GetIFDCapabilitiesResponse)3 BioSensorCapabilityType (iso.std.iso_iec._24727.tech.schema.BioSensorCapabilityType)2 DisplayCapabilityType (iso.std.iso_iec._24727.tech.schema.DisplayCapabilityType)2 GetIFDCapabilities (iso.std.iso_iec._24727.tech.schema.GetIFDCapabilities)2 KeyPadCapabilityType (iso.std.iso_iec._24727.tech.schema.KeyPadCapabilityType)2 LocalizedString (org.openecard.addon.manifest.LocalizedString)2 IFDCapabilitiesType (iso.std.iso_iec._24727.tech.schema.IFDCapabilitiesType)1 BigInteger (java.math.BigInteger)1 JAXBElement (javax.xml.bind.JAXBElement)1 Result (oasis.names.tc.dss._1_0.core.schema.Result)1 NoSuchTerminal (org.openecard.common.ifd.scio.NoSuchTerminal)1 SCIOErrorCode (org.openecard.common.ifd.scio.SCIOErrorCode)1 SCIOException (org.openecard.common.ifd.scio.SCIOException)1 SCIOTerminal (org.openecard.common.ifd.scio.SCIOTerminal)1 SingleThreadChannel (org.openecard.ifd.scio.wrapper.SingleThreadChannel)1 TerminalInfo (org.openecard.ifd.scio.wrapper.TerminalInfo)1 Element (org.w3c.dom.Element)1