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();
}
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;
}
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();
}
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;
}
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;
}
Aggregations