Search in sources :

Example 51 with GluuCustomPerson

use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.

the class PersonService method searchPersons.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.gluu.oxtrust.ldap.service.IPersonService#searchPersons(java.lang.String,
	 * int, java.util.List)
	 */
@Override
public List<GluuCustomPerson> searchPersons(String pattern, int sizeLimit, List<GluuCustomPerson> excludedPersons) throws Exception {
    Filter orFilter = buildFilter(pattern);
    Filter searchFilter = orFilter;
    if (excludedPersons != null && excludedPersons.size() > 0) {
        List<Filter> excludeFilters = new ArrayList<Filter>();
        for (GluuCustomPerson excludedPerson : excludedPersons) {
            Filter eqFilter = Filter.createEqualityFilter(OxConstants.UID, excludedPerson.getUid());
            excludeFilters.add(eqFilter);
        }
        Filter orExcludeFilter = null;
        if (excludedPersons.size() == 1) {
            orExcludeFilter = excludeFilters.get(0);
        } else {
            orExcludeFilter = Filter.createORFilter(excludeFilters);
        }
        Filter notFilter = Filter.createNOTFilter(orExcludeFilter);
        searchFilter = Filter.createANDFilter(orFilter, notFilter);
    }
    return persistenceEntryManager.findEntries(getDnForPerson(null), GluuCustomPerson.class, searchFilter, sizeLimit);
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) Filter(org.gluu.search.filter.Filter) ArrayList(java.util.ArrayList)

Example 52 with GluuCustomPerson

use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.

the class PersonService method generateInumForNewPerson.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.gluu.oxtrust.ldap.service.IPersonService#generateInumForNewPerson()
	 */
@Override
public String generateInumForNewPerson() {
    GluuCustomPerson person = null;
    String newInum = null;
    String newDn = null;
    do {
        newInum = generateInumForNewPersonImpl();
        newDn = getDnForPerson(newInum);
        person = new GluuCustomPerson();
        person.setDn(newDn);
    } while (persistenceEntryManager.contains(newDn, GluuCustomPerson.class));
    return newInum;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson)

Example 53 with GluuCustomPerson

use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.

the class PersonService method getPersonsByAttribute.

/**
 * Get list of persons by attribute
 *
 * @param attribute attribute
 * @param value     value
 * @return List <Person>
 */
@Override
public List<GluuCustomPerson> getPersonsByAttribute(String attribute, String value) throws Exception {
    GluuCustomPerson person = new GluuCustomPerson();
    person.setBaseDn(getDnForPerson(null));
    person.setAttribute(attribute, value);
    List<GluuCustomPerson> persons = persistenceEntryManager.findEntries(person);
    if ((persons != null) && (persons.size() > 0)) {
        return persons;
    }
    return null;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson)

Example 54 with GluuCustomPerson

use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.

the class PersonService method getPersonsByEmail.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.gluu.oxtrust.ldap.service.IPersonService#getPersonsByEmail(java.lang.
	 * String)
	 */
@Override
public List<GluuCustomPerson> getPersonsByEmail(String mail, String... returnAttributes) {
    log.debug("Getting user information from DB: mail = {}", mail);
    if (StringHelper.isEmpty(mail)) {
        return null;
    }
    String personDn = getDnForPerson(null);
    Filter userMailFilter;
    if (dataSourceTypeService.isSpanner(personDn)) {
        userMailFilter = Filter.createEqualityFilter("mail", StringHelper.toLowerCase(mail));
    } else {
        userMailFilter = Filter.createEqualityFilter(Filter.createLowercaseFilter("mail"), StringHelper.toLowerCase(mail));
    }
    boolean multiValued = false;
    GluuAttribute mailAttribute = attributeService.getAttributeByName("mail");
    if ((mailAttribute != null) && (mailAttribute.getOxMultiValuedAttribute() != null) && mailAttribute.getOxMultiValuedAttribute()) {
        multiValued = true;
    }
    userMailFilter.multiValued(multiValued);
    List<GluuCustomPerson> entries = persistenceEntryManager.findEntries(personDn, GluuCustomPerson.class, userMailFilter, returnAttributes);
    log.debug("Found {} entries for mail = {}", entries.size(), mail);
    return entries;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) Filter(org.gluu.search.filter.Filter) GluuAttribute(org.gluu.model.GluuAttribute)

Example 55 with GluuCustomPerson

use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.

the class ServiceUtil method personMembersAdder.

/**
 * Adds a group to a person's memberOf
 *
 * @return void
 * @throws Exception
 */
public void personMembersAdder(GluuGroup gluuGroup, String dn) throws Exception {
    List<String> members = gluuGroup.getMembers();
    for (String member : members) {
        GluuCustomPerson gluuPerson = personService.getPersonByDn(member);
        List<String> groups = gluuPerson.getMemberOf();
        if (!isMemberOfExist(groups, dn)) {
            List<String> cleanGroups = new ArrayList<String>();
            cleanGroups.add(dn);
            for (String aGroup : groups) {
                cleanGroups.add(aGroup);
            }
            gluuPerson.setMemberOf(cleanGroups);
            personService.updatePerson(gluuPerson);
        }
    }
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ArrayList(java.util.ArrayList)

Aggregations

GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)133 ArrayList (java.util.ArrayList)42 ScimPerson (org.gluu.oxtrust.model.scim.ScimPerson)27 Test (org.testng.annotations.Test)22 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)21 ConfigurableTest (org.gluu.oxtrust.action.test.ConfigurableTest)18 Produces (javax.ws.rs.Produces)17 Response (javax.ws.rs.core.Response)17 ScimPersonGroups (org.gluu.oxtrust.model.scim.ScimPersonGroups)14 ScimPersonIms (org.gluu.oxtrust.model.scim.ScimPersonIms)14 ScimPersonPhones (org.gluu.oxtrust.model.scim.ScimPersonPhones)14 ScimPersonPhotos (org.gluu.oxtrust.model.scim.ScimPersonPhotos)14 ScimRoles (org.gluu.oxtrust.model.scim.ScimRoles)14 PersonMeta (org.gluu.oxtrust.model.scim.PersonMeta)13 ScimEntitlements (org.gluu.oxtrust.model.scim.ScimEntitlements)13 ScimName (org.gluu.oxtrust.model.scim.ScimName)13 ScimPersonAddresses (org.gluu.oxtrust.model.scim.ScimPersonAddresses)13 ScimPersonEmails (org.gluu.oxtrust.model.scim.ScimPersonEmails)13 ScimCustomAttributes (org.gluu.oxtrust.model.scim.ScimCustomAttributes)12 Scimx509Certificates (org.gluu.oxtrust.model.scim.Scimx509Certificates)12