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