Search in sources :

Example 1 with ByteComparator

use of org.openecard.common.util.ByteComparator in project open-ecard by ecsec.

the class DidInfos method getDidNames.

synchronized Map<byte[], List<String>> getDidNames() throws WSHelper.WSException {
    if (allDidNames == null) {
        allDidNames = new TreeMap<>(new ByteComparator());
        // check out all applications
        for (byte[] application : getApplicationsInt()) {
            try {
                DIDList req = new DIDList();
                req.setConnectionHandle(getHandle());
                DIDQualifierType filter = new DIDQualifierType();
                filter.setApplicationIdentifier(application);
                req.setFilter(filter);
                DIDListResponse res = (DIDListResponse) dispatcher.safeDeliver(req);
                WSHelper.checkResult(res);
                if (res.getDIDNameList() != null) {
                    allDidNames.put(application, Collections.unmodifiableList(res.getDIDNameList().getDIDName()));
                }
            } catch (WSHelper.WSException ex) {
            // skip this application
            }
        }
        // prevent modification
        allDidNames = Collections.unmodifiableMap(allDidNames);
    }
    return allDidNames;
}
Also used : ByteComparator(org.openecard.common.util.ByteComparator) WSHelper(org.openecard.common.WSHelper) DIDList(iso.std.iso_iec._24727.tech.schema.DIDList) DIDQualifierType(iso.std.iso_iec._24727.tech.schema.DIDQualifierType) DIDListResponse(iso.std.iso_iec._24727.tech.schema.DIDListResponse)

Example 2 with ByteComparator

use of org.openecard.common.util.ByteComparator in project open-ecard by ecsec.

the class ListTokens method removeDuplicates.

private List<TokenInfoType> removeDuplicates(List<TokenInfoType> resultHandles) {
    // use set with compare function to remove duplicates
    TreeSet<TokenInfoType> result = new TreeSet<>(new Comparator<TokenInfoType>() {

        private final ByteComparator cmp = new ByteComparator();

        @Override
        public int compare(TokenInfoType o1, TokenInfoType o2) {
            return cmp.compare(o1.getConnectionHandle().getSlotHandle(), o2.getConnectionHandle().getSlotHandle());
        }
    });
    result.addAll(resultHandles);
    return new ArrayList<>(result);
}
Also used : ByteComparator(org.openecard.common.util.ByteComparator) TokenInfoType(org.openecard.ws.chipgateway.TokenInfoType) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList)

Aggregations

ByteComparator (org.openecard.common.util.ByteComparator)2 DIDList (iso.std.iso_iec._24727.tech.schema.DIDList)1 DIDListResponse (iso.std.iso_iec._24727.tech.schema.DIDListResponse)1 DIDQualifierType (iso.std.iso_iec._24727.tech.schema.DIDQualifierType)1 ArrayList (java.util.ArrayList)1 TreeSet (java.util.TreeSet)1 WSHelper (org.openecard.common.WSHelper)1 TokenInfoType (org.openecard.ws.chipgateway.TokenInfoType)1