/** * Get the {@link LdapRdn} with the specified key. If there are several * {@link Rdn}s with the same key, the first one found (in order of * significance) will be returned. * * @param key Attribute name of the {@link LdapRdn} to retrieve. * @return the {@link LdapRdn} with the requested key. * @throws IllegalArgumentException if no Rdn matches the given key. */ public LdapRdn getLdapRdn(String key) { for (Iterator iter = names.iterator(); iter.hasNext();) { LdapRdn rdn = (LdapRdn) iter.next(); if (ObjectUtils.nullSafeEquals(rdn.getKey(), key)) { return rdn; } } throw new IllegalArgumentException("No Rdn with the requested key: '" + key + "'"); }
/** * Get the {@link LdapRdn} with the specified key. If there are several * {@link Rdn}s with the same key, the first one found (in order of * significance) will be returned. * * @param key Attribute name of the {@link LdapRdn} to retrieve. * @return the {@link LdapRdn} with the requested key. * @throws IllegalArgumentException if no Rdn matches the given key. */ public LdapRdn getLdapRdn(String key) { for (Iterator iter = names.iterator(); iter.hasNext();) { LdapRdn rdn = (LdapRdn) iter.next(); if (ObjectUtils.nullSafeEquals(rdn.getKey(), key)) { return rdn; } } throw new IllegalArgumentException("No Rdn with the requested key: '" + key + "'"); }
/** * Get the {@link LdapRdn} with the specified key. If there are several * {@link Rdn}s with the same key, the first one found (in order of * significance) will be returned. * * @param key Attribute name of the {@link LdapRdn} to retrieve. * @return the {@link LdapRdn} with the requested key. * @throws IllegalArgumentException if no Rdn matches the given key. */ public LdapRdn getLdapRdn(String key) { for (Iterator iter = names.iterator(); iter.hasNext();) { LdapRdn rdn = (LdapRdn) iter.next(); if (ObjectUtils.nullSafeEquals(rdn.getKey(), key)) { return rdn; } } throw new IllegalArgumentException("No Rdn with the requested key: '" + key + "'"); }
/** * Get the {@link LdapRdn} with the specified key. If there are several * {@link Rdn}s with the same key, the first one found (in order of * significance) will be returned. * * @param key Attribute name of the {@link LdapRdn} to retrieve. * @return the {@link LdapRdn} with the requested key. * @throws IllegalArgumentException if no Rdn matches the given key. */ public LdapRdn getLdapRdn(String key) { for (Iterator iter = names.iterator(); iter.hasNext();) { LdapRdn rdn = (LdapRdn) iter.next(); if (ObjectUtils.nullSafeEquals(rdn.getKey(), key)) { return rdn; } } throw new IllegalArgumentException("No Rdn with the requested key: '" + key + "'"); }
@SuppressWarnings("unchecked") public List<Long> groups(String username, LdapConfig config, LdapOperations ldap, RoleProvider provider, final AttributeSet attrSet) { final List<Long> groups = new ArrayList<Long>(); final List<LdapRdn> names = dn.getNames(); for (int i = names.size(); i > 0; i--) { LdapRdn name = names.get(i-1); if ("ou".equals(name.getKey())) { final String grpName = name.getValue("ou"); groups.add(provider.createGroup(grpName, null, false, true)); break; } } return groups; }
@Test public void testLdapRdn_Parse_MultipleComponents() { LdapRdn rdn = new LdapRdn("cn=John Doe+sn=Doe"); assertThat(rdn.getComponent(0).encodeLdap()).isEqualTo("cn=John Doe"); assertThat(rdn.getComponent(1).encodeLdap()).isEqualTo("sn=Doe"); assertThat(rdn.getLdapEncoded()).isEqualTo("cn=John Doe+sn=Doe"); assertThat(rdn.getKey()).isEqualTo("cn"); assertThat(rdn.getValue()).isEqualTo("John Doe"); assertThat(rdn.getValue("cn")).isEqualTo("John Doe"); assertThat(rdn.getValue("sn")).isEqualTo("Doe"); }
@Test public void testLdapRdn_parse_simple() { LdapRdn rdn = new LdapRdn("foo=bar"); assertThat(rdn.getComponent().getKey()).isEqualTo("foo"); assertThat(rdn.getComponent().getValue()).isEqualTo("bar"); assertThat(rdn.getComponent().getLdapEncoded()).isEqualTo("foo=bar"); assertThat(rdn.getKey()).isEqualTo("foo"); assertThat(rdn.getValue()).isEqualTo("bar"); }
if (rdn.getKey().equals(searchConfiguration.getLdapIdAttribute()))