opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java
@@ -201,7 +201,7 @@ default: final Random r = rng.get(); final int p = r.nextInt(100); useInvalidPassword = (p < invalidCredPercent); useInvalidPassword = p < invalidCredPercent; break; } @@ -501,11 +501,8 @@ the first trailing argument is considered the filter, the other as attributes.*/ runner.filter = filterAndAttributeStrings.remove(0); // The rest are attributes for (final String s : filterAndAttributeStrings) { attributes.add(s); } attributes.addAll(filterAndAttributeStrings); } runner.attributes = attributes.toArray(new String[attributes.size()]); runner.baseDN = baseDN.getValue(); @@ -526,7 +523,7 @@ String.format(runner.baseDN, data); } } catch (final Exception ex1) { errPrintln(LocalizableMessage.raw("Error formatting filter or base DN: " + ex1.toString())); errPrintln(LocalizableMessage.raw("Error formatting filter or base DN: " + ex1)); return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); } opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java
@@ -97,17 +97,13 @@ super(out, err); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public boolean isInteractive() { return false; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public boolean isVerbose() { return verbose.isPresent(); @@ -131,7 +127,7 @@ final Result r = ere.getResult(); errPrintln(ERR_TOOL_RESULT_CODE.get(r.getResultCode().intValue(), r.getResultCode() .toString())); if ((r.getDiagnosticMessage() != null) && (r.getDiagnosticMessage().length() > 0)) { if (r.getDiagnosticMessage() != null && r.getDiagnosticMessage().length() > 0) { errPrintln(LocalizableMessage.raw(r.getDiagnosticMessage())); } if (r.getMatchedDN() != null && r.getMatchedDN().length() > 0) { @@ -256,14 +252,11 @@ // First element should be an attribute string. final String attributeString = attrAndDNStrings.remove(0); // Rest are DN strings for (final String s : attrAndDNStrings) { dnStrings.add(s); } dnStrings.addAll(attrAndDNStrings); // If no DNs were provided, then exit with an error. if (dnStrings.isEmpty() && (!filename.isPresent())) { if (dnStrings.isEmpty() && !filename.isPresent()) { errPrintln(ERR_LDAPCOMPARE_NO_DNS.get()); return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); } opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
@@ -160,7 +160,7 @@ errPrintln(msg); errPrintln(ERR_TOOL_RESULT_CODE.get(r.getResultCode().intValue(), r.getResultCode() .toString())); if ((r.getDiagnosticMessage() != null) && (r.getDiagnosticMessage().length() > 0)) { if (r.getDiagnosticMessage() != null && r.getDiagnosticMessage().length() > 0) { errPrintln(LocalizableMessage.raw(r.getDiagnosticMessage())); } if (r.getMatchedDN() != null && r.getMatchedDN().length() > 0) { @@ -169,7 +169,7 @@ } else { final LocalizableMessage msg = INFO_OPERATION_SUCCESSFUL.get(operationType, name); println(msg); if ((r.getDiagnosticMessage() != null) && (r.getDiagnosticMessage().length() > 0)) { if (r.getDiagnosticMessage() != null && r.getDiagnosticMessage().length() > 0) { errPrintln(LocalizableMessage.raw(r.getDiagnosticMessage())); } if (r.getReferralURIs() != null) { @@ -233,17 +233,13 @@ // Nothing to do. } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public boolean isInteractive() { return false; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public boolean isVerbose() { return verbose.isPresent(); opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
@@ -83,17 +83,13 @@ // Nothing to do. } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public boolean isInteractive() { return false; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public boolean isVerbose() { return verbose.isPresent(); @@ -279,7 +275,7 @@ errPrintln(message); final String errorMessage = e.getResult().getDiagnosticMessage(); if ((errorMessage != null) && (errorMessage.length() > 0)) { if (errorMessage != null && errorMessage.length() > 0) { message = ERR_LDAPPWMOD_FAILURE_ERROR_MESSAGE.get(errorMessage); errPrintln(message); } @@ -292,21 +288,16 @@ return e.getResult().getResultCode().intValue(); } LocalizableMessage message = INFO_LDAPPWMOD_SUCCESSFUL.get(); println(message); println(INFO_LDAPPWMOD_SUCCESSFUL.get()); final String additionalInfo = result.getDiagnosticMessage(); if ((additionalInfo != null) && (additionalInfo.length() > 0)) { message = INFO_LDAPPWMOD_ADDITIONAL_INFO.get(additionalInfo); println(message); if (additionalInfo != null && additionalInfo.length() > 0) { println(INFO_LDAPPWMOD_ADDITIONAL_INFO.get(additionalInfo)); } if (result.getGeneratedPassword() != null) { message = INFO_LDAPPWMOD_GENERATED_PASSWORD.get(ByteString.valueOf( result.getGeneratedPassword()).toString()); println(message); println(INFO_LDAPPWMOD_GENERATED_PASSWORD.get(ByteString.valueOf( result.getGeneratedPassword()).toString())); } return 0; opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
@@ -94,7 +94,7 @@ */ public final class LDAPSearch extends ConsoleApplication { private class LDAPSearchResultHandler implements SearchResultHandler { private int entryCount = 0; private int entryCount; /** {@inheritDoc} */ public boolean handleEntry(final SearchResultEntry entry) { @@ -474,9 +474,7 @@ } } // The rest are attributes for (final String s : filterAndAttributeStrings) { attributes.add(s); } attributes.addAll(filterAndAttributeStrings); } if (filename.isPresent()) { @@ -487,7 +485,7 @@ String line = null; while ((line = in.readLine()) != null) { if (line.trim().equals("")) { if ("".equals(line.trim())) { // ignore empty lines. continue; } @@ -614,7 +612,7 @@ return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); } else { final String token = tokenizer.nextToken(); if (!token.equals("ps")) { if (!"ps".equals(token)) { final LocalizableMessage message = ERR_PSEARCH_DOESNT_START_WITH_PS.get(String.valueOf(infoString)); errPrintln(message); @@ -634,16 +632,16 @@ } else { do { final String token = st.nextToken(); if (token.equals("add")) { if ("add".equals(token)) { ct.add(PersistentSearchChangeType.ADD); } else if (token.equals("delete") || token.equals("del")) { } else if ("delete".equals(token) || "del".equals(token)) { ct.add(PersistentSearchChangeType.DELETE); } else if (token.equals("modify") || token.equals("mod")) { } else if ("modify".equals(token) || "mod".equals(token)) { ct.add(PersistentSearchChangeType.MODIFY); } else if (token.equals("modifydn") || token.equals("moddn") || token.equals("modrdn")) { } else if ("modifydn".equals(token) || "moddn".equals(token) || "modrdn".equals(token)) { ct.add(PersistentSearchChangeType.MODIFY_DN); } else if (token.equals("any") || token.equals("all")) { } else if ("any".equals(token) || "all".equals(token)) { ct.add(PersistentSearchChangeType.ADD); ct.add(PersistentSearchChangeType.DELETE); ct.add(PersistentSearchChangeType.MODIFY); @@ -660,9 +658,9 @@ if (tokenizer.hasMoreTokens()) { final String token = tokenizer.nextToken(); if (token.equals("1") || token.equals("true") || token.equals("yes")) { if ("1".equals(token) || "true".equals(token) || "yes".equals(token)) { changesOnly = true; } else if (token.equals("0") || token.equals("false") || token.equals("no")) { } else if ("0".equals(token) || "false".equals(token) || "no".equals(token)) { changesOnly = false; } else { final LocalizableMessage message = @@ -674,9 +672,9 @@ if (tokenizer.hasMoreTokens()) { final String token = tokenizer.nextToken(); if (token.equals("1") || token.equals("true") || token.equals("yes")) { if ("1".equals(token) || "true".equals(token) || "yes".equals(token)) { returnECs = true; } else if (token.equals("0") || token.equals("false") || token.equals("no")) { } else if ("0".equals(token) || "false".equals(token) || "no".equals(token)) { returnECs = false; } else { final LocalizableMessage message = @@ -850,12 +848,9 @@ final ServerSideSortResponseControl control = result.getControl(ServerSideSortResponseControl.DECODER, new DecodeOptions()); if (control != null) { if (control.getResult() != ResultCode.SUCCESS) { final LocalizableMessage msg = WARN_LDAPSEARCH_SORT_ERROR.get(control.getResult().toString()); println(msg); } if (control != null && control.getResult() != ResultCode.SUCCESS) { println(WARN_LDAPSEARCH_SORT_ERROR.get(control.getResult().toString())); } } catch (final DecodeException e) { errPrintln(ERR_DECODE_CONTROL_FAILURE.get(e.getLocalizedMessage())); @@ -888,24 +883,20 @@ SimplePagedResultsControl control = result.getControl(SimplePagedResultsControl.DECODER, new DecodeOptions()); if (control != null) { if (control.getCookie().length() > 0) { if (control != null && control.getCookie().length() > 0) { if (!isQuiet()) { pressReturnToContinue(); } final Iterator<Control> iterator = search.getControls().iterator(); while (iterator.hasNext()) { if (iterator.next().getOID().equals(SimplePagedResultsControl.OID)) { if (SimplePagedResultsControl.OID.equals(iterator.next().getOID())) { iterator.remove(); } } control = SimplePagedResultsControl.newControl(true, pageSize, control .getCookie()); control = SimplePagedResultsControl.newControl(true, pageSize, control.getCookie()); search.addControl(control); continue; } } } catch (final DecodeException e) { errPrintln(ERR_DECODE_CONTROL_FAILURE.get(e.getLocalizedMessage())); } @@ -913,8 +904,8 @@ errPrintln(); errPrintln(ERR_TOOL_RESULT_CODE.get(result.getResultCode().intValue(), result .getResultCode().toString())); if ((result.getDiagnosticMessage() != null) && (result.getDiagnosticMessage().length() > 0)) { if (result.getDiagnosticMessage() != null && result.getDiagnosticMessage().length() > 0) { errPrintln(LocalizableMessage.raw(result.getDiagnosticMessage())); } if (result.getMatchedDN() != null && result.getMatchedDN().length() > 0) { opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFDiff.java
@@ -130,7 +130,7 @@ try { // First source file. final List<String> trailingArguments = argParser.getTrailingArguments(); if (!trailingArguments.get(0).equals("-")) { if (!"-".equals(trailingArguments.get(0))) { try { sourceInputStream = new FileInputStream(trailingArguments.get(0)); } catch (final FileNotFoundException e) { @@ -143,7 +143,7 @@ } // Patch file. if (!trailingArguments.get(1).equals("-")) { if (!"-".equals(trailingArguments.get(1))) { try { targetInputStream = new FileInputStream(trailingArguments.get(1)); } catch (final FileNotFoundException e) { @@ -156,7 +156,7 @@ } // Output file. if (outputFilename.isPresent() && !outputFilename.getValue().equals("-")) { if (outputFilename.isPresent() && !"-".equals(outputFilename.getValue())) { try { outputStream = new FileOutputStream(outputFilename.getValue()); } catch (final FileNotFoundException e) { opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFModify.java
@@ -141,7 +141,7 @@ try { // First source file. final List<String> trailingArguments = argParser.getTrailingArguments(); if (!trailingArguments.get(0).equals("-")) { if (!"-".equals(trailingArguments.get(0))) { try { sourceInputStream = new FileInputStream(trailingArguments.get(0)); } catch (final FileNotFoundException e) { @@ -154,7 +154,7 @@ } // Patch file. if (trailingArguments.size() > 1 && !trailingArguments.get(1).equals("-")) { if (trailingArguments.size() > 1 && !"-".equals(trailingArguments.get(1))) { try { changesInputStream = new FileInputStream(trailingArguments.get(1)); } catch (final FileNotFoundException e) { @@ -167,7 +167,7 @@ } // Output file. if (outputFilename.isPresent() && !outputFilename.getValue().equals("-")) { if (outputFilename.isPresent() && !"-".equals(outputFilename.getValue())) { try { outputStream = new FileOutputStream(outputFilename.getValue()); } catch (final FileNotFoundException e) { opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFSearch.java
@@ -194,9 +194,7 @@ } } // The rest are attributes for (final String s : filterAndAttributeStrings) { attributes.add(s); } attributes.addAll(filterAndAttributeStrings); } if (filename.isPresent()) { @@ -207,12 +205,11 @@ String line = null; while ((line = in.readLine()) != null) { if (line.trim().equals("")) { if ("".equals(line.trim())) { // ignore empty lines. continue; } final Filter ldapFilter = Filter.valueOf(line); filters.add(ldapFilter); filters.add(Filter.valueOf(line)); } } catch (final LocalizedIllegalArgumentException e) { errPrintln(e.getMessageObject()); @@ -254,7 +251,7 @@ try { // First source file. if (!trailingArguments.get(0).equals("-")) { if (!"-".equals(trailingArguments.get(0))) { try { sourceInputStream = new FileInputStream(trailingArguments.get(0)); } catch (final FileNotFoundException e) { @@ -267,7 +264,7 @@ } // Output file. if (outputFilename.isPresent() && !outputFilename.getValue().equals("-")) { if (outputFilename.isPresent() && !"-".equals(outputFilename.getValue())) { try { outputStream = new FileOutputStream(outputFilename.getValue()); } catch (final FileNotFoundException e) { opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MakeLDIF.java
@@ -203,12 +203,11 @@ } } if (constants.isPresent()) { if (!addConstantsToGenerator(constants, generator, app)) { if (constants.isPresent() && !addConstantsToGenerator(constants, generator, app)) { generator.close(); return null; } } // Force initialization of generator try { @@ -273,7 +272,7 @@ // nothing to do } // To allow tests /** To allow tests. */ MakeLDIF(PrintStream out, PrintStream err) { super(out, err); } opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ModRate.java
@@ -243,7 +243,7 @@ } String.format(runner.baseDN, data); } catch (final Exception ex1) { errPrintln(LocalizableMessage.raw("Error formatting filter or base DN: " + ex1.toString())); errPrintln(LocalizableMessage.raw("Error formatting filter or base DN: " + ex1)); return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); } opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PerformanceRunner.java
@@ -24,7 +24,6 @@ * Copyright 2010 Sun Microsystems, Inc. * Portions copyright 2011-2014 ForgeRock AS. */ package com.forgerock.opendj.ldap.tools; import static org.forgerock.util.Utils.closeSilently; @@ -420,7 +419,7 @@ Connection connection; final double targetTimeInMS = (1000.0 / (targetThroughput / (double) (numThreads * numConnections))); 1000.0 / (targetThroughput / (double) (numThreads * numConnections)); double sleepTimeInMS = 0; long start; while (!stopRequested && !(maxIterations > 0 && count >= maxIterations)) { @@ -629,11 +628,9 @@ private final ConsoleApplication app; private DataSource[] dataSourcePrototypes; // Thread local copies of the data sources /** Thread local copies of the data sources. */ private final ThreadLocal<DataSource[]> dataSources = new ThreadLocal<DataSource[]>() { /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override protected DataSource[] initialValue() { final DataSource[] prototypes = getDataSources(); opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/SearchRate.java
@@ -183,25 +183,19 @@ // Nothing to do. } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public boolean isInteractive() { return false; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public boolean isScriptFriendly() { return scriptFriendly.isPresent(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public boolean isVerbose() { return verbose.isPresent(); @@ -302,9 +296,7 @@ the first trailing argument is considered the filter, the other as attributes.*/ runner.filter = filterAndAttributeStrings.remove(0); // The rest are attributes for (final String s : filterAndAttributeStrings) { attributes.add(s); } attributes.addAll(filterAndAttributeStrings); } runner.attributes = attributes.toArray(new String[attributes.size()]); runner.baseDN = baseDN.getValue(); @@ -323,7 +315,7 @@ String.format(runner.filter, data); String.format(runner.baseDN, data); } catch (final Exception ex1) { errPrintln(LocalizableMessage.raw("Error formatting filter or base DN: " + ex1.toString())); errPrintln(LocalizableMessage.raw("Error formatting filter or base DN: " + ex1)); return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue(); } opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/Utils.java
@@ -87,25 +87,25 @@ } final String lowerOID = StaticUtils.toLowerCase(controlOID); if (lowerOID.equals("accountusable") || lowerOID.equals("accountusability")) { if ("accountusable".equals(lowerOID) || "accountusability".equals(lowerOID)) { controlOID = AccountUsabilityRequestControl.OID; } else if (lowerOID.equals("authzid") || lowerOID.equals("authorizationidentity")) { } else if ("authzid".equals(lowerOID) || "authorizationidentity".equals(lowerOID)) { controlOID = AuthorizationIdentityRequestControl.OID; } else if (lowerOID.equals("noop") || lowerOID.equals("no-op")) { } else if ("noop".equals(lowerOID) || "no-op".equals(lowerOID)) { // controlOID = OID_LDAP_NOOP_OPENLDAP_ASSIGNED; } else if (lowerOID.equals("subentries")) { } else if ("subentries".equals(lowerOID)) { // controlOID = OID_LDAP_SUBENTRIES; } else if (lowerOID.equals("managedsait")) { } else if ("managedsait".equals(lowerOID)) { // controlOID = OID_MANAGE_DSAIT_CONTROL; } else if (lowerOID.equals("pwpolicy") || lowerOID.equals("passwordpolicy")) { } else if ("pwpolicy".equals(lowerOID) || "passwordpolicy".equals(lowerOID)) { controlOID = PasswordPolicyRequestControl.OID; } else if (lowerOID.equals("subtreedelete") || lowerOID.equals("treedelete")) { } else if ("subtreedelete".equals(lowerOID) || "treedelete".equals(lowerOID)) { controlOID = SubtreeDeleteRequestControl.OID; } else if (lowerOID.equals("realattrsonly") || lowerOID.equals("realattributesonly")) { } else if ("realattrsonly".equals(lowerOID) || "realattributesonly".equals(lowerOID)) { // controlOID = OID_REAL_ATTRS_ONLY; } else if (lowerOID.equals("virtualattrsonly") || lowerOID.equals("virtualattributesonly")) { } else if ("virtualattrsonly".equals(lowerOID) || "virtualattributesonly".equals(lowerOID)) { // controlOID = OID_VIRTUAL_ATTRS_ONLY; } else if (lowerOID.equals("effectiverights") || lowerOID.equals("geteffectiverights")) { } else if ("effectiverights".equals(lowerOID) || "geteffectiverights".equals(lowerOID)) { controlOID = GetEffectiveRightsRequestControl.OID; } @@ -117,9 +117,9 @@ idx = remainder.indexOf(":"); if (idx == -1) { if (remainder.equalsIgnoreCase("true")) { if ("true".equalsIgnoreCase(remainder)) { controlCriticality = true; } else if (remainder.equalsIgnoreCase("false")) { } else if ("false".equalsIgnoreCase(remainder)) { controlCriticality = false; } else { // TODO: I18N @@ -131,9 +131,9 @@ } final String critical = remainder.substring(0, idx); if (critical.equalsIgnoreCase("true")) { if ("true".equalsIgnoreCase(critical)) { controlCriticality = true; } else if (critical.equalsIgnoreCase("false")) { } else if ("false".equalsIgnoreCase(critical)) { controlCriticality = false; } else { // TODO: I18N @@ -180,8 +180,8 @@ .getResult().getResultCode().toString())); } if ((ere.getResult().getDiagnosticMessage() != null) && (ere.getResult().getDiagnosticMessage().length() > 0)) { if (ere.getResult().getDiagnosticMessage() != null && ere.getResult().getDiagnosticMessage().length() > 0) { app.errPrintln(ERR_TOOL_ERROR_MESSAGE.get(ere.getResult().getDiagnosticMessage())); } @@ -294,7 +294,7 @@ } } // Prevent instantiation. /** Prevent instantiation. */ private Utils() { // Do nothing. }