Search in sources :

Example 16 with GluuCustomPerson

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

the class ServiceUtil method deleteGroupFromPerson.

/**
	 * Delete a Group from a Person
	 * 
	 * @return void
	 * @throws Exception
	 */
public void deleteGroupFromPerson(GluuGroup group, String dn) throws Exception {
    List<String> persons = group.getMembers();
    for (String onePerson : persons) {
        GluuCustomPerson gluuPerson = personService.getPersonByDn(onePerson);
        List<String> memberOflist = gluuPerson.getMemberOf();
        List<String> tempMemberOf = new ArrayList<String>();
        for (String aMemberOf : memberOflist) {
            tempMemberOf.add(aMemberOf);
        }
        for (String oneMemberOf : tempMemberOf) {
            if (oneMemberOf.equalsIgnoreCase(dn)) {
                tempMemberOf.remove(oneMemberOf);
                break;
            }
        }
        List<String> cleanMemberOf = new ArrayList<String>();
        for (String aMemberOf : tempMemberOf) {
            cleanMemberOf.add(aMemberOf);
        }
        gluuPerson.setMemberOf(cleanMemberOf);
        personService.updatePerson(gluuPerson);
    }
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ArrayList(java.util.ArrayList)

Example 17 with GluuCustomPerson

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

the class BaseScimWebService method getAuthorizedUser.

protected boolean getAuthorizedUser() {
    try {
        GluuCustomPerson authUser = (GluuCustomPerson) identity.getSessionMap().get(OxTrustConstants.CURRENT_PERSON);
        if (authUser == null) {
            return false;
        }
        GluuAppliance appliance = applianceService.getAppliance();
        if (appliance == null) {
            return false;
        }
        if (!(GluuBoolean.TRUE.equals(appliance.getScimEnabled()) || GluuBoolean.ENABLED.equals(appliance.getScimEnabled()))) {
            return false;
        }
        return true;
    } catch (Exception ex) {
        log.error("Exception: ", ex);
        return false;
    }
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) GluuAppliance(org.gluu.oxtrust.model.GluuAppliance)

Example 18 with GluuCustomPerson

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

the class PersonService method getPersonString.

/* (non-Javadoc)
	 * @see org.gluu.oxtrust.ldap.service.IPersonService#getPersonString(java.util.List)
	 */
@Override
public String getPersonString(List<GluuCustomPerson> persons) throws Exception {
    StringBuilder sb = new StringBuilder();
    for (Iterator<GluuCustomPerson> iterator = persons.iterator(); iterator.hasNext(); ) {
        GluuCustomPerson call = iterator.next();
        sb.append('\'').append(call.getDisplayName()).append('\'');
        if (iterator.hasNext()) {
            sb.append(", ");
        }
    }
    return sb.toString();
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson)

Example 19 with GluuCustomPerson

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

the class InumService method containsPerson.

public boolean containsPerson(String inum, String gluuInum) {
    boolean contains = true;
    GluuCustomPerson person = new GluuCustomPerson();
    person.setBaseDn(String.format("inum=%s,ou=people,o=%s,o=gluu", inum, gluuInum));
    contains = ldapEntryManager.contains(person);
    if (contains)
        return true;
    person.setBaseDn(String.format("inum=%s,ou=people,o=gluu", inum));
    contains = ldapEntryManager.contains(person);
    return contains;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson)

Example 20 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)
	 */
@Override
public List<GluuCustomPerson> searchPersons(String pattern, int sizeLimit) {
    String[] targetArray = new String[] { pattern };
    Filter uidFilter = Filter.createSubstringFilter(OxTrustConstants.uid, null, targetArray, null);
    Filter mailFilter = Filter.createSubstringFilter(OxTrustConstants.mail, null, targetArray, null);
    Filter nameFilter = Filter.createSubstringFilter(OxTrustConstants.displayName, null, targetArray, null);
    Filter inameFilter = Filter.createSubstringFilter(OxTrustConstants.iname, null, targetArray, null);
    Filter searchFilter = Filter.createORFilter(uidFilter, mailFilter, nameFilter, inameFilter);
    List<GluuCustomPerson> result = ldapEntryManager.findEntries(getDnForPerson(null), GluuCustomPerson.class, searchFilter, 0, sizeLimit);
    return result;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) Filter(com.unboundid.ldap.sdk.Filter)

Aggregations

GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)98 ArrayList (java.util.ArrayList)34 ScimPerson (org.gluu.oxtrust.model.scim.ScimPerson)27 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)25 Test (org.testng.annotations.Test)22 ConfigurableTest (org.gluu.oxtrust.action.test.ConfigurableTest)18 Produces (javax.ws.rs.Produces)15 Response (javax.ws.rs.core.Response)14 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 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)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 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)12