public void setTempSearchBase(String tempSearchBase) { try { LdapName baseName = new LdapName(tempSearchBase); tempPrefixLength = baseName.size(); this.tempSearchBase = tempSearchBase; } catch (InvalidNameException e) { throw new IllegalArgumentException("Invalid base DN value " + tempSearchBase, e); } }
public void setQueueSearchBase(String queueSearchBase) { try { LdapName baseName = new LdapName(queueSearchBase); queuePrefixLength = baseName.size(); this.queueSearchBase = queueSearchBase; } catch (InvalidNameException e) { throw new IllegalArgumentException("Invalid base DN value " + queueSearchBase, e); } }
public void setTopicSearchBase(String topicSearchBase) { try { LdapName baseName = new LdapName(topicSearchBase); topicPrefixLength = baseName.size(); this.topicSearchBase = topicSearchBase; } catch (InvalidNameException e) { throw new IllegalArgumentException("Invalid base DN value " + topicSearchBase, e); } }
private List<String> getDnAttribute(LdapName rfc2253dn, String attribute) { final List<String> attrValues = new ArrayList<>(rfc2253dn.size()); final List<Rdn> reverseRdn = new ArrayList<>(rfc2253dn.getRdns()); Collections.reverse(reverseRdn); for (Rdn rdn : reverseRdn) { if (rdn.getType().equalsIgnoreCase(attribute)) { attrValues.add(rdn.getValue().toString()); } } return Collections.unmodifiableList(attrValues); } }
protected Set<GroupPrincipal> getACLs(String destinationBase, SearchControls constraints, String roleBase, String roleAttribute) { try { Set<GroupPrincipal> roles = new HashSet<GroupPrincipal>(); Set<String> acls = new HashSet<String>(); NamingEnumeration<?> results = context.search(destinationBase, roleBase, constraints); while (results.hasMore()) { SearchResult result = (SearchResult)results.next(); Attributes attrs = result.getAttributes(); if (attrs == null) { continue; } acls = addAttributeValues(roleAttribute, attrs, acls); } for (Iterator<String> iter = acls.iterator(); iter.hasNext();) { String roleName = iter.next(); LdapName ldapname = new LdapName(roleName); Rdn rdn = ldapname.getRdn(ldapname.size() - 1); LOG.debug("Found role: [" + rdn.getValue().toString() + "]"); roles.add(new GroupPrincipal(rdn.getValue().toString())); } return roles; } catch (NamingException e) { LOG.error(e.toString()); return new HashSet<GroupPrincipal>(); } }
if (dn.size() == (getPrefixLengthForDestinationType(destinationType) + 2)) { destination = formatDestination(dn.getRdn(dn.size() - 2), destinationType); } else if (dn.size() == (getPrefixLengthForDestinationType(destinationType) + 1)) { destination = formatDestination(dn.getRdn(dn.size() - 1), destinationType); } else { throw new IllegalArgumentException("Malformed DN for representing a permission or destination entry.");
case TEMP: if (dn.size() != getPrefixLengthForDestinationType(destinationType) + 1) { case TOPIC: if (dn.size() != getPrefixLengthForDestinationType(destinationType) + 2) { throw new IllegalArgumentException("Malformed policy structure for a queue or topic destination " + "policy entry. The destination pattern and permission group entries should be " + "nested below the queue or topic policy base DN.");
private LdapSearch createLdapSearchByDn() { if ( ! name.regionMatches(true, 0, identityMapping.rdnIdentifier, 0, identityMapping.rdnIdentifier.length())) { return null; } // equal sign not checked here as whitespaces can be between yet try { LdapName ldapName = new LdapName(name); int rdnPosition = ldapName.size() - 1; Rdn rdnIdentifier = ldapName.getRdn(rdnPosition); if ( ! rdnIdentifier.getType().equalsIgnoreCase(identityMapping.rdnIdentifier)) { // uid=... log.tracef("Getting identity [%s] by DN skipped - RDN does not match [%s]", name, identityMapping.rdnIdentifier); return null; } if (identityMapping.searchDn != null) { List<Rdn> expectedStart = new LdapName(identityMapping.searchDn).getRdns(); if ( ! ldapName.startsWith(expectedStart)) { // ...,search-dn log.tracef("Getting identity [%s] by DN skipped - DN not in search-dn [%s]", name, identityMapping.searchDn); return null; } if ( ! identityMapping.searchRecursive && ldapName.size() != expectedStart.size() + 1) { log.tracef("Getting identity [%s] by DN skipped - DN not directly in search-dn and recursive search not enabled [%s]", name, identityMapping.searchDn); return null; } } return new LdapSearch(ldapName.toString(), SearchControls.OBJECT_SCOPE, 0, identityMapping.filterName, rdnIdentifier.getValue().toString()); } catch (InvalidNameException e) { log.tracef(e, "Getting identity [%s] by DN failed - will continue by name", name); } return null; }
userFilter.append(ldapName.get(ldapName.size() - 1)); userFilter.append(')'); userFilter.append(MessageFormat.format(manager.getSearchFilter(), "*"));
identity.getDirContext().modifyAttributes(identityLdapName, modItemsArray); if (renameTo != null && ! renameTo.equals(identityLdapName.getRdn(identityLdapName.size()-1).getValue())) { LdapName newLdapName = new LdapName(identityLdapName.getRdns().subList(0, identityLdapName.size()-1)); newLdapName.add(new Rdn(identityMapping.rdnIdentifier, renameTo)); identity.getDirContext().rename(identityLdapName, newLdapName);
/** * Gets the distinguished name of the parent object * @param dn The distinguished name * @param suffix the suffix defined in "dn" extension * @return the distinguished name of the parent object */ public static LdapName getParentDistingueshedName(LdapName dn, LdapName suffix) { LdapName parent = (LdapName) dn.getPrefix(dn.size() - suffix.size() - 1); return parent; }
public void setTempSearchBase(String tempSearchBase) { try { LdapName baseName = new LdapName(tempSearchBase); tempPrefixLength = baseName.size(); this.tempSearchBase = tempSearchBase; } catch (InvalidNameException e) { throw new IllegalArgumentException("Invalid base DN value " + tempSearchBase, e); } }
public void setQueueSearchBase(String queueSearchBase) { try { LdapName baseName = new LdapName(queueSearchBase); queuePrefixLength = baseName.size(); this.queueSearchBase = queueSearchBase; } catch (InvalidNameException e) { throw new IllegalArgumentException("Invalid base DN value " + queueSearchBase, e); } }
public void setTopicSearchBase(String topicSearchBase) { try { LdapName baseName = new LdapName(topicSearchBase); topicPrefixLength = baseName.size(); this.topicSearchBase = topicSearchBase; } catch (InvalidNameException e) { throw new IllegalArgumentException("Invalid base DN value " + topicSearchBase, e); } }
public void setTempSearchBase(String tempSearchBase) { try { LdapName baseName = new LdapName(tempSearchBase); tempPrefixLength = baseName.size(); this.tempSearchBase = tempSearchBase; } catch (InvalidNameException e) { throw new IllegalArgumentException("Invalid base DN value " + tempSearchBase, e); } }
public void setTempSearchBase(String tempSearchBase) { try { LdapName baseName = new LdapName(tempSearchBase); tempPrefixLength = baseName.size(); this.tempSearchBase = tempSearchBase; } catch (InvalidNameException e) { throw new IllegalArgumentException("Invalid base DN value " + tempSearchBase, e); } }
public void setQueueSearchBase(String queueSearchBase) { try { LdapName baseName = new LdapName(queueSearchBase); queuePrefixLength = baseName.size(); this.queueSearchBase = queueSearchBase; } catch (InvalidNameException e) { throw new IllegalArgumentException("Invalid base DN value " + queueSearchBase, e); } }
public void setTopicSearchBase(String topicSearchBase) { try { LdapName baseName = new LdapName(topicSearchBase); topicPrefixLength = baseName.size(); this.topicSearchBase = topicSearchBase; } catch (InvalidNameException e) { throw new IllegalArgumentException("Invalid base DN value " + topicSearchBase, e); } }
private static String getGroupNameFromDn(String dnString, String groupNameAttribute) throws NamingException { LdapName dn = new LdapName(dnString); // may throw InvalidNameException Attribute attribute = dn.getRdn(dn.size()-1).toAttributes().get(groupNameAttribute); if (attribute == null) { // We were configured with the wrong group name attribute throw new IdentityStoreConfigurationException("Group name attribute '" + groupNameAttribute + "' not found for DN: " + dnString); } return attribute.get(0).toString(); }
public Name getTemporaryName(Name originalName) { LdapName temporaryName = LdapUtils.newLdapName(originalName); // Add tempSuffix to the leaf node name. try { String leafNode = (String) temporaryName.remove(temporaryName.size() - 1); temporaryName.add(new Rdn(leafNode + tempSuffix)); } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } return temporaryName; }