Search in sources :

Example 1 with GluuStatus

use of io.jans.model.GluuStatus in project jans by JanssenProject.

the class UserService method addUser.

public User addUser(User user, boolean active) {
    String peopleBaseDN = getPeopleBaseDn();
    String inum = inumService.generatePeopleInum();
    user.setDn("inum=" + inum + "," + peopleBaseDN);
    user.setAttribute("inum", inum, false);
    GluuStatus status = active ? GluuStatus.ACTIVE : GluuStatus.REGISTER;
    user.setAttribute("jansStatus", status.getValue(), false);
    List<String> personCustomObjectClassList = getPersonCustomObjectClassList();
    if ((personCustomObjectClassList != null) && !personCustomObjectClassList.isEmpty()) {
        Set<String> allObjectClasses = new HashSet<>();
        allObjectClasses.addAll(personCustomObjectClassList);
        String[] currentObjectClasses = user.getCustomObjectClasses();
        if (ArrayHelper.isNotEmpty(currentObjectClasses)) {
            allObjectClasses.addAll(Arrays.asList(currentObjectClasses));
        }
        user.setCustomObjectClasses(allObjectClasses.toArray(new String[allObjectClasses.size()]));
    }
    user.setCreatedAt(new Date());
    persistenceEntryManager.persist(user);
    return getUserByDn(user.getDn());
}
Also used : GluuStatus(io.jans.model.GluuStatus) Date(java.util.Date) HashSet(java.util.HashSet)

Aggregations

GluuStatus (io.jans.model.GluuStatus)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1