public String mapFromContext(Object ctx) { DirContextAdapter context = (DirContextAdapter)ctx; String s=context.getStringAttribute(EventProcessorImpl.ldapAttrPerunUserId); return s; } }
public String get(String attribute, DirContextAdapter context) { String attributeName = cfg.getGroupAttribute(attribute); if (attributeName != null) { return context.getStringAttribute(attributeName); } return null; }
public String get(String attribute, DirContextAdapter context) { String attributeName = cfg.getUserAttribute(attribute); if (attributeName != null) { return context.getStringAttribute(attributeName); } return null; }
public String mapFromContext(Object ctx) { DirContextAdapter context = (DirContextAdapter)ctx; String s=context.getStringAttribute(getLdapAttributeName()); return s; } }
public String mapFromContext(Object ctx) { DirContextAdapter adapter = (DirContextAdapter) ctx; return adapter.getStringAttribute("cn"); } }
public Object mapFromContext(Object ctx) { DirContextAdapter adapter = (DirContextAdapter) ctx; assertThat(adapter.getStringAttribute("description")).isEqualTo("updated description"); assertThat(adapter.getStringAttribute("telephoneNumber")).isEqualTo("0000001"); return null; } });
public Object mapFromContext(Object ctx) { DirContextAdapter adapter = (DirContextAdapter) ctx; assertThat(adapter.getStringAttribute("description")).isEqualTo("updated description"); assertThat(adapter.getStringAttribute("telephoneNumber")).isEqualTo("0000001"); return null; } });
private void verifyBoundCorrectData() { DirContextAdapter result = (DirContextAdapter) tested.lookup(PERSON4_DN); assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person4"); assertThat(result.getStringAttribute("sn")).isEqualTo("Person4"); assertThat(result.getStringAttribute("description")).isEqualTo("Some other description"); } }
private void verifyBoundCorrectData() { DirContextAdapter result = (DirContextAdapter) tested.lookup(NEWDN); assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person6"); assertThat(result.getStringAttribute("sn")).isEqualTo("Person6"); assertThat(result.getStringAttribute("description")).isEqualTo("Some description"); } }
private void verifyBoundCorrectData() { DirContextAdapter result = (DirContextAdapter) tested.lookup(DN); assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person4"); assertThat(result.getStringAttribute("sn")).isEqualTo("Person4"); }
@Override public boolean checkUserInLdap(String username) { HashMap<String, String> configMap = acqConfigMap(); String userDN = configMap.get(LdapItemEnum.LDAP_USER_DN.getItemKey()); try { String dn = "cn=" + username + "," + userDN; DirContextAdapter adapter = (DirContextAdapter) ldapFactory.getLdapTemplateInstance().lookup(dn); String cn = adapter.getStringAttribute("cn"); if (username.equalsIgnoreCase(cn)) return true; return false; } catch (Exception e) { return false; } }
private void verifyReboundCorrectData() { DirContextAdapter result = (DirContextAdapter) tested.lookup(DN); assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person4"); assertThat(result.getStringAttribute("sn")).isEqualTo("Person4.Changed"); }
@Override public GroupOrg findByDepartment(final String department) { final AndFilter filter = new AndFilter().and(new EqualsFilter("objectclass", GROUP_OF_UNIQUE_NAMES)) .and(new EqualsFilter(DEPARTMENT_ATTRIBUTE, department)); return template.search(groupsBaseDn, filter.encode(), (Object ctx) -> (DirContextAdapter) ctx).stream() .findFirst().map(c -> c.getStringAttribute("cn")).map(Normalizer::normalize).map(this::findById) .orElse(null); } }
/** * This method depends on a DirObjectFactory ( * {@link org.springframework.ldap.core.support.DefaultDirObjectFactory}) * being set in the ContextSource. */ @Test public void testLookup_Plain() { DirContextAdapter result = (DirContextAdapter) tested.lookup("cn=Some Person2, ou=company1,ou=Sweden"); assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person2"); assertThat(result.getStringAttribute("sn")).isEqualTo("Person2"); assertThat(result.getStringAttribute("description")).isEqualTo("Sweden, Company1, Some Person2"); }
/** * Verifies that we can lookup an entry that has a multi-valued rdn, which * means more than one attribute is part of the relative DN for the entry. * */ @Test @Category(NoAdTest.class) public void testLookup_MultiValuedRdn_DirContextAdapter() { DirContextAdapter result = (DirContextAdapter) tested.lookup("cn=Some Person+sn=Person, ou=company1,ou=Norway"); assertThat(result.getStringAttribute("cn")).isEqualTo("Some Person"); assertThat(result.getStringAttribute("sn")).isEqualTo("Person"); assertThat(result.getStringAttribute("description")).isEqualTo("Norway, Company1, Some Person+Person"); }
@Test public void testGetStringAttributeWhenAttributeDoesNotExist() throws Exception { String s = tested.getStringAttribute("does not exist"); assertThat(s).isNull(); }
@Test public void testGetStringAttributes_NullValue() { String result = tested.getStringAttribute("someAbsentAttribute"); assertThat(result).isNull(); }
public void executeWithContext(DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { try { DirContextAdapter adapter = (DirContextAdapter) ctx.lookup(ldapEntryIdentification.getRelativeDn()); assertThat(adapter.getStringAttribute("cn")).isEqualTo("Some Person3"); } catch (NamingException e) { throw new RuntimeException("Failed to lookup " + ldapEntryIdentification.getRelativeDn(), e); } } };
@Test public void testGetStringAttributes_AttributeExists_NullValue() { tested.setAttribute(new BasicAttribute("someAttribute", null)); String result = tested.getStringAttribute("someAttribute"); assertThat(result).isNull(); }
@Test public void testGetStringAttributeWhenAttributeDoesExistButWithNoValue() throws Exception { final Attributes attrs = new BasicAttributes(); attrs.put(new BasicAttribute("abc")); class TestableDirContextAdapter extends DirContextAdapter { public TestableDirContextAdapter() { super(attrs, null); } } tested = new TestableDirContextAdapter(); String s = tested.getStringAttribute("abc"); assertThat(s).isNull(); }