use of org.gluu.persist.model.base.CustomObjectAttribute in project oxAuth by GluuFederation.
the class UserService method setCustomAttribute.
public void setCustomAttribute(User user, String attributeName, String attributeValue) {
CustomObjectAttribute customAttribute = getCustomAttribute(user, attributeName);
if (customAttribute == null) {
customAttribute = new CustomObjectAttribute(attributeName);
user.getCustomAttributes().add(customAttribute);
}
customAttribute.setValue(attributeValue);
}
use of org.gluu.persist.model.base.CustomObjectAttribute in project oxAuth by GluuFederation.
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<Object>();
newAttributeValues.addAll(currentAttributeValues);
if (newAttributeValues.contains(attributeValue)) {
return false;
} else {
newAttributeValues.add(attributeValue);
}
customAttribute.setValues(newAttributeValues);
}
if (multiValued != null) {
customAttribute.setMultiValued(multiValued);
}
return true;
}
use of org.gluu.persist.model.base.CustomObjectAttribute in project oxAuth by GluuFederation.
the class UserService method addDefaultUser.
public User addDefaultUser(String uid) {
String peopleBaseDN = getPeopleBaseDn();
String inum = inumService.generatePeopleInum();
User user = new User();
user.setDn("inum=" + inum + "," + peopleBaseDN);
user.setCustomAttributes(Arrays.asList(new CustomObjectAttribute("inum", inum), new CustomObjectAttribute("gluuStatus", GluuStatus.ACTIVE.getValue()), new CustomObjectAttribute("displayName", "User " + uid + " added via oxAuth custom plugin")));
user.setUserId(uid);
List<String> personCustomObjectClassList = getPersonCustomObjectClassList();
if ((personCustomObjectClassList != null) && !personCustomObjectClassList.isEmpty()) {
user.setCustomObjectClasses(personCustomObjectClassList.toArray(new String[personCustomObjectClassList.size()]));
}
user.setCreatedAt(new Date());
persistenceEntryManager.persist(user);
return getUser(uid);
}
use of org.gluu.persist.model.base.CustomObjectAttribute in project oxAuth by GluuFederation.
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 org.gluu.persist.model.base.CustomObjectAttribute in project oxAuth by GluuFederation.
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);
}
Aggregations