From d48666a047490384cdbebdcbc7d02acfb60b4c62 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Thu, 03 Apr 2014 15:21:56 +0000
Subject: [PATCH] Checkpoint for OPENDJ-1303 "opendj-cli" - Moved AuthenticatedConnectionFactory from tools to cli. -- Undo modifications on tools about abstract authenticated connection factory. (and deleted the file) -- Deleted the file from the tools. - Added functions to opendj-cli Utils. - Trivial code cleanup.
---
opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java | 46 ++++++++++++++++++++++++++++++++++------------
1 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java
index be4754b..0709410 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java
@@ -47,7 +47,6 @@
import javax.net.ssl.X509TrustManager;
import org.forgerock.i18n.LocalizableMessage;
-
import org.forgerock.opendj.ldap.ConnectionFactory;
import org.forgerock.opendj.ldap.KeyManagers;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
@@ -67,7 +66,7 @@
/**
* A connection factory designed for use with command line tools.
*/
-public class ConnectionFactoryProvider extends AbstractAuthenticatedConnectionFactory {
+public class ConnectionFactoryProvider {
/**
* The Logger.
*/
@@ -312,11 +311,41 @@
}
/**
- * Returns the connection factory.
+ * Returns the host name.
+ *
+ * @return The host name value.
+ */
+ public String getHostname() {
+ if (hostNameArg.isPresent()) {
+ return hostNameArg.getValue();
+ }
+ return hostNameArg.getDefaultValue();
+ }
+
+ /**
+ * Get the port which has to be used for the command.
+ *
+ * @return The port specified by the command line argument, or the default value, if not specified.
+ */
+ public int getPort() {
+ if (portArg.isPresent()) {
+ try {
+ return portArg.getIntValue();
+ } catch (ArgumentException e) {
+ return Integer.valueOf(portArg.getDefaultValue());
+ }
+ }
+ return Integer.valueOf(portArg.getDefaultValue());
+ }
+
+ /**
+ * Checks if any conflicting arguments are present, build the connection with
+ * selected arguments and returns the connection factory.
*
* @return The connection factory.
* @throws ArgumentException
- * If an error occurs during the parsing of the arguments.
+ * If an error occurs during the parsing of the arguments. (conflicting
+ * arguments or if an error occurs during building SSL context).
*/
public ConnectionFactory getConnectionFactory() throws ArgumentException {
if (connFactory == null) {
@@ -437,7 +466,7 @@
authenticatedConnFactory = getConnectionFactory();
final BindRequest bindRequest = getBindRequest();
if (bindRequest != null) {
- authenticatedConnFactory = newAuthenticatedConnectionFactory(authenticatedConnFactory, bindRequest);
+ authenticatedConnFactory = new AuthenticatedConnectionFactory(authenticatedConnFactory, bindRequest);
}
}
return authenticatedConnFactory;
@@ -771,11 +800,4 @@
return option.substring(equalPos + 1, option.length());
}
-
- /** {@inheritDoc} */
- @Override
- public ConnectionFactory newAuthenticatedConnectionFactory(final ConnectionFactory connection,
- final BindRequest request) throws ArgumentException {
- return null;
- }
}
--
Gitblit v1.10.0