public boolean startsWith(Name name) { if (name.size() == 0) { return false; } DistinguishedName start = null; if (name instanceof DistinguishedName) { start = (DistinguishedName) name; } else { return false; } if (start.size() > this.size()) { return false; } Iterator longiter = names.iterator(); Iterator shortiter = start.getNames().iterator(); while (shortiter.hasNext()) { Object longname = longiter.next(); Object shortname = shortiter.next(); if (!longname.equals(shortname)) { return false; } } // All names in shortiter matched. return true; }
public boolean startsWith(Name name) { if (name.size() == 0) { return false; } DistinguishedName start = null; if (name instanceof DistinguishedName) { start = (DistinguishedName) name; } else { return false; } if (start.size() > this.size()) { return false; } Iterator longiter = names.iterator(); Iterator shortiter = start.getNames().iterator(); while (shortiter.hasNext()) { Object longname = longiter.next(); Object shortname = shortiter.next(); if (!longname.equals(shortname)) { return false; } } // All names in shortiter matched. return true; }
public boolean startsWith(Name name) { if (name.size() == 0) { return false; } DistinguishedName start = null; if (name instanceof DistinguishedName) { start = (DistinguishedName) name; } else { return false; } if (start.size() > this.size()) { return false; } Iterator longiter = names.iterator(); Iterator shortiter = start.getNames().iterator(); while (shortiter.hasNext()) { Object longname = longiter.next(); Object shortname = shortiter.next(); if (!longname.equals(shortname)) { return false; } } // All names in shortiter matched. return true; }
public boolean startsWith(Name name) { if (name.size() == 0) { return false; } DistinguishedName start = null; if (name instanceof DistinguishedName) { start = (DistinguishedName) name; } else { return false; } if (start.size() > this.size()) { return false; } Iterator longiter = names.iterator(); Iterator shortiter = start.getNames().iterator(); while (shortiter.hasNext()) { Object longname = longiter.next(); Object shortname = shortiter.next(); if (!longname.equals(shortname)) { return false; } } // All names in shortiter matched. return true; }
@Test public void testMultiValueRdn() throws Exception { DistinguishedName path = new DistinguishedName("firstName=Rod+lastName=Johnson,ou=UK,dc=interface21,dc=com"); assertThat(path.size()).isEqualTo(4); assertThat(path.get(3)).isEqualTo("firstname=Rod+lastname=Johnson"); }
protected DistinguishedName getRelativeDN(String fullDN) { DistinguishedName principalDN = new DistinguishedName(fullDN); if (configuration.getBaseDN().size() > 0) { principalDN.removeFirst(configuration.getBaseDN()); } return principalDN; }
protected void getEntityByInternalId(String internalId, EntitySearchResultHandler handler) throws SecurityException { DistinguishedName principalDN = getRelativeDN(internalId); if (configuration.getSearchDN().size() == 0 || principalDN.startsWith(configuration.getSearchDN())) { SearchControls sc = getSearchControls(SearchControls.OBJECT_SCOPE, true, configuration.getEntityAttributeNames()); PagedSearchExecutor pse = new PagedSearchExecutor(principalDN, defaultSearchFilterStr, sc, handler); handler.setEntityFactory(getEntityFactory()); ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); ldapTemplate.search(pse,pse); } catch (NamingException e) { throw new SecurityException(SecurityException.UNEXPECTED.create(getClass().getName(), "getEntityByInternalId", e.getMessage()), e); } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); handler.setEntityFactory(null); } } }
protected DirContextOperations getEntityContextByInternalId(String internalId, boolean withAttributes) throws SecurityException if (configuration.getSearchDN().size() == 0 || principalDN.startsWith(configuration.getSearchDN()))
public void getEntities(Entity parent, Filter filter, EntitySearchResultHandler handler) throws SecurityException { ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader(); DistinguishedName parentDN = getRelativeDN(parent.getInternalId()); if (configuration.getSearchDN().size() == 0 || parentDN.startsWith(configuration.getSearchDN())) { String sf = createSearchFilter(filter); SearchControls sc = getSearchControls(SearchControls.ONELEVEL_SCOPE, true, configuration.getEntityAttributeNames()); handler.setEntityFactory(getEntityFactory()); PagedSearchExecutor pse = new PagedSearchExecutor(parentDN, sf, sc, handler, searchPageSize); try { Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); ldapTemplate.search(pse, pse); } catch (NamingException e) { throw new SecurityException(SecurityException.UNEXPECTED.create(getClass().getName(), "getEntities", e.getMessage()), e); } finally { Thread.currentThread().setContextClassLoader(currentClassLoader); handler.setEntityFactory(null); } } }
protected DistinguishedName getFullDN(DistinguishedName relativeDN) { DistinguishedName fullDN = new DistinguishedName(relativeDN); if (configuration.getBaseDN().size() > 0 && !fullDN.startsWith(configuration.getBaseDN())) { fullDN.prepend(configuration.getBaseDN()); } return fullDN; }
LdapRdn rdn = name.getLdapRdn(name.size() - 1); if (rdn.getKey().equals(searchConfiguration.getLdapIdAttribute()))