Search in sources :

Example 56 with ConnectionHandleType

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

the class HandlerUtils method copyHandle.

// TODO: use builder to copy handles
public static ConnectionHandleType copyHandle(ConnectionHandleType handle) {
    ConnectionHandleType result = new ConnectionHandleType();
    copyPath(result, handle);
    result.setSlotHandle(ByteUtils.clone(handle.getSlotHandle()));
    result.setRecognitionInfo(copyRecognition(handle.getRecognitionInfo()));
    result.setSlotInfo(copySlotInfo(handle.getSlotInfo()));
    return result;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)

Example 57 with ConnectionHandleType

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

the class SALFileUtils method selectApplication.

/**
 * Performs a CardApplicationConnect SAL call for the given handle.
 * The path part of the handle is used as a basis to connect the card.
 *
 * @param appId
 * @param handle
 * @return The handle of the card after performing the connect.
 * @throws org.openecard.common.WSHelper.WSException
 */
public ConnectionHandleType selectApplication(@Nonnull byte[] appId, @Nonnull ConnectionHandleType handle) throws WSException {
    CardApplicationConnect appConnectReq = new CardApplicationConnect();
    // copy path part of the handle and use it to identify the card
    CardApplicationPathType path = HandlerUtils.copyPath(handle);
    path.setCardApplication(appId);
    appConnectReq.setCardApplicationPath(path);
    CardApplicationConnectResponse resp = (CardApplicationConnectResponse) dispatcher.safeDeliver(appConnectReq);
    WSHelper.checkResult(resp);
    return resp.getConnectionHandle();
}
Also used : CardApplicationPathType(iso.std.iso_iec._24727.tech.schema.CardApplicationPathType) CardApplicationConnect(iso.std.iso_iec._24727.tech.schema.CardApplicationConnect) CardApplicationConnectResponse(iso.std.iso_iec._24727.tech.schema.CardApplicationConnectResponse)

Example 58 with ConnectionHandleType

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

the class EventHandler method signalEvent.

@Override
public void signalEvent(EventType eventType, EventObject eventData) {
    ConnectionHandleType connectionHandle = eventData.getHandle();
    for (Map.Entry<String, LinkedBlockingQueue<StatusChange>> entry : eventQueues.entrySet()) {
        try {
            LinkedBlockingQueue<StatusChange> queue = entry.getValue();
            StatusChange statusChange = new StatusChange();
            statusChange.setAction(eventType.getEventTypeIdentifier());
            statusChange.setConnectionHandle(connectionHandle);
            queue.put(statusChange);
        } catch (InterruptedException ignore) {
        }
    }
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) StatusChange(org.openecard.ws.schema.StatusChange) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) Map(java.util.Map) HashMap(java.util.HashMap)

Example 59 with ConnectionHandleType

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

the class ListTokens method determineTokenFeatures.

private boolean determineTokenFeatures(TokenInfoType next) {
    try {
        // request the missing information
        ConnectionHandleType h = new ConnectionHandleType();
        h.setSlotHandle(next.getConnectionHandle().getSlotHandle());
        DidInfos dids = new DidInfos(dispatcher, null, h);
        List<DidInfo> didInfos = dids.getDidInfos();
        boolean needsDidPin = false;
        boolean needsCertPin = false;
        TreeSet<String> algorithms = new TreeSet<>();
        // find out everything about the token
        for (DidInfo didInfo : didInfos) {
            if (didInfo.isCryptoDid()) {
                // only evaluate if we have no positive match yet
                if (!needsDidPin) {
                    needsDidPin |= didInfo.needsPin();
                }
                // only evaluate if we have no positive match yet
                if (!needsCertPin) {
                    for (DataSetInfo dataSetinfo : didInfo.getRelatedDataSets()) {
                        needsCertPin |= dataSetinfo.needsPin();
                    }
                }
                // get the algorithm of the did
                AlgorithmInfoType algInfo = didInfo.getGenericCryptoMarker().getAlgorithmInfo();
                AlgorithmIdentifierType algId = algInfo.getAlgorithmIdentifier();
                String alg = algInfo.getAlgorithm();
                try {
                    if (algId != null && algId.getAlgorithm() != null) {
                        String jcaName = AllowedSignatureAlgorithms.algIdtoJcaName(algId.getAlgorithm());
                        algorithms.add(jcaName);
                    }
                } catch (UnsupportedAlgorithmException ex) {
                    // ignore and fall back to Algorithm field
                    if (alg != null && !alg.isEmpty() && AllowedSignatureAlgorithms.isKnownJcaAlgorithm(alg)) {
                        algorithms.add(alg);
                    }
                }
            }
        }
        next.setNeedsPinForCertAccess(needsCertPin);
        next.setNeedsPinForPrivateKeyAccess(needsDidPin);
        next.getAlgorithm().addAll(algorithms);
        // finished evaluation everything successfully
        return true;
    } catch (NoSuchDid | WSHelper.WSException | SecurityConditionUnsatisfiable ex) {
        LOG.error("Failed to evaluate DID.", ex);
    }
    // there has been an error
    return false;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) SecurityConditionUnsatisfiable(org.openecard.common.SecurityConditionUnsatisfiable) DataSetInfo(org.openecard.crypto.common.sal.did.DataSetInfo) DidInfo(org.openecard.crypto.common.sal.did.DidInfo) AlgorithmInfoType(iso.std.iso_iec._24727.tech.schema.AlgorithmInfoType) TreeSet(java.util.TreeSet) AlgorithmIdentifierType(iso.std.iso_iec._24727.tech.schema.AlgorithmIdentifierType) UnsupportedAlgorithmException(org.openecard.crypto.common.UnsupportedAlgorithmException) NoSuchDid(org.openecard.crypto.common.sal.did.NoSuchDid) DidInfos(org.openecard.crypto.common.sal.did.DidInfos)

Example 60 with ConnectionHandleType

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

the class ListTokens method convertHandles.

private ArrayList<TokenInfoType> convertHandles(List<ConnectionHandleType> handles) {
    ArrayList<TokenInfoType> result = new ArrayList<>();
    for (ConnectionHandleType next : handles) {
        ConnectionHandleType.RecognitionInfo rec = next.getRecognitionInfo();
        // create token type and copy available information about it
        TokenInfoType ti = new TokenInfoType();
        org.openecard.ws.chipgateway.ConnectionHandleType h = new org.openecard.ws.chipgateway.ConnectionHandleType();
        h.setSlotHandle(next.getSlotHandle());
        h.setCardType(rec.getCardType());
        ti.setConnectionHandle(h);
        ConnectionHandleType.SlotInfo si = next.getSlotInfo();
        if (si != null) {
            ti.setHasProtectedAuthPath(si.isProtectedAuthPath());
        }
        if (determineTokenFeatures(ti)) {
            // only add this token if there are no errors
            result.add(ti);
        }
    }
    return result;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) TokenInfoType(org.openecard.ws.chipgateway.TokenInfoType) 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