Search in sources :

Example 6 with TokenInfoType

use of org.openecard.ws.chipgateway.TokenInfoType in project open-ecard by ecsec.

the class ListTokens method filterTerminalFeatures.

private List<TokenInfoType> filterTerminalFeatures(TokenInfoType filter, List<TokenInfoType> filtered) {
    ArrayList<TokenInfoType> result = new ArrayList<>();
    Boolean protectedAuthPath = filter.isHasProtectedAuthPath();
    if (protectedAuthPath != null) {
        // add all elements having the exact same value as the filter
        for (TokenInfoType next : filtered) {
            if (protectedAuthPath.equals(next.isHasProtectedAuthPath())) {
                result.add(next);
            }
        }
    } else {
        result.addAll(filtered);
    }
    return result;
}
Also used : TokenInfoType(org.openecard.ws.chipgateway.TokenInfoType) ArrayList(java.util.ArrayList)

Example 7 with TokenInfoType

use of org.openecard.ws.chipgateway.TokenInfoType in project open-ecard by ecsec.

the class ListTokens method filterTokenFeatures.

private List<TokenInfoType> filterTokenFeatures(TokenInfoType filter, List<TokenInfoType> filtered) {
    ArrayList<TokenInfoType> result = new ArrayList<>();
    Boolean needsDidPinFilter = filter.isNeedsPinForPrivateKeyAccess();
    Boolean needsCertPinFilter = filter.isNeedsPinForCertAccess();
    if (needsDidPinFilter != null || needsCertPinFilter != null) {
        for (TokenInfoType next : filtered) {
            // compare the features
            boolean tokenMatches = false;
            if (needsDidPinFilter != null && needsDidPinFilter.equals(next.isNeedsPinForPrivateKeyAccess())) {
                tokenMatches = true;
            }
            if (needsCertPinFilter != null && needsCertPinFilter.equals(next.isNeedsPinForCertAccess())) {
                tokenMatches = true;
            }
            // add if we have a match
            if (tokenMatches) {
                result.add(next);
            }
        }
    } else {
        result.addAll(filtered);
    }
    return result;
}
Also used : TokenInfoType(org.openecard.ws.chipgateway.TokenInfoType) ArrayList(java.util.ArrayList)

Example 8 with TokenInfoType

use of org.openecard.ws.chipgateway.TokenInfoType in project open-ecard by ecsec.

the class ListTokens method filterAlgorithms.

private List<TokenInfoType> filterAlgorithms(TokenInfoType filter, List<TokenInfoType> filtered) {
    ArrayList<TokenInfoType> result = new ArrayList<>();
    List<String> refAlgs = filter.getAlgorithm();
    if (!refAlgs.isEmpty()) {
        // loop over all elements to be filtered
        for (TokenInfoType nextTokenInfo : filtered) {
            List<String> tokenAlgs = nextTokenInfo.getAlgorithm();
            // check if the token has all algorithms contained in the reference list
            if (tokenAlgs.containsAll(refAlgs)) {
                result.add(nextTokenInfo);
            }
        }
    } else {
        result.addAll(filtered);
    }
    return result;
}
Also used : TokenInfoType(org.openecard.ws.chipgateway.TokenInfoType) ArrayList(java.util.ArrayList)

Example 9 with TokenInfoType

use of org.openecard.ws.chipgateway.TokenInfoType in project open-ecard by ecsec.

the class ListTokens method findTokens.

public List<TokenInfoType> findTokens() throws WSHelper.WSException {
    ArrayList<ConnectionHandleType> connected = connectCards();
    // save slots of connected cards
    for (ConnectionHandleType next : connected) {
        connectedSlots.add(next.getSlotHandle());
    }
    // convert handles to TokenInfo structure
    ArrayList<TokenInfoType> allTokens = convertHandles(connected);
    // add unknown cards to the list
    allTokens.addAll(getUnknownCards(connected));
    // process handles for each requested filter
    ArrayList<TokenInfoType> filteredLists = new ArrayList<>();
    for (TokenInfoType filter : requestedTokens) {
        List<TokenInfoType> filtered = filterTypes(filter, allTokens);
        filtered = filterTerminalFeatures(filter, filtered);
        filtered = filterTokenFeatures(filter, filtered);
        filtered = filterAlgorithms(filter, filtered);
        filteredLists.addAll(filtered);
    }
    List<TokenInfoType> resultHandles = removeDuplicates(filteredLists);
    return resultHandles;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) TokenInfoType(org.openecard.ws.chipgateway.TokenInfoType) ArrayList(java.util.ArrayList)

Example 10 with TokenInfoType

use of org.openecard.ws.chipgateway.TokenInfoType in project open-ecard by ecsec.

the class ListTokens method filterTypes.

private List<TokenInfoType> filterTypes(TokenInfoType filter, List<TokenInfoType> tokens) {
    org.openecard.ws.chipgateway.ConnectionHandleType filterHandle = filter.getConnectionHandle();
    String type = filterHandle != null ? filterHandle.getCardType() : null;
    ArrayList<TokenInfoType> result = new ArrayList<>();
    for (TokenInfoType next : tokens) {
        // add to result if it matches the desired type or if no type is given
        String cardType = next.getConnectionHandle().getCardType();
        if (type == null || type.equals(cardType)) {
            result.add(next);
        }
    }
    return result;
}
Also used : TokenInfoType(org.openecard.ws.chipgateway.TokenInfoType) ArrayList(java.util.ArrayList)

Aggregations

TokenInfoType (org.openecard.ws.chipgateway.TokenInfoType)10 ArrayList (java.util.ArrayList)8 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)3 WSHelper (org.openecard.common.WSHelper)2 GetStatus (iso.std.iso_iec._24727.tech.schema.GetStatus)1 GetStatusResponse (iso.std.iso_iec._24727.tech.schema.GetStatusResponse)1 IFDStatusType (iso.std.iso_iec._24727.tech.schema.IFDStatusType)1 SlotStatusType (iso.std.iso_iec._24727.tech.schema.SlotStatusType)1 BigInteger (java.math.BigInteger)1 Date (java.util.Date)1 TreeSet (java.util.TreeSet)1 TimeoutException (java.util.concurrent.TimeoutException)1 ByteComparator (org.openecard.common.util.ByteComparator)1 UnsupportedAlgorithmException (org.openecard.crypto.common.UnsupportedAlgorithmException)1 GetCommandType (org.openecard.ws.chipgateway.GetCommandType)1 ListTokensResponseType (org.openecard.ws.chipgateway.ListTokensResponseType)1