Search in sources :

Example 6 with GluuAttribute

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

the class CustomAttributeAction method removeCustomAttribute.

public void removeCustomAttribute(String inum) {
    if (StringHelper.isEmpty(inum)) {
        return;
    }
    GluuAttribute tmpAttribute = attributeInums.get(inum);
    if ((tmpAttribute == null) || !containsCustomAttribute(tmpAttribute)) {
        return;
    }
    String id = this.attributeIds.get(tmpAttribute);
    this.availableAttributeIds.add(id);
    for (Iterator<GluuCustomAttribute> iterator = this.customAttributes.iterator(); iterator.hasNext(); ) {
        GluuCustomAttribute tmpGluuPersonAttribute = iterator.next();
        if (tmpAttribute.equals(tmpGluuPersonAttribute.getMetadata())) {
            iterator.remove();
            break;
        }
    }
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) GluuAttribute(org.gluu.model.GluuAttribute)

Example 7 with GluuAttribute

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

the class CustomAttributeAction method renderAttribute.

public void renderAttribute(ComponentSystemEvent event) {
    // Replace dummy component id with real one
    String dummyId = event.getComponent().getAttributes().get("aid").toString();
    String clientId = event.getComponent().getClientId();
    GluuAttribute attribute = this.attributeToIds.get(dummyId);
    this.attributeIds.put(attribute, clientId);
}
Also used : GluuAttribute(org.gluu.model.GluuAttribute)

Example 8 with GluuAttribute

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

the class CustomAttributeAction method initCustomAttributes.

public void initCustomAttributes(List<GluuAttribute> attributes, List<GluuCustomAttribute> customAttributes, List<String> origins, String[] objectClassTypes, String[] objectClassDisplayNames) {
    this.attributes = attributes;
    this.customAttributes = customAttributes;
    this.origCustomAttributes = new ArrayList<GluuCustomAttribute>(customAttributes);
    // Set meta-data and sort by metadata.displayName
    attributeService.setAttributeMetadata(customAttributes, this.attributes);
    attributeService.sortCustomAttributes(customAttributes, "metadata.displayName");
    // Prepare map which allows to build tab
    this.attributeByOrigin = groupAttributesByOrigin(this.attributes);
    // Init special list and maps
    this.availableAttributeIds = new ArrayList<String>();
    this.attributeIds = new IdentityHashMap<GluuAttribute, String>();
    this.attributeToIds = new HashMap<String, GluuAttribute>();
    this.attributeInums = new HashMap<String, GluuAttribute>();
    int componentId = 1;
    for (GluuAttribute attribute : attributes) {
        log.debug("attribute: {}", attribute.getName());
        String id = "a" + String.valueOf(componentId++) + "Id";
        this.availableAttributeIds.add(id);
        this.attributeInums.put(attribute.getInum(), attribute);
        this.attributeIds.put(attribute, id);
        this.attributeToIds.put(id, attribute);
    }
    // Init origin display names
    this.originDisplayNames = attributeService.getAllAttributeOriginDisplayNames(origins, objectClassTypes, objectClassDisplayNames);
    this.activeOrigin = this.originDisplayNames.get(origins.get(0));
    // Sync Ids map
    for (GluuCustomAttribute personAttribute : customAttributes) {
        if (personAttribute.getMetadata() != null) {
            String id = this.attributeIds.get(personAttribute.getMetadata());
            this.availableAttributeIds.remove(id);
        }
    }
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) GluuAttribute(org.gluu.model.GluuAttribute)

Example 9 with GluuAttribute

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

the class CustomAttributeAction method addCustomAttribute.

public void addCustomAttribute(String inum, boolean mandatory) {
    if (StringHelper.isEmpty(inum)) {
        return;
    }
    GluuAttribute tmpAttribute = attributeInums.get(inum);
    if ((tmpAttribute == null) || containsCustomAttribute(tmpAttribute)) {
        return;
    }
    String id = this.attributeIds.get(tmpAttribute);
    this.availableAttributeIds.remove(id);
    GluuCustomAttribute tmpGluuPersonAttribute = new GluuCustomAttribute(tmpAttribute.getName(), (String) null, true, mandatory);
    tmpGluuPersonAttribute.setMetadata(tmpAttribute);
    this.customAttributes.add(tmpGluuPersonAttribute);
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) GluuAttribute(org.gluu.model.GluuAttribute)

Example 10 with GluuAttribute

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

the class CustomAttributeAction method removeMultiValuesInAttributes.

public void removeMultiValuesInAttributes(String inum, boolean mandatory, String removeValue) {
    if (StringHelper.isEmpty(inum)) {
        return;
    }
    GluuAttribute tmpAttribute = this.attributeInums.get(inum);
    if (tmpAttribute == null) {
        return;
    }
    String id = this.attributeIds.get(tmpAttribute);
    this.availableAttributeIds.remove(id);
    String[] values = null;
    String[] newValues = null;
    int index = 0;
    for (GluuCustomAttribute customAttribute : this.customAttributes) {
        if (tmpAttribute.equals(customAttribute.getMetadata())) {
            values = customAttribute.getValues();
            newValues = removeElementFromArray(values, removeValue);
            break;
        }
        index++;
    }
    removeCustomAttribute(inum);
    GluuCustomAttribute tmpGluuPersonAttribute = new GluuCustomAttribute(tmpAttribute.getName(), newValues, true, mandatory);
    tmpGluuPersonAttribute.setMetadata(tmpAttribute);
    this.customAttributes.add(index, tmpGluuPersonAttribute);
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) 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