use of org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson in project oxTrust by GluuFederation.
the class CacheRefreshTimer method getSourcePersonCompoundKeyMap.
private Map<CacheCompoundKey, GluuSimplePerson> getSourcePersonCompoundKeyMap(CacheRefreshConfiguration cacheRefreshConfiguration, List<GluuSimplePerson> sourcePersons) {
Map<CacheCompoundKey, GluuSimplePerson> result = new HashMap<CacheCompoundKey, GluuSimplePerson>();
Set<CacheCompoundKey> duplicateKeys = new HashSet<CacheCompoundKey>();
String[] keyAttributesWithoutValues = getCompoundKeyAttributesWithoutValues(cacheRefreshConfiguration);
for (GluuSimplePerson sourcePerson : sourcePersons) {
String[][] keyAttributesValues = getKeyAttributesValues(keyAttributesWithoutValues, sourcePerson);
CacheCompoundKey cacheCompoundKey = new CacheCompoundKey(keyAttributesValues);
if (result.containsKey(cacheCompoundKey)) {
duplicateKeys.add(cacheCompoundKey);
}
result.put(cacheCompoundKey, sourcePerson);
}
for (CacheCompoundKey duplicateKey : duplicateKeys) {
log.error("Non-deterministic primary key. Skipping user with key: {}", duplicateKey);
result.remove(duplicateKey);
}
return result;
}
use of org.gluu.oxtrust.ldap.cache.model.GluuSimplePerson 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;
}
Aggregations