Search in sources :

Example 31 with GluuAttribute

use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.

the class AttributeService method getAllAttributeOrigins.

/**
 * Get all origins
 *
 * @param attributes
 *            List of attributes
 * @return List of origins
 */
public List<String> getAllAttributeOrigins(Collection<GluuAttribute> attributes) {
    List<String> attributeOriginList = new ArrayList<String>();
    for (GluuAttribute attribute : attributes) {
        String origin = attribute.getOrigin();
        if (!attributeOriginList.contains(origin)) {
            attributeOriginList.add(attribute.getOrigin());
        }
    }
    String customOrigin = getCustomOrigin();
    if (!attributeOriginList.contains(customOrigin)) {
        attributeOriginList.add(customOrigin);
    }
    return attributeOriginList;
}
Also used : ArrayList(java.util.ArrayList) GluuAttribute(org.gluu.model.GluuAttribute)

Example 32 with GluuAttribute

use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.

the class AttributeService method getAllPersonAtributesImpl.

/**
 * Get all organization attributes
 *
 * @param attributes
 *            List of attributes
 * @return List of organization attributes
 */
private List<GluuAttribute> getAllPersonAtributesImpl(GluuUserRole gluuUserRole, Collection<GluuAttribute> attributes) {
    List<GluuAttribute> attributeList = new ArrayList<GluuAttribute>();
    String[] objectClassTypes = appConfiguration.getPersonObjectClassTypes();
    log.debug("objectClassTypes={}", Arrays.toString(objectClassTypes));
    for (GluuAttribute attribute : attributes) {
        if (StringHelper.equalsIgnoreCase(attribute.getOrigin(), appConfiguration.getPersonCustomObjectClass()) && (GluuUserRole.ADMIN == gluuUserRole)) {
            attribute.setCustom(true);
            attributeList.add(attribute);
            continue;
        }
        for (String objectClassType : objectClassTypes) {
            if (attribute.getOrigin().equals(objectClassType) && ((attribute.allowViewBy(gluuUserRole) || attribute.allowEditBy(gluuUserRole)))) {
                attributeList.add(attribute);
                break;
            }
        }
    }
    return attributeList;
}
Also used : ArrayList(java.util.ArrayList) GluuAttribute(org.gluu.model.GluuAttribute)

Example 33 with GluuAttribute

use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.

the class AttributeService method removeAttribute.

public void removeAttribute(String inum) {
    GluuAttribute attribute = new GluuAttribute();
    attribute.setDn(getDnForAttribute(inum));
    removeAttribute(attribute);
}
Also used : GluuAttribute(org.gluu.model.GluuAttribute)

Example 34 with GluuAttribute

use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.

the class AttributeService method attributeWithSameNameDontExist.

public boolean attributeWithSameNameDontExist(String name) {
    Filter nameFilter = Filter.createEqualityFilter("name", name);
    List<GluuAttribute> result = persistenceEntryManager.findEntries(getDnForAttribute(null), GluuAttribute.class, nameFilter, null);
    return (result != null && !result.isEmpty()) ? false : true;
}
Also used : Filter(org.gluu.search.filter.Filter) GluuAttribute(org.gluu.model.GluuAttribute)

Example 35 with GluuAttribute

use of org.gluu.model.GluuAttribute in project oxTrust by GluuFederation.

the class AttributeService method getCustomAttributesByAttributeDNs.

/**
 * Get custom attributes by attribute DNs
 *
 * @param customAttributes
 *            List of attribute DNs
 * @param attributes
 *            List of custom attributes
 */
public List<GluuCustomAttribute> getCustomAttributesByAttributeDNs(List<String> attributeDNs, HashMap<String, GluuAttribute> attributesByDNs) {
    List<GluuCustomAttribute> customAttributes = new ArrayList<GluuCustomAttribute>();
    if (attributeDNs == null) {
        return customAttributes;
    }
    for (String releasedAttributeDn : attributeDNs) {
        GluuAttribute attribute = attributesByDNs.get(releasedAttributeDn);
        if (attribute != null) {
            GluuCustomAttribute customAttribute = new GluuCustomAttribute(attribute.getName(), releasedAttributeDn);
            customAttribute.setMetadata(attribute);
            customAttributes.add(customAttribute);
        }
    }
    return customAttributes;
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) ArrayList(java.util.ArrayList) GluuAttribute(org.gluu.model.GluuAttribute)

Aggregations

GluuAttribute (org.gluu.model.GluuAttribute)68 ArrayList (java.util.ArrayList)21 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)10 IOException (java.io.IOException)8 Scope (org.oxauth.persistence.model.Scope)8 HttpEntity (org.apache.http.HttpEntity)7 HttpResponse (org.apache.http.HttpResponse)7 ParseException (org.apache.http.ParseException)7 Test (org.junit.Test)7 HttpGet (org.apache.http.client.methods.HttpGet)6 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)6 Filter (org.gluu.search.filter.Filter)5 JSONObject (org.json.JSONObject)4 Operation (io.swagger.v3.oas.annotations.Operation)3 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 FacesMessage (javax.faces.application.FacesMessage)3 UIInput (javax.faces.component.UIInput)3 AttributeValidation (org.gluu.model.attribute.AttributeValidation)3