opendj-server-legacy maven module:
Enabled "NeedBraces" checkstyle rule.
This brings opendj-server-legacy's checkstyle rules closer to ForgeRock's checkstyle rules.
AutoRefactor'ed using curly brackets after control flow statements.
Code review: Matthew Swift
| | |
| | | System.setProperty("mapAnyUriToUri", "true"); |
| | | |
| | | if(jaxbContext==null) |
| | | { |
| | | jaxbContext = JAXBContext.newInstance(PKG_NAME, getClass().getClassLoader()); |
| | | } |
| | | // assign the DSMLv2 schema for validation |
| | | if(schema==null) |
| | | { |
| | |
| | | * @param nodeTask the task to be added. |
| | | */ |
| | | public synchronized void queue(AbstractNodeTask nodeTask) { |
| | | if (nodeTask == null) throw new IllegalArgumentException("null argument"); |
| | | if (nodeTask == null) |
| | | { |
| | | throw new IllegalArgumentException("null argument"); |
| | | } |
| | | waitingQueue.add(nodeTask); |
| | | notify(); |
| | | // System.out.println("Queued " + nodeTask + " in " + _name); |
| | |
| | | * @param node the node whose associated tasks must be cancelled. |
| | | */ |
| | | public synchronized void cancelForNode(BasicNode node) { |
| | | if (node == null) throw new IllegalArgumentException("null argument"); |
| | | if (node == null) |
| | | { |
| | | throw new IllegalArgumentException("null argument"); |
| | | } |
| | | // Remove all the associated tasks from the waiting queue |
| | | for (int i = waitingQueue.size()-1; i >= 0; i--) { |
| | | AbstractNodeTask task = waitingQueue.get(i); |
| | |
| | | * @param task the task to be flushed. |
| | | */ |
| | | private synchronized void flush(AbstractNodeTask task) { |
| | | if (task == null) throw new IllegalArgumentException("null argument"); |
| | | if (task == null) |
| | | { |
| | | throw new IllegalArgumentException("null argument"); |
| | | } |
| | | workingList.remove(task.getNode()); |
| | | cancelList.remove(task.getNode()); |
| | | notify(); |
| | |
| | | |
| | | private void checkEnableSaveChanges() |
| | | { |
| | | if (ignoreChangeEvents) return; |
| | | boolean changed; |
| | | if (!ignoreChangeEvents) |
| | | { |
| | | saveChanges.setEnabled(hasChanged()); |
| | | } |
| | | } |
| | | |
| | | private boolean hasChanged() |
| | | { |
| | | if (attribute != null) |
| | | { |
| | | try |
| | | { |
| | | changed = !attribute.toString().equals(getNewAttribute().toString()); |
| | | return !attribute.toString().equals(getNewAttribute().toString()); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | changed = true; |
| | | return true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | changed = false; |
| | | } |
| | | saveChanges.setEnabled(changed); |
| | | return false; |
| | | } |
| | | |
| | | private String getAttributeName() |
| | |
| | | public void parentObjectClassesChanged( |
| | | SuperiorObjectClassesChangedEvent ev) |
| | | { |
| | | if (ignoreChangeEvents) return; |
| | | if (ignoreChangeEvents) |
| | | { |
| | | return; |
| | | } |
| | | updateAttributesWithParent(true); |
| | | checkEnableSaveChanges(); |
| | | if (ev.getNewObjectClasses().size() > 1) |
| | |
| | | |
| | | private void checkEnableSaveChanges() |
| | | { |
| | | if (ignoreChangeEvents) return; |
| | | boolean changed; |
| | | if (!ignoreChangeEvents) |
| | | { |
| | | saveChanges.setEnabled(hasChanged()); |
| | | } |
| | | } |
| | | |
| | | private boolean hasChanged() |
| | | { |
| | | if (objectClass != null) |
| | | { |
| | | try |
| | | { |
| | | changed = !objectClass.toString().equals( |
| | | getNewObjectClass().toString()); |
| | | return !objectClass.toString().equals(getNewObjectClass().toString()); |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | changed = true; |
| | | return true; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | changed = false; |
| | | } |
| | | saveChanges.setEnabled(changed); |
| | | return false; |
| | | } |
| | | |
| | | private Set<String> getAliases() |
| | |
| | | { |
| | | for (Attribute a : attrList) |
| | | { |
| | | if (a.isEmpty()) continue; |
| | | if (a.isEmpty()) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | ByteString v = a.iterator().next(); |
| | | DN subentryDN; |
| | |
| | | int pos=0, length=oidStr.length(); |
| | | char c; |
| | | if("*".equals(oidStr)) |
| | | { |
| | | return; |
| | | } |
| | | boolean lastWasPeriod = false; |
| | | while ((pos < length) && ((c = oidStr.charAt(pos++)) != ' ')) { |
| | | if (c == '.') { |
| | |
| | | LocalizableMessage message = |
| | | WARN_ACI_SYNTAX_ILLEGAL_CHAR_IN_NUMERIC_OID.get(oidStr, c, pos-1); |
| | | throw new AciException(message); |
| | | } else |
| | | } else { |
| | | lastWasPeriod = false; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | public boolean hasAccessType(EnumAccessType accessType) { |
| | | List<PermBindRulePair>pairs=getPermBindRulePairs(); |
| | | for(PermBindRulePair p : pairs) { |
| | | if(p.hasAccessType(accessType)) |
| | | if(p.hasAccessType(accessType)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | |
| | | public boolean hasRights(int rights) { |
| | | List<PermBindRulePair>pairs=getPermBindRulePairs(); |
| | | for(PermBindRulePair p : pairs) { |
| | | if(p.hasRights(rights)) |
| | | if(p.hasRights(rights)) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | |
| | | List<PermBindRulePair>pairs=getPermBindRulePairs(); |
| | | for(PermBindRulePair p : pairs) { |
| | | if(evalCtx.isDenyEval() && |
| | | (p.hasAccessType(EnumAccessType.ALLOW))) |
| | | (p.hasAccessType(EnumAccessType.ALLOW))) { |
| | | continue; |
| | | if(!p.hasRights(getEvalRights(evalCtx))) |
| | | } |
| | | if(!p.hasRights(getEvalRights(evalCtx))) { |
| | | continue; |
| | | } |
| | | res=p.getBindRule().evaluate(evalCtx); |
| | | // The evaluation result could be FAIL. Stop processing and return |
| | | //FAIL. Maybe an internal search failed. |
| | |
| | | */ |
| | | private int getEvalRights(AciEvalContext evalCtx) { |
| | | if(evalCtx.hasRights(ACI_WRITE) && |
| | | evalCtx.hasRights(ACI_SELF)) |
| | | evalCtx.hasRights(ACI_SELF)) { |
| | | return ACI_SELF; |
| | | else if(evalCtx.hasRights(ACI_COMPARE)) |
| | | } else if(evalCtx.hasRights(ACI_COMPARE)) { |
| | | return ACI_COMPARE; |
| | | else if(evalCtx.hasRights(ACI_SEARCH)) |
| | | } else if(evalCtx.hasRights(ACI_SEARCH)) { |
| | | return ACI_SEARCH; |
| | | else if(evalCtx.hasRights(ACI_READ)) |
| | | } else if(evalCtx.hasRights(ACI_READ)) { |
| | | return ACI_READ; |
| | | else if(evalCtx.hasRights(ACI_DELETE)) |
| | | } else if(evalCtx.hasRights(ACI_DELETE)) { |
| | | return ACI_DELETE; |
| | | else if(evalCtx.hasRights(ACI_ADD)) |
| | | } else if(evalCtx.hasRights(ACI_ADD)) { |
| | | return ACI_ADD; |
| | | else if(evalCtx.hasRights(ACI_WRITE)) |
| | | } else if(evalCtx.hasRights(ACI_WRITE)) { |
| | | return ACI_WRITE; |
| | | else if(evalCtx.hasRights(ACI_PROXY)) |
| | | } else if(evalCtx.hasRights(ACI_PROXY)) { |
| | | return ACI_PROXY; |
| | | else if(evalCtx.hasRights(ACI_IMPORT)) |
| | | } else if(evalCtx.hasRights(ACI_IMPORT)) { |
| | | return ACI_IMPORT; |
| | | else if(evalCtx.hasRights(ACI_EXPORT)) |
| | | } else if(evalCtx.hasRights(ACI_EXPORT)) { |
| | | return ACI_EXPORT; |
| | | } |
| | | return ACI_NULL; |
| | | } |
| | | |
| | |
| | | && operation instanceof SearchOperation) |
| | | { |
| | | hasGetEffectiveRightsControl = true; |
| | | if (getEffectiveRightsControl.getAuthzDN() == null) |
| | | if (getEffectiveRightsControl.getAuthzDN() == null) { |
| | | this.authzid = getClientDN(); |
| | | else this.authzid = getEffectiveRightsControl.getAuthzDN(); |
| | | } else { |
| | | this.authzid = getEffectiveRightsControl.getAuthzDN(); |
| | | } |
| | | this.specificAttrs = getEffectiveRightsControl.getAttributes(); |
| | | } |
| | | |
| | |
| | | String allUserAttrs= |
| | | (String)operation.getAttachment(ALL_USER_ATTRS_MATCHED); |
| | | if(allUserAttrs != null) |
| | | { |
| | | evalAllAttributes |= ACI_USER_ATTR_STAR_MATCHED; |
| | | } |
| | | //If an ACI evaluated because of an Targetattr="+", then the |
| | | //AciHandler.maySend method signaled this via adding this attachment |
| | | //string. |
| | | String allOpAttrs=(String)operation.getAttachment(ALL_OP_ATTRS_MATCHED); |
| | | if(allOpAttrs != null) |
| | | { |
| | | evalAllAttributes |= ACI_OP_ATTR_PLUS_MATCHED; |
| | | } |
| | | } |
| | | |
| | | //Reference the current authorization entry, so it can be put back |
| | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String getDecidingAciName() { |
| | | if(this.decidingAci != null) |
| | | return this.decidingAci.getName(); |
| | | else return null; |
| | | if(this.decidingAci != null) { |
| | | return this.decidingAci.getName(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | @Override |
| | | public DN getClientDN() { |
| | | if(this.useAuthzid) |
| | | { |
| | | return this.authzid; |
| | | } |
| | | else if (this.authorizationEntry != null) |
| | | { |
| | | return this.authorizationEntry.getName(); |
| | | } |
| | | return DN.rootDN(); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public String rightToString() { |
| | | if(hasRights(ACI_SEARCH)) |
| | | { |
| | | return "search"; |
| | | } |
| | | else if(hasRights(ACI_COMPARE)) |
| | | { |
| | | return "compare"; |
| | | } |
| | | else if(hasRights(ACI_READ)) |
| | | { |
| | | return "read"; |
| | | } |
| | | else if(hasRights(ACI_DELETE)) |
| | | { |
| | | return "delete"; |
| | | } |
| | | else if(hasRights(ACI_ADD)) |
| | | { |
| | | return "add"; |
| | | } |
| | | else if(hasRights(ACI_WRITE)) |
| | | { |
| | | return "write"; |
| | | } |
| | | else if(hasRights(ACI_PROXY)) |
| | | { |
| | | return "proxy"; |
| | | } |
| | | else if(hasRights(ACI_IMPORT)) |
| | | { |
| | | return "import"; |
| | | } |
| | | else if(hasRights(ACI_EXPORT)) |
| | | { |
| | | return "export"; |
| | | } |
| | | else if(hasRights(ACI_WRITE) && |
| | | hasRights(ACI_SELF)) |
| | | { |
| | | return "selfwrite"; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | |
| | | if(v == ACI_FOUND_USER_ATTR_RULE) { |
| | | evalAllAttributes |= ACI_FOUND_USER_ATTR_RULE; |
| | | evalAllAttributes &= ~ACI_USER_ATTR_STAR_MATCHED; |
| | | } else |
| | | } |
| | | else |
| | | { |
| | | evalAllAttributes |= ACI_USER_ATTR_STAR_MATCHED; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | if(v == ACI_FOUND_OP_ATTR_RULE) { |
| | | evalAllAttributes |= ACI_FOUND_OP_ATTR_RULE; |
| | | evalAllAttributes &= ~ACI_OP_ATTR_PLUS_MATCHED; |
| | | } else |
| | | } |
| | | else |
| | | { |
| | | evalAllAttributes |= ACI_OP_ATTR_PLUS_MATCHED; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | @Override |
| | | public void clearEvalAttributes(int v) { |
| | | if(v == 0) |
| | | { |
| | | evalAllAttributes=0; |
| | | } |
| | | else |
| | | { |
| | | evalAllAttributes &= ~v; |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | AttributeType attrType = DirectoryServer.getAttributeType(a |
| | | .toLowerCase()); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(a.toLowerCase()); |
| | | } |
| | | nonRightsAttrs.add(attrType); |
| | | } |
| | | } |
| | |
| | | final Entry retEntry, List<AttributeType> attrList, |
| | | boolean skipCheck, boolean specificAttr) |
| | | { |
| | | |
| | | // The attribute list might be null. |
| | | if (attrList == null) return; |
| | | if (attrList == null) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | for(AttributeType a : attrList) { |
| | | StringBuilder evalInfo=new StringBuilder(); |
| | |
| | | //in both the search and the specific attribute part of the control. |
| | | //Only try to add the attribute type if it already hasn't been added. |
| | | if(!retEntry.hasAttribute(attributeType)) |
| | | retEntry.addAttribute(attr,null); |
| | | { |
| | | retEntry.addAttribute(attr,null); |
| | | } |
| | | } |
| | | } |
| | | container.setCurrentAttributeValue(null); |
| | |
| | | //Check if read right check, if so do accessAllowedEntry. |
| | | if(container.hasRights(ACI_READ) && |
| | | container.getCurrentAttributeType() == null) |
| | | { |
| | | ret=handler.accessAllowedEntry(container); |
| | | } |
| | | else |
| | | { |
| | | ret=handler.accessAllowed(container); |
| | | if(ret) |
| | | resString.append(rightStr).append(":1"); |
| | | else |
| | | resString.append(rightStr).append(":0"); |
| | | } |
| | | |
| | | resString.append(rightStr).append(ret ? ":1" : ":0"); |
| | | } |
| | | return resString.toString(); |
| | | } |
| | |
| | | // The attribute type might have already been added, probably |
| | | // not but it is possible. |
| | | if(!retEntry.hasAttribute(attributeType)) |
| | | retEntry.addAttribute(attr,null); |
| | | { |
| | | retEntry.addAttribute(attr,null); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | //targattrfilters ACI name only if a deny targattrfilters ACI |
| | | //was not seen. It could remove the allow. |
| | | if(!evalCtx.hasTargAttrFiltersMatchOp(ACL_TARGATTR_DENY_MATCH)) |
| | | { |
| | | evalCtx.setTargAttrFiltersAciName(null); |
| | | } |
| | | } else { |
| | | //The evaluation returned false. If the reason was an |
| | | //explicit deny evaluation by a non-targattrfilters ACI, clear |
| | |
| | | //ACI that might have granted access the deny stands, else there is |
| | | //a targattrfilters ACI that might grant access. |
| | | if(evalCtx.getEvalReason() == EnumEvalReason.EVALUATED_DENY_ACI) |
| | | { |
| | | evalCtx.setTargAttrFiltersAciName(null); |
| | | } |
| | | else if(!evalCtx.hasTargAttrFiltersMatchOp(ACL_TARGATTR_ALLOW_MATCH)) |
| | | { |
| | | evalCtx.setTargAttrFiltersAciName(null); |
| | | } |
| | | } |
| | | } |
| | | //Actually build the string. |
| | | String user=anonymous; |
| | | if(!evalCtx.getClientDN().isRootDN()) |
| | | { |
| | | user=evalCtx.getClientDN().toString(); |
| | | } |
| | | String right=evalCtx.rightToString(); |
| | | AttributeType aType=evalCtx.getCurrentAttributeType(); |
| | | String attrStr="NULL"; |
| | | if(aType != null) |
| | | { |
| | | attrStr=aType.getPrimaryName(); |
| | | } |
| | | if(evalCtx.getTargAttrFiltersAciName() != null) |
| | | { |
| | | decideAci.append(", access depends on attr value"); |
| | | } |
| | | return String.format(summaryFormatStr, srcStr, accessStatus, |
| | | right,evalCtx.getResourceDN().toString(),attrStr, user, |
| | | accessReason, decideAci.toString()); |
| | |
| | | private static String getEvalReason(EnumEvalReason evalReason) |
| | | { |
| | | if (evalReason == EnumEvalReason.EVALUATED_ALLOW_ACI) |
| | | { |
| | | return EVALUATED_ALLOW; |
| | | } |
| | | else if (evalReason == EnumEvalReason.EVALUATED_DENY_ACI) |
| | | { |
| | | return EVALUATED_DENY; |
| | | } |
| | | else if (evalReason == EnumEvalReason.NO_ALLOW_ACIS) |
| | | { |
| | | return NO_ALLOWS; |
| | | } |
| | | else if (evalReason == EnumEvalReason.NO_MATCHED_ALLOWS_ACIS) |
| | | { |
| | | return NO_ALLOWS_MATCHED; |
| | | } |
| | | else if (evalReason == EnumEvalReason.SKIP_ACI) |
| | | { |
| | | return SKIP_ACI; |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | |
| | | { |
| | | int validAcis = aciList.addAci(internalSearch.getSearchEntries(), failedACIMsgs); |
| | | if (!failedACIMsgs.isEmpty()) |
| | | { |
| | | logMsgsSetLockDownMode(failedACIMsgs); |
| | | } |
| | | logger.debug(INFO_ACI_ADD_LIST_ACIS, validAcis, baseDN); |
| | | } |
| | | } |
| | |
| | | logger.warn(WARN_ACI_SERVER_DECODE_FAILED, msg); |
| | | } |
| | | if (!inLockDownMode) |
| | | { |
| | | setLockDownMode(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | private static SearchScope createScope(String expression) |
| | | throws AciException { |
| | | if(expression.equalsIgnoreCase("base")) |
| | | return SearchScope.BASE_OBJECT; |
| | | { |
| | | return SearchScope.BASE_OBJECT; |
| | | } |
| | | else if(expression.equalsIgnoreCase("onelevel")) |
| | | return SearchScope.SINGLE_LEVEL; |
| | | { |
| | | return SearchScope.SINGLE_LEVEL; |
| | | } |
| | | else if(expression.equalsIgnoreCase("subtree")) |
| | | return SearchScope.WHOLE_SUBTREE; |
| | | { |
| | | return SearchScope.WHOLE_SUBTREE; |
| | | } |
| | | else if(expression.equalsIgnoreCase("subordinate")) |
| | | return SearchScope.SUBORDINATES; |
| | | { |
| | | return SearchScope.SUBORDINATES; |
| | | } |
| | | else { |
| | | LocalizableMessage message = |
| | | WARN_ACI_SYNTAX_INVALID_TARGETSCOPE_EXPRESSION.get(expression); |
| | |
| | | targAttrFilters.hasMask(TARGATTRFILTERS_ADD)) || |
| | | (matchCtx.hasRights(ACI_DELETE) && |
| | | targAttrFilters.hasMask(TARGATTRFILTERS_DELETE))) |
| | | ret=targAttrFilters.isApplicableAddDel(matchCtx); |
| | | { |
| | | ret=targAttrFilters.isApplicableAddDel(matchCtx); |
| | | } |
| | | else if((matchCtx.hasRights(ACI_WRITE_ADD) && |
| | | targAttrFilters.hasMask(TARGATTRFILTERS_ADD)) || |
| | | (matchCtx.hasRights(ACI_WRITE_DELETE) && |
| | | targAttrFilters.hasMask(TARGATTRFILTERS_DELETE))) |
| | | ret=targAttrFilters.isApplicableMod(matchCtx, aci); |
| | | { |
| | | ret=targAttrFilters.isApplicableMod(matchCtx, aci); |
| | | } |
| | | } |
| | | return ret; |
| | | } |
| | |
| | | } |
| | | if (isFirstAttr && targetAttr == null |
| | | && aci.getTargets().getTargAttrFilters() == null) |
| | | targetMatchCtx.setEntryTestRule(true); |
| | | { |
| | | targetMatchCtx.setEntryTestRule(true); |
| | | } |
| | | } |
| | | return ret; |
| | | } |
| | |
| | | (!targets.getTarget().isPattern())) { |
| | | EnumTargetOperator op=targets.getTarget().getOperator(); |
| | | if(op != EnumTargetOperator.NOT_EQUALITY) |
| | | targetDN=targets.getTarget().getDN(); |
| | | { |
| | | targetDN=targets.getTarget().getDN(); |
| | | } |
| | | } |
| | | //Check if the scope is correct. |
| | | switch(targets.getTargetScope().asEnum()) { |
| | | case BASE_OBJECT: |
| | | if(!targetDN.equals(entryDN)) |
| | | return false; |
| | | { |
| | | return false; |
| | | } |
| | | break; |
| | | case SINGLE_LEVEL: |
| | | /* |
| | |
| | | * Non-standard interpretation of onelevel in ACI targetScope. |
| | | */ |
| | | if(!targetDN.equals(entryDN.parent())) |
| | | return false; |
| | | { |
| | | return false; |
| | | } |
| | | break; |
| | | case WHOLE_SUBTREE: |
| | | if(!entryDN.isDescendantOf(targetDN)) |
| | | return false; |
| | | { |
| | | return false; |
| | | } |
| | | break; |
| | | case SUBORDINATES: |
| | | if ((entryDN.size() <= targetDN.size()) || |
| | |
| | | if(op == EnumTargetOperator.NOT_EQUALITY) { |
| | | DN tmpDN=targets.getTarget().getDN(); |
| | | if(entryDN.isDescendantOf(tmpDN)) |
| | | return false; |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | /* |
| | |
| | | final boolean ret = targets.getTarget().matchesPattern(entryDN); |
| | | EnumTargetOperator op=targets.getTarget().getOperator(); |
| | | if(op == EnumTargetOperator.NOT_EQUALITY) |
| | | return !ret; |
| | | { |
| | | return !ret; |
| | | } |
| | | return ret; |
| | | } |
| | | return true; |
| | |
| | | */ |
| | | if(ret && targetAttr.isAllUserAttributes() && |
| | | !ctx.hasEvalUserAttributes()) |
| | | { |
| | | ctx.setEvalUserAttributes(ACI_USER_ATTR_STAR_MATCHED); |
| | | } |
| | | else |
| | | { |
| | | ctx.setEvalUserAttributes(ACI_FOUND_USER_ATTR_RULE); |
| | | } |
| | | |
| | | if(ret && targetAttr.isAllOpAttributes() && |
| | | !ctx.hasEvalOpAttributes()) |
| | | { |
| | | ctx.setEvalOpAttributes(ACI_OP_ATTR_PLUS_MATCHED); |
| | | } |
| | | else |
| | | { |
| | | ctx.setEvalOpAttributes(ACI_FOUND_OP_ATTR_RULE); |
| | | } |
| | | } |
| | | } |
| | |
| | | boolean evalHostName(String[] remoteHostName, String[] pat) { |
| | | boolean wildCard=pat[0].equals("*"); |
| | | //Check if there is a single wild-card. |
| | | if(pat.length == 1 && wildCard) |
| | | if(pat.length == 1 && wildCard) { |
| | | return true; |
| | | } |
| | | int remoteHnIndex=remoteHostName.length-pat.length; |
| | | if(remoteHnIndex < 0) |
| | | if(remoteHnIndex < 0) { |
| | | return false; |
| | | } |
| | | int patternIndex=0; |
| | | if(!wildCard) |
| | | remoteHnIndex=0; |
| | | else { |
| | | if(!wildCard) { |
| | | remoteHnIndex=0; |
| | | } else { |
| | | patternIndex=1; |
| | | remoteHnIndex++; |
| | | } |
| | | for(int i=remoteHnIndex ;i<remoteHostName.length;i++) |
| | | if(!pat[patternIndex++].equalsIgnoreCase(remoteHostName[i])) |
| | | return false; |
| | | for(int i=remoteHnIndex ;i<remoteHostName.length;i++) { |
| | | if(!pat[patternIndex++].equalsIgnoreCase(remoteHostName[i])) { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | |
| | | EnumDayOfWeek dayofweek |
| | | = EnumDayOfWeek.getDayOfWeek(calendar.get(Calendar.DAY_OF_WEEK)); |
| | | if(days.contains(dayofweek)) |
| | | matched=EnumEvalResult.TRUE; |
| | | { |
| | | matched=EnumEvalResult.TRUE; |
| | | } |
| | | return matched.getRet(type, false); |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013 ForgeRock AS |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.authorization.dseecompat; |
| | | |
| | |
| | | // ALL already existed when they got added. For compatibility reasons |
| | | // with existing deployments, they were not included in ALL. |
| | | if (hasRights(rightsMask, ACI_EXPORT)) |
| | | results.add(EXPORT); |
| | | { |
| | | results.add(EXPORT); |
| | | } |
| | | if (hasRights(rightsMask, ACI_IMPORT)) |
| | | results.add(IMPORT); |
| | | { |
| | | results.add(IMPORT); |
| | | } |
| | | if (hasRights(rightsMask, ACI_PROXY)) |
| | | results.add(PROXY); |
| | | { |
| | | results.add(PROXY); |
| | | } |
| | | |
| | | if (hasRights(rightsMask, ACI_ALL)) { |
| | | results.add(ALL); |
| | |
| | | } |
| | | // the remaining rights are already included in ALL |
| | | if (hasRights(rightsMask, ACI_READ)) |
| | | results.add(READ); |
| | | { |
| | | results.add(READ); |
| | | } |
| | | if (hasRights(rightsMask, ACI_WRITE)) |
| | | results.add(WRITE); |
| | | { |
| | | results.add(WRITE); |
| | | } |
| | | if (hasRights(rightsMask, ACI_ADD)) |
| | | results.add(ADD); |
| | | { |
| | | results.add(ADD); |
| | | } |
| | | if (hasRights(rightsMask, ACI_DELETE)) |
| | | results.add(DELETE); |
| | | { |
| | | results.add(DELETE); |
| | | } |
| | | if (hasRights(rightsMask, ACI_SEARCH)) |
| | | results.add(SEARCH); |
| | | { |
| | | results.add(SEARCH); |
| | | } |
| | | if (hasRights(rightsMask, ACI_COMPARE)) |
| | | results.add(COMPARE); |
| | | if (hasRights(rightsMask, ACI_SELF)) // included in WRITE |
| | | results.add(SELFWRITE); |
| | | { |
| | | results.add(COMPARE); |
| | | } |
| | | if (hasRights(rightsMask, ACI_SELF)) |
| | | { |
| | | results.add(SELFWRITE); |
| | | } |
| | | return results; |
| | | } |
| | | |
| | |
| | | */ |
| | | public boolean isApplicable(AciTargetMatchContext matchCtx) { |
| | | if(matchCtx.getExtOpOID() == null) |
| | | { |
| | | return false; |
| | | } |
| | | boolean ret = false; |
| | | for(String oid : extOpOIDs) |
| | | { |
| | | if(oid.equals("*") || matchCtx.getExtOpOID().equals(oid)) { |
| | | ret=true; |
| | | break; |
| | | } |
| | | if(op.equals(EnumTargetOperator.NOT_EQUALITY)) |
| | | ret = !ret; |
| | | } |
| | | if(op.equals(EnumTargetOperator.NOT_EQUALITY)) |
| | | { |
| | | ret = !ret; |
| | | } |
| | | return ret; |
| | | } |
| | | } |
| | |
| | | numLevels=1; |
| | | levels[0]=0; |
| | | } |
| | | } else parse(pattern); |
| | | } else { |
| | | parse(pattern); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | IPType ipType=IPType.IPv4; |
| | | byte[] prefixBytes; |
| | | String addrStr; |
| | | if(expr.indexOf(':') != -1) |
| | | if(expr.indexOf(':') != -1) { |
| | | ipType = IPType.IPv6; |
| | | } |
| | | if(expr.indexOf('/') != -1) { |
| | | String prefixStr=null; |
| | | String[] s = expr.split("[/]", -1); |
| | | if(s.length == 2) prefixStr=s[1]; |
| | | if(s.length == 2) { |
| | | prefixStr=s[1]; |
| | | } |
| | | int prefix = getPrefixValue(ipType, s.length, expr, prefixStr); |
| | | prefixBytes=getPrefixBytes(prefix, ipType); |
| | | addrStr=s[0]; |
| | | } else if(expr.indexOf('+') != -1) { |
| | | String netMaskStr=null; |
| | | String[] s = expr.split("[+]", -1); |
| | | if(s.length == 2) |
| | | if(s.length == 2) { |
| | | netMaskStr=s[1]; |
| | | } |
| | | prefixBytes=getNetmaskBytes(netMaskStr, s.length, expr); |
| | | addrStr=s[0]; |
| | | } else { |
| | |
| | | prefixBytes=getPrefixBytes(prefix, ipType); |
| | | addrStr=expr; |
| | | } |
| | | //Set the bit set size fo IN6ADDRSZ even though only 4 positions are |
| | | //used. |
| | | // Set the bit set size fo IN6ADDRSZ even though only 4 positions are used. |
| | | BitSet wildCardBitSet = new BitSet(IN6ADDRSZ); |
| | | byte[] addrBytes; |
| | | if(ipType == IPType.IPv4) |
| | | addrBytes = procIPv4Addr(addrStr, wildCardBitSet, expr); |
| | | else { |
| | | if(ipType == IPType.IPv4) { |
| | | addrBytes = procIPv4Addr(addrStr, wildCardBitSet, expr); |
| | | } else { |
| | | addrBytes=procIPv6Addr(addrStr, expr); |
| | | //The IPv6 address processed above might be a IPv4-compatible |
| | | //address, in which case only 4 bytes will be returned in the |
| | |
| | | WARN_ACI_SYNTAX_INVALID_PREFIX_FORMAT.get(expr); |
| | | throw new AciException(message); |
| | | } |
| | | if(prefixStr != null) |
| | | if(prefixStr != null) { |
| | | prefix = Integer.parseInt(prefixStr); |
| | | } |
| | | //Must be between 0 to maxprefix. |
| | | if((prefix < 0) || (prefix > maxPrefix)) { |
| | | LocalizableMessage message = |
| | |
| | | private static byte[] getPrefixBytes(int prefix, IPType ipType) { |
| | | int i; |
| | | int maxSize=IN4ADDRSZ; |
| | | if(ipType==IPType.IPv6) |
| | | if(ipType==IPType.IPv6) { |
| | | maxSize= IN6ADDRSZ; |
| | | } |
| | | byte[] prefixBytes=new byte[maxSize]; |
| | | for(i=0;prefix > 8 ; i++) { |
| | | prefixBytes[i] = (byte) 0xff; |
| | |
| | | * Process the specified netmask string. Only pertains to IPv4 address |
| | | * expressions. |
| | | * |
| | | * @param netmaskStr String represntation of the netmask parsed from the |
| | | * @param netmaskStr String representation of the netmask parsed from the |
| | | * address expression. |
| | | * @param numParts The number of parts in the IP address expression. |
| | | * 1 if there isn't a netmask, and 2 if there is. Anything |
| | |
| | | } |
| | | for(int i=0; i < IN4ADDRSZ; i++) { |
| | | String quad=s[i].trim(); |
| | | if(quad.equals("*")) |
| | | if(quad.equals("*")) { |
| | | wildCardBitSet.set(i) ; |
| | | } |
| | | else { |
| | | long val=Integer.parseInt(quad); |
| | | //must be between 0-255 |
| | |
| | | ipType=IPType.IPv6; |
| | | Inet6Address addr6 = (Inet6Address) remoteAddr; |
| | | addressBytes= addr6.getAddress(); |
| | | if(addr6.isIPv4CompatibleAddress()) |
| | | if(addr6.isIPv4CompatibleAddress()) { |
| | | ipType=IPType.IPv4; |
| | | } |
| | | } |
| | | if(ipType != this.ipType) |
| | | if(ipType != this.ipType) { |
| | | return EnumEvalResult.FALSE; |
| | | if(matchAddress(addressBytes)) |
| | | } |
| | | if(matchAddress(addressBytes)) { |
| | | matched=EnumEvalResult.TRUE; |
| | | } |
| | | return matched; |
| | | } |
| | | |
| | |
| | | * parsed from the IP bind rule expression. |
| | | */ |
| | | private boolean matchAddress(byte[] addrBytes) { |
| | | if(wildCardBitSet.cardinality() == IN4ADDRSZ) |
| | | if(wildCardBitSet.cardinality() == IN4ADDRSZ) { |
| | | return true; |
| | | } |
| | | for(int i=0;i <rulePrefixBytes.length; i++) { |
| | | if (!wildCardBitSet.get(i) |
| | | && (ruleAddrBytes[i] & rulePrefixBytes[i]) != |
| | | (addrBytes[i] & rulePrefixBytes[i])) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | |
| | | separatorPattern.split(rights.replaceAll("\\s", "")); |
| | | for (String r : rightsStr) { |
| | | EnumRight right = EnumRight.decode(r); |
| | | if (right != null) |
| | | this.rights|= EnumRight.getMask(right); |
| | | else { |
| | | if (right != null) { |
| | | this.rights|= EnumRight.getMask(right); |
| | | } else { |
| | | LocalizableMessage message = |
| | | WARN_ACI_SYNTAX_INVALID_RIGHTS_KEYWORD.get(rights); |
| | | throw new AciException(message); |
| | |
| | | * context evaluation. |
| | | */ |
| | | public EnumEvalResult evaluate(AciEvalContext evalCtx) { |
| | | EnumEvalResult matched=EnumEvalResult.FALSE; |
| | | int currentSSF = evalCtx.getCurrentSSF(); |
| | | switch (type) { |
| | | case EQUAL_BINDRULE_TYPE: |
| | | case NOT_EQUAL_BINDRULE_TYPE: |
| | | if (currentSSF == ssf) |
| | | matched=EnumEvalResult.TRUE; |
| | | break; |
| | | |
| | | case LESS_OR_EQUAL_BINDRULE_TYPE: |
| | | if (currentSSF <= ssf) |
| | | matched=EnumEvalResult.TRUE; |
| | | break; |
| | | |
| | | case LESS_BINDRULE_TYPE: |
| | | if (currentSSF < ssf) |
| | | matched=EnumEvalResult.TRUE; |
| | | break; |
| | | |
| | | case GREATER_OR_EQUAL_BINDRULE_TYPE: |
| | | if (currentSSF >= ssf) |
| | | matched=EnumEvalResult.TRUE; |
| | | break; |
| | | |
| | | case GREATER_BINDRULE_TYPE: |
| | | if (currentSSF > ssf) |
| | | matched=EnumEvalResult.TRUE; |
| | | } |
| | | EnumEvalResult matched = getMatched(currentSSF); |
| | | return matched.getRet(type, false); |
| | | } |
| | | |
| | | private EnumEvalResult getMatched(int currentSSF) { |
| | | switch (type) { |
| | | case EQUAL_BINDRULE_TYPE: |
| | | case NOT_EQUAL_BINDRULE_TYPE: |
| | | if (currentSSF == ssf) { |
| | | return EnumEvalResult.TRUE; |
| | | } |
| | | break; |
| | | |
| | | case LESS_OR_EQUAL_BINDRULE_TYPE: |
| | | if (currentSSF <= ssf) { |
| | | return EnumEvalResult.TRUE; |
| | | } |
| | | break; |
| | | |
| | | case LESS_BINDRULE_TYPE: |
| | | if (currentSSF < ssf) { |
| | | return EnumEvalResult.TRUE; |
| | | } |
| | | break; |
| | | |
| | | case GREATER_OR_EQUAL_BINDRULE_TYPE: |
| | | if (currentSSF >= ssf) { |
| | | return EnumEvalResult.TRUE; |
| | | } |
| | | break; |
| | | |
| | | case GREATER_BINDRULE_TYPE: |
| | | if (currentSSF > ssf) { |
| | | return EnumEvalResult.TRUE; |
| | | } |
| | | } |
| | | return EnumEvalResult.FALSE; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() |
| | |
| | | //handling. |
| | | int semicolon = attributeName.indexOf(';'); |
| | | if (semicolon != -1) |
| | | attributeName=attributeName.substring(0, semicolon); |
| | | { |
| | | attributeName=attributeName.substring(0, semicolon); |
| | | } |
| | | String filterString=matcher.group(filterPos); |
| | | AttributeType attrType = DirectoryServer.getAttributeType(attributeName); |
| | | if (attrType == null) { |
| | |
| | | private static String getReverseOp(String op) |
| | | { |
| | | if (getMask(op) == TARGATTRFILTERS_DELETE) |
| | | { |
| | | return "add"; |
| | | } |
| | | return "del"; |
| | | } |
| | | |
| | |
| | | */ |
| | | private static int getMask(String op) { |
| | | if(op.equals("add")) |
| | | return TARGATTRFILTERS_ADD; |
| | | { |
| | | return TARGATTRFILTERS_ADD; |
| | | } |
| | | return TARGATTRFILTERS_DELETE; |
| | | } |
| | | |
| | |
| | | //context's rights and the mask. |
| | | if((matchCtx.hasRights(ACI_WRITE_ADD) || matchCtx.hasRights(ACI_ADD)) && |
| | | hasMask(TARGATTRFILTERS_ADD)) |
| | | mask=TARGATTRFILTERS_ADD; |
| | | { |
| | | mask=TARGATTRFILTERS_ADD; |
| | | } |
| | | else if((matchCtx.hasRights(ACI_WRITE_DELETE) || |
| | | matchCtx.hasRights(ACI_DELETE)) && |
| | | hasMask(TARGATTRFILTERS_DELETE)) |
| | | mask=TARGATTRFILTERS_DELETE; |
| | | { |
| | | mask=TARGATTRFILTERS_DELETE; |
| | | } |
| | | |
| | | //Check the first list first, it always has to be there. If it doesn't |
| | | //match then check the second if it exists. |
| | | if(firstFilterList.hasMask(mask)) |
| | | return firstFilterList; |
| | | { |
| | | return firstFilterList; |
| | | } |
| | | else if((secondFilterList != null) && |
| | | secondFilterList.hasMask(mask)) |
| | | return secondFilterList; |
| | | { |
| | | return secondFilterList; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | |
| | | //If the list is empty return true and go on to the targattr check |
| | | //in AciTargets.isApplicable(). |
| | | if(attrFilterList == null) |
| | | return true; |
| | | { |
| | | return true; |
| | | } |
| | | Map<AttributeType, SearchFilter> filterList = |
| | | attrFilterList.getAttributeTypeFilterList(); |
| | | boolean attrMatched=true; |
| | |
| | | boolean result) |
| | | { |
| | | if (EnumTargetOperator.NOT_EQUALITY.equals(op)) |
| | | { |
| | | return !result; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | |
| | | TargAttrFilterList attrFilterList=getTargAttrFilterList(matchCtx); |
| | | //List didn't match current operation return true. |
| | | if(attrFilterList == null) |
| | | return true; |
| | | { |
| | | return true; |
| | | } |
| | | |
| | | Map<AttributeType, SearchFilter> filterList = |
| | | attrFilterList.getAttributeTypeFilterList(); |
| | |
| | | String attribute = attr.toLowerCase(); |
| | | if(attribute.equals("*")) { |
| | | if(!allUserAttributes) |
| | | allUserAttributes=true; |
| | | { |
| | | allUserAttributes=true; |
| | | } |
| | | else { |
| | | LocalizableMessage message = |
| | | WARN_ACI_TARGETATTR_INVALID_ATTR_TOKEN.get(attrStr); |
| | |
| | | } |
| | | } else if(attribute.equals("+")) { |
| | | if(!allOpAttributes) |
| | | allOpAttributes=true; |
| | | { |
| | | allOpAttributes=true; |
| | | } |
| | | else { |
| | | LocalizableMessage message = |
| | | WARN_ACI_TARGETATTR_INVALID_ATTR_TOKEN.get(attrStr); |
| | |
| | | attrType = DirectoryServer.getDefaultAttributeType(attribute); |
| | | } |
| | | if(attrType.isOperational()) |
| | | opAttributes.add(attrType); |
| | | { |
| | | opAttributes.add(attrType); |
| | | } |
| | | else |
| | | attributes.add(attrType); |
| | | { |
| | | attributes.add(attrType); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | public boolean isApplicable(AciTargetMatchContext matchCtx) { |
| | | if(matchCtx.getControlOID() == null) |
| | | { |
| | | return false; |
| | | } |
| | | boolean ret = false; |
| | | for(String oid : controlOIDS) |
| | | { |
| | | if(oid.equals("*") || matchCtx.getControlOID().equals(oid)) { |
| | | ret=true; |
| | | break; |
| | | } |
| | | if(op.equals(EnumTargetOperator.NOT_EQUALITY)) |
| | | ret = !ret; |
| | | } |
| | | if(op.equals(EnumTargetOperator.NOT_EQUALITY)) |
| | | { |
| | | ret = !ret; |
| | | } |
| | | return ret; |
| | | } |
| | | } |
| | |
| | | boolean ret; |
| | | ret=matchesFilter(matchCtx.getResourceEntry()); |
| | | if(op.equals(EnumTargetOperator.NOT_EQUALITY)) |
| | | ret = !ret; |
| | | { |
| | | ret = !ret; |
| | | } |
| | | return ret; |
| | | } |
| | | |
| | |
| | | //Handle anonymous checks here |
| | | if(isAnonUser) { |
| | | if(dnTypeURL.getUserDNType() == EnumUserDNType.ANYONE) |
| | | matched = EnumEvalResult.TRUE; |
| | | } else |
| | | matched=evalNonAnonymous(evalCtx, dnTypeURL); |
| | | { |
| | | matched = EnumEvalResult.TRUE; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | matched=evalNonAnonymous(evalCtx, dnTypeURL); |
| | | } |
| | | } |
| | | return matched.getRet(type, undefined); |
| | | } |
| | |
| | | } |
| | | case SELF: |
| | | { |
| | | if (clientDN.equals(resDN)) matched = EnumEvalResult.TRUE; |
| | | if (clientDN.equals(resDN)) |
| | | { |
| | | matched = EnumEvalResult.TRUE; |
| | | } |
| | | break; |
| | | } |
| | | case PARENT: |
| | |
| | | DN parentDN = resDN.parent(); |
| | | if ((parentDN != null) && |
| | | (parentDN.equals(clientDN))) |
| | | matched = EnumEvalResult.TRUE; |
| | | { |
| | | matched = EnumEvalResult.TRUE; |
| | | } |
| | | break; |
| | | } |
| | | case ALL: |
| | |
| | | { |
| | | DN dn = url.getBaseDN(); |
| | | if (clientDN.equals(dn)) |
| | | matched = EnumEvalResult.TRUE; |
| | | { |
| | | matched = EnumEvalResult.TRUE; |
| | | } |
| | | else { |
| | | //This code handles the case where a root dn entry does |
| | | //not have bypass-acl privilege and the ACI bind rule |
| | |
| | | DN clientActualDN= |
| | | DirectoryServer.getActualRootBindDN(clientDN); |
| | | if(actualDN != null) |
| | | dn=actualDN; |
| | | { |
| | | dn=actualDN; |
| | | } |
| | | if(clientActualDN != null) |
| | | clientDN=clientActualDN; |
| | | { |
| | | clientDN=clientActualDN; |
| | | } |
| | | if(clientDN.equals(dn)) |
| | | matched=EnumEvalResult.TRUE; |
| | | { |
| | | matched=EnumEvalResult.TRUE; |
| | | } |
| | | } |
| | | } catch (DirectoryException ex) { |
| | | //TODO add message |
| | |
| | | SearchScope scope=url.getScope(); |
| | | if(scope == SearchScope.WHOLE_SUBTREE) { |
| | | if(!evalCtx.getClientDN().isDescendantOf(urlDN)) |
| | | return EnumEvalResult.FALSE; |
| | | { |
| | | return EnumEvalResult.FALSE; |
| | | } |
| | | } else if(scope == SearchScope.SINGLE_LEVEL) { |
| | | DN parent=evalCtx.getClientDN().parent(); |
| | | if((parent != null) && !parent.equals(urlDN)) |
| | | return EnumEvalResult.FALSE; |
| | | { |
| | | return EnumEvalResult.FALSE; |
| | | } |
| | | } else if(scope == SearchScope.SUBORDINATES) { |
| | | DN userDN = evalCtx.getClientDN(); |
| | | if ((userDN.size() <= urlDN.size()) || |
| | |
| | | } |
| | | } else { |
| | | if(!evalCtx.getClientDN().equals(urlDN)) |
| | | return EnumEvalResult.FALSE; |
| | | { |
| | | return EnumEvalResult.FALSE; |
| | | } |
| | | } |
| | | try { |
| | | if(filter.matchesEntry(evalCtx.getClientEntry())) |
| | | ret=EnumEvalResult.TRUE; |
| | | { |
| | | ret=EnumEvalResult.TRUE; |
| | | } |
| | | } catch (DirectoryException ex) { |
| | | return EnumEvalResult.FALSE; |
| | | } |
| | |
| | | // class with null authzDN and attribute list, else try to |
| | | // decode the value. |
| | | if (value == null) |
| | | { |
| | | return new GetEffectiveRightsRequestControl(isCritical, (DN)null, |
| | | (List<AttributeType>)null); |
| | | } |
| | | else |
| | | { |
| | | ASN1Reader reader = ASN1.getReader(value); |
| | |
| | | String lowerAuthzIDString = authzIDString.toLowerCase(); |
| | | //Make sure authzId starts with "dn:" and is a valid DN. |
| | | if (lowerAuthzIDString.startsWith("dn:")) |
| | | { |
| | | authzDN = DN.valueOf(authzIDString.substring(3)); |
| | | } |
| | | else { |
| | | LocalizableMessage message = INFO_GETEFFECTIVERIGHTS_INVALID_AUTHZID.get( |
| | | lowerAuthzIDString); |
| | |
| | | |
| | | this.size = size; |
| | | if(cookie == null) |
| | | this.cookie=ByteString.empty(); |
| | | { |
| | | this.cookie=ByteString.empty(); |
| | | } |
| | | else |
| | | this.cookie = cookie; |
| | | { |
| | | this.cookie = cookie; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | |
| | | return ByteString.valueOf(buffer); |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | |
| | | return ByteString.valueOf(buffer); |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | |
| | | return ByteString.wrap(digestBytes); |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | return ByteString.valueOf(output); |
| | | } |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | return ByteString.valueOf(output); |
| | | } |
| | |
| | | finally |
| | | { |
| | | if (plaintextPasswordBytes != null) |
| | | { |
| | | Arrays.fill(plaintextPasswordBytes, (byte) 0); |
| | | } |
| | | } |
| | | |
| | | return userPWDigestBytes.equals(storedPassword); |
| | |
| | | finally |
| | | { |
| | | if (plaintextPasswordBytes != null) |
| | | { |
| | | Arrays.fill(plaintextPasswordBytes, (byte) 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | finally |
| | | { |
| | | if (plaintextPasswordBytes != null) |
| | | { |
| | | Arrays.fill(plaintextPasswordBytes, (byte) 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | private String |
| | | getQOP(DigestMD5SASLMechanismHandlerCfg configuration) { |
| | | QualityOfProtection QOP = configuration.getQualityOfProtection(); |
| | | if(QOP.equals(QualityOfProtection.CONFIDENTIALITY)) |
| | | return "auth-conf"; |
| | | else if(QOP.equals(QualityOfProtection.INTEGRITY)) |
| | | return "auth-int"; |
| | | else |
| | | return "auth"; |
| | | if(QOP.equals(QualityOfProtection.CONFIDENTIALITY)) { |
| | | return "auth-conf"; |
| | | } else if(QOP.equals(QualityOfProtection.INTEGRITY)) { |
| | | return "auth-int"; |
| | | } else { |
| | | return "auth"; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | message.append("major code (").append(gex.getMajor()).append(") ") |
| | | .append(gex.getMajorString()); |
| | | if(gex.getMinor() != 0) |
| | | { |
| | | message.append(", minor code (").append(gex.getMinor()).append(") ") |
| | | .append(gex.getMinorString()); |
| | | } |
| | | return message.toMessage(); |
| | | } |
| | | |
| | |
| | | private String getQOP(GSSAPISASLMechanismHandlerCfg configuration) |
| | | { |
| | | QualityOfProtection QOP = configuration.getQualityOfProtection(); |
| | | if (QOP.equals(QualityOfProtection.CONFIDENTIALITY)) |
| | | if (QOP.equals(QualityOfProtection.CONFIDENTIALITY)) { |
| | | return "auth-conf"; |
| | | else if (QOP.equals(QualityOfProtection.INTEGRITY)) |
| | | } else if (QOP.equals(QualityOfProtection.INTEGRITY)) { |
| | | return "auth-int"; |
| | | else |
| | | } else { |
| | | return "auth"; |
| | | } |
| | | } |
| | | } |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | finally |
| | | { |
| | | if (plaintextPasswordBytes != null) |
| | | { |
| | | Arrays.fill(plaintextPasswordBytes, (byte) 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | |
| | | return ByteString.valueOf(buffer); |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | finally |
| | | { |
| | | if (plaintextPasswordBytes != null) |
| | | { |
| | | Arrays.fill(plaintextPasswordBytes, (byte) 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | finally |
| | | { |
| | | if (plaintextBytes != null) |
| | | { |
| | | Arrays.fill(plaintextBytes, (byte) 0); |
| | | } |
| | | } |
| | | |
| | | return ByteString.valueOf(buffer); |
| | |
| | | } |
| | | |
| | | // Shutdown the wrapped writer. |
| | | if (shutdownWrapped && writer != null) writer.shutdown(); |
| | | if (shutdownWrapped && writer != null) |
| | | { |
| | | writer.shutdown(); |
| | | } |
| | | |
| | | DirectoryServer.deregisterShutdownListener(this); |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS. |
| | | * Portions Copyright 2014-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.loggers; |
| | | |
| | |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | if (i > 0) |
| | | { |
| | | buffer.append(", "); |
| | | } |
| | | buffer.append(array[i]); |
| | | } |
| | | buffer.append(" ]"); |
| | |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | if (i > 0) |
| | | { |
| | | buffer.append(", "); |
| | | } |
| | | buffer.append(array[i]); |
| | | } |
| | | buffer.append(" ]"); |
| | |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | if (i > 0) |
| | | { |
| | | buffer.append(", "); |
| | | } |
| | | buffer.append(array[i]); |
| | | } |
| | | buffer.append(" ]"); |
| | |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | if (i > 0) |
| | | { |
| | | buffer.append(", "); |
| | | } |
| | | buffer.append(array[i]); |
| | | } |
| | | buffer.append(" ]"); |
| | |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | if (i > 0) |
| | | { |
| | | buffer.append(", "); |
| | | } |
| | | buffer.append(array[i]); |
| | | } |
| | | buffer.append(" ]"); |
| | |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | if (i > 0) |
| | | { |
| | | buffer.append(", "); |
| | | } |
| | | buffer.append(array[i]); |
| | | } |
| | | buffer.append(" ]"); |
| | |
| | | StringBuilder buffer= new StringBuilder(); |
| | | buffer.append("[ "); |
| | | for (int i= 0; i < array.length; i++) { |
| | | if (i > 0) buffer.append(", "); |
| | | if (i > 0) |
| | | { |
| | | buffer.append(", "); |
| | | } |
| | | buffer.append(array[i]); |
| | | } |
| | | buffer.append(" ]"); |
| | |
| | | boolean firstElement= true; |
| | | while (iter.hasNext()) { |
| | | Object lValue= iter.next(); |
| | | if (!firstElement) buffer.append(", "); |
| | | if (!firstElement) |
| | | { |
| | | buffer.append(", "); |
| | | } |
| | | buffer.append(decorateArg(lValue)); |
| | | firstElement= false; |
| | | } |
| | |
| | | boolean firstEntry= true; |
| | | while (iter.hasNext()) { |
| | | Map.Entry entry= (Map.Entry)iter.next(); |
| | | if (!firstEntry) buffer.append(", "); |
| | | if (!firstEntry) |
| | | { |
| | | buffer.append(", "); |
| | | } |
| | | buffer.append(decorateArg(entry.getKey())); |
| | | buffer.append("="); |
| | | buffer.append(decorateArg(entry.getValue())); |
| | |
| | | // Recurse if we have a cause |
| | | Throwable ourCause = t.getCause(); |
| | | if (ourCause != null) |
| | | { |
| | | formatStackTraceForCause(ourCause, maxDepth, buffer, trace); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Generate a String representation of the possibly filtered stack trace from |
| | | * the current position in executation. |
| | | * the current position in execution. |
| | | * |
| | | * @param stackTrace |
| | | * - The stack trace elements to format. |
| | |
| | | } |
| | | |
| | | // Shutdown the wrapped writer. |
| | | if (shutdownWrapped && writer != null) writer.shutdown(); |
| | | if (shutdownWrapped && writer != null) |
| | | { |
| | | writer.shutdown(); |
| | | } |
| | | |
| | | DirectoryServer.deregisterShutdownListener(this); |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.http; |
| | | |
| | |
| | | final String indent = "\n "; |
| | | final StringBuilder sb = new StringBuilder(); |
| | | sb.append("{"); |
| | | if (prettyPrint) sb.append(indent); |
| | | if (prettyPrint) { |
| | | sb.append(indent); |
| | | } |
| | | sb.append("\"code\": ").append(re.getCode()).append(","); |
| | | if (prettyPrint) sb.append(indent); |
| | | if (prettyPrint) { |
| | | sb.append(indent); |
| | | } |
| | | sb.append("\"message\": \"").append(re.getMessage()).append("\","); |
| | | if (prettyPrint) sb.append(indent); |
| | | if (prettyPrint) { |
| | | sb.append(indent); |
| | | } |
| | | sb.append("\"reason\": \"").append(re.getReason()).append("\""); |
| | | if (prettyPrint) sb.append("\n"); |
| | | if (prettyPrint) { |
| | | sb.append("\n"); |
| | | } |
| | | sb.append("}"); |
| | | return sb.toString(); |
| | | } |
| | |
| | | */ |
| | | public boolean equals(Object obj) |
| | | { |
| | | if (obj == null) |
| | | return false; |
| | | if (obj == this) |
| | | { |
| | | return true; |
| | | } |
| | | if (!(obj instanceof DirectoryRMIServerSocketFactory)) |
| | | { |
| | | return false; |
| | | } |
| | | DirectoryRMIServerSocketFactory that = |
| | | (DirectoryRMIServerSocketFactory) obj; |
| | | return (getClass().equals(that.getClass()) && checkParameters(that)); |
| | |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock, AS. |
| | | * Portions Copyright 2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | public static AttrHistorical createAttributeHistorical( |
| | | AttributeType type) |
| | | { |
| | | if (type.isSingleValue()) |
| | | return new AttrHistoricalSingle(); |
| | | else |
| | | return new AttrHistoricalMultiple(); |
| | | return type.isSingleValue() ? new AttrHistoricalSingle() : new AttrHistoricalMultiple(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @return the List of ValueInfo |
| | | */ |
| | | public abstract Map<AttrValueHistorical,AttrValueHistorical> |
| | | getValuesHistorical(); |
| | | public abstract Map<AttrValueHistorical, AttrValueHistorical> getValuesHistorical(); |
| | | |
| | | |
| | | /** |
| | |
| | | AttrValueHistorical info = it.next(); |
| | | if (csn.isNewerThanOrEqualTo(info.getValueUpdateTime()) && |
| | | csn.isNewerThanOrEqualTo(info.getValueDeleteTime())) |
| | | it.remove(); |
| | | { |
| | | it.remove(); |
| | | } |
| | | } |
| | | |
| | | if (csn.isNewerThan(deleteTime)) |
| | |
| | | case DEL: |
| | | this.deleteTime = csn; |
| | | if (value != null) |
| | | { |
| | | this.value = value; |
| | | } |
| | | break; |
| | | |
| | | case REPL: |
| | | this.addTime = this.deleteTime = csn; |
| | | if (value != null) |
| | | { |
| | | this.value = value; |
| | | } |
| | | break; |
| | | |
| | | case DELATTR: |
| | |
| | | public int compare(FakeOperation op1, FakeOperation op2) |
| | | { |
| | | if (op1 == null) |
| | | { |
| | | return -1; |
| | | } |
| | | return op1.getCSN().compareTo(op2.getCSN()); |
| | | } |
| | | } |
| | |
| | | */ |
| | | public enum HistAttrModificationKey |
| | | { |
| | | /** |
| | | * The key for attribute value deletion. |
| | | */ |
| | | /** The key for attribute value deletion. */ |
| | | DEL("del"), |
| | | |
| | | /** |
| | | * The key for attribute deletion. |
| | | */ |
| | | /** The key for attribute deletion. */ |
| | | DELATTR("delAttr"), |
| | | |
| | | /** |
| | | * The key for attribute replace. |
| | | */ |
| | | /** The key for attribute replace. */ |
| | | REPL("repl"), |
| | | |
| | | /** |
| | | * The key for attribute value addition. |
| | | */ |
| | | /** The key for attribute value addition. */ |
| | | ADD("add"); |
| | | |
| | | /** The string representation of this key. */ |
| | |
| | | */ |
| | | public static HistAttrModificationKey decodeKey(String histkey) |
| | | { |
| | | if (histkey == null) |
| | | return null; |
| | | |
| | | if (histkey.compareTo("repl") == 0) |
| | | if ("repl".equals(histkey)) { |
| | | return HistAttrModificationKey.REPL; |
| | | |
| | | if (histkey.compareTo("add") == 0) |
| | | } else if ("add".equals(histkey)) { |
| | | return HistAttrModificationKey.ADD; |
| | | |
| | | if (histkey.compareTo("del") == 0) |
| | | } else if ("del".equals(histkey)) { |
| | | return HistAttrModificationKey.DEL; |
| | | |
| | | if (histkey.compareTo("attrDel") == 0) |
| | | } else if ("attrDel".equals(histkey)) { |
| | | return HistAttrModificationKey.DELATTR; |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | |
| | | * |
| | | * @return A string representation of this HistKey. |
| | | */ |
| | | @Override |
| | | public String toString() |
| | | { |
| | | return key; |
| | | } |
| | | |
| | | } |
| | |
| | | // modifications were done to the entries. |
| | | attrType = DirectoryServer.getSchema().getAttributeType(attrString); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrString); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | if (lastRetrievedChange != null) |
| | | { |
| | | if (logger.isInfoEnabled()) |
| | | { |
| | | logger.info(LocalizableMessage.raw("publish loop" |
| | | + " >=" + currentStartCSN + " <=" + endCSN |
| | | + " nentries=" + op.getEntriesSent() |
| | | + " result=" + op.getResultCode() |
| | | + " lastRetrievedChange=" + lastRetrievedChange)); |
| | | } |
| | | currentStartCSN = lastRetrievedChange; |
| | | } |
| | | else |
| | | { |
| | | if (logger.isInfoEnabled()) |
| | | { |
| | | logger.info(LocalizableMessage.raw("publish loop" |
| | | + " >=" + currentStartCSN + " <=" + endCSN |
| | | + " nentries=" + op.getEntriesSent() |
| | | + " result=" + op.getResultCode() |
| | | + " no changes")); |
| | | } |
| | | currentStartCSN = endCSN; |
| | | } |
| | | } while (pendingChanges.recoveryUntil(currentStartCSN) |
| | |
| | | protected byte[] encodeMods(List<Modification> mods) |
| | | { |
| | | if ((mods == null) || (mods.size() == 0)) |
| | | { |
| | | return new byte[0]; |
| | | } |
| | | |
| | | ByteStringBuilder byteBuilder = new ByteStringBuilder(); |
| | | ASN1Writer writer = ASN1.getWriter(byteBuilder); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions copyright 2013-2014 ForgeRock AS. |
| | | * Portions copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.replication.protocol; |
| | | |
| | |
| | | { |
| | | // First byte is the type |
| | | if (in[0] != MSG_TYPE_STOP) |
| | | throw new DataFormatException("input is not a valid Stop message: " + |
| | | in[0]); |
| | | { |
| | | throw new DataFormatException("input is not a valid Stop message: " + in[0]); |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public byte[] getBytes(short protocolVersion) |
| | | { |
| | | return new byte[] |
| | | { |
| | | MSG_TYPE_STOP |
| | | }; |
| | | return new byte[] { MSG_TYPE_STOP }; |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | // The session initiator decides whether to use SSL. |
| | | // Until here session is encrypted then it depends on the negotiation |
| | | if (!sessionInitiatorSSLEncryption) |
| | | { |
| | | session.stopEncryption(); |
| | | } |
| | | |
| | | // wait and process StartSessionMsg from remote RS |
| | | StartSessionMsg inStartSessionMsg = |
| | |
| | | this.dsInfo = dsInfo; |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | debugInfo("()"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | public void startHandler() |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | debugInfo("start"); |
| | | } |
| | | DirectoryServer.deregisterMonitorProvider(this); |
| | | DirectoryServer.registerMonitorProvider(this); |
| | | } |
| | |
| | | public void stopHandler() |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | debugInfo("stop"); |
| | | } |
| | | DirectoryServer.deregisterMonitorProvider(this); |
| | | } |
| | | |
| | |
| | | // Until here session is encrypted then it depends on the negotiation |
| | | // The session initiator decides whether to use SSL. |
| | | if (!this.sslEncryption) |
| | | { |
| | | session.stopEncryption(); |
| | | } |
| | | |
| | | if (getProtocolVersion() > ProtocolVersion.REPLICATION_PROTOCOL_V1) |
| | | { |
| | |
| | | The session initiator decides whether to use SSL. |
| | | */ |
| | | if (!sslEncryption) |
| | | { |
| | | session.stopEncryption(); |
| | | } |
| | | |
| | | TopologyMsg inTopoMsg = null; |
| | | if (getProtocolVersion() > ProtocolVersion.REPLICATION_PROTOCOL_V1) |
| | |
| | | // Process TopologyMsg sent by remote RS: store matching new info |
| | | // (this will also warn our connected DSs of the new received info) |
| | | if (inTopoMsg!=null) |
| | | { |
| | | replicationServerDomain.receiveTopoInfoFromRS(inTopoMsg, this, false); |
| | | } |
| | | |
| | | logger.debug(INFO_REPLICATION_SERVER_CONNECTION_FROM_RS, getReplicationServerId(), getServerId(), |
| | | replicationServerDomain.getBaseDN(), session.getReadableRemoteAddress()); |
| | |
| | | { |
| | | // Sanity check: this should never happen |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Received unexpected SD ack from DS id: " |
| | | + ackingServer.getServerId() + " ack message: " + ackMsg); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | |
| | | { |
| | | // Sanity check: this should never happen |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Received unexpected ack from server id: " + |
| | | ackingServerId + " ack message: " + ackMsg); |
| | | } |
| | | return false; |
| | | } else |
| | | { |
| | |
| | | { |
| | | // Sanity check: this should never happen |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Received unexpected ack from server id: " |
| | | + ackingServerId + " ack message: " + ackMsg); |
| | | return false; |
| | | } |
| | | return false; |
| | | } else |
| | | { |
| | | // Analyze received ack and update info for the ack to be later computed |
| | |
| | | // don't try anymore to join and return. |
| | | } |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("SH.shutdowned(" + this + ")"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.server; |
| | | |
| | |
| | | private void logException(Exception e) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace( |
| | | "In " + getName() + " " + stackTraceToSingleLineString(e)); |
| | | { |
| | | logger.trace("In " + getName() + " " + stackTraceToSingleLineString(e)); |
| | | } |
| | | } |
| | | } |
| | |
| | | * out which one is the best to connect to. |
| | | */ |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo("phase 1 : will perform PhaseOneH with each RS in order to " |
| | | + "elect the preferred one"); |
| | | { |
| | | debugInfo("phase 1 : will perform PhaseOneH with each RS in order to elect the preferred one"); |
| | | } |
| | | |
| | | // Get info from every available replication servers |
| | | Map<Integer, ReplicationServerInfo> rsInfos = |
| | |
| | | |
| | | // Best found, now initialize connection to this one (handshake phase 1) |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo("phase 2 : will perform PhaseOneH with the preferred RS=" |
| | | + evals.getBestRS()); |
| | | { |
| | | debugInfo("phase 2 : will perform PhaseOneH with the preferred RS=" + evals.getBestRS()); |
| | | } |
| | | |
| | | final ConnectedRS electedRS = performPhaseOneHandshake( |
| | | evals.getBestRS().getServerURL(), true); |
| | |
| | | { |
| | | eval.accept(rsId, rsInfo); |
| | | if (!rsInfo.serverState.isEmpty()) |
| | | { |
| | | emptyState = false; |
| | | } |
| | | } |
| | | else if (rsInfo.getGenerationId() == -1) |
| | | { |
| | |
| | | } |
| | | logger.info(message); |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo("best replication servers evaluation results: " |
| | | + evals); |
| | | { |
| | | debugInfo("best replication servers evaluation results: " + evals); |
| | | } |
| | | reStart(true); |
| | | } |
| | | |
| | |
| | | public void stop() |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | debugInfo("is stopping and will close the connection to RS(" |
| | | + getRsServerId() + ")"); |
| | | { |
| | | debugInfo("is stopping and will close the connection to RS(" + getRsServerId() + ")"); |
| | | } |
| | | |
| | | synchronized (startStopLock) |
| | | { |
| | |
| | | else |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | debugInfo("is not configured to send CSN heartbeat interval"); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | private void receiveChangeStatus(ChangeStatusMsg csMsg) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Replication domain " + getBaseDN() + |
| | | " received change status message:\n" + csMsg); |
| | | } |
| | | |
| | | ServerStatus reqStatus = csMsg.getRequestedStatus(); |
| | | |
| | |
| | | break; |
| | | default: |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("updateDomainForNewStatus: unexpected status: " + |
| | | status); |
| | | { |
| | | logger.trace("updateDomainForNewStatus: unexpected status: " + status); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | receiveEntryBytes() method. |
| | | */ |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace( |
| | | "[IE] processErrorMsg:" + getServerId() + |
| | | " baseDN: " + getBaseDN() + |
| | | " Error Msg received: " + errorMsg); |
| | | } |
| | | |
| | | if (errorMsg.getCreationTime() > ieCtx.startTime) |
| | | { |
| | |
| | | public void run() |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("[IE] starting " + getName()); |
| | | } |
| | | try |
| | | { |
| | | initializeRemote(serverIdToInitialize, serverIdToInitialize, null, |
| | |
| | | } |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("[IE] ending " + getName()); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | private void setAckVal(int serverId, int numAck) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("[IE] setAckVal[" + serverId + "]=" + numAck); |
| | | } |
| | | |
| | | this.ackVals.put(serverId, numAck); |
| | | |
| | |
| | | public int getSlowestServer() |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("[IE] getSlowestServer" + slowestServerId |
| | | + " " + this.ackVals.get(slowestServerId)); |
| | | } |
| | | |
| | | return this.slowestServerId; |
| | | } |
| | |
| | | } |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("[IE] In " + broker.getReplicationMonitorInstanceName() |
| | | + " export ends with connected=" + broker.isConnected() |
| | | + " exportRootException=" + exportRootException); |
| | | } |
| | | |
| | | if (exportRootException != null) |
| | | { |
| | |
| | | // We are still disconnected, so we wait for the listener thread |
| | | // to reconnect - wait 10s |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace( |
| | | "[IE] Exporter wait for reconnection by the listener thread"); |
| | | { |
| | | logger.trace("[IE] Exporter wait for reconnection by the listener thread"); |
| | | } |
| | | int att=0; |
| | | while (!broker.shuttingDown() |
| | | && !broker.isConnected() |
| | |
| | | final Set<Integer> replicasWeAreWaitingFor = new HashSet<>(ieCtx.startList); |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace( |
| | | "[IE] wait for start replicasWeAreWaitingFor=" + replicasWeAreWaitingFor); |
| | | { |
| | | logger.trace("[IE] wait for start replicasWeAreWaitingFor=" + replicasWeAreWaitingFor); |
| | | } |
| | | |
| | | int waitResultAttempt = 0; |
| | | boolean done; |
| | |
| | | for (DSInfo dsi : getReplicaInfos().values()) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace( |
| | | "[IE] wait for start dsId " + dsi.getDsId() |
| | | + " " + dsi.getStatus() |
| | | + " " + dsi.getGenerationId() |
| | | + " " + getGenerationID()); |
| | | } |
| | | if (ieCtx.startList.contains(dsi.getDsId())) |
| | | { |
| | | if (dsi.getStatus() != ServerStatus.FULL_UPDATE_STATUS) |
| | |
| | | ieCtx.failureList.addAll(replicasWeAreWaitingFor); |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace( |
| | | "[IE] wait for start ends with " + ieCtx.failureList); |
| | | { |
| | | logger.trace("[IE] wait for start ends with " + ieCtx.failureList); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | final Set<Integer> replicasWeAreWaitingFor = new HashSet<>(ieCtx.startList); |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace( |
| | | "[IE] wait for end replicasWeAreWaitingFor=" + replicasWeAreWaitingFor); |
| | | { |
| | | logger.trace("[IE] wait for end replicasWeAreWaitingFor=" + replicasWeAreWaitingFor); |
| | | } |
| | | |
| | | /* |
| | | In case some new servers appear during the init, we want them to be |
| | |
| | | ieCtx.failureList.addAll(replicasWeAreWaitingFor); |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace( |
| | | "[IE] wait for end ends with " + ieCtx.failureList); |
| | | { |
| | | logger.trace("[IE] wait for end ends with " + ieCtx.failureList); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | throws IOException |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("[IE] Entering exportLDIFEntry entry=" + |
| | | Arrays.toString(lDIFEntry)); |
| | | { |
| | | logger.trace("[IE] Entering exportLDIFEntry entry=" + Arrays.toString(lDIFEntry)); |
| | | } |
| | | |
| | | // build the message |
| | | ImportExportContext ieCtx = importExportContext.get(); |
| | |
| | | int slowestCnt = ieCtx.ackVals.get(slowestServerId); |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("[IE] Entering exportLDIFEntry waiting " + |
| | | " our=" + ourLastExportedCnt + " slowest=" + slowestCnt); |
| | | } |
| | | |
| | | if ((ourLastExportedCnt - slowestCnt) > ieCtx.initWindow) |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("[IE] Entering exportLDIFEntry waiting"); |
| | | } |
| | | |
| | | // our export is too far beyond the slowest importer - let's wait |
| | | try { Thread.sleep(100); } |
| | |
| | | else |
| | | { |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("[IE] slowest got to us => stop waiting"); |
| | | } |
| | | break; |
| | | } |
| | | } // Waiting the slowest loop |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | logger.trace("[IE] Entering exportLDIFEntry pub entry=" |
| | | + Arrays.toString(lDIFEntry)); |
| | | { |
| | | logger.trace("[IE] Entering exportLDIFEntry pub entry=" + Arrays.toString(lDIFEntry)); |
| | | } |
| | | |
| | | boolean sent = broker.publish(entryMessage, false); |
| | | |
| | |
| | | badFileCount++; |
| | | } |
| | | } |
| | | if (badFileCount > 0) return 1; |
| | | if (badFileCount > 0) |
| | | { |
| | | return 1; |
| | | } |
| | | importConfig = new LDIFImportConfig(fileList); |
| | | } |
| | | else |
| | |
| | | //Single '+', never return objectclass. |
| | | if(allOperationalAttrs && objectClassNames.isEmpty() && |
| | | attributeNames.isEmpty()) |
| | | { |
| | | includeObjectclassAttrs=false; |
| | | } |
| | | //If "objectclass" isn't specified in the attributes to return, then |
| | | //don't include objectclass attribute. |
| | | if(!attributeNames.isEmpty() && objectClassNames.isEmpty() && |
| | | !attributeNames.contains("objectclass")) |
| | | includeObjectclassAttrs=false; |
| | | { |
| | | includeObjectclassAttrs=false; |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | getOutputStream().println(); |
| | | MenuResult<TaskEntry> r = |
| | | new PrintTaskInfo(task.getValue()).invoke(this); |
| | | if (r.isAgain()) return 1; |
| | | if (r.isAgain()) |
| | | { |
| | | return 1; |
| | | } |
| | | } else if (summary.isPresent()) { |
| | | getOutputStream().println(); |
| | | printSummaryTable(); |
| | | } else if (cancel.isPresent()) { |
| | | MenuResult<TaskEntry> r = |
| | | new CancelTask(cancel.getValue()).invoke(this); |
| | | if (r.isAgain()) return 1; |
| | | if (r.isAgain()) |
| | | { |
| | | return 1; |
| | | } |
| | | } else if (!isInteractive()) { |
| | | // no-prompt option |
| | | getOutputStream().println(); |
| | |
| | | } else { |
| | | message = ERR_TASK_TOOL_START_TIME_NO_LDAP.get(e.getMessage()); |
| | | } |
| | | if (err != null) err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | if (err != null) |
| | | { |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | } |
| | | ret = 1; |
| | | } catch (DecodeException ae) { |
| | | LocalizableMessage message = ERR_TASK_TOOL_DECODE_ERROR.get(ae.getMessage()); |
| | | if (err != null) err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | if (err != null) |
| | | { |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | } |
| | | ret = 1; |
| | | } catch (IOException ioe) { |
| | | LocalizableMessage message = ERR_TASK_TOOL_IO_ERROR.get(ioe); |
| | | if (err != null) err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | if (err != null) |
| | | { |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | } |
| | | ret = 1; |
| | | } catch (LDAPException le) { |
| | | LocalizableMessage message = ERR_TASK_TOOL_LDAP_ERROR.get(le.getMessage()); |
| | | if (err != null) err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | if (err != null) |
| | | { |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | } |
| | | ret = 1; |
| | | } catch (ArgumentException | OpenDsException e) { |
| | | LocalizableMessage message = e.getMessageObject(); |
| | | if (err != null) err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | if (err != null) |
| | | { |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | } |
| | | ret = 1; |
| | | } finally |
| | | { |
| | |
| | | public boolean equals(Object obj) |
| | | { |
| | | if (obj == null) |
| | | { |
| | | return false; |
| | | } |
| | | if (obj == this) |
| | | { |
| | | return true; |
| | | } |
| | | if (getClass() != obj.getClass()) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | HostPort other = (HostPort) obj; |
| | | if (normalizedHost == null) |
| | | { |
| | | if (other.normalizedHost != null) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | else if (!normalizedHost.equals(other.normalizedHost)) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | return port == other.port; |
| | | } |
| | |
| | | Enumeration<String> aliasEnumeration = null; |
| | | KeyStore keyStore = getKeyStore(); |
| | | if (keyStore == null) |
| | | { |
| | | return null; |
| | | } |
| | | aliasEnumeration = keyStore.aliases(); |
| | | if (aliasEnumeration == null) |
| | | { |
| | | return new String[0]; |
| | | } |
| | | ArrayList<String> aliasList = new ArrayList<>(); |
| | | while (aliasEnumeration.hasMoreElements()) |
| | | { |
| | | aliasList.add(aliasEnumeration.nextElement()); |
| | | } |
| | | String[] aliases = new String[aliasList.size()]; |
| | | return aliasList.toArray(aliases); |
| | | } |
| | |
| | | int a = IP[j] - 1; |
| | | int b = block[a]; |
| | | if (j <= 31) |
| | | { |
| | | _c._L[j] = b; |
| | | } |
| | | else |
| | | { |
| | | _c._R[j - 32] = b; |
| | | } |
| | | } |
| | | /* |
| | | * Perform an encryption operation 16 times. |
| | |
| | | * key bits. |
| | | */ |
| | | for (int j = 0; j < 48; j++) |
| | | { |
| | | _c._preS[j] = _c._R[_c._E[j] - 1] ^ _c._KS[i][j]; |
| | | } |
| | | /* |
| | | * The pre-select bits are now considered in 8 groups of 6 bits each. The |
| | | * 8 selection functions map these 6-bit quantities into 4-bit quantities |
| | |
| | | * The new R is L ^ f(R, K). The f here has to be permuted first, though. |
| | | */ |
| | | for (int j = 0; j < 32; j++) |
| | | { |
| | | _c._R[j] = _c._L[j] ^ _c._f[P[j] - 1]; |
| | | } |
| | | /* |
| | | * Finally, the new L (the original R) is copied back. |
| | | */ |
| | |
| | | { |
| | | int c = pw[n]; |
| | | for (int j = 0; j < 7; j++, i++) |
| | | { |
| | | _c._ablock[i] = (c >> (6 - j)) & 01; |
| | | } |
| | | i++; |
| | | } |
| | | |
| | |
| | | { |
| | | int c = salt[i]; |
| | | _c._iobuf[i] = c; |
| | | if (c > 'Z') c -= 6; |
| | | if (c > '9') c -= 7; |
| | | if (c > 'Z') |
| | | { |
| | | c -= 6; |
| | | } |
| | | if (c > '9') |
| | | { |
| | | c -= 7; |
| | | } |
| | | c -= '.'; |
| | | for (int j = 0; j < 6; j++) |
| | | { |
| | |
| | | } |
| | | |
| | | for (int i = 0; i < 25; i++) |
| | | { |
| | | encrypt(_c._ablock, 0); |
| | | } |
| | | |
| | | int i; |
| | | for (i = 0; i < 11; i++) |
| | |
| | | c |= _c._ablock[6 * i + j]; |
| | | } |
| | | c += '.'; |
| | | if (c > '9') c += 7; |
| | | if (c > 'Z') c += 6; |
| | | if (c > '9') |
| | | { |
| | | c += 7; |
| | | } |
| | | if (c > 'Z') |
| | | { |
| | | c += 6; |
| | | } |
| | | _c._iobuf[i + 2] = c; |
| | | } |
| | | _c._iobuf[i + 2] = 0; |
| | | if (_c._iobuf[1] == 0) _c._iobuf[1] = _c._iobuf[0]; |
| | | if (_c._iobuf[1] == 0) |
| | | { |
| | | _c._iobuf[1] = _c._iobuf[0]; |
| | | } |
| | | return (_c._iobuf); |
| | | } |
| | | } |
| | |
| | | else if (!ks.containsAlias(alias) |
| | | || ks |
| | | .entryInstanceOf(alias, KeyStore.TrustedCertificateEntry.class)) |
| | | { |
| | | trustedCert(alias, cf, ks, inStream); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage msg = ERR_CERTMGR_ALIAS_INVALID.get(alias); |
| | |
| | | throw new KeyStoreException(msg.toString()); |
| | | } |
| | | X509Certificate cert = (X509Certificate) cf.generateCertificate(in); |
| | | if (isSelfSigned(cert)) cert.verify(cert.getPublicKey()); |
| | | if (isSelfSigned(cert)) |
| | | { |
| | | cert.verify(cert.getPublicKey()); |
| | | } |
| | | ks.setCertificateEntry(alias, cert); |
| | | } |
| | | catch (Exception e) |
| | |
| | | */ |
| | | public static byte[] getBytes(String s) |
| | | { |
| | | if (s == null) return null; |
| | | if (s == null) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | try |
| | | { |
| | |
| | | Collection<Integer> excludeIds, BuildInformation current, |
| | | BuildInformation neu) |
| | | { |
| | | if (excludeIds == null) excludeIds = Collections.emptySet(); |
| | | if (excludeIds == null) |
| | | { |
| | | excludeIds = Collections.emptySet(); |
| | | } |
| | | List<VersionCompatibilityIssue> issueList = new ArrayList<>(); |
| | | for (VersionCompatibilityIssue evt : VERSION_COMPATIBILITY_ISSUES) { |
| | | if (!excludeIds.contains(evt.getCause().getId())) { |
| | |
| | | <?xml version="1.0"?> |
| | | <!-- |
| | | The contents of this file are subject to the terms of the Common Development and |
| | | Distribution License (the License). You may not use this file except in compliance with the |
| | | License. |
| | | |
| | | You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the |
| | | specific language governing permission and limitations under the License. |
| | | |
| | | When distributing Covered Software, include this CDDL Header Notice in each file and include |
| | | the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL |
| | | Header, with the fields enclosed by brackets [] replaced by your own identifying |
| | | information: "Portions Copyrighted [year] [name of copyright owner]". |
| | | |
| | | Copyright 2012-2015 ForgeRock AS. All rights reserved. |
| | | --> |
| | | <!DOCTYPE module PUBLIC |
| | | "-//Puppy Crawl//DTD Check Configuration 1.2//EN" |
| | | "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> |
| | |
| | | </module> |
| | | |
| | | |
| | | <!-- As per Sun conventions --> |
| | | <!-- Use braces for with all control flow statements --> |
| | | <module name="NeedBraces" /> |
| | | <!-- Don't allow empty statements (those that contain just a semicolon) --> |
| | | <module name="EmptyStatement" /> |
| | | </module> |
| | |
| | | if (p.waitFor() != 0) { |
| | | ByteStringBuilder stdOut = new ByteStringBuilder(); |
| | | ByteStringBuilder stdErr = new ByteStringBuilder(); |
| | | while(stdOut.append(p.getInputStream(), 512) > 0); |
| | | while(stdErr.append(p.getErrorStream(), 512) > 0); |
| | | while(stdOut.append(p.getInputStream(), 512) > 0) {} |
| | | while(stdErr.append(p.getErrorStream(), 512) > 0) {} |
| | | throw new IllegalStateException( |
| | | "setup server process failed:\n" + |
| | | "exit value: " + p.exitValue() + "\n" + |
| | |
| | | } |
| | | |
| | | private void writeContents(File f, String content) throws IOException { |
| | | if (!f.exists()) f.createNewFile(); |
| | | if (!f.exists()) |
| | | { |
| | | f.createNewFile(); |
| | | } |
| | | FileWriter fw = new FileWriter(f); |
| | | fw.write(content); |
| | | fw.flush(); |
| | |
| | | argList.add(filter); |
| | | String[] attrs=attr.split("\\s+"); |
| | | for(String a : attrs) |
| | | argList.add(a); |
| | | { |
| | | argList.add(a); |
| | | } |
| | | String[] args = new String[argList.size()]; |
| | | oStream.reset(); |
| | | int retVal = |
| | |
| | | argList.add("sub"); |
| | | argList.add(filter); |
| | | if(attr != null) { |
| | | String[] attrs=attr.split("\\s+"); |
| | | for(String a : attrs) |
| | | argList.add(a); |
| | | Collections.addAll(argList, attr.split("\\s+")); |
| | | } |
| | | String[] args = new String[argList.size()]; |
| | | oStream.reset(); |
| | | int retVal = |
| | | LDAPSearch.mainSearch(argList.toArray(args), false, oStream, oStream); |
| | | int retVal = LDAPSearch.mainSearch(argList.toArray(args), false, oStream, oStream); |
| | | Assert.assertEquals(retVal, expectedRc, "Returned error: " + oStream); |
| | | return oStream.toString(); |
| | | } |
| | |
| | | protected void LDIFModify(String ldif, String bindDn, String bindPassword, |
| | | String controlStr, int expectedRc) throws Exception |
| | | { |
| | | _LDIFModify(ldif, bindDn, bindPassword, controlStr, false, expectedRc, |
| | | false); |
| | | _LDIFModify(ldif, bindDn, bindPassword, controlStr, false, expectedRc, false); |
| | | } |
| | | |
| | | protected void LDIFModify(String ldif, String bindDn, String bindPassword) |
| | |
| | | oStream.reset(); |
| | | int retVal =LDAPModify.mainModify(args, false, oStream, oStream); |
| | | if (expectedRc != -1) |
| | | { |
| | | Assert.assertEquals(retVal, expectedRc, "Returned error: " + oStream); |
| | | } |
| | | } |
| | | |
| | | protected void deleteAttrFromEntry(String dn, String attr) throws Exception { |
| | |
| | | ldif.append("newrdn: ").append(newRDN).append(EOL); |
| | | ldif.append("deleteoldrdn: ").append(deleteOldRDN).append(EOL); |
| | | if(newSuperior != null) |
| | | ldif.append("newsuperior: ").append(newSuperior).append(EOL); |
| | | { |
| | | ldif.append("newsuperior: ").append(newSuperior).append(EOL); |
| | | } |
| | | ldif.append(EOL); |
| | | return ldif.toString(); |
| | | } |
| | |
| | | ldif.append("changetype: modify").append(EOL); |
| | | ldif.append("delete: ").append(attr).append(EOL); |
| | | for(String aci : acis) |
| | | { |
| | | ldif.append(attr).append(":").append(aci).append(EOL); |
| | | } |
| | | ldif.append(EOL); |
| | | return ldif.toString(); |
| | | } |
| | |
| | | ldif.append("dn: ").append(dn).append(EOL); |
| | | ldif.append("changetype: add").append(EOL); |
| | | for(String l : lines) |
| | | ldif.append(l).append(EOL); |
| | | { |
| | | ldif.append(l).append(EOL); |
| | | } |
| | | ldif.append(EOL); |
| | | return ldif.toString(); |
| | | } |
| | |
| | | ldif.append("changetype: modify").append(EOL); |
| | | ldif.append("add: ").append(attr).append(EOL); |
| | | for(String aci : acis) |
| | | { |
| | | ldif.append(attr).append(":").append(aci).append(EOL); |
| | | } |
| | | ldif.append(EOL); |
| | | return ldif.toString(); |
| | | } |
| | |
| | | while(true) { |
| | | String s = br.readLine(); |
| | | if(s == null) |
| | | { |
| | | break; |
| | | } |
| | | if(s.startsWith("dn:")) |
| | | { |
| | | continue; |
| | | } |
| | | String[] a=s.split(": "); |
| | | if(a.length != 2) |
| | | { |
| | | break; |
| | | } |
| | | attrMap.put(a[0].toLowerCase(),a[1]); |
| | | } |
| | | } catch (IOException e) { |
| | |
| | | ldif.append("changetype: modify").append(EOL); |
| | | ldif.append("add: " + attr).append(EOL); |
| | | for(String aci : acis) |
| | | ldif.append(aci).append(EOL); |
| | | { |
| | | ldif.append(aci).append(EOL); |
| | | } |
| | | ldif.append(EOL); |
| | | return ldif.toString(); |
| | | } |
| | |
| | | argList.add("-f"); |
| | | argList.add(tempFile.getAbsolutePath()); |
| | | if(contFlag) |
| | | argList.add("-c"); |
| | | { |
| | | argList.add("-c"); |
| | | } |
| | | if(proxyDN != null) { |
| | | argList.add("-Y"); |
| | | argList.add("dn:" + proxyDN); |
| | |
| | | ldif.append("newrdn: " + newRDN).append(EOL); |
| | | ldif.append("deleteoldrdn: " + deleteOldRDN).append(EOL); |
| | | if(newSuperior != null) |
| | | ldif.append("newsuperior: " + newSuperior).append(EOL); |
| | | { |
| | | ldif.append("newsuperior: " + newSuperior).append(EOL); |
| | | } |
| | | ldif.append(EOL); |
| | | return ldif.toString(); |
| | | } |
| | |
| | | ldif.append("userpassword: ").append(password).append(EOL); |
| | | for(String attr : attrs) { |
| | | if(attr.startsWith("ldap://")) |
| | | ldif.append("labeledURI: ").append(attr).append(EOL); |
| | | { |
| | | ldif.append("labeledURI: ").append(attr).append(EOL); |
| | | } |
| | | else if(attr.startsWith("cn=group")) |
| | | ldif.append("seeAlso: ").append(attr).append(EOL); |
| | | { |
| | | ldif.append("seeAlso: ").append(attr).append(EOL); |
| | | } |
| | | else |
| | | ldif.append("manager: ").append(attr).append(EOL); |
| | | { |
| | | ldif.append("manager: ").append(attr).append(EOL); |
| | | } |
| | | } |
| | | ldif.append(EOL); |
| | | return ldif.toString(); |
| | |
| | | ldif.append("objectclass: groupOfNames").append(EOL); |
| | | ldif.append("objectclass: top").append(EOL); |
| | | for(String member : members) |
| | | ldif.append("member: " + member).append(EOL); |
| | | { |
| | | ldif.append("member: " + member).append(EOL); |
| | | } |
| | | ldif.append(EOL); |
| | | return ldif.toString(); |
| | | } |
| | |
| | | InetAddress addr=InetAddress.getByName(ipStr); |
| | | EnumEvalResult res=ip.evaluate(addr); |
| | | if(res != EnumEvalResult.TRUE) |
| | | throw new RuntimeException ("Addr: " + ipStr + |
| | | "expr: " + mixed); |
| | | { |
| | | throw new RuntimeException ("Addr: " + ipStr + "expr: " + mixed); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | InetAddress addr=InetAddress.getByName(ipStr); |
| | | EnumEvalResult res=ip.evaluate(addr); |
| | | if(res != EnumEvalResult.TRUE) |
| | | throw new RuntimeException ("Addr: " + ipStr + |
| | | "expr: " + ip4compat); |
| | | { |
| | | throw new RuntimeException ("Addr: " + ipStr + "expr: " + ip4compat); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | InetAddress addr=InetAddress.getByName(ipStr); |
| | | EnumEvalResult res=ip.evaluate(addr); |
| | | if(res != EnumEvalResult.TRUE) |
| | | throw new RuntimeException ("Addr: " + ipStr + |
| | | "expr: " + ip6ExprCidr); |
| | | { |
| | | throw new RuntimeException ("Addr: " + ipStr + "expr: " + ip6ExprCidr); |
| | | } |
| | | IP ip1=(IP) IP.decode(ip6ExprCidrB, EnumBindRuleType.EQUAL_BINDRULE_TYPE); |
| | | EnumEvalResult res1=ip1.evaluate(addr); |
| | | if(res1 != EnumEvalResult.TRUE) |
| | | throw new RuntimeException ("Addr: " + ipStr + |
| | | "expr: " + ip6ExprCidrB); |
| | | { |
| | | throw new RuntimeException ("Addr: " + ipStr + "expr: " + ip6ExprCidrB); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | InetAddress addr=InetAddress.getByName(ipStr); |
| | | EnumEvalResult res=ip.evaluate(addr); |
| | | if(res != EnumEvalResult.TRUE) |
| | | throw new RuntimeException ("Addr: " + ipStr + |
| | | "expr: " + ip6Expr); |
| | | { |
| | | throw new RuntimeException ("Addr: " + ipStr + "expr: " + ip6Expr); |
| | | } |
| | | IP ip1=(IP) IP.decode(ip6ExprC, EnumBindRuleType.EQUAL_BINDRULE_TYPE); |
| | | EnumEvalResult res1=ip1.evaluate(addr); |
| | | if(res1 != EnumEvalResult.TRUE) |
| | | throw new RuntimeException ("Addr: " + ipStr + |
| | | "expr: " + ip6ExprC); |
| | | { |
| | | throw new RuntimeException ("Addr: " + ipStr + "expr: " + ip6ExprC); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | InetAddress addr=InetAddress.getByName(ipStr); |
| | | EnumEvalResult res=ip.evaluate(addr); |
| | | if(res != EnumEvalResult.TRUE) |
| | | throw new RuntimeException ("Addr: " + ipStr + |
| | | "expr: " + cidr); |
| | | { |
| | | throw new RuntimeException ("Addr: " + ipStr + "expr: " + cidr); |
| | | } |
| | | |
| | | IP ip1=(IP) IP.decode(cidrWc, EnumBindRuleType.EQUAL_BINDRULE_TYPE); |
| | | EnumEvalResult res1=ip.evaluate(addr); |
| | | if(res1 != EnumEvalResult.TRUE) |
| | | throw new RuntimeException ("Addr: " + ipStr + |
| | | "expr: " + cidrWc); |
| | | { |
| | | throw new RuntimeException ("Addr: " + ipStr + "expr: " + cidrWc); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | InetAddress addr=InetAddress.getByName(ipStr); |
| | | EnumEvalResult res=ip.evaluate(addr); |
| | | if(res != EnumEvalResult.TRUE) |
| | | throw new RuntimeException ("Addr: " + ipStr + |
| | | "expr: " + netmaskWc); |
| | | { |
| | | throw new RuntimeException ("Addr: " + ipStr + "expr: " + netmaskWc); |
| | | } |
| | | IP ip1 = (IP) IP.decode(netmaskWcOverRide, |
| | | EnumBindRuleType.EQUAL_BINDRULE_TYPE); |
| | | EnumEvalResult res1=ip1.evaluate(addr); |
| | | if(res1 != EnumEvalResult.TRUE) |
| | | throw new RuntimeException ("Addr: " + ipStr + |
| | | "expr: " + netmaskWc); |
| | | { |
| | | throw new RuntimeException ("Addr: " + ipStr + "expr: " + netmaskWc); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | InetAddress addr=InetAddress.getByName(ipStr); |
| | | EnumEvalResult res=ip.evaluate(addr); |
| | | if(res != EnumEvalResult.TRUE) |
| | | throw new RuntimeException ("Addr: " + ipStr + |
| | | "expr: " + ipExpr); |
| | | { |
| | | throw new RuntimeException ("Addr: " + ipStr + "expr: " + ipExpr); |
| | | } |
| | | IP ipWc=(IP) IP.decode(ipExprWc, EnumBindRuleType.EQUAL_BINDRULE_TYPE); |
| | | EnumEvalResult resWc=ipWc.evaluate(addr); |
| | | if(resWc != EnumEvalResult.TRUE) |
| | | throw new RuntimeException ("Addr: " + ipStr + |
| | | "expr:" + ipExprWc); |
| | | { |
| | | throw new RuntimeException ("Addr: " + ipStr + "expr:" + ipExprWc); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param resultString The string containing the results from the search. |
| | | * @return True if the "SearchReference" string is seen in the results. |
| | | */ |
| | | protected boolean |
| | | isRefMap(String resultString) { |
| | | boolean ret=false; |
| | | protected boolean isRefMap(String resultString) { |
| | | StringReader r=new StringReader(resultString); |
| | | BufferedReader br=new BufferedReader(r); |
| | | try { |
| | | while(true) { |
| | | String s = br.readLine(); |
| | | if(s == null) |
| | | { |
| | | break; |
| | | } |
| | | if(s.startsWith("SearchReference")) { |
| | | ret=true; |
| | | break; |
| | | return true; |
| | | } |
| | | } |
| | | } catch (IOException e) { |
| | | Assert.assertEquals(0, 1, e.getMessage()); |
| | | } |
| | | return ret; |
| | | return false; |
| | | } |
| | | } |
| | |
| | | subInitialTestCurrent = null; |
| | | subAnyTestCurrent = null; |
| | | subFinalTestCurrent = null; |
| | | if ((i & 0x8) != 0) attTypeCurrent = attTypeTest; |
| | | if ((i & 0x8) != 0) rawAttTypeTestCurrent = rawAttTypeTest; |
| | | if ((i & 0x4) != 0) subInitialTestCurrent = subInitialTest; |
| | | if ((i & 0x2) != 0) subAnyTestCurrent = subAnyTest; |
| | | if ((i & 0x1) != 0) subFinalTestCurrent = subFinalTest; |
| | | if ((i & 0x8) != 0) { |
| | | attTypeCurrent = attTypeTest; |
| | | } |
| | | if ((i & 0x8) != 0) { |
| | | rawAttTypeTestCurrent = rawAttTypeTest; |
| | | } |
| | | if ((i & 0x4) != 0) { |
| | | subInitialTestCurrent = subInitialTest; |
| | | } |
| | | if ((i & 0x2) != 0) { |
| | | subAnyTestCurrent = subAnyTest; |
| | | } |
| | | if ((i & 0x1) != 0) { |
| | | subFinalTestCurrent = subFinalTest; |
| | | } |
| | | |
| | | if (attTypeCurrent == null) |
| | | { |
| | |
| | | attTypeTestCurrent = null; |
| | | attValueTestCurrent = null ; |
| | | |
| | | if ((i & 0x4) != 0) attTypeTestCurrent = attTypeTest; |
| | | if ((i & 0x4) != 0) rawAttTypeTestCurrent = rawAttTypeTest; |
| | | if ((i & 0x2) != 0) rawMatchingRuleidTestCurrent = matchingRuleIdTest; |
| | | if ((i & 0x2) != 0) matchingRuleidTestCurrent = matchingRule ; |
| | | if ((i & 0x1) != 0) attValueTestCurrent = attValueTest; |
| | | if ((i & 0x4) != 0) { |
| | | attTypeTestCurrent = attTypeTest; |
| | | } |
| | | if ((i & 0x4) != 0) { |
| | | rawAttTypeTestCurrent = rawAttTypeTest; |
| | | } |
| | | if ((i & 0x2) != 0) { |
| | | rawMatchingRuleidTestCurrent = matchingRuleIdTest; |
| | | } |
| | | if ((i & 0x2) != 0) { |
| | | matchingRuleidTestCurrent = matchingRule ; |
| | | } |
| | | if ((i & 0x1) != 0) { |
| | | attValueTestCurrent = attValueTest; |
| | | } |
| | | |
| | | boolean exceptionExpected = (attTypeTestCurrent == null) |
| | | || (attValueTestCurrent == null) || (matchingRuleidTestCurrent == null); |
| | |
| | | Set<Integer> keys = exceptedValues.keySet() ; |
| | | for (int i=-10 ; i< 10 ; i++) |
| | | { |
| | | if (keys.contains(i)) continue ; |
| | | assertNull(PasswordPolicyErrorType.valueOf(i)); |
| | | if (!keys.contains(i)) |
| | | { |
| | | assertNull(PasswordPolicyErrorType.valueOf(i)); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | Set<Integer> keys = exceptedValues.keySet() ; |
| | | for (int i=-10 ; i< 10 ; i++) |
| | | { |
| | | if (keys.contains(i)) continue ; |
| | | if (keys.contains(i)) |
| | | { |
| | | continue; |
| | | } |
| | | try |
| | | { |
| | | PersistentSearchChangeType.valueOf(i); |
| | |
| | | "description: Reject Test Case"); |
| | | String[] args = null; |
| | | if (authentication) |
| | | { |
| | | args = new String[] |
| | | { |
| | | "--noPropertiesFile", |
| | |
| | | "-f", |
| | | filePath, |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | args = new String[] |
| | | { |
| | | "--noPropertiesFile", |
| | |
| | | "-f", |
| | | filePath, |
| | | }; |
| | | } |
| | | return LDAPModify.mainModify(args, false, null, null); |
| | | } |
| | | |
| | |
| | | "description: New Description"); |
| | | String[] args = null; |
| | | if (authentication) |
| | | { |
| | | args = new String[] |
| | | { |
| | | "--noPropertiesFile", |
| | |
| | | "-f", |
| | | path |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | args = new String[] |
| | | { |
| | | "--noPropertiesFile", |
| | |
| | | "-f", |
| | | path |
| | | }; |
| | | } |
| | | return LDAPModify.mainModify(args, false, null, null); |
| | | } |
| | | |
| | |
| | | { |
| | | String[] args = null; |
| | | if (authentication) |
| | | { |
| | | args = new String[] |
| | | { |
| | | "--noPropertiesFile", |
| | |
| | | "o:test", |
| | | "o=test" |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | args = new String[] |
| | | { |
| | | "--noPropertiesFile", |
| | |
| | | "o:test", |
| | | "o=test" |
| | | }; |
| | | } |
| | | |
| | | return LDAPCompare.mainCompare(args, false, null, null); |
| | | } |
| | |
| | | "newrdn: o=mod_rejectTestCase", "deleteoldrdn: 0"); |
| | | String[] args = null; |
| | | if (authentication) |
| | | { |
| | | args = new String[] |
| | | { |
| | | "--noPropertiesFile", |
| | |
| | | "-f", |
| | | path |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | args = new String[] |
| | | { |
| | | "--noPropertiesFile", |
| | |
| | | "-f", |
| | | path |
| | | }; |
| | | } |
| | | return LDAPModify.mainModify(args, false, null, null); |
| | | } |
| | | |
| | |
| | | { |
| | | String[] args = null; |
| | | if (authentication) |
| | | { |
| | | args = new String[] |
| | | { |
| | | "--noPropertiesFile", |
| | |
| | | "password", |
| | | "o=mod_rejectTestCase,o=test" |
| | | }; |
| | | } |
| | | else |
| | | { |
| | | args = new String[] |
| | | { |
| | | "--noPropertiesFile", |
| | |
| | | String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "o=mod_rejectTestCase,o=test" |
| | | }; |
| | | } |
| | | return LDAPDelete.mainDelete(args, false, null, null); |
| | | } |
| | | |
| | |
| | | Assert.assertTrue(Arrays.equals(jpegBytes, jpegBytes1)); |
| | | } finally { |
| | | if(ctx != null) |
| | | { |
| | | ctx.close(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | Assert.assertTrue(Arrays.equals(jpegBytes, jpegBytes1)); |
| | | } finally { |
| | | if(ctx != null) |
| | | { |
| | | ctx.close(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | ctx.modifyAttributes(testUserDN, mods); |
| | | } finally { |
| | | if (ctx != null) |
| | | { |
| | | ctx.close(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | ctx.destroySubcontext(testUserDN); |
| | | } finally { |
| | | if(ctx != null) |
| | | { |
| | | ctx.close(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | AttributeType attrType = |
| | | DirectoryServer.getAttributeType(attrTypeString); |
| | | if (attrType == null) |
| | | { |
| | | attrType = DirectoryServer.getDefaultAttributeType(attrTypeString); |
| | | } |
| | | return attrType; |
| | | } |
| | | |
| | |
| | | String[] credentials; |
| | | if ((user == null) && (password == null)) { |
| | | credentials = null; |
| | | } else |
| | | } |
| | | else |
| | | { |
| | | credentials = new String[] { user, password }; |
| | | } |
| | | env.put("jmx.remote.credentials", credentials); |
| | | |
| | | env.put("jmx.remote.x.client.connection.check.period", 0); |
| | |
| | | String[] credentials; |
| | | if ((user == null) && (password == null)) { |
| | | credentials = null; |
| | | } else |
| | | } |
| | | else |
| | | { |
| | | credentials = new String[] { user, password }; |
| | | } |
| | | env.put("jmx.remote.credentials", credentials); |
| | | |
| | | // Provide the Trust manager. |
| | |
| | | Attribute status = (Attribute) mbsc.getAttribute(name, |
| | | "ds-cfg-enabled"); |
| | | if (status != null) |
| | | { |
| | | status.getValue(); |
| | | } |
| | | Attribute attr = new Attribute( |
| | | "ds-cfg-enabled", enabled); |
| | | mbsc.setAttribute(name, attr); |
| | |
| | | for (ByteString v : a.getValues()) |
| | | { |
| | | String val = v.toString(); |
| | | if(val.equals("sn#1") || val.equals("sn#2") |
| | | || val.equals("sn#3")) |
| | | { |
| | | snWithMultiVal = true; |
| | | } |
| | | else //All the values should match. |
| | | snWithMultiVal = false; |
| | | snWithMultiVal = val.equals("sn#1") || val.equals("sn#2") || val.equals("sn#3"); |
| | | } |
| | | } |
| | | } |
| | |
| | | LDAPAttribute o1 = e1.next(); |
| | | LDAPAttribute o2 = e2.next(); |
| | | if (o1 == null ? o2 != null : !testEqual(o1, o2)) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | return !e1.hasNext() && !e2.hasNext(); |
| | | } |
| | |
| | | { |
| | | remove(replServer); |
| | | if (domain != null) |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | remove(replServer); |
| | | if (domain != null) |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | remove(replServer); |
| | | if (domain != null) |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | remove(replServer); |
| | | if (domain != null) |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDN); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | if (all) |
| | | { |
| | | if (replServerId != replServerId1) |
| | | { |
| | | servers.add("localhost:" + getRSPort(replServerId1)); |
| | | } |
| | | if (replServerId != replServerId2) |
| | | { |
| | | servers.add("localhost:" + getRSPort(replServerId2)); |
| | | } |
| | | if (replServerId != replServerId3) |
| | | { |
| | | servers.add("localhost:" + getRSPort(replServerId3)); |
| | | } |
| | | } |
| | | int rsPort = getRSPort(replServerId); |
| | | String rsDir = "generationIdTest" + replServerId + testCase + "Db"; |
| | |
| | | if (replServer1.getGenerationId(baseDN) == expectedGenId |
| | | && replServer2.getGenerationId(baseDN) == expectedGenId |
| | | && replServer3.getGenerationId(baseDN) == expectedGenId) |
| | | { |
| | | break; |
| | | } |
| | | wait++; |
| | | Thread.sleep(100); |
| | | } |
| | |
| | | // and ReplLDIFOutputStream with big entries |
| | | char bigAttributeValue[] = new char[30240]; |
| | | for (int i=0; i<bigAttributeValue.length; i++) |
| | | { |
| | | bigAttributeValue[i] = Integer.toString(i).charAt(0); |
| | | } |
| | | |
| | | String[] entries = new String[entriesCnt + 2]; |
| | | entries[0] = "dn: " + EXAMPLE_DN + "\n" |
| | |
| | | log("Broker " + serverId + " Wait for entry or done msg"); |
| | | ReplicationMsg msg = broker.receive(); |
| | | if (msg == null) |
| | | { |
| | | break; |
| | | } |
| | | |
| | | if (msg instanceof InitializeTargetMsg) |
| | | { |
| | |
| | | { |
| | | SortedSet<String> servers = new TreeSet<>(); |
| | | if (replServerId != replServer1ID) |
| | | { |
| | | servers.add("localhost:" + getReplServerPort(replServer1ID)); |
| | | } |
| | | if (replServerId != replServer2ID) |
| | | { |
| | | servers.add("localhost:" + getReplServerPort(replServer2ID)); |
| | | } |
| | | if (replServerId != replServer3ID) |
| | | { |
| | | servers.add("localhost:" + getReplServerPort(replServer3ID)); |
| | | } |
| | | |
| | | final int port = getReplServerPort(replServerId); |
| | | ReplServerFakeConfiguration conf = |
| | |
| | | connectServer1ToReplServer(replServer1ID); |
| | | |
| | | if (server2 == null) |
| | | { |
| | | server2 = openReplicationSession(baseDN, |
| | | server2ID, 100, getReplServerPort(replServer1ID), 1000); |
| | | } |
| | | |
| | | // In S1 launch the total update |
| | | addTask(taskInitFromS2, ResultCode.SUCCESS, null); |
| | |
| | | addTestEntriesToDB(); |
| | | |
| | | if (server2 == null) |
| | | { |
| | | server2 = openReplicationSession(baseDN, |
| | | server2ID, 100, getReplServerPort(replServer1ID), 1000); |
| | | } |
| | | |
| | | InitializeRequestMsg initMsg = new InitializeRequestMsg(baseDN, server2ID, server1ID, 100); |
| | | server2.publish(initMsg); |
| | |
| | | |
| | | // S1 is the server we are running in, S2 is simulated by a broker |
| | | if (server2 == null) |
| | | { |
| | | server2 = openReplicationSession(baseDN, |
| | | server2ID, 100, getReplServerPort(replServer1ID), 1000); |
| | | } |
| | | |
| | | // Launch in S1 the task that will initialize S2 |
| | | addTask(taskInitTargetS2, ResultCode.SUCCESS, null); |
| | |
| | | |
| | | // S1 is the server we are running in, S2 and S3 are simulated by brokers |
| | | if (server2 == null) |
| | | { |
| | | server2 = openReplicationSession(baseDN, |
| | | server2ID, 100, getReplServerPort(replServer1ID), 1000); |
| | | } |
| | | |
| | | if (server3 == null) |
| | | { |
| | | server3 = openReplicationSession(baseDN, |
| | | server3ID, 100, getReplServerPort(replServer1ID), 1000); |
| | | } |
| | | |
| | | // Launch in S1 the task that will initialize S2 |
| | | addTask(taskInitTargetAll, ResultCode.SUCCESS, null); |
| | |
| | | |
| | | // S1 is the server we are running in, S2 is simulated by a broker |
| | | if (server2==null) |
| | | { |
| | | server2 = openReplicationSession(baseDN, |
| | | server2ID, 100, getReplServerPort(replServer1ID), 1000); |
| | | } |
| | | |
| | | // Creates config to synchronize suffix |
| | | connectServer1ToReplServer(replServer1ID); |
| | |
| | | { |
| | | readGenerationId = replDomain.getGenerationID(); |
| | | if (readGenerationId == EXPECTED_GENERATION_ID) |
| | | { |
| | | break; |
| | | } |
| | | log(testCase + " genId=" + readGenerationId); |
| | | Thread.sleep(1000); |
| | | } |
| | |
| | | checkConnection(30, broker, port); |
| | | |
| | | if (timeout != 0) |
| | | { |
| | | broker.setSoTimeout(timeout); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | protected void deleteEntry(DN dn) throws Exception |
| | | { |
| | | if (dn.parent().rdn().toString().equalsIgnoreCase("cn=domains")) |
| | | { |
| | | deleteEntry(DN.valueOf("cn=external changelog," + dn)); |
| | | } |
| | | |
| | | DeleteOperation op = connection.processDelete(dn); |
| | | assertTrue(op.getResultCode() == SUCCESS || op.getResultCode() == NO_SUCH_OBJECT, |
| | |
| | | |
| | | // Check for unexpected replication config/objects left |
| | | if (callParanoiaCheck) |
| | | { |
| | | paranoiaCheck(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | do |
| | | { |
| | | if (count++>0) |
| | | { |
| | | Thread.sleep(100); |
| | | } |
| | | op = connection.processSearch(newSearchRequest("cn=replication,cn=monitor", WHOLE_SUBTREE, monitorFilter)); |
| | | } |
| | | while (op.getSearchEntries().isEmpty() && (count<100)); |
| | |
| | | boolean found = false; |
| | | int count = timeout/100; |
| | | if (count<1) |
| | | { |
| | | count=1; |
| | | } |
| | | |
| | | do |
| | | { |
| | |
| | | { |
| | | int count = timeout/200; |
| | | if (count<1) |
| | | { |
| | | count=1; |
| | | } |
| | | Thread.sleep(50); |
| | | boolean found = DirectoryServer.entryExists(dn); |
| | | while ((count> 0) && (found != exist)) |
| | |
| | | { |
| | | ReplicationMsg msg = broker.receive(); |
| | | if (msg == null) |
| | | { |
| | | break; |
| | | } |
| | | count ++; |
| | | } |
| | | } catch (Exception e) |
| | |
| | | { |
| | | Attribute attr; |
| | | if (reader == null) |
| | | { |
| | | attr = Attributes.create("received-messages", "not yet started"); |
| | | } |
| | | else |
| | | attr = Attributes.create("received-messages", String |
| | | .valueOf(reader.getCurrentCount())); |
| | | { |
| | | attr = Attributes.create("received-messages", String.valueOf(reader.getCurrentCount())); |
| | | } |
| | | List<Attribute> list = new LinkedList<>(); |
| | | list.add(attr); |
| | | attr = Attributes.create("base-dn", "ou=People," + TEST_ROOT_DN_STRING); |
| | |
| | | replicationServer = new FakeReplicationServer(rsGroupId, replServerPort, RS_SERVER_ID, |
| | | 1, testcase); |
| | | if (rsGroupId != 1) |
| | | { |
| | | replicationServer.setAssured(false); |
| | | } |
| | | replicationServer.start(TIMEOUT_SCENARIO); |
| | | |
| | | long startTime; |
| | |
| | | replicationServer = new FakeReplicationServer(rsGroupId, replServerPort, RS_SERVER_ID, |
| | | true, testcase); |
| | | if (rsGroupId != 1) |
| | | { |
| | | replicationServer.setAssured(false); |
| | | } |
| | | replicationServer.start(TIMEOUT_SCENARIO); |
| | | |
| | | long startTime; |
| | |
| | | do |
| | | { |
| | | nsec++; |
| | | if (nsec == 10) // 10 seconds timeout |
| | | if (nsec == 10) |
| | | { |
| | | fail(testCase + ": timeout waiting for domain connection to fake RS after " + nsec + " seconds."); |
| | | } |
| | | Thread.sleep(1000); |
| | | } while (!rs.isHandshakeOk()); |
| | | } |
| | |
| | | do |
| | | { |
| | | nsec++; |
| | | if (nsec == 10) // 10 seconds timeout |
| | | if (nsec == 10) |
| | | { |
| | | fail(testCase + ": timeout waiting for scenario to be exectued on fake RS after " + nsec + " seconds."); |
| | | } |
| | | Thread.sleep(1000); |
| | | } while (!rs.isScenarioExecuted()); |
| | | } |
| | |
| | | AckMsg ackMsg = replicationServer.sendAssuredAddMsg(entry, parentUid); |
| | | |
| | | if (rsGroupId == 2) |
| | | fail("Should only go here for RS with same group id as DS"); |
| | | { |
| | | fail("Should only go here for RS with same group id as DS"); |
| | | } |
| | | |
| | | // Ack received, replay has occurred |
| | | assertNotNull(DirectoryServer.getEntry(entry.getName())); |
| | |
| | | { |
| | | // Expected |
| | | if (rsGroupId == 1) |
| | | fail("Should only go here for RS with group id different from DS one"); |
| | | { |
| | | fail("Should only go here for RS with group id different from DS one"); |
| | | } |
| | | |
| | | return; |
| | | } |
| | |
| | | do |
| | | { |
| | | if (count++>0) |
| | | { |
| | | Thread.sleep(100); |
| | | } |
| | | final SearchRequest request = newSearchRequest(dn, SearchScope.WHOLE_SUBTREE, monitorFilter); |
| | | op = connection.processSearch(request); |
| | | } |
| | |
| | | |
| | | List<Attribute> attrs = entry.getAttribute(assuredAttr); |
| | | if (attrs == null || attrs.isEmpty()) |
| | | { |
| | | return Collections.emptyMap(); |
| | | } |
| | | |
| | | // Parse and store values |
| | | Map<Integer,Integer> resultMap = new HashMap<>(); |
| | |
| | | Thread.sleep(50); |
| | | ii++; |
| | | if (ii>10) |
| | | { |
| | | assertEquals(operation.getResultCode(), expectedResult, |
| | | operation.getErrorMessage().toString()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | this.assuredSdLevel = assuredSdLevel; |
| | | this.assuredTimeout = assuredTimeout; |
| | | if (refUrls != null) |
| | | { |
| | | this.refUrls = refUrls; |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | String serverStr = rd.getReplicationServer(); |
| | | rdPort = HostPort.valueOf(serverStr).getPort(); |
| | | if (rdPort == rsPort) |
| | | { |
| | | rightPort = true; |
| | | } |
| | | } |
| | | if (connected && rightPort) |
| | | { |
| | |
| | | replServers.add("localhost:" + rs1Port); |
| | | replServers.add("localhost:" + rs2Port); |
| | | replServers.add("localhost:" + rs3Port); |
| | | } else |
| | | } |
| | | else |
| | | { |
| | | fail("Unknown test case: " + testCase); |
| | | } |
| | | |
| | | return replServers; |
| | | } |
| | |
| | | replServers.add("localhost:" + rs3Port); |
| | | } |
| | | else |
| | | { |
| | | fail("Unknown test case: " + testCase); |
| | | } |
| | | } |
| | | else if (serverId == RS2_ID) |
| | | { |
| | |
| | | // 3 servers used for this test case. |
| | | replServers.add("localhost:" + rs1Port); |
| | | replServers.add("localhost:" + rs3Port); |
| | | } else |
| | | } |
| | | else |
| | | { |
| | | fail("Unknown test case: " + testCase); |
| | | } |
| | | } |
| | | else if (serverId == RS3_ID) |
| | | { |
| | |
| | | replServers.add("localhost:" + rs3Port); |
| | | } |
| | | else |
| | | { |
| | | fail("Invalid test case: " + testCase); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | finally |
| | | { |
| | | if (domain != null) |
| | | { |
| | | MultimasterReplication.deleteDomain(baseDn); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | String serverStr = rd.getReplicationServer(); |
| | | rdPort = HostPort.valueOf(serverStr).getPort(); |
| | | if (rdPort == rsPort) |
| | | { |
| | | rightPort = true; |
| | | } |
| | | } |
| | | if (connected && rightPort) |
| | | { |
| | |
| | | { |
| | | // First check that the Replication domain is connected |
| | | if (!rd.isConnected()) |
| | | { |
| | | return -1; |
| | | } |
| | | |
| | | String serverStr = rd.getReplicationServer(); |
| | | return HostPort.valueOf(serverStr).getPort(); |
| | |
| | | // Test connection |
| | | boolean connected = false; |
| | | if (rd != null) |
| | | { |
| | | connected = rd.isConnected(); |
| | | } |
| | | else |
| | | { |
| | | connected = rb.isConnected(); |
| | | } |
| | | |
| | | if (connected) |
| | | { |
| | |
| | | } finally |
| | | { |
| | | endTest(); |
| | | if (bw != null) bw.shutdown(); |
| | | if (br3 != null) br3.shutdown(); |
| | | if (br2 != null) br2.shutdown(); |
| | | if (bw != null) |
| | | { |
| | | bw.shutdown(); |
| | | } |
| | | if (br3 != null) |
| | | { |
| | | br3.shutdown(); |
| | | } |
| | | if (br2 != null) |
| | | { |
| | | br2.shutdown(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | // Finalize test |
| | | endTest(); |
| | | if (bw != null) bw.shutdown(); |
| | | if (br != null) br.shutdown(); |
| | | if (bw != null) |
| | | { |
| | | bw.shutdown(); |
| | | } |
| | | if (br != null) |
| | | { |
| | | br.shutdown(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | public void pause() |
| | | { |
| | | if (isPaused()) |
| | | { |
| | | return; // Already suspended |
| | | } |
| | | suspended.set(true); |
| | | // Wait for all messages sent |
| | | while (!sessionDone.get()) |
| | |
| | | ReplicationMsg msg = rb.receive(); // Allow more messages to be sent by broker writer |
| | | rb.updateWindowAfterReplay(); // Allow RS to send more messages to broker |
| | | if (msg != null) |
| | | { |
| | | debugInfo("Broker " + serverId + " reader received: " + msg); |
| | | } |
| | | lastMsg = msg; |
| | | } catch (SocketTimeoutException ex) |
| | | { |
| | | if (shutdown) |
| | | { |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | debugInfo("Broker " + serverId + " reader thread is dying"); |
| | |
| | | String serverStr = rd.getReplicationServer(); |
| | | rdPort = HostPort.valueOf(serverStr).getPort(); |
| | | if (rdPort == rsPort) |
| | | { |
| | | rightPort = true; |
| | | } |
| | | } |
| | | if (connected && rightPort) |
| | | { |
| | |
| | | public boolean equals(Object obj) |
| | | { |
| | | if (obj == null || getClass() != obj.getClass()) |
| | | { |
| | | return false; |
| | | } |
| | | TopoView other = (TopoView) obj; |
| | | return checkLists(dsList, other.dsList) |
| | | && checkLists(rsList, other.rsList); |
| | |
| | | private boolean checkLists(List<?> list, List<?> otherList) |
| | | { |
| | | if (otherList.size() != list.size()) |
| | | { |
| | | return false; |
| | | } |
| | | for (Object otherObj : otherList) |
| | | { |
| | | int found = 0; |
| | | for (Object thisObj : list) |
| | | { |
| | | if (thisObj.equals(otherObj)) |
| | | { |
| | | found++; |
| | | } |
| | | } |
| | | // Not found |
| | | if (found == 0) |
| | | { |
| | | return false; |
| | | } |
| | | // Should never see twice as dsInfo structure in a dsList |
| | | assertFalse(found > 1); |
| | | // Ok, found exactly once in the list, examine next structure |
| | |
| | | |
| | | fakeReplicationDomain.startPublishService(); |
| | | if (startListen) |
| | | { |
| | | fakeReplicationDomain.startListenService(); |
| | | } |
| | | |
| | | // Test connection |
| | | assertTrue(fakeReplicationDomain.isConnected()); |
| | |
| | | |
| | | // Check call time |
| | | if (fakeDsIsEligible && (fakeDsScen == TIMEOUT_DS_SCENARIO)) |
| | | { |
| | | assertBetweenInclusive(sendUpdateTime, SMALL_TIMEOUT, SMALL_TIMEOUT + 1000); |
| | | } |
| | | else |
| | | { |
| | | assertThat(sendUpdateTime).isLessThan(MAX_SEND_UPDATE_TIME); |
| | | } |
| | | |
| | | // Check monitoring values (check that ack has been correctly received) |
| | | Thread.sleep(500); // Sleep a while as counters are updated just after sending thread is unblocked |
| | |
| | | if (all) |
| | | { |
| | | if (changelogId != changelog1ID) |
| | | { |
| | | servers.add("localhost:" + getChangelogPort(changelog1ID)); |
| | | } |
| | | if (changelogId != changelog2ID) |
| | | { |
| | | servers.add("localhost:" + getChangelogPort(changelog2ID)); |
| | | } |
| | | } |
| | | int chPort = getChangelogPort(changelogId); |
| | | String chDir = "monitorTest" + changelogId + suffix + "Db"; |
| | |
| | | for (BrokerReader r : reader) |
| | | { |
| | | if (r != null) |
| | | { |
| | | assertNull(r.errDetails, r.exc + " " + r.errDetails); |
| | | } |
| | | } |
| | | } |
| | | debugInfo("Ending multipleWriterMultipleReader"); |
| | |
| | | { |
| | | ReplicationMsg msg = broker2.receive(); |
| | | if (msg == null) |
| | | { |
| | | break; |
| | | } |
| | | if (msg instanceof TopologyMsg) |
| | | { |
| | | continue; // ignore |
| | | } |
| | | msgs.add(msg); |
| | | |
| | | broker2.updateWindowAfterReplay(); |
| | |
| | | // may prevent to process a WindowMsg that would unblock the dual |
| | | // writer thread. |
| | | if (msg == null) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | } catch (SocketTimeoutException e) |
| | | { |
| | |
| | | broker.publish(msg); |
| | | |
| | | if ((count % 10) == 0) |
| | | debugInfo("writer " + broker.getServerId() + " to send="+count); |
| | | { |
| | | debugInfo("writer " + broker.getServerId() + " to send="+count); |
| | | } |
| | | } |
| | | debugInfo("writer " + broker.getServerId() + " ends sent="+ccount); |
| | | } |
| | |
| | | // Connect only replicationServer[0] to ReplicationServer[1] |
| | | // and not the other way |
| | | if (i==0) |
| | | { |
| | | servers.add("localhost:" + changelogPorts[1]); |
| | | } |
| | | ReplServerFakeConfiguration conf = |
| | | new ReplServerFakeConfiguration(changelogPorts[i], "replicationServerTestReplicationServerConnectedDb"+i, replicationDbImplementation, |
| | | 0, changelogIds[i], 0, 100, servers); |
| | |
| | | Pair<Boolean, Record<Integer, Integer>> result = |
| | | reader.seekToRecord(key, GREATER_THAN_OR_EQUAL_TO_KEY, AFTER_MATCHING_KEY); |
| | | final long te = System.nanoTime() - ts; |
| | | if (te < minTime) minTime = te; |
| | | if (te > maxTime) maxTime = te; |
| | | if (te < minTime) |
| | | { |
| | | minTime = te; |
| | | } |
| | | if (te > maxTime) |
| | | { |
| | | maxTime = te; |
| | | } |
| | | // show time for seeks that last more than N microseconds (tune as needed) |
| | | if (te/1000 > 1000) |
| | | { |
| | |
| | | reader.positionToKey(0, val, GREATER_THAN_OR_EQUAL_TO_KEY, AFTER_MATCHING_KEY); |
| | | assertThat(result.getSecond()).isEqualTo(Record.from(val, val)); |
| | | long te = System.nanoTime() - ts; |
| | | if (te < minTime) minTime = te; |
| | | if (te > maxTime) maxTime = te; |
| | | if (te < minTime) |
| | | { |
| | | minTime = te; |
| | | } |
| | | if (te > maxTime) |
| | | { |
| | | maxTime = te; |
| | | } |
| | | } |
| | | System.out.println("Time taken: " + ((System.nanoTime() - t1)/1000000) + " milliseconds"); |
| | | System.out.println("Min time for a search: " + minTime/1000 + " microseconds"); |
| | |
| | | new CSN(looser1T2, 0, myId2), |
| | | new CSN(looser1T3, 0, myId3)); |
| | | if (looser1IsLocal) |
| | | { |
| | | ReplicationServer.onlyForTestsAddlocalReplicationServer(LOOSER1); |
| | | } |
| | | |
| | | // State for server 2 |
| | | ServerState aState2 = newServerState( |
| | |
| | | new CSN(winnerT2, 0, myId2), |
| | | new CSN(winnerT3, 0, myId3)); |
| | | if (winnerIsLocal) |
| | | { |
| | | ReplicationServer.onlyForTestsAddlocalReplicationServer(WINNER); |
| | | } |
| | | |
| | | // State for server 3 |
| | | ServerState aState3 = newServerState( |
| | |
| | | new CSN(looser2T2, 0, myId2), |
| | | new CSN(looser2T3, 0, myId3)); |
| | | if (looser2IsLocal) |
| | | { |
| | | ReplicationServer.onlyForTestsAddlocalReplicationServer(LOOSER2); |
| | | } |
| | | |
| | | Map<Integer, ReplicationServerInfo> rsInfos = newRSInfos( |
| | | newRSInfo(11, LOOSER1, aState1, 0, 1), |
| | |
| | | // State for server 1 |
| | | ServerState aState1 = newServerState(new CSN(looser1T1, 0, myId1)); |
| | | if (looser1IsLocal) |
| | | { |
| | | ReplicationServer.onlyForTestsAddlocalReplicationServer(LOOSER1); |
| | | } |
| | | |
| | | // State for server 2 |
| | | ServerState aState2 = newServerState(new CSN(winnerT1, 0, myId1)); |
| | | if (winnerIsLocal) |
| | | { |
| | | ReplicationServer.onlyForTestsAddlocalReplicationServer(WINNER); |
| | | } |
| | | |
| | | // State for server 3 |
| | | ServerState aState3 = newServerState(new CSN(looser2T1, 0, myId1)); |
| | | if (looser2IsLocal) |
| | | { |
| | | ReplicationServer.onlyForTestsAddlocalReplicationServer(LOOSER2); |
| | | } |
| | | |
| | | Map<Integer, ReplicationServerInfo> rsInfos = newRSInfos( |
| | | newRSInfo(11, LOOSER1, aState1, looser1GenId, looser1GroupId), |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.service; |
| | | |
| | |
| | | ERR_BACKEND_EXPORT_ENTRY.get("", "")); |
| | | } |
| | | if (ret>0) |
| | | { |
| | | importString.append(new String(buffer, 0, ret)); |
| | | } |
| | | } |
| | | while (ret >= 0); |
| | | } |
| | |
| | | public boolean processUpdate(UpdateMsg updateMsg) |
| | | { |
| | | if (queue != null) |
| | | { |
| | | queue.add(updateMsg); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.service; |
| | | |
| | |
| | | public boolean processUpdate(UpdateMsg updateMsg) |
| | | { |
| | | if (queue != null) |
| | | { |
| | | queue.add(updateMsg); |
| | | } |
| | | return true; |
| | | } |
| | | } |
| | |
| | | * Test the normalization and the approximate comparison. |
| | | */ |
| | | @Test(dataProvider= "acceptableValues") |
| | | public void testAcceptableValues(String value, Boolean result) |
| | | throws Exception |
| | | public void testAcceptableValues(String value, Boolean result) throws Exception |
| | | { |
| | | // Make sure that the specified class can be instantiated as a task. |
| | | |
| | |
| | | syntax.valueIsAcceptable(ByteString.valueOf(value), reason); |
| | | |
| | | if (liveResult != result) |
| | | fail(syntax + ".valueIsAcceptable gave bad result for " + value + |
| | | "reason : " + reason); |
| | | |
| | | { |
| | | fail(syntax + ".valueIsAcceptable gave bad result for " + value + " reason : " + reason); |
| | | } |
| | | } |
| | | } |
| | |
| | | syntax.valueIsAcceptable(byteStringValue, reason); |
| | | |
| | | if (liveResult != result) |
| | | fail(syntax + ".valueIsAcceptable gave bad result for " + value + |
| | | "reason : " + reason); |
| | | |
| | | { |
| | | fail(syntax + ".valueIsAcceptable gave bad result for " + value + " reason : " + reason); |
| | | } |
| | | } |
| | | } |