Search in sources :

Example 16 with GluuAttribute

use of org.gluu.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.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);
    jsonConfigurationService.saveOxTrustappConfiguration(this.oxTrustappConfiguration);
    facesMessages.add(FacesMessage.SEVERITY_INFO, "Registration configuration updated successfully");
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : ArrayList(java.util.ArrayList) RegistrationConfiguration(org.gluu.oxtrust.model.RegistrationConfiguration) GluuOrganization(org.gluu.oxtrust.model.GluuOrganization) GluuAttribute(org.gluu.model.GluuAttribute)

Example 17 with GluuAttribute

use of org.gluu.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.gluu.model.GluuAttribute)

Example 18 with GluuAttribute

use of org.gluu.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("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.gluu.model.GluuAttribute) RegistrationConfiguration(org.gluu.oxtrust.model.RegistrationConfiguration)

Example 19 with GluuAttribute

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

the class UpdateAttributeAction method add.

public String add() {
    if (this.attribute != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    this.update = false;
    this.showAttributeDeleteConfirmation = false;
    this.attribute = new GluuAttribute();
    attribute.setAttributeValidation(new AttributeValidation());
    this.attribute.setStatus(GluuStatus.ACTIVE);
    this.attribute.setEditType(new GluuUserRole[] { GluuUserRole.ADMIN });
    this.canEdit = true;
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : AttributeValidation(org.gluu.model.attribute.AttributeValidation) GluuAttribute(org.gluu.model.GluuAttribute)

Example 20 with GluuAttribute

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

the class OxTrustAttributeValidator method validate.

@Override
public void validate(FacesContext context, UIComponent comp, Object value) {
    GluuAttribute attribute = (GluuAttribute) comp.getAttributes().get("attribute");
    if (attribute == null) {
        ((UIInput) comp).setValid(true);
        return;
    }
    AttributeValidation attributeValidation = attribute.getAttributeValidation();
    Integer minvalue = attributeValidation != null ? attributeValidation.getMinLength() : null;
    Integer maxValue = attributeValidation != null ? attributeValidation.getMaxLength() : null;
    String regexpValue = attributeValidation != null ? attributeValidation.getRegexp() : null;
    String attributeValue = (String) value;
    // Minimum length validation
    if (minvalue != null) {
        int min = attributeValidation.getMinLength();
        if ((attributeValue != null) && (attributeValue.length() < min)) {
            ((UIInput) comp).setValid(false);
            FacesMessage message = new FacesMessage(attribute.getDisplayName() + " should be at least " + min + " symbols. ");
            message.setSeverity(FacesMessage.SEVERITY_ERROR);
            context.addMessage(comp.getClientId(context), message);
        }
    }
    // default maxlength
    int max = 400;
    if (maxValue != null) {
        max = attributeValidation.getMaxLength();
    }
    // Maximum Length validation
    if ((attributeValue != null) && (attributeValue.length() > max)) {
        ((UIInput) comp).setValid(false);
        FacesMessage message = new FacesMessage(attribute.getDisplayName() + " should not exceed " + max + " symbols. ");
        message.setSeverity(FacesMessage.SEVERITY_ERROR);
        context.addMessage(comp.getClientId(context), message);
    }
    if ((attribute.getName().equalsIgnoreCase("mail") && ((regexpValue == null) || (StringHelper.isEmpty(regexpValue))))) {
        regexpValue = "^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@" + "[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$";
    }
    if ((regexpValue != null) && StringHelper.isNotEmpty(regexpValue)) {
        java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(regexpValue);
        if ((attributeValue != null) && !(attributeValue.trim().equals(""))) {
            java.util.regex.Matcher matcher = pattern.matcher(attributeValue);
            boolean flag = matcher.matches();
            if (!flag) {
                ((UIInput) comp).setValid(false);
                FacesMessage message = new FacesMessage(attribute.getDisplayName() + " Format is invalid. ");
                message.setSeverity(FacesMessage.SEVERITY_ERROR);
                context.addMessage(comp.getClientId(context), message);
            }
        }
    }
}
Also used : AttributeValidation(org.gluu.model.attribute.AttributeValidation) UIInput(javax.faces.component.UIInput) FacesMessage(javax.faces.application.FacesMessage) 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