use of io.jans.as.common.model.common.User in project jans by JanssenProject.
the class UserService method addUserAttributeByUserInum.
public User addUserAttributeByUserInum(String userInum, String attributeName, Object attributeValue) {
log.debug("Add user attribute by user inum to LDAP: attributeName = '{}', attributeValue = '{}'", attributeName, attributeValue);
User user = getUserByInum(userInum);
if (user == null) {
return null;
}
boolean result = addUserAttribute(user, attributeName, attributeValue);
if (!result) {
// We uses this result in Person Authentication Scripts
addUserAttribute(user, attributeName, attributeValue);
}
return updateUser(user);
}
use of io.jans.as.common.model.common.User 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.as.common.model.common.User in project jans by JanssenProject.
the class UserService method getUniqueUserByAttributes.
public User getUniqueUserByAttributes(List<String> attributeNames, String attributeValue) {
log.debug("Getting user information from LDAP: attributeNames = '{}', attributeValue = '{}'", attributeNames, attributeValue);
if (attributeNames != null) {
for (String attributeName : attributeNames) {
User searchUser = new User();
searchUser.setDn(getPeopleBaseDn());
List<CustomObjectAttribute> customAttributes = new ArrayList<>();
customAttributes.add(new CustomObjectAttribute(attributeName, attributeValue));
searchUser.setCustomAttributes(customAttributes);
try {
List<User> entries = persistenceEntryManager.findEntries(searchUser);
log.debug(Constants.LOG_FOUND, entries.size());
if (entries.size() == 1) {
return entries.get(0);
} else if (entries.size() > 1) {
break;
}
} catch (Exception e) {
log.debug(e.getMessage(), e);
}
}
}
return null;
}
use of io.jans.as.common.model.common.User 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.as.common.model.common.User in project jans by JanssenProject.
the class UserService method addUserAttribute.
public User addUserAttribute(String userId, String attributeName, Object attributeValue, Boolean multiValued) {
log.debug("Add user attribute to LDAP: attributeName = '{}', attributeValue = '{}'", attributeName, attributeValue);
User user = getUser(userId);
if (user == null) {
// We uses this result in Person Authentication Scripts
return null;
}
boolean result = addUserAttribute(user, attributeName, attributeValue, multiValued);
if (!result) {
// We uses this result in Person Authentication Scripts
return null;
}
return updateUser(user);
}
Aggregations