userFilter.append(ldapName.get(ldapName.size() - 1)); userFilter.append(')'); userFilter.append(MessageFormat.format(manager.getSearchFilter(), "*"));
ln = new LdapName(lm.getNewMainIdentifier()); msgBuffer.append("changetype: modrdn\nnewrdn: "); msgBuffer.append(ln.get(ln.size()-1)); msgBuffer.append("\ndeleteoldrdn: 1\nnewsuperior: "); if (ln.size() > 1) {
/** * This method escapes the special characters in a LdapName according to the ldap filter escaping standards. * * @param ldn LDAP name * @return A String which special characters are escaped */ private String escapeLdapNameForFilter(LdapName ldn) { if (ldn == null) { if (LOG.isDebugEnabled()) { LOG.debug("Received null value to escape special characters. Returning null"); } return null; } StringBuilder escapedDN = new StringBuilder(); for (int i = ldn.size() - 1; i > -1; i--) { //escaping the rdns separately and re-constructing the DN escapedDN = escapedDN.append(escapeSpecialCharactersForFilterWithStarAsRegex(ldn.get(i))); if (i != 0) { escapedDN = escapedDN.append(","); } } if (LOG.isDebugEnabled()) { LOG.debug("Escaped DN value for filter : " + escapedDN.toString()); } return escapedDN.toString(); }
import javax.naming.ldap.LdapName; .... public static void main(String args[]){ try { LdapName dn = new LdapName("CN=x,OU=y,O=z,ST=v,C=COM"); System.out.println(dn.get(dn.size() - 1)); }catch (InvalidNameException e) { System.out.println(e.getMessage()); } }
private LdapEntry parseRole(String dn, String groupNameAttribute, URI groupReferralAddress) { try { LdapName ldapName = new LdapName(Rdn.unescapeValue(dn).toString()); for (int i = ldapName.size() - 1; i >= 0; i--) { String rdnString = ldapName.get(i); Rdn rdn = new Rdn(rdnString); Attribute attr = rdn.toAttributes().get(groupNameAttribute); if (attr != null) { Object value = attr.get(); if (value != null) { return new LdapEntry( (value instanceof byte[]) ? new String((byte[]) value, StandardCharsets.UTF_8) : value.toString(), dn, groupReferralAddress); } } } } catch (NamingException e) { SECURITY_LOGGER.tracef("Unable to parse role from DN (%s): %s", dn, e.getMessage()); } return null; }
private LdapEntry parseRole(String dn, String groupNameAttribute, URI groupReferralAddress) { try { LdapName ldapName = new LdapName(Rdn.unescapeValue(dn).toString()); for (int i = ldapName.size() - 1; i >= 0; i--) { String rdnString = ldapName.get(i); Rdn rdn = new Rdn(rdnString); Attribute attr = rdn.toAttributes().get(groupNameAttribute); if (attr != null) { Object value = attr.get(); if (value != null) { return new LdapEntry( (value instanceof byte[]) ? new String((byte[]) value, StandardCharsets.UTF_8) : value.toString(), dn, groupReferralAddress); } } } } catch (NamingException e) { SECURITY_LOGGER.tracef("Unable to parse role from DN (%s): %s", dn, e.getMessage()); } return null; }
public Name getTemporaryName(Name originalName) { int thisSequenceNo = NEXT_SEQUENCE_NO.getAndIncrement(); LdapName tempName = LdapUtils.newLdapName(originalName); try { String leafNode = tempName.get(tempName.size() - 1) + thisSequenceNo; LdapName newName = LdapUtils.newLdapName(subtreeNode); newName.add(leafNode); return newName; } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } } }
public Name getTemporaryName(Name originalName) { int thisSequenceNo = NEXT_SEQUENCE_NO.getAndIncrement(); LdapName tempName = LdapUtils.newLdapName(originalName); try { String leafNode = tempName.get(tempName.size() - 1) + thisSequenceNo; LdapName newName = LdapUtils.newLdapName(subtreeNode); newName.add(leafNode); return newName; } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } } }
public Name getTemporaryName(Name originalName) { int thisSequenceNo = NEXT_SEQUENCE_NO.getAndIncrement(); LdapName tempName = LdapUtils.newLdapName(originalName); try { String leafNode = tempName.get(tempName.size() - 1) + thisSequenceNo; LdapName newName = LdapUtils.newLdapName(subtreeNode); newName.add(leafNode); return newName; } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } } }
public Name getTemporaryName(Name originalName) { int thisSequenceNo = NEXT_SEQUENCE_NO.getAndIncrement(); LdapName tempName = LdapUtils.newLdapName(originalName); try { String leafNode = tempName.get(tempName.size() - 1) + thisSequenceNo; LdapName newName = LdapUtils.newLdapName(subtreeNode); newName.add(leafNode); return newName; } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } } }
userFilter.append(ldapName.get(ldapName.size() - 1)); userFilter.append(')'); userFilter.append(MessageFormat.format(manager.getSearchFilter(), "*"));
String rdn = name.get(name.size() - 1); int pos = rdn.indexOf("="); id = rdn.substring(pos + 1);