/** * Retrieves all entries from the LDAP directory under the base DN. * * @param consumer Consumes the matching directory entries. Must not be * {@code null}. */ public void retrieveEntries(final Consumer<ReadOnlyEntry> consumer) { retrieveEntries(MATCH_ANY_FILTER, consumer); }
/** * Checks if the specified LDAP exception is caused by the LDAP server * being unavailable, disconnected or timing out. * * @param e The LDAP exception. Must not be {@code null}. * * @return {@code true} if the LDAP exception is caused by the LDAP * server being unavailable, disconnected or timing out, else * {@code false}. */ protected static boolean indicatesConnectionException(final LDAPException e) { return indicatesConnectionException(e.getResultCode()); }
@Override public int size() { // Infinispan code analysis on 8.2 shows that this method is never called in practise, and // is not wired to the data / cache container API Loggers.LDAP_LOG.trace("[IL0258] LDAP store: Counting {} entries", getCacheName()); final int count = ldapConnector.countEntries(); Loggers.LDAP_LOG.trace("[IL0259] LDAP store: Counted {} {} entries", count, getCacheName()); return count; }
checkBaseDN(); ldapModifyRequestFactory = new LDAPModifyRequestFactory(attributes); ldapTimers = new LDAPTimers(cacheName + ".");
/** * Counts the number of entries under the base DN. * * @return The entry count. */ public int countEntries() { SearchRequest request = new SearchRequest( config.ldapDirectory.baseDN.toString(), SearchScope.ONE, MATCH_ANY_FILTER, SearchRequest.NO_ATTRIBUTES); final AtomicInteger count = new AtomicInteger(); doSearch(request, entry -> count.incrementAndGet()); return count.intValue(); }
@Override public void clear() { Loggers.LDAP_LOG.trace("[IL0260] LDAP store: Clearing {} entries", getCacheName()); int numDeleted = ldapConnector.deleteEntries(); Loggers.LDAP_LOG.debug("[IL0254] LDAP store: Cleared {} {} entries", numDeleted, getCacheName()); }
@Override public void stop() { if (ldapConnector != null) { ldapConnector.shutdown(); Loggers.MAIN_LOG.info("[IL0205] Stopped LDAP external store connector for cache {}", getCacheName()); } super.stop(); }
@Override public boolean delete(final Object key) { // The CacheWriter should remove from the external storage the entry identified by the specified key. // Note that keys will be in the cache's native format, which means that if the cache is being used by a remoting protocol // such as HotRod or REST and compatibility mode has not been enabled, then they will be encoded in a byte[]. Loggers.LDAP_LOG.trace("[IL0252] LDAP store: Deleting {} entry with key {}", getCacheName(), key); DN dn = new DN(ldapEntryTransformer.resolveRDN(resolveKey(key)), config.ldapDirectory.baseDN); return ldapConnector.deleteEntry(dn); }
@Override public boolean contains(final Object key) { // This method will be invoked by the PersistenceManager to determine if the loader contains the specified key. // The implementation should be as fast as possible, e.g. it should strive to transfer the least amount of data possible // from the external storage to perform the check. Also, if possible, make sure the field is indexed on the external storage // so that its existence can be determined as quickly as possible. // // Note that keys will be in the cache's native format, which means that if the cache is being used by a remoting protocol // such as HotRod or REST and compatibility mode has not been enabled, then they will be encoded in a byte[]. Loggers.LDAP_LOG.trace("[IL0250] LDAP store: Checking {} cache key {}", getCacheName(), key); DN dn = new DN(ldapEntryTransformer.resolveRDN(resolveKey(key)), config.ldapDirectory.baseDN); return ldapConnector.entryExists(dn); }
checkBaseDN(); ldapModifyRequestFactory = new LDAPModifyRequestFactory(attributes); ldapTimers = new LDAPTimers(cacheName + ".");
/** * Counts the number of entries under the base DN. * * @return The entry count. */ public int countEntries() { SearchRequest request = new SearchRequest( config.ldapDirectory.baseDN.toString(), SearchScope.ONE, MATCH_ANY_FILTER, SearchRequest.NO_ATTRIBUTES); final AtomicInteger count = new AtomicInteger(); doSearch(request, entry -> count.incrementAndGet()); return count.intValue(); }
/** * Retrieves all entries from the LDAP directory under the base DN. * * @param consumer Consumes the matching directory entries. Must not be * {@code null}. */ public void retrieveEntries(final Consumer<ReadOnlyEntry> consumer) { retrieveEntries(MATCH_ANY_FILTER, consumer); }
/** * Checks if the specified LDAP exception is caused by the LDAP server * being unavailable, disconnected or timing out. * * @param e The LDAP exception. Must not be {@code null}. * * @return {@code true} if the LDAP exception is caused by the LDAP * server being unavailable, disconnected or timing out, else * {@code false}. */ protected static boolean indicatesConnectionException(final LDAPException e) { return indicatesConnectionException(e.getResultCode()); }
@Override public int size() { // Infinispan code analysis on 8.2 shows that this method is never called in practise, and // is not wired to the data / cache container API Loggers.LDAP_LOG.trace("[IL0258] LDAP store: Counting {} entries", getCacheName()); final int count = ldapConnector.countEntries(); Loggers.LDAP_LOG.trace("[IL0259] LDAP store: Counted {} {} entries", count, getCacheName()); return count; }
@Override public void clear() { Loggers.LDAP_LOG.trace("[IL0260] LDAP store: Clearing {} entries", getCacheName()); int numDeleted = ldapConnector.deleteEntries(); Loggers.LDAP_LOG.debug("[IL0254] LDAP store: Cleared {} {} entries", numDeleted, getCacheName()); }
@Override public void stop() { if (ldapConnector != null) { ldapConnector.shutdown(); Loggers.MAIN_LOG.info("[IL0205] Stopped LDAP external store connector for cache {}", getCacheName()); } super.stop(); }
@Override public boolean delete(final Object key) { // The CacheWriter should remove from the external storage the entry identified by the specified key. // Note that keys will be in the cache's native format, which means that if the cache is being used by a remoting protocol // such as HotRod or REST and compatibility mode has not been enabled, then they will be encoded in a byte[]. Loggers.LDAP_LOG.trace("[IL0252] LDAP store: Deleting {} entry with key {}", getCacheName(), key); DN dn = new DN(ldapEntryTransformer.resolveRDN(resolveKey(key)), config.ldapDirectory.baseDN); return ldapConnector.deleteEntry(dn); }
@Override public boolean contains(final Object key) { // This method will be invoked by the PersistenceManager to determine if the loader contains the specified key. // The implementation should be as fast as possible, e.g. it should strive to transfer the least amount of data possible // from the external storage to perform the check. Also, if possible, make sure the field is indexed on the external storage // so that its existence can be determined as quickly as possible. // // Note that keys will be in the cache's native format, which means that if the cache is being used by a remoting protocol // such as HotRod or REST and compatibility mode has not been enabled, then they will be encoded in a byte[]. Loggers.LDAP_LOG.trace("[IL0250] LDAP store: Checking {} cache key {}", getCacheName(), key); DN dn = new DN(ldapEntryTransformer.resolveRDN(resolveKey(key)), config.ldapDirectory.baseDN); return ldapConnector.entryExists(dn); }
/** * Retrieves all entries from the LDAP directory under the base DN that * match the specified filter. * * @param filter The LDAP search filter. Must not be {@code null}. * @param consumer Consumes the matching directory entries. Must not be * {@code null}. */ public void retrieveEntries(final Filter filter, final Consumer<ReadOnlyEntry> consumer) { SearchRequest searchRequest = new SearchRequest( config.ldapDirectory.baseDN.toString(), SearchScope.ONE, filter, SearchRequest.ALL_USER_ATTRIBUTES); doSearch(searchRequest, consumer); }
/** * Retrieves all entries from the LDAP directory under the base DN that * match the specified filter. * * @param filter The LDAP search filter. Must not be {@code null}. * @param consumer Consumes the matching directory entries. Must not be * {@code null}. */ public void retrieveEntries(final Filter filter, final Consumer<ReadOnlyEntry> consumer) { SearchRequest searchRequest = new SearchRequest( config.ldapDirectory.baseDN.toString(), SearchScope.ONE, filter, SearchRequest.ALL_USER_ATTRIBUTES); doSearch(searchRequest, consumer); }