use of org.gluu.site.ldap.persistence.LdapEntryManager in project oxCore by GluuFederation.
the class LdapSample method main.
public static void main(String[] args) {
// Prepare sample connection details
LdapSampleEntryManager ldapSampleEntryManager = new LdapSampleEntryManager();
// Create LDAP entry manager
LdapEntryManager ldapEntryManager = ldapSampleEntryManager.createLdapEntryManager();
// Find all users which have specified object classes defined in SimpleUser
List<SimpleUser> users = ldapEntryManager.findEntries("o=gluu", SimpleUser.class, null);
for (SimpleUser user : users) {
log.debug("User with uid: " + user.getUserId());
}
if (users.size() > 0) {
// Add attribute "streetAddress" to first user
SimpleUser user = users.get(0);
user.getCustomAttributes().add(new CustomAttribute("streetAddress", "Somewhere: " + System.currentTimeMillis()));
ldapEntryManager.merge(user);
}
Filter filter = Filter.createEqualityFilter("gluuStatus", "active");
List<SimpleAttribute> attributes = ldapEntryManager.findEntries("o=gluu", SimpleAttribute.class, filter, SearchScope.SUB, null, null, 10, 0, 0);
for (SimpleAttribute attribute : attributes) {
log.debug("Attribute with displayName: " + attribute.getCustomAttributes().get(1));
}
List<SimpleSession> sessions = ldapEntryManager.findEntries("o=gluu", SimpleSession.class, filter, SearchScope.SUB, null, null, 10, 0, 0);
log.debug("Found sessions: " + sessions.size());
List<SimpleGrant> grants = ldapEntryManager.findEntries("o=gluu", SimpleGrant.class, null, SearchScope.SUB, new String[] { "oxAuthGrantId" }, null, 10, 0, 0);
log.debug("Found grants: " + grants.size());
try {
VirtualListViewResponse virtualListViewResponse = new VirtualListViewResponse();
SearchResult searchResult = ldapEntryManager.getLdapOperationService().searchSearchResult("o=gluu", Filter.createEqualityFilter("objectClass", "gluuPerson"), SearchScope.SUB, 10, 100, 100000, "displayName", null, virtualListViewResponse, "uid", "displayName", "gluuStatus");
log.debug("Found persons: " + virtualListViewResponse.getTotalResults());
System.out.println(searchResult.getSearchEntries());
} catch (Exception ex) {
log.error("Failed to search", ex);
}
}
use of org.gluu.site.ldap.persistence.LdapEntryManager in project oxCore by GluuFederation.
the class LdapSampleEntryManager method createLdapEntryManager.
public LdapEntryManager createLdapEntryManager() {
Properties connectionProperties = getSampleConnectionProperties();
LDAPConnectionProvider connectionProvider = createConnectionProvider(connectionProperties);
Properties bindConnectionProperties = prepareBindConnectionProperties(connectionProperties);
LDAPConnectionProvider bindConnectionProvider = createBindConnectionProvider(bindConnectionProperties, connectionProperties);
LdapEntryManager ldapEntryManager = new LdapEntryManager(new OperationsFacade(connectionProvider, bindConnectionProvider));
log.debug("Created LdapEntryManager: " + ldapEntryManager);
return ldapEntryManager;
}
use of org.gluu.site.ldap.persistence.LdapEntryManager in project oxAuth by GluuFederation.
the class LdapStatusTimer method processInt.
private void processInt() {
logConnectionProviderStatistic(ldapEntryManager, "connectionProvider", "bindConnectionProvider");
for (int i = 0; i < ldapAuthEntryManagers.size(); i++) {
LdapEntryManager ldapAuthEntryManager = ldapAuthEntryManagers.get(i);
logConnectionProviderStatistic(ldapAuthEntryManager, "authConnectionProvider#" + i, "bindAuthConnectionProvider#" + i);
}
}
use of org.gluu.site.ldap.persistence.LdapEntryManager in project oxTrust by GluuFederation.
the class ConfigurationFactory method loadConfigurationFromLdap.
private 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 (LdapMappingException ex) {
log.error("Failed to load configuration from LDAP", ex);
}
return null;
}
use of org.gluu.site.ldap.persistence.LdapEntryManager in project oxTrust by GluuFederation.
the class CacheRefreshTimer method updateTargetEntriesViaVDS.
private List<String> updateTargetEntriesViaVDS(CacheRefreshConfiguration cacheRefreshConfiguration, LdapServerConnection targetServerConnection, Set<String> changedInums) {
List<String> result = new ArrayList<String>();
LdapEntryManager targetLdapEntryManager = targetServerConnection.getLdapEntryManager();
Filter filter = cacheRefreshService.createObjectClassPresenceFilter();
for (String changedInum : changedInums) {
String baseDn = "action=synchronizecache," + personService.getDnForPerson(changedInum);
try {
targetLdapEntryManager.findEntries(baseDn, GluuDummyEntry.class, filter, null, cacheRefreshConfiguration.getLdapSearchSizeLimit());
result.add(changedInum);
log.debug("Updated entry with inum {}", changedInum);
} catch (LdapMappingException ex) {
log.error("Failed to update entry with inum '{}' using baseDN {}", ex, changedInum, baseDn);
}
}
return result;
}
Aggregations