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);
}
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;
}
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;
}
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;
}
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);
}
}
}
Aggregations