Search in sources :

Example 1 with RegistrationScript

use of org.gluu.oxtrust.service.python.interfaces.RegistrationScript 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 RegistrationScript

use of org.gluu.oxtrust.service.python.interfaces.RegistrationScript in project oxTrust by GluuFederation.

the class RegistrationInterceptionService method createRegistrationScriptFromStringWithPythonException.

private RegistrationScript createRegistrationScriptFromStringWithPythonException(RegistrationInterceptorScript script) {
    String pythonScriptText = script.getCustomScript();
    if (pythonScriptText == null) {
        return null;
    }
    RegistrationScript pythonScript = null;
    InputStream bis = null;
    try {
        bis = new ByteArrayInputStream(pythonScriptText.getBytes(Util.UTF8_STRING_ENCODING));
        pythonScript = pythonService.loadPythonScript(bis, "RegistrationScriptClass", RegistrationScript.class, new PyObject[] { new PyLong(System.currentTimeMillis()) });
    } catch (UnsupportedEncodingException e) {
        log.error(e.getMessage(), e);
    } catch (PythonException e) {
        log.error(e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(bis);
    }
    return pythonScript;
}
Also used : RegistrationScript(org.gluu.oxtrust.service.python.interfaces.RegistrationScript) PyLong(org.python.core.PyLong) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) UnsupportedEncodingException(java.io.UnsupportedEncodingException) PythonException(org.xdi.exception.PythonException) PyObject(org.python.core.PyObject)

Example 3 with RegistrationScript

use of org.gluu.oxtrust.service.python.interfaces.RegistrationScript 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 4 with RegistrationScript

use of org.gluu.oxtrust.service.python.interfaces.RegistrationScript in project oxTrust by GluuFederation.

the class RegistrationInterceptionService method runInitRegistrationScripts.

public boolean runInitRegistrationScripts(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> sortedEnabledInitRegistrationScripts = sort(getActive(getInitRegistrationScripts(scripts)));
        if (sortedEnabledInitRegistrationScripts != null) {
            boolean result = true;
            for (RegistrationInterceptorScript script : sortedEnabledInitRegistrationScripts) {
                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

RegistrationScript (org.gluu.oxtrust.service.python.interfaces.RegistrationScript)4 GluuOrganization (org.gluu.oxtrust.model.GluuOrganization)3 RegistrationConfiguration (org.gluu.oxtrust.model.RegistrationConfiguration)3 RegistrationInterceptorScript (org.gluu.oxtrust.model.RegistrationInterceptorScript)3 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 PyLong (org.python.core.PyLong)1 PyObject (org.python.core.PyObject)1 PythonException (org.xdi.exception.PythonException)1