Search in sources :

Example 1 with RegistrationConfiguration

use of org.gluu.oxtrust.model.RegistrationConfiguration 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 2 with RegistrationConfiguration

use of org.gluu.oxtrust.model.RegistrationConfiguration 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 3 with RegistrationConfiguration

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

the class RegisterPersonAction method initRecaptcha.

private void initRecaptcha() {
    GluuOrganization organization = organizationService.getOrganization();
    RegistrationConfiguration config = organization.getOxRegistrationConfiguration();
    boolean registrationCustomized = config != null;
    this.captchaDisabled = !recaptchaService.isEnabled();
    if (!this.captchaDisabled) {
        this.captchaDisabled = registrationCustomized && config.isCaptchaDisabled();
    }
}
Also used : RegistrationConfiguration(org.gluu.oxtrust.model.RegistrationConfiguration) GluuOrganization(org.gluu.oxtrust.model.GluuOrganization)

Example 4 with RegistrationConfiguration

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

the class RegistrationInterceptionService method runPostRegistrationScripts.

public boolean runPostRegistrationScripts(GluuCustomPerson person, Map<String, String[]> requestParameters) {
    GluuOrganization org = organizationService.getOrganization();
    RegistrationConfiguration config = org.getOxRegistrationConfiguration();
    if (config != null && config.isRegistrationInterceptorsConfigured()) {
        List<RegistrationInterceptorScript> scripts = config.getRegistrationInterceptorScripts();
        List<RegistrationInterceptorScript> sortedEnabledPostRegistrationScripts = sort(getActive(getPostRegistrationScripts(scripts)));
        if (sortedEnabledPostRegistrationScripts != null) {
            boolean result = true;
            for (RegistrationInterceptorScript script : sortedEnabledPostRegistrationScripts) {
                RegistrationScript registrationScript = createRegistrationScriptFromStringWithPythonException(script);
                result &= registrationScript.execute(script.getCustomAttributes(), person, requestParameters);
            }
            return result;
        } else {
            return true;
        }
    } else {
        return true;
    }
}
Also used : RegistrationScript(org.gluu.oxtrust.service.python.interfaces.RegistrationScript) RegistrationInterceptorScript(org.gluu.oxtrust.model.RegistrationInterceptorScript) RegistrationConfiguration(org.gluu.oxtrust.model.RegistrationConfiguration) GluuOrganization(org.gluu.oxtrust.model.GluuOrganization)

Example 5 with RegistrationConfiguration

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

the class RegistrationInterceptionService method runPreRegistrationScripts.

public boolean runPreRegistrationScripts(GluuCustomPerson person, Map<String, String[]> requestParameters) {
    GluuOrganization org = organizationService.getOrganization();
    RegistrationConfiguration config = org.getOxRegistrationConfiguration();
    if (config != null && config.isRegistrationInterceptorsConfigured()) {
        List<RegistrationInterceptorScript> scripts = config.getRegistrationInterceptorScripts();
        List<RegistrationInterceptorScript> sortedEnabledPreRegistrationScripts = sort(getActive(getPreRegistrationScripts(scripts)));
        if (sortedEnabledPreRegistrationScripts != null) {
            boolean result = true;
            for (RegistrationInterceptorScript script : sortedEnabledPreRegistrationScripts) {
                RegistrationScript registrationScript = createRegistrationScriptFromStringWithPythonException(script);
                result &= registrationScript.execute(script.getCustomAttributes(), person, requestParameters);
            }
            return result;
        } else {
            return true;
        }
    } else {
        return true;
    }
}
Also used : RegistrationScript(org.gluu.oxtrust.service.python.interfaces.RegistrationScript) RegistrationInterceptorScript(org.gluu.oxtrust.model.RegistrationInterceptorScript) RegistrationConfiguration(org.gluu.oxtrust.model.RegistrationConfiguration) GluuOrganization(org.gluu.oxtrust.model.GluuOrganization)

Aggregations

GluuOrganization (org.gluu.oxtrust.model.GluuOrganization)7 RegistrationConfiguration (org.gluu.oxtrust.model.RegistrationConfiguration)7 RegistrationInterceptorScript (org.gluu.oxtrust.model.RegistrationInterceptorScript)4 ArrayList (java.util.ArrayList)3 RegistrationScript (org.gluu.oxtrust.service.python.interfaces.RegistrationScript)3 GluuAttribute (org.xdi.model.GluuAttribute)3 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)1