Search in sources :

Example 1 with CustomObjectAttribute

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);
}
Also used : CustomObjectAttribute(org.gluu.persist.model.base.CustomObjectAttribute)

Example 2 with CustomObjectAttribute

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;
}
Also used : CustomObjectAttribute(org.gluu.persist.model.base.CustomObjectAttribute) ArrayList(java.util.ArrayList)

Example 3 with CustomObjectAttribute

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);
}
Also used : CustomObjectAttribute(org.gluu.persist.model.base.CustomObjectAttribute) User(org.gluu.oxauth.model.common.User) Date(java.util.Date)

Example 4 with CustomObjectAttribute

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);
}
Also used : CustomObjectAttribute(org.gluu.persist.model.base.CustomObjectAttribute)

Example 5 with CustomObjectAttribute

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);
}
Also used : CustomObjectAttribute(org.gluu.persist.model.base.CustomObjectAttribute)

Aggregations

CustomObjectAttribute (org.gluu.persist.model.base.CustomObjectAttribute)11 User (org.gluu.oxauth.model.common.User)5 ArrayList (java.util.ArrayList)4 Date (java.util.Date)1 SimpleUser (org.gluu.oxauth.model.common.SimpleUser)1