use of org.gluu.persist.PersistenceEntryManager in project oxTrust by GluuFederation.
the class CacheRefreshTimer method loadSourceServerEntriesWithoutLimits.
private List<GluuSimplePerson> loadSourceServerEntriesWithoutLimits(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection[] sourceServerConnections) throws SearchException {
Filter customFilter = cacheRefreshService.createFilter(cacheRefreshConfiguration.getCustomLdapFilter());
String[] keyAttributes = getCompoundKeyAttributes(cacheRefreshConfiguration);
String[] keyAttributesWithoutValues = getCompoundKeyAttributesWithoutValues(cacheRefreshConfiguration);
String[] keyObjectClasses = getCompoundKeyObjectClasses(cacheRefreshConfiguration);
String[] sourceAttributes = getSourceAttributes(cacheRefreshConfiguration);
String[] returnAttributes = ArrayHelper.arrayMerge(keyAttributesWithoutValues, sourceAttributes);
Set<String> addedDns = new HashSet<String>();
List<GluuSimplePerson> sourcePersons = new ArrayList<GluuSimplePerson>();
for (LdapServerConnection sourceServerConnection : sourceServerConnections) {
String sourceServerName = sourceServerConnection.getSourceServerName();
PersistenceEntryManager sourcePersistenceEntryManager = sourceServerConnection.getPersistenceEntryManager();
String[] baseDns = sourceServerConnection.getBaseDns();
Filter filter = cacheRefreshService.createFilter(keyAttributes, keyObjectClasses, "", customFilter);
if (log.isTraceEnabled()) {
log.trace("Using next filter to load entris from source server: {}", filter);
}
for (String baseDn : baseDns) {
List<GluuSimplePerson> currentSourcePersons = sourcePersistenceEntryManager.findEntries(baseDn, GluuSimplePerson.class, filter, SearchScope.SUB, returnAttributes, null, 0, 0, cacheRefreshConfiguration.getLdapSearchSizeLimit());
// Add to result and ignore root entry if needed
for (GluuSimplePerson currentSourcePerson : currentSourcePersons) {
currentSourcePerson.setSourceServerName(sourceServerName);
// if (!StringHelper.equalsIgnoreCase(baseDn,
// currentSourcePerson.getDn())) {
String currentSourcePersonDn = currentSourcePerson.getDn().toLowerCase();
if (!addedDns.contains(currentSourcePersonDn)) {
sourcePersons.add(currentSourcePerson);
addedDns.add(currentSourcePersonDn);
}
// }
}
}
}
return sourcePersons;
}
use of org.gluu.persist.PersistenceEntryManager 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("Initializing application services");
showBuildInfo();
configurationFactory.create();
PersistenceEntryManager localLdapEntryManager = persistenceEntryManagerInstance.get();
initializeLdifArchiver(localLdapEntryManager);
// Initialize template engine
templateService.initTemplateEngine();
// Initialize python interpreter
pythonService.initPythonInterpreter(configurationFactory.getBaseConfiguration().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.PERSISTENCE_EXTENSION);
// Start timer
initSchedulerService();
// Schedule timer tasks
metricService.initTimer();
configurationFactory.initTimer();
loggerService.initTimer();
ldapStatusTimer.initTimer();
metadataValidationTimer.initTimer();
entityIDMonitoringService.initTimer();
cacheRefreshTimer.initTimer();
customScriptManager.initTimer(supportedCustomScriptTypes);
cleanerTimer.initTimer();
statusCheckerDaily.initTimer();
statusCheckerTimer.initTimer();
logFileSizeChecker.initTimer();
updateChecker.initTimer();
transcodingRulesUpdater.initTimer();
// Notify other components/plugins about finish application initialization
eventApplicationInitialized.select(ApplicationInitialized.Literal.APPLICATION).fire(new ApplicationInitializedEvent());
}
use of org.gluu.persist.PersistenceEntryManager in project oxCore by GluuFederation.
the class SchemaService method addObjectClass.
/**
* Add new object class with specified attributes
*
* @param objectClass
* Object class name
* @param attributeTypes
* Attribute types
*/
public void addObjectClass(String objectClass, String attributeTypes, String schemaAddObjectClassWithoutAttributeTypesDefinition, String schemaAddObjectClassWithAttributeTypesDefinition) {
SchemaEntry schemaEntry = new SchemaEntry();
schemaEntry.setDn(getDnForSchema());
String objectClassDefinition;
if (StringHelper.isEmpty(attributeTypes)) {
objectClassDefinition = String.format(schemaAddObjectClassWithoutAttributeTypesDefinition, objectClass, objectClass);
} else {
objectClassDefinition = String.format(schemaAddObjectClassWithAttributeTypesDefinition, objectClass, objectClass, attributeTypes);
}
schemaEntry.addObjectClass(objectClassDefinition);
log.debug("Adding new objectClass: {}", schemaEntry);
PersistenceEntryManager ldapPersistenceEntryManager = getPersistenceEntryManager();
ldapPersistenceEntryManager.merge(schemaEntry);
}
use of org.gluu.persist.PersistenceEntryManager in project oxCore by GluuFederation.
the class SchemaService method addAttributeTypeToObjectClass.
/**
* Add attribute type to object class
*
* @param objectClass
* Object class name
* @param attributeType
* Attribute type name
* @throws Exception
*/
public void addAttributeTypeToObjectClass(String objectClass, String attributeType) throws Exception {
SchemaEntry schema = getSchema();
String objectClassDefinition = getObjectClassDefinition(schema, objectClass);
if (objectClassDefinition == null) {
throw new InvalidSchemaUpdateException(String.format("Can't add attributeType %s to objectClass %s because objectClass doesn't exist", attributeType, objectClass));
}
String newObjectClassDefinition = null;
String attributeTypesStartPattern = "MAY ( ";
int index = objectClassDefinition.indexOf(attributeTypesStartPattern);
if (index != -1) {
int index2 = objectClassDefinition.indexOf(")", index);
newObjectClassDefinition = objectClassDefinition.substring(0, index2) + "$ " + attributeType + " " + objectClassDefinition.substring(index2);
} else {
attributeTypesStartPattern = "MUST objectClass ";
index = objectClassDefinition.indexOf(attributeTypesStartPattern);
if (index != -1) {
int index2 = index + attributeTypesStartPattern.length();
newObjectClassDefinition = objectClassDefinition.substring(0, index2) + "MAY ( " + attributeType + " ) " + objectClassDefinition.substring(index2);
}
}
log.debug("Current object class definition:" + objectClassDefinition);
log.debug("New object class definition:" + newObjectClassDefinition);
if (newObjectClassDefinition == null) {
throw new InvalidSchemaUpdateException(String.format("Invalid objectClass definition format"));
}
// Remove OC definition
removeObjectClassWithDefinition(objectClassDefinition);
// Add updated OC definition
SchemaEntry newSchemaEntry = new SchemaEntry();
newSchemaEntry.setDn(getDnForSchema());
newSchemaEntry.addObjectClass(newObjectClassDefinition);
log.debug("Adding attributeType to objectClass: {}", newSchemaEntry);
PersistenceEntryManager ldapPersistenceEntryManager = getPersistenceEntryManager();
ldapPersistenceEntryManager.merge(newSchemaEntry);
}
use of org.gluu.persist.PersistenceEntryManager in project oxCore by GluuFederation.
the class ExternalPersistenceExtensionService method reloadExternal.
@Override
protected void reloadExternal() {
for (Iterator<PersistenceEntryManager> it = persistenceEntryManagerInstance.iterator(); it.hasNext(); ) {
PersistenceEntryManager persistenceEntryManager = it.next();
executePersistenceExtensionAfterCreate(null, persistenceEntryManager);
}
for (Iterator<List<PersistenceEntryManager>> it = persistenceEntryManagerListInstance.iterator(); it.hasNext(); ) {
List<PersistenceEntryManager> persistenceEntryManagerList = it.next();
for (PersistenceEntryManager persistenceEntryManager : persistenceEntryManagerList) {
executePersistenceExtensionAfterCreate(null, persistenceEntryManager);
}
}
}
Aggregations