use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.
the class UserService method getUserByAttributes.
public User getUserByAttributes(Object attributeValue, String[] attributeNames, Boolean multiValued, String... returnAttributes) {
if (ArrayHelper.isEmpty(attributeNames)) {
return null;
}
if (log.isDebugEnabled())
log.debug("Getting user information from DB: {} = {}", ArrayHelper.toString(attributeNames), attributeValue);
String peopleBaseDn = getPeopleBaseDn();
List<Filter> filters = new ArrayList<>();
for (String attributeName : attributeNames) {
Filter filter;
if (dataSourceTypeService.isSpanner(peopleBaseDn)) {
filter = Filter.createEqualityFilter(attributeName, attributeValue);
} else {
filter = Filter.createEqualityFilter(Filter.createLowercaseFilter(attributeName), attributeValue);
}
if (multiValued != null) {
filter.multiValued(multiValued);
}
filters.add(filter);
}
Filter searchFiler;
if (filters.size() == 1) {
searchFiler = filters.get(0);
} else {
searchFiler = Filter.createORFilter(filters);
}
List<User> entries = persistenceEntryManager.findEntries(getPeopleBaseDn(), User.class, searchFiler, returnAttributes, 1);
if (log.isDebugEnabled())
log.debug("Found {} entries for user {} = {}", entries.size(), ArrayHelper.toString(attributeNames), attributeValue);
return entries.isEmpty() ? null : entries.get(0);
}
use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.
the class UserService method getUsersByAttribute.
public List<User> getUsersByAttribute(String attributeName, Object attributeValue, Boolean multiValued, int limit) {
if (log.isDebugEnabled())
log.debug("Getting user information from LDAP: attributeName = '{}', attributeValue = '{}'", escapeLog(attributeName), escapeLog(attributeValue));
if (StringHelper.isEmpty(attributeName) || (attributeValue == null)) {
return Collections.emptyList();
}
Filter filter = Filter.createEqualityFilter(attributeName, attributeValue);
if (multiValued != null) {
filter.multiValued(multiValued);
}
List<User> entries = persistenceEntryManager.findEntries(getPeopleBaseDn(), User.class, filter, limit);
log.debug("Found '{}' entries", entries.size());
return entries;
}
use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.
the class UserService method getUsersWithPersistentJwts.
public List<User> getUsersWithPersistentJwts() {
String baseDN = getPeopleBaseDn();
Filter filter = Filter.createPresenceFilter("jansPersistentJWT");
return persistenceEntryManager.findEntries(baseDN, User.class, filter);
}
use of io.jans.orm.search.filter.Filter in project jans by JanssenProject.
the class UserService method getUser.
public User getUser(String userId, String... returnAttributes) {
final String escapedUserId = escapeLog(userId);
log.debug("Getting user information from LDAP: userId = {}", escapedUserId);
if (StringHelper.isEmpty(userId)) {
return null;
}
String peopleBaseDn = getPeopleBaseDn();
Filter userUidFilter;
if (dataSourceTypeService.isSpanner(peopleBaseDn)) {
userUidFilter = Filter.createEqualityFilter("uid", StringHelper.toLowerCase(userId));
} else {
userUidFilter = Filter.createEqualityFilter(Filter.createLowercaseFilter("uid"), StringHelper.toLowerCase(userId));
}
List<User> entries = persistenceEntryManager.findEntries(peopleBaseDn, User.class, userUidFilter, returnAttributes);
log.debug("Found {} entries for user id = {}", entries.size(), escapedUserId);
return entries.isEmpty() ? null : entries.get(0);
}
use of io.jans.orm.search.filter.Filter 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