Search in sources :

Example 21 with GluuAttribute

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

the class RegisterPersonAction method initAttributes.

private void initAttributes() {
    List<GluuAttribute> allPersonAttributes = attributeService.getAllActivePersonAttributes(GluuUserRole.ADMIN);
    List<String> allAttributOrigins = attributeService.getAllAttributeOrigins(allPersonAttributes);
    GluuOrganization organization = organizationService.getOrganization();
    List<GluuCustomAttribute> customAttributes = this.person.getCustomAttributes();
    boolean isNewPerson = (customAttributes == null) || customAttributes.isEmpty();
    if (isNewPerson) {
        customAttributes = new ArrayList<GluuCustomAttribute>();
        this.person.setCustomAttributes(customAttributes);
    }
    String[] personOCs = appConfiguration.getPersonObjectClassTypes();
    String[] personOCDisplayNames = appConfiguration.getPersonObjectClassDisplayNames();
    customAttributeAction.initCustomAttributes(allPersonAttributes, customAttributes, allAttributOrigins, personOCs, personOCDisplayNames);
    List<GluuCustomAttribute> mandatoryAttributes = new ArrayList<GluuCustomAttribute>();
    RegistrationConfiguration config = organization.getOxRegistrationConfiguration();
    boolean registrationCustomized = config != null;
    boolean registrationAttributesCustomized = registrationCustomized && config.getAdditionalAttributes() != null && !config.getAdditionalAttributes().isEmpty();
    if (registrationAttributesCustomized) {
        for (String attributeInum : config.getAdditionalAttributes()) {
            GluuAttribute attribute = attributeService.getAttributeByInum(attributeInum);
            GluuCustomAttribute customAttribute = new GluuCustomAttribute(attribute.getName(), "", false, false);
            mandatoryAttributes.add(customAttribute);
        }
    }
    for (GluuCustomAttribute attribute : personService.getMandatoryAtributes()) {
        if (!mandatoryAttributes.contains(attribute)) {
            mandatoryAttributes.add(attribute);
        }
    }
    mandatoryAttributes.addAll(personService.getMandatoryAtributes());
    if (isNewPerson) {
        customAttributeAction.addCustomAttributes(mandatoryAttributes);
    }
    hiddenAttributes = new ArrayList<String>();
    hiddenAttributes.add("inum");
    hiddenAttributes.add("iname");
    hiddenAttributes.add("userPassword");
    hiddenAttributes.add("gluuStatus");
    hiddenAttributes.add("oxExternalUid");
    hiddenAttributes.add("oxLastLogonTime");
}
Also used : GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) ArrayList(java.util.ArrayList) GluuOrganization(org.gluu.oxtrust.model.GluuOrganization) GluuAttribute(org.xdi.model.GluuAttribute) RegistrationConfiguration(org.gluu.oxtrust.model.RegistrationConfiguration)

Example 22 with GluuAttribute

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

the class RegistrationManagementAction method lookupAttributeData.

public String lookupAttributeData() {
    GluuAttribute attribute = attributeService.getAttributeByName(attributeName);
    attributeData = "Uid:\t" + attributeName;
    attributeData += "<br/>Description:\t" + attribute.getDescription();
    attributeData += "<br/>Origin:\t" + attribute.getOrigin();
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : GluuAttribute(org.xdi.model.GluuAttribute)

Example 23 with GluuAttribute

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

the class RegistrationManagementAction method save.

public String save() {
    GluuOrganization org = organizationService.getOrganization();
    RegistrationConfiguration config = org.getOxRegistrationConfiguration();
    if (config == null) {
        config = new RegistrationConfiguration();
    }
    config.setRegistrationInterceptorsConfigured(configureInterceptors);
    if (configureInterceptors) {
        config.setRegistrationInterceptorScripts(registrationInterceptors);
    } else {
        config.setRegistrationInterceptorScripts(null);
    }
    config.setCaptchaDisabled(captchaDisabled);
    List<String> attributeList = new ArrayList<String>();
    if (configureRegistrationForm) {
        for (GluuAttribute attribute : selectedAttributes) {
            attributeList.add(attribute.getInum());
        }
    }
    config.setAdditionalAttributes(attributeList);
    org.setOxRegistrationConfiguration(config);
    organizationService.updateOrganization(org);
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : ArrayList(java.util.ArrayList) RegistrationConfiguration(org.gluu.oxtrust.model.RegistrationConfiguration) GluuOrganization(org.gluu.oxtrust.model.GluuOrganization) GluuAttribute(org.xdi.model.GluuAttribute)

Example 24 with GluuAttribute

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

the class UpdateScopeAction method removeDuplicates.

public void removeDuplicates() {
    List<GluuAttribute> tempAvailableClaims = new ArrayList<GluuAttribute>();
    for (int i = 0; i < this.availableClaims.size(); i++) {
        for (int j = i + 1; j < this.availableClaims.size(); ) {
            if (this.availableClaims.get(i).getDisplayName().equalsIgnoreCase(this.availableClaims.get(j).getDisplayName())) {
                this.availableClaims.remove(j);
            } else {
                j++;
            }
        }
    }
    for (GluuAttribute availableClaim : this.availableClaims) {
        if (availableClaim != null) {
            tempAvailableClaims.add(availableClaim);
        }
    }
    this.availableClaims = tempAvailableClaims;
}
Also used : ArrayList(java.util.ArrayList) GluuAttribute(org.xdi.model.GluuAttribute)

Example 25 with GluuAttribute

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

the class PersonImportAction method convertTableToPersons.

protected List<GluuCustomPerson> convertTableToPersons(Table table, List<ImportAttribute> importAttributes) throws Exception {
    // Prepare for conversion to list of GluuCustomPerson and check data
    // type
    Map<String, List<AttributeData>> entriesAttributes = new HashMap<String, List<AttributeData>>();
    int rows = table.getCountRows();
    boolean validTable = true;
    for (int i = 1; i <= rows; i++) {
        List<AttributeData> attributeDataList = new ArrayList<AttributeData>();
        for (ImportAttribute importAttribute : importAttributes) {
            if (importAttribute.getCol() == -1) {
                continue;
            }
            GluuAttribute attribute = importAttribute.getAttribute();
            String cellValue = table.getCellValue(importAttribute.getCol(), i);
            if (StringHelper.isEmpty(cellValue)) {
                if (attribute.isRequred()) {
                    facesMessages.add(FacesMessage.SEVERITY_ERROR, "Import failed. Empty '{}' not allowed", attribute.getDisplayName());
                    validTable = false;
                }
                continue;
            }
            String ldapValue = getTypedValue(attribute, cellValue);
            if (StringHelper.isEmpty(ldapValue)) {
                facesMessages.add(FacesMessage.SEVERITY_ERROR, "Invalid value '{}' in column '{}' at row {} were specified", cellValue, attribute.getDisplayName(), i + 1);
                validTable = false;
                continue;
            }
            AttributeData attributeData = new AttributeData(attribute.getName(), ldapValue);
            attributeDataList.add(attributeData);
        }
        entriesAttributes.put(Integer.toString(i), attributeDataList);
    }
    if (!validTable) {
        return null;
    }
    // Convert to GluuCustomPerson and set right DN
    List<GluuCustomPerson> persons = personService.createEntities(entriesAttributes);
    log.info("Found {} persons in input Excel file", persons.size());
    for (GluuCustomPerson person : persons) {
        for (String key : entriesAttributes.keySet()) {
            boolean flag = false;
            for (AttributeData AttributeData : entriesAttributes.get(key)) {
                if (AttributeData.getName().equalsIgnoreCase("uid")) {
                    if (person.getUid().equalsIgnoreCase(AttributeData.getValue())) {
                        for (AttributeData AttributeData1 : entriesAttributes.get(key)) {
                            if (AttributeData1.getName().equalsIgnoreCase("userPassword")) {
                                person.setUserPassword(AttributeData1.getValue());
                                flag = true;
                                break;
                            } else if (AttributeData1.getName().equalsIgnoreCase("gluuStatus")) {
                                person.setStatus(GluuStatus.getByValue(AttributeData1.getValue()));
                                flag = true;
                                break;
                            }
                        }
                    }
                } else {
                    if (flag)
                        break;
                }
            }
            if (flag)
                break;
        }
    }
    return persons;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GluuAttribute(org.xdi.model.GluuAttribute) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ArrayList(java.util.ArrayList) List(java.util.List) AttributeData(org.gluu.site.ldap.persistence.AttributeData)

Aggregations

GluuAttribute (org.xdi.model.GluuAttribute)64 ArrayList (java.util.ArrayList)24 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)15 JSONObject (org.codehaus.jettison.json.JSONObject)9 JSONArray (org.codehaus.jettison.json.JSONArray)8 GluuAttributeDataType (org.xdi.model.GluuAttributeDataType)6 IOException (java.io.IOException)5 BigDecimal (java.math.BigDecimal)5 Date (java.util.Date)5 HashMap (java.util.HashMap)5 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)5 Extension (org.gluu.oxtrust.model.scim2.Extension)5 JwtSubClaimObject (org.xdi.oxauth.model.jwt.JwtSubClaimObject)5 Filter (com.unboundid.ldap.sdk.Filter)4 List (java.util.List)4 GluuSAMLTrustRelationship (org.gluu.oxtrust.model.GluuSAMLTrustRelationship)4 Claim (org.xdi.oxauth.model.authorize.Claim)4 Scope (org.xdi.oxauth.model.common.Scope)4 PairwiseIdentifier (org.xdi.oxauth.model.ldap.PairwiseIdentifier)4 DynamicScopeExternalContext (org.xdi.oxauth.service.external.context.DynamicScopeExternalContext)4