use of io.jans.orm.model.base.CustomObjectAttribute in project jans by JanssenProject.
the class User method setAttribute.
public void setAttribute(String attributeName, String attributeValue, Boolean multiValued) {
CustomObjectAttribute attribute = new CustomObjectAttribute(attributeName, attributeValue);
if (multiValued != null) {
attribute.setMultiValued(multiValued);
}
removeAttribute(attributeName);
getCustomAttributes().add(attribute);
}
use of io.jans.orm.model.base.CustomObjectAttribute in project jans by JanssenProject.
the class User method setAttribute.
public void setAttribute(String attributeName, String[] attributeValues, Boolean multiValued) {
CustomObjectAttribute attribute = new CustomObjectAttribute(attributeName, Arrays.asList(attributeValues));
if (multiValued != null) {
attribute.setMultiValued(multiValued);
}
removeAttribute(attributeName);
getCustomAttributes().add(attribute);
}
use of io.jans.orm.model.base.CustomObjectAttribute in project jans by JanssenProject.
the class User method setAttribute.
public void setAttribute(String attributeName, List<String> attributeValues, Boolean multiValued) {
CustomObjectAttribute attribute = new CustomObjectAttribute(attributeName, attributeValues);
if (multiValued != null) {
attribute.setMultiValued(multiValued);
}
removeAttribute(attributeName);
getCustomAttributes().add(attribute);
}
use of io.jans.orm.model.base.CustomObjectAttribute 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.orm.model.base.CustomObjectAttribute in project jans by JanssenProject.
the class UserService method addUserAttribute.
public boolean addUserAttribute(User user, String attributeName, Object attributeValue, Boolean multiValued) {
CustomObjectAttribute customAttribute = getCustomAttribute(user, attributeName);
if (customAttribute == null) {
customAttribute = new CustomObjectAttribute(attributeName, attributeValue);
user.getCustomAttributes().add(customAttribute);
} else {
List<Object> currentAttributeValues = customAttribute.getValues();
List<Object> newAttributeValues = new ArrayList<>();
newAttributeValues.addAll(currentAttributeValues);
if (newAttributeValues.contains(attributeValue)) {
return false;
} else {
newAttributeValues.add(attributeValue);
}
customAttribute.setValues(newAttributeValues);
}
if (multiValued != null) {
customAttribute.setMultiValued(multiValued);
}
return true;
}
Aggregations