Search in sources :

Example 1 with GluuOrganization

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

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

Example 3 with GluuOrganization

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

the class AuthOrganizationService method getOrganizationCustomMessage.

/**
 * Returns custom message defined for the organization
 *
 * @param customMessageId
 *            message id
 * @return custom message
 */
public String getOrganizationCustomMessage(String customMessageId) throws Exception {
    GluuOrganization organization = getOrganization();
    String key = OxTrustConstants.CACHE_ORGANIZATION_CUSTOM_MESSAGE_KEY + "_" + organization.getInum();
    @SuppressWarnings("unchecked") Map<String, String> organizationCustomMessage = (Map<String, String>) cacheService.get(OxConstants.CACHE_APPLICATION_NAME, key);
    if (organizationCustomMessage == null) {
        organizationCustomMessage = new HashMap<String, String>();
        String[] customMessages = organization.getCustomMessages();
        if (ArrayHelper.isNotEmpty(customMessages)) {
            for (String customMessage : customMessages) {
                int idx = customMessage.indexOf(':');
                if ((idx > 0) && (idx + 1 < customMessage.length())) {
                    String msgKey = customMessage.substring(0, idx).trim();
                    String msgValue = customMessage.substring(idx + 1).trim();
                    if (StringHelper.isNotEmpty(msgKey) && StringHelper.isNotEmpty(msgValue)) {
                        organizationCustomMessage.put(msgKey, msgValue);
                    }
                }
            }
        }
        cacheService.put(OxConstants.CACHE_APPLICATION_NAME, key, organizationCustomMessage);
    }
    return organizationCustomMessage.get(customMessageId);
}
Also used : GluuOrganization(org.gluu.oxtrust.model.GluuOrganization) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with GluuOrganization

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

the class OrganizationService method getOrganizationCustomMessage.

/**
 * Returns custom message defined for the organization
 *
 * @param customMessageId
 *            message id
 * @return custom message
 */
public String getOrganizationCustomMessage(String customMessageId) {
    GluuOrganization organization = getOrganization();
    String key = OxTrustConstants.CACHE_ORGANIZATION_CUSTOM_MESSAGE_KEY + "_" + organization.getInum();
    @SuppressWarnings("unchecked") Map<String, String> organizationCustomMessage = (Map<String, String>) cacheService.get(OxConstants.CACHE_APPLICATION_NAME, key);
    if (organizationCustomMessage == null) {
        organizationCustomMessage = new HashMap<String, String>();
        String[] customMessages = organization.getCustomMessages();
        if (ArrayHelper.isNotEmpty(customMessages)) {
            for (String customMessage : customMessages) {
                int idx = customMessage.indexOf(':');
                if ((idx > 0) && (idx + 1 < customMessage.length())) {
                    String msgKey = customMessage.substring(0, idx).trim();
                    String msgValue = customMessage.substring(idx + 1).trim();
                    if (StringHelper.isNotEmpty(msgKey) && StringHelper.isNotEmpty(msgValue)) {
                        organizationCustomMessage.put(msgKey, msgValue);
                    }
                }
            }
        }
        cacheService.put(OxConstants.CACHE_APPLICATION_NAME, key, organizationCustomMessage);
    }
    return organizationCustomMessage.get(customMessageId);
}
Also used : GluuOrganization(org.gluu.oxtrust.model.GluuOrganization) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with GluuOrganization

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

the class UpdateOrganizationAction method modifyOrganization.

private String modifyOrganization() {
    if (this.organization != null) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    try {
        GluuOrganization tmpOrganization = organizationService.getOrganization();
        this.organization = new GluuOrganization();
        try {
            PropertyUtils.copyProperties(this.organization, tmpOrganization);
        } catch (Exception ex) {
            log.error("Failed to load organization", ex);
            this.organization = null;
        }
    } catch (BasePersistenceException ex) {
        log.error("Failed to load organization", ex);
    }
    if (this.organization == null) {
        return OxTrustConstants.RESULT_FAILURE;
    }
    this.loginPageCustomMessage = organizationService.getOrganizationCustomMessage(OxTrustConstants.CUSTOM_MESSAGE_LOGIN_PAGE);
    this.welcomePageCustomMessage = organizationService.getOrganizationCustomMessage(OxTrustConstants.CUSTOM_MESSAGE_WELCOME_PAGE);
    this.welcomeTitleText = organizationService.getOrganizationCustomMessage(OxTrustConstants.CUSTOM_MESSAGE_TITLE_TEXT);
    initOxAuthSetting();
    configurations = new ArrayList<GluuConfiguration>();
    configurations.addAll(configurationService.getConfigurations());
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) GluuOrganization(org.gluu.oxtrust.model.GluuOrganization) GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration) BasePersistenceException(org.gluu.persist.exception.BasePersistenceException) IOException(java.io.IOException)

Aggregations

GluuOrganization (org.gluu.oxtrust.model.GluuOrganization)25 RegistrationConfiguration (org.gluu.oxtrust.model.RegistrationConfiguration)7 Date (java.util.Date)6 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 GluuAttribute (org.gluu.model.GluuAttribute)3 RegistrationInterceptorScript (org.gluu.oxtrust.model.RegistrationInterceptorScript)3 RegistrationScript (org.gluu.oxtrust.service.python.interfaces.RegistrationScript)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)2 ParseException (java.text.ParseException)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 UserRole (org.gluu.model.user.UserRole)1 DuplicateEmailException (org.gluu.oxtrust.exception.DuplicateEmailException)1 GluuConfiguration (org.gluu.oxtrust.model.GluuConfiguration)1 GluuCustomAttribute (org.gluu.oxtrust.model.GluuCustomAttribute)1 PasswordResetRequest (org.gluu.oxtrust.model.PasswordResetRequest)1