Prep work for OPENDJ-1342: align APIs for DNs: isDescendantOf() => isSubordinateOrEqualTo()
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.task; |
| | |
| | | { |
| | | for (BaseDNDescriptor baseDN : backend.getBaseDns()) |
| | | { |
| | | if (groupDn.isDescendantOf(baseDN.getDn())) |
| | | if (groupDn.isSubordinateOrEqualTo(baseDN.getDn())) |
| | | { |
| | | backendSet.add(backend.getBackendID()); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.task; |
| | |
| | | { |
| | | for (DN dn : entries) |
| | | { |
| | | if (dn.isDescendantOf(baseDN.getDn())) |
| | | if (dn.isSubordinateOrEqualTo(baseDN.getDn())) |
| | | { |
| | | backendSet.add(backend.getBackendID()); |
| | | break; |
| | |
| | | boolean isDnDeleted = false; |
| | | for (DN deletedDn : alreadyDeleted) |
| | | { |
| | | if (dn.isDescendantOf(deletedDn)) |
| | | if (dn.isSubordinateOrEqualTo(deletedDn)) |
| | | { |
| | | isDnDeleted = true; |
| | | break; |
| | |
| | | { |
| | | for (BaseDNDescriptor baseDN : backend.getBaseDns()) |
| | | { |
| | | if (newDn.isDescendantOf(baseDN.getDn()) || |
| | | oldDn.isDescendantOf(baseDN.getDn())) |
| | | if (newDn.isSubordinateOrEqualTo(baseDN.getDn()) || |
| | | oldDn.isSubordinateOrEqualTo(baseDN.getDn())) |
| | | { |
| | | backendSet.add(backend.getBackendID()); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.task; |
| | | |
| | |
| | | { |
| | | for (BaseDNDescriptor baseDN : backend.getBaseDns()) |
| | | { |
| | | if (dn.isDescendantOf(baseDN.getDn())) |
| | | if (dn.isSubordinateOrEqualTo(baseDN.getDn())) |
| | | { |
| | | backendSet.add(backend.getBackendID()); |
| | | } |
| | |
| | | try |
| | | { |
| | | DN nodeDN = DN.valueOf(node.getDN()); |
| | | if (dn.isDescendantOf(nodeDN)) |
| | | if (dn.isSubordinateOrEqualTo(nodeDN)) |
| | | { |
| | | if (dn.size() == nodeDN.size() + 1) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.guitools.controlpanel.task; |
| | |
| | | { |
| | | for (BaseDNDescriptor baseDN : backend.getBaseDns()) |
| | | { |
| | | if (dn.isDescendantOf(baseDN.getDn())) |
| | | if (dn.isSubordinateOrEqualTo(baseDN.getDn())) |
| | | { |
| | | backendSet.add(backend.getBackendID()); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | try |
| | | { |
| | | DN dn = DN.valueOf(dnArray[i]); |
| | | if (dn.isDescendantOf(baseDN.getDn())) |
| | | if (dn.isSubordinateOrEqualTo(baseDN.getDn())) |
| | | { |
| | | found = true; |
| | | break; |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.guitools.controlpanel.ui; |
| | | |
| | |
| | | DN dn = DN.valueOf(sDn); |
| | | for (DN parentDN : parentReadOnly) |
| | | { |
| | | if (dn.isDescendantOf(parentDN)) |
| | | if (dn.isSubordinateOrEqualTo(parentDN)) |
| | | { |
| | | isReadOnly = true; |
| | | break; |
| | |
| | | { |
| | | for (DN parentDN : parentDNs) |
| | | { |
| | | if (dn.isDescendantOf(parentDN)) |
| | | if (dn.isSubordinateOrEqualTo(parentDN)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | { |
| | | for (DN dn : getBaseDNs()) |
| | | { |
| | | if (entryDN.isDescendantOf(dn)) |
| | | if (entryDN.isSubordinateOrEqualTo(dn)) |
| | | { |
| | | for (Backend<?> b : subordinateBackends) |
| | | { |
| | |
| | | { |
| | | for (DN baseDN : baseDNs) |
| | | { |
| | | if (entryDN.isDescendantOf(baseDN) && !isExcluded(excludeDNs, entryDN)) |
| | | if (entryDN.isSubordinateOrEqualTo(baseDN) && !isExcluded(excludeDNs, entryDN)) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | } |
| | | for (DN excludeDN : excludeDNs) |
| | | { |
| | | if (entryDN.isDescendantOf(excludeDN)) |
| | | if (entryDN.isSubordinateOrEqualTo(excludeDN)) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | * Portions Copyright 2013-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | aciList.entrySet().iterator(); |
| | | while (iterator.hasNext()) { |
| | | Map.Entry<DN,List<Aci>> hashEntry = iterator.next(); |
| | | if(hashEntry.getKey().isDescendantOf(oldDN)) { |
| | | if(hashEntry.getKey().isSubordinateOrEqualTo(oldDN)) { |
| | | int keyRDNCount=hashEntry.getKey().size(); |
| | | int keepRDNCount=keyRDNCount - oldRDNCount; |
| | | RDN[] newRDNs = new RDN[keepRDNCount + newRDNCount]; |
| | |
| | | } |
| | | break; |
| | | case WHOLE_SUBTREE: |
| | | if(!entryDN.isDescendantOf(targetDN)) |
| | | if(!entryDN.isSubordinateOrEqualTo(targetDN)) |
| | | { |
| | | return false; |
| | | } |
| | | break; |
| | | case SUBORDINATES: |
| | | if (entryDN.size() <= targetDN.size() || |
| | | !entryDN.isDescendantOf(targetDN)) { |
| | | !entryDN.isSubordinateOrEqualTo(targetDN)) { |
| | | return false; |
| | | } |
| | | break; |
| | |
| | | EnumTargetOperator op=targets.getTarget().getOperator(); |
| | | if(op == EnumTargetOperator.NOT_EQUALITY) { |
| | | DN tmpDN=targets.getTarget().getDN(); |
| | | if(entryDN.isDescendantOf(tmpDN)) |
| | | if(entryDN.isSubordinateOrEqualTo(tmpDN)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | for(ByteString v : attrs.get(0)) { |
| | | try { |
| | | DN groupDN = DN.valueOf(v.toString()); |
| | | if(suffixDN != null && !groupDN.isDescendantOf(suffixDN)) |
| | | if(suffixDN != null && !groupDN.isSubordinateOrEqualTo(suffixDN)) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | patternDN = PatternDN.decodeSuffix(targetURL.getRawBaseDN()); |
| | | } else { |
| | | urlDN=targetURL.getBaseDN(); |
| | | if(!urlDN.isDescendantOf(aciDN)) { |
| | | if(!urlDN.isSubordinateOrEqualTo(aciDN)) { |
| | | throw new AciException(WARN_ACI_SYNTAX_TARGET_DN_NOT_DESCENDENTOF.get(urlDN, aciDN)); |
| | | } |
| | | } |
| | |
| | | } |
| | | SearchScope scope=url.getScope(); |
| | | if(scope == SearchScope.WHOLE_SUBTREE) { |
| | | if(!evalCtx.getClientDN().isDescendantOf(urlDN)) |
| | | if(!evalCtx.getClientDN().isSubordinateOrEqualTo(urlDN)) |
| | | { |
| | | return EnumEvalResult.FALSE; |
| | | } |
| | |
| | | } else if(scope == SearchScope.SUBORDINATES) { |
| | | DN userDN = evalCtx.getClientDN(); |
| | | if (userDN.size() <= urlDN.size() || |
| | | !userDN.isDescendantOf(urlDN)) { |
| | | !userDN.isSubordinateOrEqualTo(urlDN)) { |
| | | return EnumEvalResult.FALSE; |
| | | } |
| | | } else { |
| | |
| | | if (dit.containsKey(entryDN)) |
| | | { |
| | | final DN nextDN = dit.higherKey(entryDN); |
| | | return ConditionResult.valueOf(nextDN != null && nextDN.isDescendantOf(entryDN)); |
| | | return ConditionResult.valueOf(nextDN != null && nextDN.isSubordinateOrEqualTo(entryDN)); |
| | | } |
| | | return ConditionResult.UNDEFINED; |
| | | } |
| | |
| | | final int childDNSize = entryDN.size() + 1; |
| | | for (final DN dn : dit.tailMap(entryDN, false).navigableKeySet()) |
| | | { |
| | | if (!dn.isDescendantOf(entryDN)) |
| | | if (!dn.isSubordinateOrEqualTo(entryDN)) |
| | | { |
| | | break; |
| | | } |
| | |
| | | searchOperation.returnEntry(entry, null); |
| | | } |
| | | } |
| | | else if (scope == SearchScope.BASE_OBJECT || !dn.isDescendantOf(baseDN)) |
| | | else if (scope == SearchScope.BASE_OBJECT || !dn.isSubordinateOrEqualTo(baseDN)) |
| | | { |
| | | // No more entries will be in scope. |
| | | break; |
| | |
| | | for (Map.Entry<DN, Backend<?>> entry : getSubordinateBaseDNs().entrySet()) |
| | | { |
| | | DN baseDN = entry.getKey(); |
| | | if (entryDN.isDescendantOf(baseDN)) |
| | | if (entryDN.isSubordinateOrEqualTo(baseDN)) |
| | | { |
| | | Backend<?> b = entry.getValue(); |
| | | if (b.entryExists(entryDN)) |
| | |
| | | { |
| | | // Check if this entry is an immediate child. |
| | | if (entryDN.size() == aBaseDN.size() + 1 |
| | | && entryDN.isDescendantOf(aBaseDN)) |
| | | && entryDN.isSubordinateOrEqualTo(aBaseDN)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | else if (searchScope == SearchScope.WHOLE_SUBTREE) |
| | | { |
| | | if (entryDN.isDescendantOf(aBaseDN)) |
| | | if (entryDN.isSubordinateOrEqualTo(aBaseDN)) |
| | | { |
| | | return true; |
| | | } |
| | | } |
| | | else if (searchScope == SearchScope.SUBORDINATES |
| | | && entryDN.size() > aBaseDN.size() |
| | | && entryDN.isDescendantOf(aBaseDN)) |
| | | && entryDN.isSubordinateOrEqualTo(aBaseDN)) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | private DN getMatchedDN(ReadableTransaction txn, DN targetDN) throws DirectoryException |
| | | { |
| | | DN parentDN = targetDN.getParentDNInSuffix(); |
| | | while (parentDN != null && parentDN.isDescendantOf(baseDN)) |
| | | while (parentDN != null && parentDN.isSubordinateOrEqualTo(baseDN)) |
| | | { |
| | | if (entryExists(txn, parentDN)) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2015 ForgeRock AS. |
| | | * Portions Copyright 2012-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.backends.pluggable; |
| | | |
| | |
| | | { |
| | | for (DN includeBranch : includeBranches) |
| | | { |
| | | if (includeBranch.isDescendantOf(baseDN) || |
| | | if (includeBranch.isSubordinateOrEqualTo(baseDN) || |
| | | includeBranch.isAncestorOf(baseDN)) |
| | | { |
| | | exportContainers.add(entryContainer); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | logger.traceException(e); |
| | | } |
| | | } |
| | | if (newAuthNDN != null && authNDN != null && authNDN.isDescendantOf(oldEntry.getName())) |
| | | if (newAuthNDN != null && authNDN != null && authNDN.isSubordinateOrEqualTo(oldEntry.getName())) |
| | | { |
| | | if (newAuthNSet == null) |
| | | { |
| | |
| | | conn.getAuthenticationInfo().setAuthenticationDN(newAuthNDN); |
| | | newAuthNSet.add(conn); |
| | | } |
| | | if (newAuthZDN != null && authZDN != null && authZDN.isDescendantOf(oldEntry.getName())) |
| | | if (newAuthZDN != null && authZDN != null && authZDN.isSubordinateOrEqualTo(oldEntry.getName())) |
| | | { |
| | | if (newAuthZSet == null) |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.core; |
| | | |
| | |
| | | { |
| | | otherBaseDNs.add(dn); |
| | | |
| | | if (baseDN.isAncestorOf(dn) || baseDN.isDescendantOf(dn)) |
| | | if (baseDN.isAncestorOf(dn) || baseDN.isSubordinateOrEqualTo(dn)) |
| | | { |
| | | LocalizableMessage message = ERR_REGISTER_BASEDN_HIERARCHY_CONFLICT. |
| | | get(baseDN, backend.getBackendID(), dn); |
| | |
| | | |
| | | for (DN dn : otherBaseDNs) |
| | | { |
| | | if (!dn.isDescendantOf(parentDN)) |
| | | if (!dn.isSubordinateOrEqualTo(parentDN)) |
| | | { |
| | | LocalizableMessage msg = ERR_REGISTER_BASEDN_DIFFERENT_PARENT_BASES.get(baseDN, backendID, dn); |
| | | throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM, msg); |
| | |
| | | { |
| | | for (DN dn : b.getBaseDNs()) |
| | | { |
| | | if (dn.isDescendantOf(baseDN)) |
| | | if (dn.isSubordinateOrEqualTo(baseDN)) |
| | | { |
| | | subordinateBackends.add(b); |
| | | break; |
| | |
| | | |
| | | final Entry entry = op.getEntryToAdd(); |
| | | final DN entryDN = op.getEntryDN(); |
| | | if (entryDN.isDescendantOf(instanceKeysDN)) |
| | | if (entryDN.isSubordinateOrEqualTo(instanceKeysDN)) |
| | | { |
| | | handleInstanceKeyAddOperation(entry); |
| | | } |
| | | else if (entryDN.isDescendantOf(secretKeysDN)) |
| | | else if (entryDN.isSubordinateOrEqualTo(secretKeysDN)) |
| | | { |
| | | try |
| | | { |
| | |
| | | public PostResponse doPostResponse(PostResponseDeleteOperation op) |
| | | { |
| | | if (op.getResultCode() != ResultCode.SUCCESS |
| | | || !op.getEntryDN().isDescendantOf(instanceKeysDN)) |
| | | || !op.getEntryDN().isSubordinateOrEqualTo(instanceKeysDN)) |
| | | { |
| | | return PostResponse.continueOperationProcessing(); |
| | | } |
| | |
| | | |
| | | final Entry newEntry = op.getModifiedEntry(); |
| | | final DN entryDN = op.getEntryDN(); |
| | | if (entryDN.isDescendantOf(instanceKeysDN)) |
| | | if (entryDN.isSubordinateOrEqualTo(instanceKeysDN)) |
| | | { |
| | | handleInstanceKeyModifyOperation(newEntry); |
| | | } |
| | | else if (entryDN.isDescendantOf(secretKeysDN)) |
| | | else if (entryDN.isSubordinateOrEqualTo(secretKeysDN)) |
| | | { |
| | | try |
| | | { |
| | |
| | | |
| | | private DN getMatchedDNForDescendantOfConfig(DN dn) |
| | | { |
| | | if (dn.isDescendantOf(configRootEntry.getDN())) |
| | | if (dn.isSubordinateOrEqualTo(configRootEntry.getDN())) |
| | | { |
| | | return getMatchedDN(dn); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | DN urlBaseDN = memberURL.getBaseDN(); |
| | | if (baseDN != null) |
| | | { |
| | | if (baseDN.isDescendantOf(urlBaseDN)) |
| | | if (baseDN.isSubordinateOrEqualTo(urlBaseDN)) |
| | | { |
| | | // The base DN requested by the user is below the base DN for this |
| | | // URL, so we'll use the base DN requested by the user. |
| | | urlBaseDN = baseDN; |
| | | } |
| | | else if (! urlBaseDN.isDescendantOf(baseDN)) |
| | | else if (! urlBaseDN.isSubordinateOrEqualTo(baseDN)) |
| | | { |
| | | // The base DN from the URL is outside the base requested by the user, |
| | | // so we can skip this URL altogether. |
| | |
| | | while (iterator.hasNext()) |
| | | { |
| | | DN existingBaseDN = iterator.next(); |
| | | if (urlBaseDN.isDescendantOf(existingBaseDN)) |
| | | if (urlBaseDN.isSubordinateOrEqualTo(existingBaseDN)) |
| | | { |
| | | // The base DN for the current URL is below an existing base DN, |
| | | // so we can just add this URL to the existing list and be done. |
| | |
| | | found = true; |
| | | break; |
| | | } |
| | | else if (existingBaseDN.isDescendantOf(urlBaseDN)) |
| | | else if (existingBaseDN.isSubordinateOrEqualTo(urlBaseDN)) |
| | | { |
| | | // The base DN for the current URL is above the existing base DN, |
| | | // so we should use the base DN for the current URL instead of the |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | |
| | | { |
| | | CacheEntry e = iterator.next(); |
| | | DN entryDN = e.getEntry().getName(); |
| | | if (entryDN.isDescendantOf(baseDN)) |
| | | if (entryDN.isSubordinateOrEqualTo(baseDN)) |
| | | { |
| | | iterator.remove(); |
| | | dnMap.remove(entryDN); |
| | |
| | | boolean isAppropriate = false; |
| | | for (DN subBase : subBackend.getBaseDNs()) |
| | | { |
| | | if (subBase.isDescendantOf(baseDN)) |
| | | if (subBase.isSubordinateOrEqualTo(baseDN)) |
| | | { |
| | | isAppropriate = true; |
| | | break; |
| | |
| | | { |
| | | for (DN baseDN: baseDNs) |
| | | { |
| | | if (dn.isDescendantOf(baseDN)) |
| | | if (dn.isSubordinateOrEqualTo(baseDN)) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | |
| | | for (DN baseDN : baseDNs) |
| | | { |
| | | if (entryDN.isDescendantOf(baseDN)) |
| | | if (entryDN.isSubordinateOrEqualTo(baseDN)) |
| | | { |
| | | return baseDNs; |
| | | } |
| | |
| | | // Is the entry a sub entry of the replicated domain main entry ? |
| | | DN replicatedDn = replicationDomainCfg.getBaseDN(); |
| | | DN entryDn = entry.getName(); |
| | | if (entryDn.isDescendantOf(replicatedDn)) |
| | | if (entryDn.isSubordinateOrEqualTo(replicatedDn)) |
| | | { |
| | | // Found the matching replicated domain configuration object |
| | | matchingReplicatedDomainCfg = replicationDomainCfg; |
| | |
| | | * |
| | | * |
| | | * Copyright 2007-2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | * Portions Copyright 2013-2016 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | * Check if the operation to be run is a deleteOperation on a |
| | | * children of the current DeleteOperation. |
| | | */ |
| | | if (pendingMsg.getDN().isDescendantOf(targetDN)) |
| | | if (pendingMsg.getDN().isSubordinateOrEqualTo(targetDN)) |
| | | { |
| | | hasDependencies = true; |
| | | addDependency(change, pendingChange); |
| | |
| | | * Check if the operation to be run is an ModifyDNOperation |
| | | * on a children of the current DeleteOperation |
| | | */ |
| | | if (pendingMsg.getDN().isDescendantOf(targetDN) |
| | | if (pendingMsg.getDN().isSubordinateOrEqualTo(targetDN) |
| | | || pendingModDn.newDNIsParent(targetDN)) |
| | | { |
| | | hasDependencies = true; |
| | |
| | | { |
| | | for (DN importBase : defaultIncludeBranches) |
| | | { |
| | | if (!baseDN.equals(importBase) && baseDN.isDescendantOf(importBase)) |
| | | if (!baseDN.equals(importBase) && baseDN.isSubordinateOrEqualTo(importBase)) |
| | | { |
| | | excludeBranches.add(baseDN); |
| | | break; |
| | |
| | | { |
| | | for (DN importBase : defaultIncludeBranches) |
| | | { |
| | | if (!baseDN.equals(importBase) && baseDN.isDescendantOf(importBase)) |
| | | if (!baseDN.equals(importBase) && baseDN.isSubordinateOrEqualTo(importBase)) |
| | | { |
| | | excludeBranches.add(baseDN); |
| | | break; |
| | |
| | | for (String adn : getCommonSuffixes(ctxSource, ctxDest, SuffixRelationType.REPLICATED)) |
| | | { |
| | | DN dn = DN.valueOf(adn); |
| | | if (DN.valueOf(targetDN).isDescendantOf(dn) && dn.isDescendantOf(targetBaseDN)) |
| | | if (DN.valueOf(targetDN).isSubordinateOrEqualTo(dn) && dn.isSubordinateOrEqualTo(targetBaseDN)) |
| | | { |
| | | targetBaseDN = dn; |
| | | } |
| | |
| | | { |
| | | Reject.ifNull(fromDN, toDN); |
| | | |
| | | if (!isDescendantOf(fromDN)) |
| | | if (!isSubordinateOrEqualTo(fromDN)) |
| | | { |
| | | return this; |
| | | } |
| | |
| | | * @return <CODE>true</CODE> if this DN is a descendant of the |
| | | * provided DN, or <CODE>false</CODE> if not. |
| | | */ |
| | | public boolean isDescendantOf(DN dn) |
| | | public boolean isSubordinateOrEqualTo(DN dn) |
| | | { |
| | | int offset = numComponents - dn.numComponents; |
| | | if (offset < 0) |
| | |
| | | |
| | | case WHOLE_SUBTREE: |
| | | // This DN must be a descendant of the provided base DN. |
| | | return isDescendantOf(baseDN); |
| | | return isSubordinateOrEqualTo(baseDN); |
| | | |
| | | case SUBORDINATES: |
| | | // This DN must be a descendant of the provided base DN, but |
| | | // not equal to it. |
| | | return !equals(baseDN) && isDescendantOf(baseDN); |
| | | return !equals(baseDN) && isSubordinateOrEqualTo(baseDN); |
| | | |
| | | default: |
| | | // This is a scope that we don't recognize. |
| | |
| | | { |
| | | inheritFromDN = DN.decode(value); |
| | | // Respect subentry root scope. |
| | | if (!inheritFromDN.isDescendantOf( |
| | | if (!inheritFromDN.isSubordinateOrEqualTo( |
| | | subEntry.getDN().parent())) |
| | | { |
| | | inheritFromDN = null; |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | |
| | |
| | | public boolean isDNWithinScope(final DN dn) |
| | | { |
| | | |
| | | if (!dn.isDescendantOf(baseDN)) |
| | | if (!dn.isSubordinateOrEqualTo(baseDN)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | // Check exclusions. |
| | | for (final DN chopBeforeDN : chopBefore.keySet()) |
| | | { |
| | | if (dn.isDescendantOf(chopBeforeDN)) |
| | | if (dn.isSubordinateOrEqualTo(chopBeforeDN)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | |
| | | for (final DN chopAfterDN : chopAfter.keySet()) |
| | | { |
| | | if (!dn.equals(chopAfterDN) && dn.isDescendantOf(chopAfterDN)) |
| | | if (!dn.equals(chopAfterDN) && dn.isSubordinateOrEqualTo(chopAfterDN)) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | { |
| | | for (DN dn : b.getBaseDNs()) |
| | | { |
| | | if (dn.isDescendantOf(entryDN)) |
| | | if (dn.isSubordinateOrEqualTo(entryDN)) |
| | | { |
| | | setResultCodeAndMessageNoInfoDisclosure(entry, |
| | | ResultCode.NOT_ALLOWED_ON_NONLEAF, |
| | |
| | | } |
| | | else |
| | | { |
| | | if (newSuperior.isDescendantOf(entryDN)) |
| | | if (newSuperior.isSubordinateOrEqualTo(entryDN)) |
| | | { |
| | | setResultCode(ResultCode.UNWILLING_TO_PERFORM); |
| | | appendErrorMessage(ERR_MODDN_NEW_SUPERIOR_IN_SUBTREE.get(entryDN, newSuperior)); |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.workflowelement.localbackend; |
| | | |
| | |
| | | { |
| | | for (DN subordinateDN : subordinate.getBaseDNs()) |
| | | { |
| | | if (subordinateDN.isDescendantOf(baseDN)) |
| | | if (subordinateDN.isSubordinateOrEqualTo(baseDN)) |
| | | { |
| | | results.add(registeredLocalBackends.get(subordinateDN)); |
| | | } |
| | |
| | | assertTrue(p.isAncestorOf(c)); |
| | | assertFalse(c.isAncestorOf(p)); |
| | | |
| | | assertTrue(c.isDescendantOf(p)); |
| | | assertFalse(p.isDescendantOf(c)); |
| | | assertTrue(c.isSubordinateOrEqualTo(p)); |
| | | assertFalse(p.isSubordinateOrEqualTo(c)); |
| | | |
| | | assertEquals(p, e); |
| | | assertEquals(p.hashCode(), e.hashCode()); |
| | |
| | | assertTrue(p.isAncestorOf(c)); |
| | | assertFalse(c.isAncestorOf(p)); |
| | | |
| | | assertTrue(c.isDescendantOf(p)); |
| | | assertFalse(p.isDescendantOf(c)); |
| | | assertTrue(c.isSubordinateOrEqualTo(p)); |
| | | assertFalse(p.isSubordinateOrEqualTo(c)); |
| | | |
| | | assertEquals(c, e); |
| | | assertEquals(c.hashCode(), e.hashCode()); |
| | |
| | | DN dn = DN.valueOf(s); |
| | | DN other = DN.valueOf(d); |
| | | |
| | | assertEquals(dn.isDescendantOf(other), e, s + " isDescendantOf " |
| | | assertEquals(dn.isSubordinateOrEqualTo(other), e, s + " isDescendantOf " |
| | | + d); |
| | | } |
| | | |
| | |
| | | AssertionError.class }) |
| | | public void testIsDescendantOfException() throws Exception { |
| | | DN dn = DN.valueOf("dc=com"); |
| | | dn.isDescendantOf(null); |
| | | dn.isSubordinateOrEqualTo(null); |
| | | } |
| | | |
| | | |