Search in sources :

Example 1 with CustomScriptType

use of org.xdi.model.custom.script.CustomScriptType in project oxAuth by GluuFederation.

the class AppInitializer method applicationInitialized.

public void applicationInitialized(@Observes @Initialized(ApplicationScoped.class) Object init) {
    createConnectionProvider();
    configurationFactory.create();
    LdapEntryManager localLdapEntryManager = ldapEntryManagerInstance.get();
    List<GluuLdapConfiguration> ldapAuthConfigs = loadLdapAuthConfigs(localLdapEntryManager);
    createAuthConnectionProviders(ldapAuthConfigs);
    setDefaultAuthenticationMethod(localLdapEntryManager);
    // Initialize python interpreter
    pythonService.initPythonInterpreter(configurationFactory.getLdapConfiguration().getString("pythonModulesDir", null));
    // Initialize script manager
    List<CustomScriptType> supportedCustomScriptTypes = Arrays.asList(CustomScriptType.PERSON_AUTHENTICATION, CustomScriptType.CLIENT_REGISTRATION, CustomScriptType.ID_GENERATOR, CustomScriptType.UMA_AUTHORIZATION_POLICY, CustomScriptType.APPLICATION_SESSION, CustomScriptType.DYNAMIC_SCOPE);
    // Start timer
    quartzSchedulerManager.start();
    // Schedule timer tasks
    metricService.initTimer();
    configurationFactory.initTimer();
    ldapStatusTimer.initTimer();
    cleanerTimer.initTimer();
    customScriptManager.initTimer(supportedCustomScriptTypes);
    keyGeneratorTimer.initTimer();
    initTimer();
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) CustomScriptType(org.xdi.model.custom.script.CustomScriptType) GluuLdapConfiguration(org.xdi.model.ldap.GluuLdapConfiguration)

Example 2 with CustomScriptType

use of org.xdi.model.custom.script.CustomScriptType in project oxTrust by GluuFederation.

the class ManageCustomScriptAction method modify.

public String modify() {
    if (this.initialized) {
        return OxTrustConstants.RESULT_SUCCESS;
    }
    CustomScriptType[] allowedCustomScriptTypes = this.applianceService.getCustomScriptTypes();
    this.customScriptsByTypes = new HashMap<CustomScriptType, List<CustomScript>>();
    for (CustomScriptType customScriptType : allowedCustomScriptTypes) {
        this.customScriptsByTypes.put(customScriptType, new ArrayList<CustomScript>());
    }
    try {
        List<CustomScript> customScripts = customScriptService.findCustomScripts(Arrays.asList(allowedCustomScriptTypes));
        for (CustomScript customScript : customScripts) {
            CustomScriptType customScriptType = customScript.getScriptType();
            List<CustomScript> customScriptsByType = this.customScriptsByTypes.get(customScriptType);
            CustomScript typedCustomScript = customScript;
            if (CustomScriptType.PERSON_AUTHENTICATION == customScriptType) {
                typedCustomScript = new AuthenticationCustomScript(customScript);
            }
            if (typedCustomScript.getConfigurationProperties() == null) {
                typedCustomScript.setConfigurationProperties(new ArrayList<SimpleCustomProperty>());
            }
            if (typedCustomScript.getModuleProperties() == null) {
                typedCustomScript.setModuleProperties(new ArrayList<SimpleCustomProperty>());
            }
            customScriptsByType.add(typedCustomScript);
        }
    } catch (Exception ex) {
        log.error("Failed to load custom scripts ", ex);
        return OxTrustConstants.RESULT_FAILURE;
    }
    this.initialized = true;
    return OxTrustConstants.RESULT_SUCCESS;
}
Also used : AuthenticationCustomScript(org.xdi.model.custom.script.model.auth.AuthenticationCustomScript) CustomScript(org.xdi.model.custom.script.model.CustomScript) CustomScriptType(org.xdi.model.custom.script.CustomScriptType) ArrayList(java.util.ArrayList) List(java.util.List) AuthenticationCustomScript(org.xdi.model.custom.script.model.auth.AuthenticationCustomScript) SimpleCustomProperty(org.xdi.model.SimpleCustomProperty) LdapMappingException(org.gluu.site.ldap.persistence.exception.LdapMappingException)

Example 3 with CustomScriptType

use of org.xdi.model.custom.script.CustomScriptType in project oxTrust by GluuFederation.

the class AppInitializer method applicationInitialized.

/**
	 * Initialize components and schedule DS connection time checker
	 */
public void applicationInitialized(@Observes @Initialized(ApplicationScoped.class) Object init) {
    log.debug("Creating application components");
    showBuildInfo();
    // Initialize local LDAP connection provider
    createConnectionProvider();
    configurationFactory.create();
    LdapEntryManager localLdapEntryManager = ldapEntryManagerInstance.get();
    // Initialize central LDAP connection provider
    createCentralConnectionProvider();
    initializeLdifArchiver(localLdapEntryManager);
    // Initialize template engine
    templateService.initTemplateEngine();
    // Initialize SubversionService
    subversionService.initSubversionService();
    // Initialize python interpreter
    pythonService.initPythonInterpreter(configurationFactory.getLdapConfiguration().getString("pythonModulesDir", null));
    // Initialize Shibboleth
    shibbolethInitializer.createShibbolethConfiguration();
    // Initialize script manager
    List<CustomScriptType> supportedCustomScriptTypes = Arrays.asList(CustomScriptType.CACHE_REFRESH, CustomScriptType.UPDATE_USER, CustomScriptType.USER_REGISTRATION, CustomScriptType.ID_GENERATOR, CustomScriptType.SCIM);
    // Start timer
    quartzSchedulerManager.start();
    // Schedule timer tasks
    metricService.initTimer();
    configurationFactory.initTimer();
    ldapStatusTimer.initTimer();
    metadataValidationTimer.initTimer();
    entityIDMonitoringService.initTimer();
    cacheRefreshTimer.initTimer();
    customScriptManager.initTimer(supportedCustomScriptTypes);
    statusCheckerDaily.initTimer();
    statusCheckerTimer.initTimer();
    svnSyncTimer.initTimer();
    logFileSizeChecker.initTimer();
    loggerService.updateLoggerConfigLocation();
}
Also used : LdapEntryManager(org.gluu.site.ldap.persistence.LdapEntryManager) CustomScriptType(org.xdi.model.custom.script.CustomScriptType)

Example 4 with CustomScriptType

use of org.xdi.model.custom.script.CustomScriptType in project oxCore by GluuFederation.

the class CustomScriptManager method groupCustomScriptConfigurationsByScriptType.

private Map<CustomScriptType, List<CustomScriptConfiguration>> groupCustomScriptConfigurationsByScriptType(Map<String, CustomScriptConfiguration> customScriptConfigurations) {
    Map<CustomScriptType, List<CustomScriptConfiguration>> newCustomScriptConfigurationsByScriptType = new HashMap<CustomScriptType, List<CustomScriptConfiguration>>();
    for (CustomScriptType customScriptType : this.supportedCustomScriptTypes) {
        List<CustomScriptConfiguration> customConfigurationsByScriptType = new ArrayList<CustomScriptConfiguration>();
        newCustomScriptConfigurationsByScriptType.put(customScriptType, customConfigurationsByScriptType);
    }
    for (CustomScriptConfiguration customScriptConfiguration : customScriptConfigurations.values()) {
        CustomScriptType customScriptType = customScriptConfiguration.getCustomScript().getScriptType();
        List<CustomScriptConfiguration> customConfigurationsByScriptType = newCustomScriptConfigurationsByScriptType.get(customScriptType);
        customConfigurationsByScriptType.add(customScriptConfiguration);
    }
    return newCustomScriptConfigurationsByScriptType;
}
Also used : HashMap(java.util.HashMap) CustomScriptType(org.xdi.model.custom.script.CustomScriptType) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CustomScriptConfiguration(org.xdi.model.custom.script.conf.CustomScriptConfiguration)

Example 5 with CustomScriptType

use of org.xdi.model.custom.script.CustomScriptType in project oxCore by GluuFederation.

the class CustomScriptManager method createExternalTypeFromStringWithPythonException.

public BaseExternalType createExternalTypeFromStringWithPythonException(CustomScript customScript, Map<String, SimpleCustomProperty> configurationAttributes) throws PythonException {
    String script = customScript.getScript();
    if (script == null) {
        return null;
    }
    CustomScriptType customScriptType = customScript.getScriptType();
    BaseExternalType externalType = null;
    InputStream bis = null;
    try {
        bis = new ByteArrayInputStream(script.getBytes("UTF-8"));
        externalType = pythonService.loadPythonScript(bis, customScriptType.getPythonClass(), customScriptType.getCustomScriptType(), new PyObject[] { new PyLong(System.currentTimeMillis()) });
    } catch (UnsupportedEncodingException e) {
        log.error(e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(bis);
    }
    if (externalType == null) {
        return null;
    }
    boolean initialized = false;
    try {
        initialized = externalType.init(configurationAttributes);
    } catch (Exception ex) {
        log.error("Failed to initialize custom script: '{0}'", ex, customScript.getName());
    }
    if (initialized) {
        return externalType;
    }
    return null;
}
Also used : PyLong(org.python.core.PyLong) ByteArrayInputStream(java.io.ByteArrayInputStream) CustomScriptType(org.xdi.model.custom.script.CustomScriptType) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) BaseExternalType(org.xdi.model.custom.script.type.BaseExternalType) UnsupportedEncodingException(java.io.UnsupportedEncodingException) PyObject(org.python.core.PyObject) PythonException(org.xdi.exception.PythonException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

CustomScriptType (org.xdi.model.custom.script.CustomScriptType)7 ArrayList (java.util.ArrayList)4 List (java.util.List)3 CustomScript (org.xdi.model.custom.script.model.CustomScript)3 LdapEntryManager (org.gluu.site.ldap.persistence.LdapEntryManager)2 LdapMappingException (org.gluu.site.ldap.persistence.exception.LdapMappingException)2 AuthenticationCustomScript (org.xdi.model.custom.script.model.auth.AuthenticationCustomScript)2 Filter (com.unboundid.ldap.sdk.Filter)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashMap (java.util.HashMap)1 PyLong (org.python.core.PyLong)1 PyObject (org.python.core.PyObject)1 PythonException (org.xdi.exception.PythonException)1 SimpleCustomProperty (org.xdi.model.SimpleCustomProperty)1 CustomScriptConfiguration (org.xdi.model.custom.script.conf.CustomScriptConfiguration)1 BaseExternalType (org.xdi.model.custom.script.type.BaseExternalType)1 GluuLdapConfiguration (org.xdi.model.ldap.GluuLdapConfiguration)1