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

Gaetan Boismal
26.52.2015 f108c7ba5e5ec4c4d8dbedb48a58010a69de675b
OPENDJ-2468 Fix authrate tool

The tool was broken since d750ad39895.
Problem was that we tried to rebind with the bind request template in
the PerformanceRunner (see changes done in PerformanceRunner in
d750ad39895).
We do not want to rebind in authrate tool.
To fix that, a field bindRequestTemplate has been added to the
AuthRate.BindPerformanceRunner.
This prevent us to use the bindRequest needed by the other tool to
perform rebinds.
2 files modified
21 ■■■■■ changed files
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java 19 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties 2 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java
@@ -202,7 +202,7 @@
                    break;
                }
                final BindRequest bindRequest = getBindRequest();
                final BindRequest bindRequest = bindRequestTemplate;
                if (bindRequest instanceof SimpleBindRequest) {
                    final SimpleBindRequest o = (SimpleBindRequest) bindRequest;
                    if (br == null) {
@@ -317,12 +317,18 @@
        private DereferenceAliasesPolicy dereferencesAliasesPolicy;
        private String[] attributes;
        private int invalidCredPercent;
        /** Template of the bind requests which will be send to the remote server. */
        private BindRequest bindRequestTemplate;
        private BindPerformanceRunner(final PerformanceRunnerOptions options)
                throws ArgumentException {
            super(options);
        }
        private void setBindRequestTemplate(final BindRequest bindRequestTemplate) {
            this.bindRequestTemplate = bindRequestTemplate;
        }
        @Override
        WorkerThread newWorkerThread(final Connection connection,
                final ConnectionFactory connectionFactory) {
@@ -480,13 +486,12 @@
            }
            connectionFactory = connectionFactoryProvider.getUnauthenticatedConnectionFactory();
            runner.setBindRequest(connectionFactoryProvider.getBindRequest());
            runner.validate();
            if (runner.getBindRequest() == null) {
                throw new ArgumentException(LocalizableMessage
                        .raw("Authentication information must be provided to use this tool"));
            final BindRequest bindRequestTemplate = connectionFactoryProvider.getBindRequest();
            if (bindRequestTemplate == null) {
                throw new ArgumentException(ERR_AUTHRATE_NO_BIND_DN_PROVIDED.get());
            }
            runner.setBindRequestTemplate(bindRequestTemplate);
            runner.validate();
        } catch (final ArgumentException ae) {
            argParser.displayMessageAndUsageReference(getErrStream(), ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties
@@ -505,6 +505,8 @@
ERR_TOOL_ARG_NEEDED_WHEN_USING_ARG=%s must be used when using %s
ERR_TOOL_ARG_MUST_BE_USED_WHEN_ARG_CONDITION=%s must be used if %s is %s
INFO_TOOL_WARMING_UP=Warming up for %d seconds...
ERR_AUTHRATE_NO_BIND_DN_PROVIDED=Authentication information must be provided \
 to use this tool
 #
 # MakeLDIF tool
 #