Search in sources :

Example 1 with PACECapabilities

use of org.openecard.common.ifd.PACECapabilities in project open-ecard by ecsec.

the class TerminalInfo method getPACECapabilities.

public List<PACECapabilities.PACECapability> getPACECapabilities() throws SCIOException {
    List<PACECapabilities.PACECapability> result = new LinkedList<>();
    if (PACECapabilities == null) {
        if (isConnected()) {
            if (supportsPace()) {
                int ctrlCode = getPaceCtrlCode();
                ExecutePACERequest.Function paceFunc = ExecutePACERequest.Function.GetReaderPACECapabilities;
                byte[] getCapabilityRequest = new ExecutePACERequest(paceFunc).toBytes();
                byte[] response = channel.transmitControlCommand(ctrlCode, getCapabilityRequest);
                ExecutePACEResponse paceResponse = new ExecutePACEResponse(response);
                if (paceResponse.isError()) {
                    String msg = "PACE is advertised but the result iss errornous.\n";
                    msg += paceResponse.getResult().getResultMessage().getValue();
                    throw new SCIOException(msg, SCIOErrorCode.SCARD_F_UNKNOWN_ERROR);
                }
                PACECapabilities cap = new PACECapabilities(paceResponse.getData());
                PACECapabilities = cap.getFeaturesEnum();
                result.addAll(PACECapabilities);
            }
        }
    } else {
        result.addAll(PACECapabilities);
    }
    return Collections.unmodifiableList(result);
}
Also used : PACECapabilities(org.openecard.common.ifd.PACECapabilities) SCIOException(org.openecard.common.ifd.scio.SCIOException) ExecutePACEResponse(org.openecard.ifd.scio.reader.ExecutePACEResponse) ExecutePACERequest(org.openecard.ifd.scio.reader.ExecutePACERequest) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 PACECapabilities (org.openecard.common.ifd.PACECapabilities)1 SCIOException (org.openecard.common.ifd.scio.SCIOException)1 ExecutePACERequest (org.openecard.ifd.scio.reader.ExecutePACERequest)1 ExecutePACEResponse (org.openecard.ifd.scio.reader.ExecutePACEResponse)1