Search in sources :

Example 1 with PersistenceEntryManager

use of io.jans.orm.PersistenceEntryManager in project jans by JanssenProject.

the class AppInitializer method createMetricPersistenceEntryManager.

@Produces
@ApplicationScoped
@Named(ApplicationFactory.PERSISTENCE_METRIC_ENTRY_MANAGER_NAME)
@ReportMetric
public PersistenceEntryManager createMetricPersistenceEntryManager() {
    Properties connectionProperties = prepareCustomPersistanceProperties(ApplicationFactory.PERSISTENCE_METRIC_CONFIG_GROUP_NAME);
    PersistenceEntryManager persistenceEntryManager = applicationFactory.getPersistenceEntryManagerFactory().createEntryManager(connectionProperties);
    log.info("Created {}: {} with operation service: {}", ApplicationFactory.PERSISTENCE_METRIC_ENTRY_MANAGER_NAME, persistenceEntryManager, persistenceEntryManager.getOperationService());
    externalPersistenceExtensionService.executePersistenceExtensionAfterCreate(connectionProperties, persistenceEntryManager);
    return persistenceEntryManager;
}
Also used : PersistenceEntryManager(io.jans.orm.PersistenceEntryManager) Properties(java.util.Properties) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ReportMetric(io.jans.service.metric.inject.ReportMetric) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 2 with PersistenceEntryManager

use of io.jans.orm.PersistenceEntryManager in project jans by JanssenProject.

the class AppInitializer method createPersistenceAuthEntryManager.

@Produces
@ApplicationScoped
@Named(ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME)
public List<PersistenceEntryManager> createPersistenceAuthEntryManager() {
    List<PersistenceEntryManager> persistenceAuthEntryManagers = new ArrayList<>();
    if (this.persistenceAuthConfigs.size() == 0) {
        return persistenceAuthEntryManagers;
    }
    PersistenceEntryManagerFactory persistenceEntryManagerFactory = applicationFactory.getPersistenceEntryManagerFactory(LdapEntryManagerFactory.class);
    List<Properties> persistenceAuthProperties = prepareAuthConnectionProperties(this.persistenceAuthConfigs, persistenceEntryManagerFactory.getPersistenceType());
    log.trace("Attempting to create LDAP auth PersistenceEntryManager with properties: {}", persistenceAuthProperties);
    for (int i = 0; i < persistenceAuthProperties.size(); i++) {
        PersistenceEntryManager persistenceAuthEntryManager = persistenceEntryManagerFactory.createEntryManager(persistenceAuthProperties.get(i));
        log.debug("Created {}#{}: {}", ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, i, persistenceAuthEntryManager);
        persistenceAuthEntryManagers.add(persistenceAuthEntryManager);
        externalPersistenceExtensionService.executePersistenceExtensionAfterCreate(persistenceAuthProperties.get(i), persistenceAuthEntryManager);
    }
    return persistenceAuthEntryManagers;
}
Also used : PersistenceEntryManager(io.jans.orm.PersistenceEntryManager) ArrayList(java.util.ArrayList) PersistenceEntryManagerFactory(io.jans.orm.PersistenceEntryManagerFactory) Properties(java.util.Properties) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 3 with PersistenceEntryManager

use of io.jans.orm.PersistenceEntryManager in project jans by JanssenProject.

the class AppInitializer method applicationInitialized.

public void applicationInitialized(@Observes @Initialized(ApplicationScoped.class) Object init) {
    log.debug("Initializing application services");
    configurationFactory.create();
    PersistenceEntryManager localPersistenceEntryManager = persistenceEntryManagerInstance.get();
    log.trace("Attempting to use {}: {}", ApplicationFactory.PERSISTENCE_ENTRY_MANAGER_NAME, localPersistenceEntryManager.getOperationService());
    GluuConfiguration newConfiguration = loadConfiguration(localPersistenceEntryManager, "jansDbAuth", "jansAuthMode");
    this.persistenceAuthConfigs = loadPersistenceAuthConfigs(newConfiguration);
    // Initialize python interpreter
    pythonService.initPythonInterpreter(configurationFactory.getBaseConfiguration().getString("pythonModulesDir", null));
    // Initialize script manager
    List<CustomScriptType> supportedCustomScriptTypes = Lists.newArrayList(CustomScriptType.values());
    supportedCustomScriptTypes.remove(CustomScriptType.CACHE_REFRESH);
    supportedCustomScriptTypes.remove(CustomScriptType.UPDATE_USER);
    supportedCustomScriptTypes.remove(CustomScriptType.USER_REGISTRATION);
    supportedCustomScriptTypes.remove(CustomScriptType.SCIM);
    supportedCustomScriptTypes.remove(CustomScriptType.IDP);
    statService.init();
    // Start timer
    initSchedulerService();
    // Schedule timer tasks
    metricService.initTimer();
    configurationFactory.initTimer();
    loggerService.initTimer();
    ldapStatusTimer.initTimer();
    cleanerTimer.initTimer();
    customScriptManager.initTimer(supportedCustomScriptTypes);
    keyGeneratorTimer.initTimer();
    statTimer.initTimer();
    expirationNotificatorTimer.initTimer();
    initTimer();
    initCibaRequestsProcessor();
    // Set default authentication method after
    setDefaultAuthenticationMethod(newConfiguration);
    // Notify plugins about finish application initialization
    eventApplicationInitialized.select(ApplicationInitialized.Literal.APPLICATION).fire(new ApplicationInitializedEvent());
}
Also used : PersistenceEntryManager(io.jans.orm.PersistenceEntryManager) ApplicationInitializedEvent(io.jans.service.cdi.event.ApplicationInitializedEvent) CustomScriptType(io.jans.model.custom.script.CustomScriptType) GluuConfiguration(io.jans.as.persistence.model.configuration.GluuConfiguration)

Example 4 with PersistenceEntryManager

use of io.jans.orm.PersistenceEntryManager in project jans by JanssenProject.

the class AppInitializer method recreatePersistanceEntryManagerImpl.

protected void recreatePersistanceEntryManagerImpl(Instance<PersistenceEntryManager> instance, String persistenceEntryManagerName, Annotation... qualifiers) {
    // Get existing application scoped instance
    PersistenceEntryManager oldPersistenceEntryManager = CdiUtil.getContextBean(beanManager, PersistenceEntryManager.class, persistenceEntryManagerName);
    // Close existing connections
    closePersistenceEntryManager(oldPersistenceEntryManager, persistenceEntryManagerName);
    // Force to create new bean
    PersistenceEntryManager persistenceEntryManager = instance.get();
    instance.destroy(persistenceEntryManager);
    log.info("Recreated instance {}: {} with operation service: {}", persistenceEntryManagerName, persistenceEntryManager, persistenceEntryManager.getOperationService());
}
Also used : PersistenceEntryManager(io.jans.orm.PersistenceEntryManager)

Example 5 with PersistenceEntryManager

use of io.jans.orm.PersistenceEntryManager in project jans by JanssenProject.

the class AppInitializer method closePersistenceEntryManagers.

private void closePersistenceEntryManagers(List<PersistenceEntryManager> oldPersistenceEntryManagers) {
    // Close existing connections
    for (PersistenceEntryManager oldPersistenceEntryManager : oldPersistenceEntryManagers) {
        log.debug("Attempting to destroy {}: {}", ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, oldPersistenceEntryManager);
        oldPersistenceEntryManager.destroy();
        log.debug("Destroyed {}: {}", ApplicationFactory.PERSISTENCE_AUTH_ENTRY_MANAGER_NAME, oldPersistenceEntryManager);
        externalPersistenceExtensionService.executePersistenceExtensionAfterDestroy(oldPersistenceEntryManager);
    }
}
Also used : PersistenceEntryManager(io.jans.orm.PersistenceEntryManager)

Aggregations

PersistenceEntryManager (io.jans.orm.PersistenceEntryManager)48 Properties (java.util.Properties)10 SchemaEntry (io.jans.model.SchemaEntry)7 PersistenceEntryManagerFactory (io.jans.orm.PersistenceEntryManagerFactory)7 ApplicationScoped (javax.enterprise.context.ApplicationScoped)7 Produces (javax.enterprise.inject.Produces)7 Named (javax.inject.Named)7 BasePersistenceException (io.jans.orm.exception.BasePersistenceException)5 ConfigurationException (io.jans.exception.ConfigurationException)3 GluuLdapConfiguration (io.jans.model.ldap.GluuLdapConfiguration)3 ArrayList (java.util.ArrayList)3 GluuConfiguration (io.jans.as.persistence.model.configuration.GluuConfiguration)2 CustomScriptType (io.jans.model.custom.script.CustomScriptType)2 ApplicationInitializedEvent (io.jans.service.cdi.event.ApplicationInitializedEvent)2 ReportMetric (io.jans.service.metric.inject.ReportMetric)2 InvalidSchemaUpdateException (io.jans.util.exception.InvalidSchemaUpdateException)2 List (java.util.List)2 Conf (io.jans.as.model.config.Conf)1 WebKeysConfiguration (io.jans.as.model.config.WebKeysConfiguration)1 AbstractCryptoProvider (io.jans.as.model.crypto.AbstractCryptoProvider)1