use of org.xdi.config.oxtrust.LdapOxTrustConfiguration in project oxTrust by GluuFederation.
the class ConfigurationFactory method reloadConfiguration.
private void reloadConfiguration() {
// Reload LDAP configuration if needed
String ldapFileName = determineLdapConfigurationFileName();
File ldapFile = new File(ldapFileName);
if (ldapFile.exists()) {
final long lastModified = ldapFile.lastModified();
if (!StringHelper.equalsIgnoreCase(this.prevLdapFileName, ldapFileName) || (lastModified > ldapFileLastModifiedTime)) {
// reload configuration only if it was modified
// Reload configuration only if it was modified
this.prevLdapFileName = loadLdapConfiguration(ldapFileName);
event.select(LdapConfigurationReload.Literal.INSTANCE).fire(LDAP_CONFIGUARION_RELOAD_EVENT_TYPE);
}
}
// Reload LDAP central configuration if needed
File ldapCentralFile = new File(LDAP_CENTRAL_PROPERTIES_FILE);
if (ldapCentralFile.exists()) {
final long lastModified = ldapCentralFile.lastModified();
if (lastModified > ldapCentralFileLastModifiedTime) {
// Reload configuration only if it was modified
loadLdapCentralConfiguration();
event.select(LdapCentralConfigurationReload.Literal.INSTANCE).fire(LDAP_CENTRAL_CONFIGUARION_RELOAD_EVENT_TYPE);
}
} else if (this.ldapCentralConfiguration != null) {
// Allow to remove not mandatory configuration file
this.ldapCentralConfiguration = null;
event.select(LdapCentralConfigurationReload.Literal.INSTANCE).fire(LDAP_CENTRAL_CONFIGUARION_RELOAD_EVENT_TYPE);
}
if (!loadedFromLdap) {
return;
}
final LdapOxTrustConfiguration conf = loadConfigurationFromLdap("oxRevision");
if (conf == null) {
return;
}
if (conf.getRevision() <= this.loadedRevision) {
return;
}
createFromLdap(false);
}
use of org.xdi.config.oxtrust.LdapOxTrustConfiguration in project oxTrust by GluuFederation.
the class JsonConfigurationService method getOxTrustConfiguration.
private LdapOxTrustConfiguration getOxTrustConfiguration() {
String configurationDn = configurationFactory.getConfigurationDn();
LdapOxTrustConfiguration ldapOxTrustConfiguration = loadOxTrustConfig(configurationDn);
return ldapOxTrustConfiguration;
}
use of org.xdi.config.oxtrust.LdapOxTrustConfiguration in project oxTrust by GluuFederation.
the class JsonConfigurationService method saveOxTrustappConfiguration.
public boolean saveOxTrustappConfiguration(AppConfiguration oxTrustappConfiguration) {
LdapOxTrustConfiguration ldapOxTrustConfiguration = getOxTrustConfiguration();
ldapOxTrustConfiguration.setApplication(oxTrustappConfiguration);
ldapOxTrustConfiguration.setRevision(ldapOxTrustConfiguration.getRevision() + 1);
ldapEntryManager.merge(ldapOxTrustConfiguration);
return true;
}
use of org.xdi.config.oxtrust.LdapOxTrustConfiguration in project oxTrust by GluuFederation.
the class ConfigurationFactory method createFromLdap.
private boolean createFromLdap(boolean recoverFromFiles) {
log.info("Loading configuration from LDAP...");
try {
final LdapOxTrustConfiguration conf = loadConfigurationFromLdap();
if (conf != null) {
init(conf);
// Destroy old configuration
if (this.loaded) {
destroy(AppConfiguration.class);
destroy(CacheRefreshConfiguration.class);
destroy(ImportPersonConfig.class);
destroy(AttributeResolverConfiguration.class);
}
this.loaded = true;
configurationUpdateEvent.select(ConfigurationUpdate.Literal.INSTANCE).fire(this.appConfiguration);
return true;
}
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
if (recoverFromFiles) {
log.warn("Unable to find configuration in LDAP, try to load configuration from file system... ");
if (createFromFile()) {
this.loadedFromLdap = false;
return true;
}
}
return false;
}
use of org.xdi.config.oxtrust.LdapOxTrustConfiguration in project oxTrust by GluuFederation.
the class ConfigurationFactory method loadConfigurationFromLdap.
public LdapOxTrustConfiguration loadConfigurationFromLdap(String... returnAttributes) {
final LdapEntryManager ldapEntryManager = ldapEntryManagerInstance.get();
final String configurationDn = getConfigurationDn();
try {
final LdapOxTrustConfiguration conf = ldapEntryManager.find(LdapOxTrustConfiguration.class, configurationDn, returnAttributes);
return conf;
} catch (BaseMappingException ex) {
log.error("Failed to load configuration from LDAP", ex);
}
return null;
}
Aggregations