mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
25.01.2016 22928337852f0af9e8b716ce5ba73c93dc28949d
OPENDJ-2772 Remove ignored ldapVersion argument

When this parameter was provided in the tools, we checked that the
protocol version was 2 or 3 but we did not do anything else (the ldap
bind is done in protocol v3).
This commit removes the -V, --ldapVersion argument which is useless and
could even be misleading for a user.
9 files modified
72 ■■■■■ changed files
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java 5 ●●●●● patch | view | raw | blame | history
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java 3 ●●●● patch | view | raw | blame | history
opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java 16 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java 7 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPDelete.java 9 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java 7 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java 7 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java 7 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/Utils.java 11 ●●●●● patch | view | raw | blame | history
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java
@@ -207,11 +207,6 @@
     */
    public static final String OPTION_LONG_EFFECTIVERIGHTSATTR = "getEffectiveRightsAttribute";
    /** The value for the short option protocol version attributes. */
    public static final char OPTION_SHORT_PROTOCOL_VERSION = 'V';
    /** The value for the long option protocol version attribute. */
    public static final String OPTION_LONG_PROTOCOL_VERSION = "ldapVersion";
    /** The value for the long option version. */
    public static final char OPTION_SHORT_PRODUCT_VERSION = 'V';
    /** The value for the long option version. */
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
@@ -1473,8 +1473,7 @@
                            || OPTION_LONG_ADMIN_UID.equals(longId)
                            || OPTION_LONG_REPORT_AUTHZ_ID.equals(longId)
                            || OPTION_LONG_USE_PW_POLICY_CTL.equals(longId)
                            || OPTION_LONG_USE_SASL_EXTERNAL.equals(longId)
                            || OPTION_LONG_PROTOCOL_VERSION.equals(longId);
                            || OPTION_LONG_USE_SASL_EXTERNAL.equals(longId);
        }
        return false;
    }
opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
@@ -160,22 +160,6 @@
    }
    /**
     * Returns the "ldapVersion" integer argument.
     *
     * @return The "ldapVersion" argument.
     * @throws ArgumentException
     *             If there is a problem with any of the parameters used to create this argument.
     */
    public static IntegerArgument ldapVersionArgument() throws ArgumentException {
        return IntegerArgument.builder(OPTION_LONG_PROTOCOL_VERSION)
                .shortIdentifier(OPTION_SHORT_PROTOCOL_VERSION)
                .description(INFO_DESCRIPTION_VERSION.get())
                .defaultValue(3)
                .valuePlaceholder(INFO_PROTOCOL_VERSION_PLACEHOLDER.get())
                .buildArgument();
    }
    /**
     * Returns the "quiet" boolean argument.
     *
     * @return The "quiet" argument.
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java
@@ -25,7 +25,6 @@
import static com.forgerock.opendj.ldap.tools.Utils.addControlsToRequest;
import static com.forgerock.opendj.ldap.tools.Utils.printErrorMessage;
import static com.forgerock.opendj.ldap.tools.Utils.readAssertionControl;
import static com.forgerock.opendj.ldap.tools.Utils.ensureLdapProtocolVersionIsSupported;
import static com.forgerock.opendj.ldap.tools.Utils.getConnection;
import static com.forgerock.opendj.cli.CommonArguments.*;
@@ -48,7 +47,6 @@
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.ConnectionFactoryProvider;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
/** A tool that can be used to issue Compare requests to the Directory Server. */
@@ -118,7 +116,6 @@
        BooleanArgument dryRun;
        BooleanArgument showUsage;
        IntegerArgument ldapProtocolVersion;
        StringArgument assertionFilter;
        StringArgument controlStr;
        StringArgument proxyAuthzID;
@@ -154,9 +151,6 @@
            controlStr = controlArgument();
            argParser.addArgument(controlStr);
            ldapProtocolVersion = ldapVersionArgument();
            argParser.addArgument(ldapProtocolVersion);
            dryRun = noOpArgument();
            argParser.addArgument(dryRun);
@@ -177,7 +171,6 @@
        if (argParser.usageOrVersionDisplayed()) {
            return ResultCode.SUCCESS.intValue();
        }
        ensureLdapProtocolVersionIsSupported(ldapProtocolVersion);
        final List<String> trailingArguments = argParser.getTrailingArguments();
        final String attribute = trailingArguments.get(0);
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPDelete.java
@@ -19,7 +19,6 @@
import static com.forgerock.opendj.cli.ArgumentConstants.USE_SYSTEM_STREAM_TOKEN;
import static com.forgerock.opendj.cli.CommonArguments.continueOnErrorArgument;
import static com.forgerock.opendj.cli.CommonArguments.controlArgument;
import static com.forgerock.opendj.cli.CommonArguments.ldapVersionArgument;
import static com.forgerock.opendj.cli.CommonArguments.noOpArgument;
import static com.forgerock.opendj.ldap.tools.LDAPToolException.newToolException;
import static com.forgerock.opendj.ldap.tools.LDAPToolException.newToolParamException;
@@ -31,7 +30,6 @@
import static com.forgerock.opendj.cli.ToolVersionHandler.newSdkVersionHandler;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import static com.forgerock.opendj.ldap.tools.Utils.addControlsToRequest;
import static com.forgerock.opendj.ldap.tools.Utils.ensureLdapProtocolVersionIsSupported;
import static com.forgerock.opendj.ldap.tools.Utils.getConnection;
import static com.forgerock.opendj.ldap.tools.Utils.printErrorMessage;
import static com.forgerock.opendj.ldap.tools.Utils.printSuccessMessage;
@@ -42,7 +40,6 @@
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.ConnectionFactoryProvider;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.Connection;
@@ -131,7 +128,6 @@
        final BooleanArgument deleteSubtree;
        final BooleanArgument dryRun;
        final BooleanArgument showUsage;
        final IntegerArgument ldapProtocolVersion;
        final StringArgument controlStr;
        final StringArgument propertiesFileArgument;
        final BooleanArgument noPropertiesFileArgument;
@@ -159,9 +155,6 @@
            controlStr = controlArgument();
            argParser.addArgument(controlStr);
            ldapProtocolVersion = ldapVersionArgument();
            argParser.addArgument(ldapProtocolVersion);
            dryRun = noOpArgument();
            argParser.addArgument(dryRun);
@@ -175,12 +168,10 @@
            throw newToolParamException(ae, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
        }
        argParser.parseArguments(args, getErrStream(), connectionFactoryProvider);
        if (argParser.usageOrVersionDisplayed()) {
            return ResultCode.SUCCESS.intValue();
        }
        ensureLdapProtocolVersionIsSupported(ldapProtocolVersion);
        final List<Control> controls = readControls(controlStr);
        if (deleteSubtree.isPresent()) {
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
@@ -26,7 +26,6 @@
import static com.forgerock.opendj.ldap.tools.Utils.printSuccessMessage;
import static com.forgerock.opendj.ldap.tools.Utils.readAssertionControl;
import static com.forgerock.opendj.ldap.tools.Utils.readControls;
import static com.forgerock.opendj.ldap.tools.Utils.ensureLdapProtocolVersionIsSupported;
import static com.forgerock.opendj.ldap.tools.Utils.printErrorMessage;
import static com.forgerock.opendj.cli.CommonArguments.*;
@@ -68,7 +67,6 @@
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.ConnectionFactoryProvider;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
/**
@@ -271,7 +269,6 @@
        BooleanArgument continueOnError;
        BooleanArgument noop;
        BooleanArgument showUsage;
        IntegerArgument ldapProtocolVersion;
        StringArgument assertionFilter;
        StringArgument controlStr;
        StringArgument filename;
@@ -325,9 +322,6 @@
            controlStr = controlArgument();
            argParser.addArgument(controlStr);
            ldapProtocolVersion = ldapVersionArgument();
            argParser.addArgument(ldapProtocolVersion);
            continueOnError = continueOnErrorArgument();
            argParser.addArgument(continueOnError);
@@ -349,7 +343,6 @@
        if (argParser.usageOrVersionDisplayed()) {
            return ResultCode.SUCCESS.intValue();
        }
        ensureLdapProtocolVersionIsSupported(ldapProtocolVersion);
        controls = readControls(controlStr);
        if (proxyAuthzID.isPresent()) {
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
@@ -24,7 +24,6 @@
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import static com.forgerock.opendj.cli.CommonArguments.*;
import static com.forgerock.opendj.ldap.tools.Utils.addControlsToRequest;
import static com.forgerock.opendj.ldap.tools.Utils.ensureLdapProtocolVersionIsSupported;
import static com.forgerock.opendj.ldap.tools.Utils.printErrorMessage;
import static com.forgerock.opendj.ldap.tools.Utils.readControls;
@@ -44,7 +43,6 @@
import com.forgerock.opendj.cli.ConnectionFactoryProvider;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.FileBasedArgument;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
/**
@@ -126,7 +124,6 @@
        FileBasedArgument currentPWFile;
        FileBasedArgument newPWFile;
        BooleanArgument showUsage;
        IntegerArgument ldapProtocolVersion;
        StringArgument currentPW;
        StringArgument controlStr;
        StringArgument newPW;
@@ -178,9 +175,6 @@
            controlStr = controlArgument();
            argParser.addArgument(controlStr);
            ldapProtocolVersion = ldapVersionArgument();
            argParser.addArgument(ldapProtocolVersion);
            verbose = verboseArgument();
            argParser.addArgument(verbose);
@@ -196,7 +190,6 @@
        if (argParser.usageOrVersionDisplayed()) {
            return ResultCode.SUCCESS.intValue();
        }
        ensureLdapProtocolVersionIsSupported(ldapProtocolVersion);
        final PasswordModifyExtendedRequest request = Requests.newPasswordModifyExtendedRequest();
        addControlsToRequest(request, readControls(controlStr));
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
@@ -74,7 +74,6 @@
import static com.forgerock.opendj.cli.ToolVersionHandler.newSdkVersionHandler;
import static com.forgerock.opendj.ldap.tools.LDAPToolException.newToolParamException;
import static com.forgerock.opendj.ldap.tools.Utils.addControlsToRequest;
import static com.forgerock.opendj.ldap.tools.Utils.ensureLdapProtocolVersionIsSupported;
import static com.forgerock.opendj.ldap.tools.Utils.computeWrapColumn;
import static com.forgerock.opendj.ldap.tools.Utils.printErrorMessage;
import static com.forgerock.opendj.ldap.tools.Utils.printPasswordPolicyResults;
@@ -242,7 +241,6 @@
        BooleanArgument typesOnly;
        IntegerArgument simplePageSize;
        IntegerArgument timeLimit;
        IntegerArgument ldapProtocolVersion;
        StringArgument baseDN;
        StringArgument controlStr;
        MultiChoiceArgument<DereferenceAliasesPolicy> dereferencePolicy;
@@ -340,10 +338,6 @@
                            .multiValued()
                            .valuePlaceholder(INFO_ATTRIBUTE_PLACEHOLDER.get())
                            .buildAndAddToParser(argParser);
            ldapProtocolVersion = ldapVersionArgument();
            argParser.addArgument(ldapProtocolVersion);
            dereferencePolicy =
                    MultiChoiceArgument.<DereferenceAliasesPolicy>builder("dereferencePolicy")
                            .shortIdentifier('a')
@@ -419,7 +413,6 @@
                                                      scope,
                                                      filter,
                                                      attributes.toArray(new String[attributes.size()]));
            ensureLdapProtocolVersionIsSupported(ldapProtocolVersion);
        } catch (final LocalizedIllegalArgumentException e) {
            errPrintln(e.getMessageObject());
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/Utils.java
@@ -297,17 +297,6 @@
        return filesLines;
    }
    static void ensureLdapProtocolVersionIsSupported(final IntegerArgument version) throws LDAPToolException {
        try {
            final int versionNumber = version.getIntValue();
            if (versionNumber != 2 && versionNumber != 3) {
                throw newToolParamException(ERR_DESCRIPTION_INVALID_VERSION.get(String.valueOf(versionNumber)));
            }
        } catch (final ArgumentException e) {
            throw newToolParamException(e, ERR_DESCRIPTION_INVALID_VERSION.get(String.valueOf(version.getValue())));
        }
    }
    static void addControlsToRequest(final Request request, final List<Control> controls) throws LDAPToolException {
        for (final Control control : controls) {
            request.addControl(control);