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;
}
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);
}
Aggregations