Search in sources :

Example 6 with GluuOrganization

use of org.gluu.oxtrust.model.GluuOrganization 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 7 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(OxTrustConstants.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(OxTrustConstants.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 8 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 9 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 10 with GluuOrganization

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

the class AuthOrganizationService method getOrganizationByInum.

/**
	 * Get organization by DN
	 * 
	 * @param inum
	 *            inum
	 * @return Organization
	 */
public GluuOrganization getOrganizationByInum(String inum) throws Exception {
    String key = OxTrustConstants.CACHE_ORGANIZATION_KEY + "_" + inum;
    GluuOrganization organization = (GluuOrganization) cacheService.get(OxTrustConstants.CACHE_APPLICATION_NAME, key);
    if (organization == null) {
        organization = ldapAuthEntryManager.find(GluuOrganization.class, getDnForOrganization(inum));
        cacheService.put(OxTrustConstants.CACHE_APPLICATION_NAME, key, organization);
    }
    return organization;
}
Also used : GluuOrganization(org.gluu.oxtrust.model.GluuOrganization)

Aggregations

GluuOrganization (org.gluu.oxtrust.model.GluuOrganization)18 RegistrationConfiguration (org.gluu.oxtrust.model.RegistrationConfiguration)7 ArrayList (java.util.ArrayList)4 RegistrationInterceptorScript (org.gluu.oxtrust.model.RegistrationInterceptorScript)4 IOException (java.io.IOException)3 RegistrationScript (org.gluu.oxtrust.service.python.interfaces.RegistrationScript)3 GluuAttribute (org.xdi.model.GluuAttribute)3 File (java.io.File)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 GluuImage (org.xdi.model.GluuImage)2 DownloadWrapper (org.xdi.util.io.DownloadWrapper)2 ParseException (java.text.ParseException)1 HashSet (java.util.HashSet)1 AuthenticationFailedException (javax.mail.AuthenticationFailedException)1 MessagingException (javax.mail.MessagingException)1 ServletException (javax.servlet.ServletException)1