Search in sources :

Example 1 with PersistenceConfiguration

use of org.gluu.persist.model.PersistenceConfiguration in project oxTrust by GluuFederation.

the class ConfigurationFactory method reloadConfiguration.

private void reloadConfiguration() {
    // Reload LDAP configuration if needed
    PersistenceConfiguration newPersistenceConfiguration = persistanceFactoryService.loadPersistenceConfiguration(getApplicationPropertiesFileName());
    if (newPersistenceConfiguration != null) {
        if (!StringHelper.equalsIgnoreCase(this.persistenceConfiguration.getFileName(), newPersistenceConfiguration.getFileName()) || (newPersistenceConfiguration.getLastModifiedTime() > this.persistenceConfiguration.getLastModifiedTime())) {
            // Reload configuration only if it was modified
            this.persistenceConfiguration = newPersistenceConfiguration;
            event.select(LdapConfigurationReload.Literal.INSTANCE).fire(PERSISTENCE_CONFIGUARION_RELOAD_EVENT_TYPE);
        }
    }
    // Reload Base configuration if needed
    File baseConfiguration = new File(BASE_PROPERTIES_FILE);
    if (baseConfiguration.exists()) {
        final long lastModified = baseConfiguration.lastModified();
        if (lastModified > baseConfigurationFileLastModifiedTime) {
            // Reload configuration only if it was modified
            loadBaseConfiguration();
            event.select(BaseConfigurationReload.Literal.INSTANCE).fire(BASE_CONFIGUARION_RELOAD_EVENT_TYPE);
        }
    }
    if (!loadedFromLdap) {
        return;
    }
    final C conf = loadConfigurationFromDb("oxRevision");
    if (conf == null) {
        return;
    }
    if (!isNewRevision(conf)) {
        return;
    }
    createFromDb();
}
Also used : PersistenceConfiguration(org.gluu.persist.model.PersistenceConfiguration) File(java.io.File)

Example 2 with PersistenceConfiguration

use of org.gluu.persist.model.PersistenceConfiguration in project oxTrust by GluuFederation.

the class AppInitializer method preparePersistanceProperties.

protected Properties preparePersistanceProperties() {
    PersistenceConfiguration persistenceConfiguration = this.configurationFactory.getPersistenceConfiguration();
    FileConfiguration persistenceConfig = persistenceConfiguration.getConfiguration();
    Properties connectionProperties = (Properties) persistenceConfig.getProperties();
    EncryptionService securityService = encryptionServiceInstance.get();
    Properties decryptedConnectionProperties = securityService.decryptAllProperties(connectionProperties);
    return decryptedConnectionProperties;
}
Also used : FileConfiguration(org.gluu.orm.util.properties.FileConfiguration) PersistenceConfiguration(org.gluu.persist.model.PersistenceConfiguration) Properties(java.util.Properties)

Example 3 with PersistenceConfiguration

use of org.gluu.persist.model.PersistenceConfiguration in project oxAuth by GluuFederation.

the class ConfigurationFactory method reloadConfiguration.

private void reloadConfiguration() {
    // Reload LDAP configuration if needed
    PersistenceConfiguration newPersistenceConfiguration = persistanceFactoryService.loadPersistenceConfiguration(LDAP_PROPERTIES_FILE);
    if (newPersistenceConfiguration != null) {
        if (!StringHelper.equalsIgnoreCase(this.persistenceConfiguration.getFileName(), newPersistenceConfiguration.getFileName()) || (newPersistenceConfiguration.getLastModifiedTime() > this.persistenceConfiguration.getLastModifiedTime())) {
            // Reload configuration only if it was modified
            this.persistenceConfiguration = newPersistenceConfiguration;
            event.select(LdapConfigurationReload.Literal.INSTANCE).fire(PERSISTENCE_CONFIGUARION_RELOAD_EVENT_TYPE);
        }
    }
    // Reload Base configuration if needed
    File baseConfiguration = new File(BASE_PROPERTIES_FILE);
    if (baseConfiguration.exists()) {
        final long lastModified = baseConfiguration.lastModified();
        if (lastModified > baseConfigurationFileLastModifiedTime) {
            // Reload configuration only if it was modified
            loadBaseConfiguration();
            event.select(BaseConfigurationReload.Literal.INSTANCE).fire(BASE_CONFIGUARION_RELOAD_EVENT_TYPE);
        }
    }
    if (!loadedFromLdap) {
        return;
    }
    if (!isRevisionIncreased()) {
        return;
    }
    createFromLdap(false);
}
Also used : PersistenceConfiguration(org.gluu.persist.model.PersistenceConfiguration) File(java.io.File)

Example 4 with PersistenceConfiguration

use of org.gluu.persist.model.PersistenceConfiguration in project oxAuth by GluuFederation.

the class AppInitializer method preparePersistanceProperties.

protected Properties preparePersistanceProperties() {
    PersistenceConfiguration persistenceConfiguration = this.configurationFactory.getPersistenceConfiguration();
    FileConfiguration persistenceConfig = persistenceConfiguration.getConfiguration();
    Properties connectionProperties = (Properties) persistenceConfig.getProperties();
    EncryptionService securityService = encryptionServiceInstance.get();
    Properties decryptedConnectionProperties = securityService.decryptAllProperties(connectionProperties);
    return decryptedConnectionProperties;
}
Also used : FileConfiguration(org.gluu.orm.util.properties.FileConfiguration) PersistenceConfiguration(org.gluu.persist.model.PersistenceConfiguration) EncryptionService(org.gluu.oxauth.service.common.EncryptionService) Properties(java.util.Properties)

Aggregations

PersistenceConfiguration (org.gluu.persist.model.PersistenceConfiguration)4 File (java.io.File)2 Properties (java.util.Properties)2 FileConfiguration (org.gluu.orm.util.properties.FileConfiguration)2 EncryptionService (org.gluu.oxauth.service.common.EncryptionService)1