From f108c7ba5e5ec4c4d8dbedb48a58010a69de675b Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Thu, 26 Nov 2015 17:52:22 +0000
Subject: [PATCH] OPENDJ-2468 Fix authrate tool
---
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java | 19 ++++++++++++-------
opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties | 2 ++
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java b/opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java
index bf0f3fb..47c3ded 100644
--- a/opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java
+++ b/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();
diff --git a/opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties b/opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties
index 4e849e1..827f83f 100755
--- a/opendj-sdk/opendj-ldap-toolkit/src/main/resources/com/forgerock/opendj/ldap/tools/tools.properties
+++ b/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
#
--
Gitblit v1.10.0