use of io.jans.as.server.model.fido.u2f.DeviceRegistration in project jans by JanssenProject.
the class UserService method countFidoRegisteredDevices.
public long countFidoRegisteredDevices(String username, String domain) {
String userInum = getUserInum(username);
if (userInum == null) {
return 0;
}
String baseDn = getBaseDnForFidoDevices(userInum);
if (persistenceEntryManager.hasBranchesSupport(baseDn)) {
if (!persistenceEntryManager.contains(baseDn, SimpleBranch.class)) {
return 0;
}
}
Filter resultFilter = Filter.createEqualityFilter("jansStatus", DeviceRegistrationStatus.ACTIVE.getValue());
List<DeviceRegistration> fidoRegistrations = persistenceEntryManager.findEntries(baseDn, DeviceRegistration.class, resultFilter);
if (StringUtils.isEmpty(domain)) {
return fidoRegistrations.size();
}
return fidoRegistrations.parallelStream().filter(f -> StringHelper.equals(domain, networkService.getHost(f.getApplication()))).count();
}
Aggregations