From 16bdb19cdda5201d272cd6ca5bf876c88493327c Mon Sep 17 00:00:00 2001
From: Fabio Pistolesi <fabio.pistolesi@forgerock.com>
Date: Mon, 14 Sep 2015 09:32:51 +0000
Subject: [PATCH] OPENDJ-1654 LDAPOptions should be converted in a SchemaOptions style API

---
 opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java                |   30 
 opendj-core/clirr-ignored-api-changes.xml                                                           |   23 
 opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java                    |   11 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicTransportProvider.java                 |   13 
 opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPListener.java                  |   20 
 opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPReaderWriterTestCase.java      |    8 
 opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java                     |    6 
 opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactory.java         |   54 +-
 opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactoryTestCase.java |   16 
 opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Server.java                    |    6 
 opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java                      |   97 +++-
 opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicLDAPListener.java                      |    7 
 opendj-core/src/test/java/org/forgerock/opendj/io/LDAPReaderWriterTestCase.java                     |    7 
 opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/ConnectionFactoryTestCase.java            |   21 
 opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnection.java                |   11 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicLDAPConnectionFactory.java             |   16 
 opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/RewriterProxy.java             |   10 
 opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPListenerTestCase.java          |   16 
 opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPServerFilter.java                     |    7 
 opendj-core/src/main/java/org/forgerock/opendj/ldap/CommonLDAPOptions.java                          |  253 +-----------
 opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuthAsync.java           |   29 
 opendj-core/src/test/java/org/forgerock/opendj/ldap/LDAPServer.java                                 |    7 
 opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyUtils.java                         |   13 
 opendj-core/src/main/java/org/forgerock/opendj/ldap/spi/TransportProvider.java                      |    9 
 /dev/null                                                                                           |  311 ----------------
 opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java                    |   14 
 opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java                        |   14 
 opendj-grizzly/src/main/java/com/forgerock/opendj/grizzly/GrizzlyTransportProvider.java             |    7 
 opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPClientFilter.java                     |    5 
 opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/PasswordResetForAD.java        |   17 
 opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionTestCase.java        |    8 
 opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java                  |   16 
 opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPListener.java                               |   43 +
 33 files changed, 357 insertions(+), 768 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 99611dd..33dca1b 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
@@ -30,6 +30,7 @@
 import static com.forgerock.opendj.cli.CliMessages.*;
 import static com.forgerock.opendj.cli.CliConstants.DEFAULT_LDAP_PORT;
 import static com.forgerock.opendj.cli.Utils.getHostNameForLdapUrl;
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -52,7 +53,6 @@
 import org.forgerock.opendj.ldap.ConnectionFactory;
 import org.forgerock.opendj.ldap.KeyManagers;
 import org.forgerock.opendj.ldap.LDAPConnectionFactory;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.SSLContextBuilder;
 import org.forgerock.opendj.ldap.TrustManagers;
 import org.forgerock.opendj.ldap.controls.AuthorizationIdentityRequestControl;
@@ -64,6 +64,7 @@
 import org.forgerock.opendj.ldap.requests.GSSAPISASLBindRequest;
 import org.forgerock.opendj.ldap.requests.PlainSASLBindRequest;
 import org.forgerock.opendj.ldap.requests.Requests;
+import org.forgerock.util.Options;
 
 /**
  * A connection factory designed for use with command line tools.
@@ -413,12 +414,14 @@
                         e);
             }
 
-            LDAPOptions options = new LDAPOptions();
+            Options options = Options.defaultOptions();
 
             if (sslContext != null) {
-                options.setSSLContext(sslContext).setUseStartTLS(useStartTLSArg.isPresent());
+                options.set(SSL_CONTEXT, sslContext)
+                    .set(USE_STARTTLS, useStartTLSArg.isPresent());
             }
-            options.setConnectTimeout(getConnectTimeout(), TimeUnit.MILLISECONDS);
+            options.set(CONNECT_TIMEOUT_IN_MILLISECONDS,
+                TimeUnit.MILLISECONDS.toMillis(getConnectTimeout()));
             connFactory = new LDAPConnectionFactory(hostNameArg.getValue(), port, options);
         }
         return connFactory;
diff --git a/opendj-core/clirr-ignored-api-changes.xml b/opendj-core/clirr-ignored-api-changes.xml
index cf07495..1e04740 100644
--- a/opendj-core/clirr-ignored-api-changes.xml
+++ b/opendj-core/clirr-ignored-api-changes.xml
@@ -109,16 +109,16 @@
   <difference>
     <className>org/forgerock/opendj/ldap/LDAPConnectionFactory</className>
     <differenceType>7005</differenceType>
-    <method>%regex[LDAPConnectionFactory\(java\.net\.SocketAddress(, org\.forgerock\.opendj\.ldap\.LDAPOptions)?\)]</method>
-    <to>%regex[LDAPConnectionFactory\(java\.net\.InetSocketAddress(, org\.forgerock\.opendj\.ldap\.LDAPOptions)?\)]</to>
-    <justification>OPENDJ-1270: Changed constructors to only accept InetSocketAddresses instead of more generic SocketAddress</justification>
+    <method>%regex[LDAPConnectionFactory\(java\.lang\.String(.)*(org\.forgerock\.opendj\.ldap\.LDAPOptions)\)]</method>
+    <to>%regex[LDAPConnectionFactory\(java\.lang\.String(.)*(org\.forgerock\.util\.Options)\)]</to>
+    <justification>OPENDJ-1654: LDAPOptions should be converted in a SchemaOptions style API</justification>
   </difference>
   <difference>
     <className>org/forgerock/opendj/ldap/LDAPListener</className>
     <differenceType>7005</differenceType>
-    <method>%regex[LDAPListener\(java\.net\.SocketAddress, org\.forgerock\.opendj\.ldap\.ServerConnectionFactory(,\s*org\.forgerock\.opendj\.ldap\.LDAPListenerOptions)?\)]</method>
-    <to>%regex[LDAPListener\(java\.net\.InetSocketAddress,\s*org\.forgerock\.opendj\.ldap\.ServerConnectionFactory(,\s*org\.forgerock\.opendj\.ldap\.LDAPListenerOptions)?\)]</to>
-    <justification>OPENDJ-1270: Changed constructors to only accept InetSocketAddresses instead of more generic SocketAddress</justification>
+    <method>%regex[LDAPListener\((.*), org\.forgerock\.opendj\.ldap\.ServerConnectionFactory(,\s*org\.forgerock\.opendj\.ldap\.LDAPListenerOptions)?\)]</method>
+    <to>%regex[LDAPListener\((.*)\s*org\.forgerock\.opendj\.ldap\.ServerConnectionFactory(,\s*org\.forgerock\.util\.Options)?\)]</to>
+    <justification>OPENDJ-1654: LDAPOptions should be converted in a SchemaOptions style API</justification>
   </difference>
 
   <difference>
@@ -500,5 +500,14 @@
     <differenceType>8001</differenceType>
     <justification>OPENDJ-1666 Update sdk to forgerock-util 2.0.0</justification>
   </difference>
-
+  <difference>
+    <className>org/forgerock/opendj/ldap/LDAPListenerOptions</className>
+    <differenceType>8001</differenceType>
+    <justification>OPENDJ-1654: LDAPOptions should be converted in a SchemaOptions style API</justification>
+  </difference>
+  <difference>
+    <className>org/forgerock/opendj/ldap/LDAPOptions</className>
+    <differenceType>8001</differenceType>
+    <justification>OPENDJ-1654: LDAPOptions should be converted in a SchemaOptions style API</justification>
+  </difference>
 </differences>
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/CommonLDAPOptions.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/CommonLDAPOptions.java
index cff3107..b42b5e3 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/CommonLDAPOptions.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/CommonLDAPOptions.java
@@ -20,28 +20,17 @@
  *
  * CDDL HEADER END
  *
- *      Copyright 2014 ForgeRock AS.
+ *      Copyright 2014-2015 ForgeRock AS.
  */
 
 package org.forgerock.opendj.ldap;
 
-import org.forgerock.util.Reject;
+import org.forgerock.util.Option;
 
 /**
  * Common options for LDAP clients and listeners.
  */
-abstract class CommonLDAPOptions<T extends CommonLDAPOptions<T>> {
-    /** Default values for options taken from Java properties. */
-    private static final boolean DEFAULT_TCP_NO_DELAY;
-    private static final boolean DEFAULT_REUSE_ADDRESS;
-    private static final boolean DEFAULT_KEEPALIVE;
-    private static final int DEFAULT_LINGER;
-    static {
-        DEFAULT_LINGER = getIntProperty("org.forgerock.opendj.io.linger", -1);
-        DEFAULT_TCP_NO_DELAY = getBooleanProperty("org.forgerock.opendj.io.tcpNoDelay", true);
-        DEFAULT_REUSE_ADDRESS = getBooleanProperty("org.forgerock.opendj.io.reuseAddress", true);
-        DEFAULT_KEEPALIVE = getBooleanProperty("org.forgerock.opendj.io.keepAlive", true);
-    }
+abstract class CommonLDAPOptions {
 
     static boolean getBooleanProperty(final String name, final boolean defaultValue) {
         final String value = System.getProperty(name);
@@ -57,60 +46,12 @@
         }
     }
 
-    private DecodeOptions decodeOptions;
-    private ClassLoader providerClassLoader;
-    private String transportProvider;
-    private boolean tcpNoDelay = DEFAULT_TCP_NO_DELAY;
-    private boolean keepAlive = DEFAULT_KEEPALIVE;
-    private boolean reuseAddress = DEFAULT_REUSE_ADDRESS;
-    private int linger = DEFAULT_LINGER;
-
-    CommonLDAPOptions() {
-        this.decodeOptions = new DecodeOptions();
-    }
-
-    CommonLDAPOptions(final CommonLDAPOptions<?> options) {
-        this.decodeOptions = new DecodeOptions(options.decodeOptions);
-        this.providerClassLoader = options.providerClassLoader;
-        this.transportProvider = options.transportProvider;
-        this.linger = options.linger;
-        this.keepAlive = options.keepAlive;
-        this.reuseAddress = options.reuseAddress;
-        this.tcpNoDelay = options.tcpNoDelay;
-    }
-
+    /** Sets the decoding options which will be used to control how requests and responses are decoded. */
+    public static final Option<DecodeOptions> DECODE_OPTIONS = Option.withDefault(new DecodeOptions());
     /**
-     * Returns the decoding options which will be used to control how requests
-     * and responses are decoded.
-     *
-     * @return The decoding options which will be used to control how requests
-     *         and responses are decoded (never {@code null}).
-     */
-    public DecodeOptions getDecodeOptions() {
-        return decodeOptions;
-    }
-
-    /**
-     * Returns the value of the {@link java.net.SocketOptions#SO_LINGER
-     * SO_LINGER} socket option for new connections.
+     * Specifies the class loader which will be used to load the {@link TransportProvider}.
      * <p>
-     * The default setting is {@code -1} (disabled) and may be configured using
-     * the {@code org.forgerock.opendj.io.linger} property.
-     *
-     * @return The value of the {@link java.net.SocketOptions#SO_LINGER
-     *         SO_LINGER} socket option for new connections, or -1 if linger
-     *         should be disabled.
-     */
-    public int getLinger() {
-        return linger;
-    }
-
-    /**
-     * Returns the class loader which will be used to load the
-     * {@code TransportProvider}.
-     * <p>
-     * By default this method will return {@code null} indicating that the
-     * default class loader will be used.
+     * By default the default class loader will be used.
      * <p>
      * The transport provider is loaded using {@code java.util.ServiceLoader},
      * the JDK service-provider loading facility. The provider must be
@@ -119,106 +60,36 @@
      * class loader from which the file was actually loaded. This method allows
      * to provide a class loader to be used for loading the provider.
      *
-     * @return The class loader which will be used when loading the transport
-     *         provider, or {@code null} if the default class loader should be
-     *         used.
      */
-    public ClassLoader getProviderClassLoader() {
-        return providerClassLoader;
-    }
-
+    public static final Option<ClassLoader> PROVIDER_CLASS_LOADER = Option.of(ClassLoader.class, null);
     /**
-     * Returns the name of the provider used for transport.
+     * Specifies the name of the provider to use for transport.
      * <p>
-     * Transport providers implement {@code TransportProvider} interface.
+     * Transport providers implement {@link TransportProvider} interface.
      * <p>
      * The name should correspond to the name of an existing provider, as
      * returned by {@code TransportProvider#getName()} method.
-     *
-     * @return The name of transport provider. The name is {@code null} if no
-     *         specific provider has been selected. In that case, the first
-     *         provider found will be used.
      */
-    public String getTransportProvider() {
-        return transportProvider;
-    }
-
+    public static final Option<String> TRANSPORT_PROVIDER = Option.of(String.class, null);
     /**
-     * Returns the value of the {@link java.net.SocketOptions#SO_KEEPALIVE
-     * SO_KEEPALIVE} socket option for new connections.
+     * Specifies the value of the {@link java.net.SocketOptions#TCP_NODELAY
+     * TCP_NODELAY} socket option for new connections.
      * <p>
      * The default setting is {@code true} and may be configured using the
-     * {@code org.forgerock.opendj.io.keepAlive} property.
-     *
-     * @return The value of the {@link java.net.SocketOptions#SO_KEEPALIVE
-     *         SO_KEEPALIVE} socket option for new connections.
+     * {@code org.forgerock.opendj.io.tcpNoDelay} property.
      */
-    public boolean isKeepAlive() {
-        return keepAlive;
-    }
-
+    public static final Option<Boolean> TCP_NO_DELAY = Option.withDefault(
+        getBooleanProperty("org.forgerock.opendj.io.tcpNoDelay", true));
     /**
-     * Returns the value of the {@link java.net.SocketOptions#SO_REUSEADDR
+     * Specifies the value of the {@link java.net.SocketOptions#SO_REUSEADDR
      * SO_REUSEADDR} socket option for new connections.
      * <p>
      * The default setting is {@code true} and may be configured using the
      * {@code org.forgerock.opendj.io.reuseAddress} property.
      *
-     * @return The value of the {@link java.net.SocketOptions#SO_REUSEADDR
-     *         SO_REUSEADDR} socket option for new connections.
      */
-    public boolean isReuseAddress() {
-        return reuseAddress;
-    }
-
-    /**
-     * Returns the value of the {@link java.net.SocketOptions#TCP_NODELAY
-     * TCP_NODELAY} socket option for new connections.
-     * <p>
-     * The default setting is {@code true} and may be configured using the
-     * {@code org.forgerock.opendj.io.tcpNoDelay} property.
-     *
-     * @return The value of the {@link java.net.SocketOptions#TCP_NODELAY
-     *         TCP_NODELAY} socket option for new connections.
-     */
-    public boolean isTCPNoDelay() {
-        return tcpNoDelay;
-    }
-
-    /**
-     * Sets the decoding options which will be used to control how requests and
-     * responses are decoded.
-     *
-     * @param decodeOptions
-     *            The decoding options which will be used to control how
-     *            requests and responses are decoded (never {@code null}).
-     * @return A reference to this set of options.
-     * @throws NullPointerException
-     *             If {@code decodeOptions} was {@code null}.
-     */
-    public T setDecodeOptions(final DecodeOptions decodeOptions) {
-        Reject.ifNull(decodeOptions);
-        this.decodeOptions = decodeOptions;
-        return getThis();
-    }
-
-    /**
-     * Specifies the value of the {@link java.net.SocketOptions#SO_KEEPALIVE
-     * SO_KEEPALIVE} socket option for new connections.
-     * <p>
-     * The default setting is {@code true} and may be configured using the
-     * {@code org.forgerock.opendj.io.keepAlive} property.
-     *
-     * @param keepAlive
-     *            The value of the {@link java.net.SocketOptions#SO_KEEPALIVE
-     *            SO_KEEPALIVE} socket option for new connections.
-     * @return A reference to this set of options.
-     */
-    public T setKeepAlive(final boolean keepAlive) {
-        this.keepAlive = keepAlive;
-        return getThis();
-    }
-
+    public static final Option<Boolean> REUSE_ADDRESS = Option.withDefault(
+        getBooleanProperty("org.forgerock.opendj.io.reuseAddress", true));
     /**
      * Specifies the value of the {@link java.net.SocketOptions#SO_LINGER
      * SO_LINGER} socket option for new connections.
@@ -232,88 +103,16 @@
      *            should be disabled.
      * @return A reference to this set of options.
      */
-    public T setLinger(final int linger) {
-        this.linger = linger;
-        return getThis();
-    }
-
+    public static final Option<Integer> LINGER = Option.withDefault(
+        getIntProperty("org.forgerock.opendj.io.linger", -1));
     /**
-     * Sets the class loader which will be used to load the
-     * {@code TransportProvider}.
-     * <p>
-     * The default class loader will be used if no class loader is set using
-     * this method.
-     * <p>
-     * The transport provider is loaded using {@code java.util.ServiceLoader},
-     * the JDK service-provider loading facility. The provider must be
-     * accessible from the same class loader that was initially queried to
-     * locate the configuration file; note that this is not necessarily the
-     * class loader from which the file was actually loaded. This method allows
-     * to provide a class loader to be used for loading the provider.
-     *
-     * @param classLoader
-     *            The class loader which will be used when loading the transport
-     *            provider, or {@code null} if the default class loader should
-     *            be used.
-     * @return A reference to this set of options.
-     */
-    public T setProviderClassLoader(final ClassLoader classLoader) {
-        this.providerClassLoader = classLoader;
-        return getThis();
-    }
-
-    /**
-     * Specifies the value of the {@link java.net.SocketOptions#SO_REUSEADDR
-     * SO_REUSEADDR} socket option for new connections.
+     * Specifies the value of the {@link java.net.SocketOptions#SO_KEEPALIVE
+     * SO_KEEPALIVE} socket option for new connections.
      * <p>
      * The default setting is {@code true} and may be configured using the
-     * {@code org.forgerock.opendj.io.reuseAddress} property.
+     * {@code org.forgerock.opendj.io.keepAlive} property.
      *
-     * @param reuseAddress
-     *            The value of the {@link java.net.SocketOptions#SO_REUSEADDR
-     *            SO_REUSEADDR} socket option for new connections.
-     * @return A reference to this set of options.
      */
-    public T setReuseAddress(final boolean reuseAddress) {
-        this.reuseAddress = reuseAddress;
-        return getThis();
-    }
-
-    /**
-     * Specifies the value of the {@link java.net.SocketOptions#TCP_NODELAY
-     * TCP_NODELAY} socket option for new connections.
-     * <p>
-     * The default setting is {@code true} and may be configured using the
-     * {@code org.forgerock.opendj.io.tcpNoDelay} property.
-     *
-     * @param tcpNoDelay
-     *            The value of the {@link java.net.SocketOptions#TCP_NODELAY
-     *            TCP_NODELAY} socket option for new connections.
-     * @return A reference to this set of options.
-     */
-    public T setTCPNoDelay(final boolean tcpNoDelay) {
-        this.tcpNoDelay = tcpNoDelay;
-        return getThis();
-    }
-
-    /**
-     * Sets the name of the provider to use for transport.
-     * <p>
-     * Transport providers implement {@code TransportProvider} interface.
-     * <p>
-     * The name should correspond to the name of an existing provider, as
-     * returned by {@code TransportProvider#getName()} method.
-     *
-     * @param providerName
-     *            The name of transport provider, or {@code null} if no specific
-     *            provider is preferred. In that case, the first provider found
-     *            will be used.
-     * @return A reference to this set of options.
-     */
-    public T setTransportProvider(final String providerName) {
-        this.transportProvider = providerName;
-        return getThis();
-    }
-
-    abstract T getThis();
+    public static final Option<Boolean> KEEPALIVE = Option.withDefault(
+        getBooleanProperty("org.forgerock.opendj.io.keepAlive", true));
 }
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java
index 2c9ce2b..22246d1 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2009-2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2014 ForgeRock AS.
+ *      Portions Copyright 2011-2015 ForgeRock AS.
  */
 
 package org.forgerock.opendj.ldap;
@@ -31,14 +31,74 @@
 
 import org.forgerock.opendj.ldap.spi.LDAPConnectionFactoryImpl;
 import org.forgerock.opendj.ldap.spi.TransportProvider;
+import org.forgerock.util.Option;
+import org.forgerock.util.Options;
 import org.forgerock.util.Reject;
 import org.forgerock.util.promise.Promise;
 
+import javax.net.ssl.SSLContext;
+import java.util.Collections;
+import java.util.List;
+
 /**
  * A factory class which can be used to obtain connections to an LDAP Directory
  * Server.
  */
-public final class LDAPConnectionFactory implements ConnectionFactory {
+public final class LDAPConnectionFactory extends CommonLDAPOptions implements ConnectionFactory {
+
+    /**
+     * Specifies the SSL context which will be used when initiating connections with the Directory Server.
+     * <p>
+     * By default no SSL context will be used, indicating that connections will not be secured.
+     * If an SSL context is set then connections will be secured using either SSL or StartTLS
+     * depending on {@link #USE_STARTTLS}.
+     */
+    public static final Option<SSLContext> SSL_CONTEXT = Option.of(SSLContext.class, null);
+    /**
+     * Specifies whether SSL or StartTLS should be used for securing connections when an SSL context is specified.
+     * <p>
+     * By default SSL will be used in preference to StartTLS.
+     */
+    public static final Option<Boolean> USE_STARTTLS = Option.withDefault(false);
+    /**
+     * Specifies the operation timeout in milliseconds. If a response is not
+     * received from the Directory Server within the timeout period, then the
+     * operation will be abandoned and a {@link TimeoutResultException} error
+     * result returned. A timeout setting of 0 disables operation timeout limits.
+     * <p>
+     * The default operation timeout is 0 (no timeout) and may be configured
+     * using the {@code org.forgerock.opendj.io.timeout} property.
+     */
+    public static final Option<Long> TIMEOUT_IN_MILLISECONDS = Option.of(Long.class,
+        (long) getIntProperty("org.forgerock.opendj.io.timeout", 0));
+    /**
+     * Specifies the connect timeout spcified in milliseconds. If a connection is not established
+     * within the timeout period, then a {@link TimeoutResultException} error result will be returned.
+     * <p>
+     * The default operation timeout is 10 seconds and may be configured using
+     * the {@code org.forgerock.opendj.io.connectTimeout} property.
+     * A timeout setting of 0 causes the OS connect timeout to be used.
+     */
+    public static final Option<Long> CONNECT_TIMEOUT_IN_MILLISECONDS = Option.of(Long.class,
+        (long) getIntProperty("org.forgerock.opendj.io.connectTimeout", 10000));
+    /**
+     * Specifies the cipher suites enabled for secure connections with the Directory Server.
+     * <p>
+     * The suites must be supported by the SSLContext specified by option {@link SSL_CONTEXT}.
+     * Only the suites listed in the parameter are enabled for use.
+     */
+    public static final Option<List<String>> ENABLED_CIPHER_SUITES = Option.withDefault(
+        Collections.<String>emptyList());
+    /**
+     * Specifies the protocol versions enabled for secure connections with the
+     * Directory Server.
+     * <p>
+     * The protocols must be supported by the SSLContext specified by option {@link SSL_CONTEXT}.
+     * Only the protocols listed in the parameter are enabled for use.
+     */
+    public static final Option<List<String>> ENABLED_PROTOCOLS =
+        Option.withDefault(Collections.<String>emptyList());
+
     /**
      * We implement the factory using the pimpl idiom in order to avoid making
      * too many implementation classes public.
@@ -55,17 +115,14 @@
      * connections to the Directory Server at the provided host and port
      * number.
      *
-     * @param host
-     *            The host name.
-     * @param port
-     *            The port number.
-     * @throws NullPointerException
-     *             If {@code host} was {@code null}.
+     * @param host The host name.
+     * @param port The port number.
+     * @throws NullPointerException      If {@code host} was {@code null}.
      * @throws ProviderNotFoundException if no provider is available or if the
-     *             provider requested using options is not found.
+     *                                   provider requested using options is not found.
      */
     public LDAPConnectionFactory(final String host, final int port) {
-        this(host, port, new LDAPOptions());
+        this(host, port, Options.defaultOptions());
     }
 
     /**
@@ -73,21 +130,17 @@
      * connections to the Directory Server at the provided host and port
      * number.
      *
-     * @param host
-     *            The host name.
-     * @param port
-     *            The port number.
-     * @param options
-     *            The LDAP options to use when creating connections.
-     * @throws NullPointerException
-     *             If {@code host} or {@code options} was {@code null}.
+     * @param host    The host name.
+     * @param port    The port number.
+     * @param options The LDAP options to use when creating connections.
+     * @throws NullPointerException      If {@code host} or {@code options} was {@code null}.
      * @throws ProviderNotFoundException if no provider is available or if the
-     *             provider requested using options is not found.
+     *                                   provider requested using options is not found.
      */
-    public LDAPConnectionFactory(final String host, final int port, final LDAPOptions options) {
+    public LDAPConnectionFactory(final String host, final int port, final Options options) {
         Reject.ifNull(host, options);
-        this.provider = getProvider(TransportProvider.class, options.getTransportProvider(),
-                options.getProviderClassLoader());
+        this.provider = getProvider(TransportProvider.class, options.get(TRANSPORT_PROVIDER),
+                options.get(PROVIDER_CLASS_LOADER));
         this.impl = provider.getLDAPConnectionFactory(host, port, options);
     }
 
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPListener.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPListener.java
index 736de1d..1543985 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPListener.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPListener.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2009-2010 Sun Microsystems, Inc.
- *      Portions copyright 2012-2014 ForgeRock AS.
+ *      Portions copyright 2012-2015 ForgeRock AS.
  */
 
 package org.forgerock.opendj.ldap;
@@ -36,6 +36,8 @@
 
 import org.forgerock.opendj.ldap.spi.LDAPListenerImpl;
 import org.forgerock.opendj.ldap.spi.TransportProvider;
+import org.forgerock.util.Option;
+import org.forgerock.util.Options;
 import org.forgerock.util.Reject;
 
 /**
@@ -92,7 +94,19 @@
  * }
  * </pre>
  */
-public final class LDAPListener implements Closeable {
+public final class LDAPListener extends CommonLDAPOptions implements Closeable {
+
+    /**
+     * Specifies the maximum queue length for incoming connections requests. If a
+     * connection request arrives when the queue is full, the connection is refused.
+     */
+    public static final Option<Integer> BACKLOG = Option.withDefault(50);
+    /**
+     * Specifies the maximum request size in bytes for incoming LDAP requests.
+     * If an incoming request exceeds the limit then the connection will be aborted by the listener.
+     * Default value is 5MiB.
+     */
+    public static final Option<Integer> MAX_REQUEST_SIZE_BYTES = Option.withDefault(5 * 1024 * 1024);
 
     /**
      * We implement the factory using the pimpl idiom in order have
@@ -122,7 +136,7 @@
      */
     public LDAPListener(final int port,
             final ServerConnectionFactory<LDAPClientContext, Integer> factory) throws IOException {
-        this(port, factory, new LDAPListenerOptions());
+        this(port, factory, Options.defaultOptions());
     }
 
     /**
@@ -144,11 +158,11 @@
      */
     public LDAPListener(final int port,
             final ServerConnectionFactory<LDAPClientContext, Integer> factory,
-            final LDAPListenerOptions options) throws IOException {
+            final Options options) throws IOException {
         Reject.ifNull(factory, options);
         final InetSocketAddress address = new InetSocketAddress(port);
-        this.provider = getProvider(TransportProvider.class, options.getTransportProvider(),
-                options.getProviderClassLoader());
+        this.provider = getProvider(TransportProvider.class, options.get(TRANSPORT_PROVIDER),
+            options.get(PROVIDER_CLASS_LOADER));
         this.impl = provider.getLDAPListener(address, factory, options);
     }
 
@@ -169,7 +183,7 @@
      */
     public LDAPListener(final InetSocketAddress address,
             final ServerConnectionFactory<LDAPClientContext, Integer> factory) throws IOException {
-        this(address, factory, new LDAPListenerOptions());
+        this(address, factory, Options.defaultOptions());
     }
 
     /**
@@ -192,10 +206,10 @@
      */
     public LDAPListener(final InetSocketAddress address,
             final ServerConnectionFactory<LDAPClientContext, Integer> factory,
-            final LDAPListenerOptions options) throws IOException {
+            final Options options) throws IOException {
         Reject.ifNull(address, factory, options);
-        this.provider = getProvider(TransportProvider.class, options.getTransportProvider(),
-                options.getProviderClassLoader());
+        this.provider = getProvider(TransportProvider.class, options.get(TRANSPORT_PROVIDER),
+            options.get(PROVIDER_CLASS_LOADER));
         this.impl = provider.getLDAPListener(address, factory, options);
     }
 
@@ -218,7 +232,7 @@
      */
     public LDAPListener(final String host, final int port,
             final ServerConnectionFactory<LDAPClientContext, Integer> factory) throws IOException {
-        this(host, port, factory, new LDAPListenerOptions());
+        this(host, port, factory, Options.defaultOptions());
     }
 
     /**
@@ -243,11 +257,11 @@
      */
     public LDAPListener(final String host, final int port,
             final ServerConnectionFactory<LDAPClientContext, Integer> factory,
-            final LDAPListenerOptions options) throws IOException {
+            final Options options) throws IOException {
         Reject.ifNull(host, factory, options);
         final InetSocketAddress address = new InetSocketAddress(host, port);
-        this.provider = getProvider(TransportProvider.class, options.getTransportProvider(),
-                options.getProviderClassLoader());
+        this.provider = getProvider(TransportProvider.class, options.get(TRANSPORT_PROVIDER),
+            options.get(PROVIDER_CLASS_LOADER));
         this.impl = provider.getLDAPListener(address, factory, options);
     }
 
@@ -312,5 +326,4 @@
     public String toString() {
         return impl.toString();
     }
-
 }
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPListenerOptions.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPListenerOptions.java
deleted file mode 100644
index 76e371b..0000000
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPListenerOptions.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2010 Sun Microsystems, Inc.
- *      Portions copyright 2012-2014 ForgeRock AS.
- */
-
-package org.forgerock.opendj.ldap;
-
-/**
- * Common options for LDAP listeners.
- */
-public final class LDAPListenerOptions extends CommonLDAPOptions<LDAPListenerOptions> {
-    private int backlog;
-    private int maxRequestSize;
-
-    /**
-     * Creates a new set of listener options with default settings. SSL will not
-     * be enabled, and a default set of decode options will be used.
-     */
-    public LDAPListenerOptions() {
-        super();
-    }
-
-    /**
-     * Creates a new set of listener options having the same initial set of
-     * options as the provided set of listener options.
-     *
-     * @param options
-     *            The set of listener options to be copied.
-     */
-    public LDAPListenerOptions(final LDAPListenerOptions options) {
-        super(options);
-        this.backlog = options.backlog;
-        this.maxRequestSize = options.maxRequestSize;
-    }
-
-    /**
-     * Returns the maximum queue length for incoming connections requests. If a
-     * connection request arrives when the queue is full, the connection is
-     * refused. If the backlog is less than {@code 1} then a default value of
-     * {@code 50} will be used.
-     *
-     * @return The maximum queue length for incoming connections requests.
-     */
-    public int getBacklog() {
-        return backlog;
-    }
-
-    /**
-     * Returns the maximum request size in bytes for incoming LDAP requests. If
-     * an incoming request exceeds the limit then the connection will be aborted
-     * by the listener. If the limit is less than {@code 1} then a default value
-     * of {@code 5MB} will be used.
-     *
-     * @return The maximum request size in bytes for incoming LDAP requests.
-     */
-    public int getMaxRequestSize() {
-        return maxRequestSize;
-    }
-
-    /**
-     * Sets the maximum queue length for incoming connections requests. If a
-     * connection request arrives when the queue is full, the connection is
-     * refused. If the backlog is less than {@code 1} then a default value of
-     * {@code 50} will be used.
-     *
-     * @param backlog
-     *            The maximum queue length for incoming connections requests.
-     * @return A reference to this LDAP listener options.
-     */
-    public LDAPListenerOptions setBacklog(final int backlog) {
-        this.backlog = backlog;
-        return this;
-    }
-
-    /**
-     * Sets the maximum request size in bytes for incoming LDAP requests. If an
-     * incoming request exceeds the limit then the connection will be aborted by
-     * the listener. If the limit is less than {@code 1} then a default value of
-     * {@code 5MB} will be used.
-     *
-     * @param maxRequestSize
-     *            The maximum request size in bytes for incoming LDAP requests.
-     * @return A reference to this LDAP listener options.
-     */
-    public LDAPListenerOptions setMaxRequestSize(final int maxRequestSize) {
-        this.maxRequestSize = maxRequestSize;
-        return this;
-    }
-
-    @Override
-    LDAPListenerOptions getThis() {
-        return this;
-    }
-}
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPOptions.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPOptions.java
deleted file mode 100644
index a8fd382..0000000
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/LDAPOptions.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License").  You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
- * or http://forgerock.org/license/CDDLv1.0.html.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at legal-notices/CDDLv1_0.txt.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information:
- *      Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- *
- *
- *      Copyright 2010 Sun Microsystems, Inc.
- *      Portions copyright 2012-2015 ForgeRock AS.
- */
-
-package org.forgerock.opendj.ldap;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import javax.net.ssl.SSLContext;
-
-import org.forgerock.util.Reject;
-
-/**
- * Common options for LDAP client connections.
- * <p>
- * For example you set LDAP options when you want to use StartTLS.
- *
- * <pre>
- * LDAPOptions options = new LDAPOptions();
- * SSLContext sslContext =
- *         new SSLContextBuilder().setTrustManager(...).getSSLContext();
- * options.setSSLContext(sslContext);
- * options.setUseStartTLS(true);
- *
- * String host = ...;
- * int port = ...;
- * LDAPConnectionFactory factory = new LDAPConnectionFactory(host, port, options);
- * Connection connection = factory.getConnection();
- * // Connection uses StartTLS...
- * </pre>
- */
-public final class LDAPOptions extends CommonLDAPOptions<LDAPOptions> {
-    /** Default values for options taken from Java properties. */
-    private static final long DEFAULT_TIMEOUT;
-    private static final long DEFAULT_CONNECT_TIMEOUT;
-    static {
-        DEFAULT_TIMEOUT = getIntProperty("org.forgerock.opendj.io.timeout", 0);
-        DEFAULT_CONNECT_TIMEOUT = getIntProperty("org.forgerock.opendj.io.connectTimeout", 5000);
-    }
-
-    private SSLContext sslContext;
-    private boolean useStartTLS;
-    private long timeoutInMillis = DEFAULT_TIMEOUT;
-    private long connectTimeoutInMillis = DEFAULT_CONNECT_TIMEOUT;
-    private final List<String> enabledCipherSuites = new LinkedList<>();
-    private final List<String> enabledProtocols = new LinkedList<>();
-
-    /**
-     * Creates a new set of connection options with default settings. SSL will
-     * not be enabled, and a default set of decode options will be used.
-     */
-    public LDAPOptions() {
-        super();
-    }
-
-    /**
-     * Creates a new set of connection options having the same initial set of
-     * options as the provided set of connection options.
-     *
-     * @param options
-     *            The set of connection options to be copied.
-     */
-    public LDAPOptions(final LDAPOptions options) {
-        super(options);
-        this.sslContext = options.sslContext;
-        this.timeoutInMillis = options.timeoutInMillis;
-        this.useStartTLS = options.useStartTLS;
-        this.enabledCipherSuites.addAll(options.getEnabledCipherSuites());
-        this.enabledProtocols.addAll(options.getEnabledProtocols());
-        this.connectTimeoutInMillis = options.connectTimeoutInMillis;
-    }
-
-    /**
-     * Adds the cipher suites enabled for secure connections with the Directory
-     * Server.
-     * <p>
-     * The suites must be supported by the SSLContext specified in
-     * {@link #setSSLContext(SSLContext)}. Following a successful call to this
-     * method, only the suites listed in the protocols parameter are enabled for
-     * use.
-     *
-     * @param suites
-     *            Names of all the suites to enable.
-     * @return A reference to this set of options.
-     */
-    public LDAPOptions addEnabledCipherSuite(final String... suites) {
-        for (final String suite : suites) {
-            enabledCipherSuites.add(Reject.checkNotNull(suite));
-        }
-        return this;
-    }
-
-    /**
-     * Adds the protocol versions enabled for secure connections with the
-     * Directory Server.
-     * <p>
-     * The protocols must be supported by the SSLContext specified in
-     * {@link #setSSLContext(SSLContext)}. Following a successful call to this
-     * method, only the protocols listed in the protocols parameter are enabled
-     * for use.
-     *
-     * @param protocols
-     *            Names of all the protocols to enable.
-     * @return A reference to this set of options.
-     */
-    public LDAPOptions addEnabledProtocol(final String... protocols) {
-        for (final String protocol : protocols) {
-            enabledProtocols.add(Reject.checkNotNull(protocol));
-        }
-        return this;
-    }
-
-    /**
-     * Returns the connect timeout in the specified unit. If a connection is not
-     * established within the timeout period, then a
-     * {@link TimeoutResultException} error result will be returned. A timeout
-     * setting of 0 causes the OS connect timeout to be used.
-     * <p>
-     * The default operation timeout is 10 seconds and may be configured using
-     * the {@code org.forgerock.opendj.io.connectTimeout} property.
-     *
-     * @param unit
-     *            The time unit.
-     * @return The connect timeout, which may be 0 if there is no connect
-     *         timeout.
-     */
-    public long getConnectTimeout(final TimeUnit unit) {
-        return unit.convert(connectTimeoutInMillis, TimeUnit.MILLISECONDS);
-    }
-
-    /**
-     * Returns the names of the protocol versions which are currently enabled
-     * for secure connections with the Directory Server.
-     *
-     * @return An array of protocols or empty set if the default protocols are
-     *         to be used.
-     */
-    public List<String> getEnabledCipherSuites() {
-        return enabledCipherSuites;
-    }
-
-    /**
-     * Returns the names of the protocol versions which are currently enabled
-     * for secure connections with the Directory Server.
-     *
-     * @return An array of protocols or empty set if the default protocols are
-     *         to be used.
-     */
-    public List<String> getEnabledProtocols() {
-        return enabledProtocols;
-    }
-
-    /**
-     * Returns the SSL context which will be used when initiating connections
-     * with the Directory Server.
-     * <p>
-     * By default no SSL context will be used, indicating that connections will
-     * not be secured. If a non-{@code null} SSL context is returned then
-     * connections will be secured using either SSL or StartTLS depending on
-     * {@link #useStartTLS()}.
-     *
-     * @return The SSL context which will be used when initiating secure
-     *         connections with the Directory Server, which may be {@code null}
-     *         indicating that connections will not be secured.
-     */
-    public SSLContext getSSLContext() {
-        return sslContext;
-    }
-
-    /**
-     * Returns the operation timeout in the specified unit. If a response is not
-     * received from the Directory Server within the timeout period, then the
-     * operation will be abandoned and a {@link TimeoutResultException} error
-     * result returned. A timeout setting of 0 disables operation timeout
-     * limits.
-     * <p>
-     * The default operation timeout is 0 (no timeout) and may be configured
-     * using the {@code org.forgerock.opendj.io.timeout} property.
-     *
-     * @param unit
-     *            The time unit.
-     * @return The operation timeout, which may be 0 if there is no operation
-     *         timeout.
-     */
-    public long getTimeout(final TimeUnit unit) {
-        return unit.convert(timeoutInMillis, TimeUnit.MILLISECONDS);
-    }
-
-    /**
-     * Sets the connect timeout. If a connection is not established within the
-     * timeout period, then a {@link TimeoutResultException} error result will
-     * be returned. A timeout setting of 0 causes the OS connect timeout to be
-     * used.
-     * <p>
-     * The default operation timeout is 10 seconds and may be configured using
-     * the {@code org.forgerock.opendj.io.connectTimeout} property.
-     *
-     * @param timeout
-     *            The connect timeout, which may be 0 if there is no connect
-     *            timeout.
-     * @param unit
-     *            The time unit.
-     * @return A reference to this set of options.
-     */
-    public LDAPOptions setConnectTimeout(final long timeout, final TimeUnit unit) {
-        this.connectTimeoutInMillis = unit.toMillis(timeout);
-        return this;
-    }
-
-    /**
-     * Sets the SSL context which will be used when initiating connections with
-     * the Directory Server.
-     * <p>
-     * By default no SSL context will be used, indicating that connections will
-     * not be secured. If a non-{@code null} SSL context is returned then
-     * connections will be secured using either SSL or StartTLS depending on
-     * {@link #useStartTLS()}.
-     *
-     * @param sslContext
-     *            The SSL context which will be used when initiating secure
-     *            connections with the Directory Server, which may be
-     *            {@code null} indicating that connections will not be secured.
-     * @return A reference to this set of options.
-     */
-    public LDAPOptions setSSLContext(final SSLContext sslContext) {
-        this.sslContext = sslContext;
-        return this;
-    }
-
-    /**
-     * Sets the operation timeout. If a response is not received from the
-     * Directory Server within the timeout period, then the operation will be
-     * abandoned and a {@link TimeoutResultException} error result returned. A
-     * timeout setting of 0 disables operation timeout limits.
-     * <p>
-     * The default operation timeout is 0 (no timeout) and may be configured
-     * using the {@code org.forgerock.opendj.io.timeout} property.
-     *
-     * @param timeout
-     *            The operation timeout, which may be 0 if there is no operation
-     *            timeout.
-     * @param unit
-     *            The time unit.
-     * @return A reference to this set of options.
-     */
-    public LDAPOptions setTimeout(final long timeout, final TimeUnit unit) {
-        this.timeoutInMillis = unit.toMillis(timeout);
-        return this;
-    }
-
-    /**
-     * Specifies whether or not SSL or StartTLS should be used for securing
-     * connections when an SSL context is specified.
-     * <p>
-     * By default SSL will be used in preference to StartTLS.
-     *
-     * @param useStartTLS
-     *            {@code true} if StartTLS should be used for securing
-     *            connections when an SSL context is specified, otherwise
-     *            {@code false} indicating that SSL should be used.
-     * @return A reference to this set of options.
-     */
-    public LDAPOptions setUseStartTLS(final boolean useStartTLS) {
-        this.useStartTLS = useStartTLS;
-        return this;
-    }
-
-    /**
-     * Indicates whether or not SSL or StartTLS should be used for securing
-     * connections when an SSL context is specified.
-     * <p>
-     * By default SSL will be used in preference to StartTLS.
-     *
-     * @return {@code true} if StartTLS should be used for securing connections
-     *         when an SSL context is specified, otherwise {@code false}
-     *         indicating that SSL should be used.
-     */
-    public boolean useStartTLS() {
-        return useStartTLS;
-    }
-
-    @Override
-    LDAPOptions getThis() {
-        return this;
-    }
-}
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/spi/TransportProvider.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/spi/TransportProvider.java
index a9c87a7..8ee7c2e 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/spi/TransportProvider.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/spi/TransportProvider.java
@@ -21,7 +21,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2013-2014 ForgeRock AS.
+ *      Copyright 2013-2015 ForgeRock AS.
  */
 package org.forgerock.opendj.ldap.spi;
 
@@ -29,9 +29,8 @@
 import java.net.InetSocketAddress;
 
 import org.forgerock.opendj.ldap.LDAPClientContext;
-import org.forgerock.opendj.ldap.LDAPListenerOptions;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.ServerConnectionFactory;
+import org.forgerock.util.Options;
 
 /**
  * Interface for transport providers, which provide implementation
@@ -57,7 +56,7 @@
      *            The LDAP options to use when creating connections.
      * @return an implementation of {@code LDAPConnectionFactory}
      */
-    LDAPConnectionFactoryImpl getLDAPConnectionFactory(String host, int port, LDAPOptions options);
+    LDAPConnectionFactoryImpl getLDAPConnectionFactory(String host, int port, Options options);
 
   /**
      * Returns an implementation of {@code LDAPListener}.
@@ -75,7 +74,7 @@
      *             address.
      */
     LDAPListenerImpl getLDAPListener(InetSocketAddress address,
-            ServerConnectionFactory<LDAPClientContext, Integer> factory, LDAPListenerOptions options)
+            ServerConnectionFactory<LDAPClientContext, Integer> factory, Options options)
             throws IOException;
 
 }
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/io/LDAPReaderWriterTestCase.java b/opendj-core/src/test/java/org/forgerock/opendj/io/LDAPReaderWriterTestCase.java
index 5c3f26b..9ce760d 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/io/LDAPReaderWriterTestCase.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/io/LDAPReaderWriterTestCase.java
@@ -21,18 +21,18 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2013 ForgeRock AS.
+ *      Copyright 2013-2015 ForgeRock AS.
  */
 package org.forgerock.opendj.io;
 
 import static org.fest.assertions.Assertions.*;
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.DECODE_OPTIONS;
 
 import java.io.IOException;
 
 import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.DecodeException;
 import org.forgerock.opendj.ldap.Entry;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.LinkedHashMapEntry;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SdkTestCase;
@@ -57,6 +57,7 @@
 import org.forgerock.opendj.ldap.responses.Result;
 import org.forgerock.opendj.ldap.responses.SearchResultEntry;
 import org.forgerock.opendj.ldap.responses.SearchResultReference;
+import org.forgerock.util.Options;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
@@ -264,7 +265,7 @@
                     ExtendedRequest<R> request) throws DecodeException, IOException {
                 CancelExtendedRequest cancelRequest =
                         CancelExtendedRequest.DECODER.decodeExtendedRequest(request,
-                                new LDAPOptions().getDecodeOptions());
+                            Options.defaultOptions().get(DECODE_OPTIONS));
                 assertThat(cancelRequest.getOID()).isEqualTo(oidCancel);
                 assertThat(cancelRequest.getRequestID()).isEqualTo(requestID);
             }
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/LDAPServer.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/LDAPServer.java
index adbbb0e..212b203 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/LDAPServer.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/LDAPServer.java
@@ -75,9 +75,11 @@
 
 import com.forgerock.opendj.ldap.controls.AccountUsabilityRequestControl;
 import com.forgerock.opendj.ldap.controls.AccountUsabilityResponseControl;
+import org.forgerock.util.Options;
 
 import static org.forgerock.opendj.ldap.LdapException.*;
 import static org.forgerock.opendj.ldap.TestCaseUtils.*;
+import static org.forgerock.opendj.ldap.LDAPListener.*;
 
 /**
  * A simple ldap server that manages 1000 entries and used for running
@@ -547,9 +549,8 @@
             return;
         }
         sslContext = new SSLContextBuilder().getSSLContext();
-        listener =
-                new LDAPListener(findFreeSocketAddress(), getInstance(),
-                        new LDAPListenerOptions().setBacklog(4096));
+        listener = new LDAPListener(findFreeSocketAddress(), getInstance(),
+                        Options.defaultOptions().set(BACKLOG, 4096));
         isRunning = true;
     }
 
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicLDAPConnectionFactory.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicLDAPConnectionFactory.java
index aa60a59..4596658 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicLDAPConnectionFactory.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicLDAPConnectionFactory.java
@@ -21,7 +21,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2013-2014 ForgeRock AS.
+ *      Copyright 2013-2015 ForgeRock AS.
  */
 
 package org.forgerock.opendj.ldap.spi;
@@ -30,8 +30,8 @@
 
 import org.forgerock.opendj.ldap.Connection;
 import org.forgerock.opendj.ldap.LdapException;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.util.Options;
 import org.forgerock.util.promise.Promise;
 
 import static org.forgerock.opendj.ldap.LdapException.*;
@@ -43,24 +43,22 @@
  */
 public final class BasicLDAPConnectionFactory implements LDAPConnectionFactoryImpl {
 
-    private final LDAPOptions options;
+    private final Options options;
     private final String host;
     private final int port;
 
     /**
      * Creates a new LDAP connection factory which does nothing.
-     *
-     * @param host
+     *  @param host
      *            The address of the Directory Server to connect to.
      * @param port
      *            The port of the Directory Server to connect to.
      * @param options
-     *            The LDAP connection options to use when creating connections.
      */
-    public BasicLDAPConnectionFactory(final String host, final int port, final LDAPOptions options) {
+    public BasicLDAPConnectionFactory(final String host, final int port, final Options options) {
         this.host = host;
         this.port = port;
-        this.options = new LDAPOptions(options);
+        this.options = Options.copyOf(options);
     }
 
     @Override
@@ -107,7 +105,7 @@
         return getClass().getSimpleName() + "(" + host + ':' + port + ')';
     }
 
-    LDAPOptions getLDAPOptions() {
+    Options getLDAPOptions() {
         return options;
     }
 }
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicLDAPListener.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicLDAPListener.java
index 4a68244..6281bc1 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicLDAPListener.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicLDAPListener.java
@@ -21,7 +21,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2013-2014 ForgeRock AS.
+ *      Copyright 2013-2015 ForgeRock AS.
  */
 
 package org.forgerock.opendj.ldap.spi;
@@ -30,8 +30,8 @@
 import java.net.InetSocketAddress;
 
 import org.forgerock.opendj.ldap.LDAPClientContext;
-import org.forgerock.opendj.ldap.LDAPListenerOptions;
 import org.forgerock.opendj.ldap.ServerConnectionFactory;
+import org.forgerock.util.Options;
 
 /**
  * Basic LDAP listener implementation to use for tests only.
@@ -55,7 +55,7 @@
      */
     public BasicLDAPListener(final InetSocketAddress address,
             final ServerConnectionFactory<LDAPClientContext, Integer> factory,
-            final LDAPListenerOptions options) throws IOException {
+            final Options options) throws IOException {
         this.connectionFactory = factory;
         this.socketAddress = address;
     }
@@ -65,7 +65,6 @@
         // nothing to do
     }
 
-    /** {@inheritDoc} */
     @Override
     public InetSocketAddress getSocketAddress() {
         return socketAddress;
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicTransportProvider.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicTransportProvider.java
index 475f05e..223d312 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicTransportProvider.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/spi/BasicTransportProvider.java
@@ -21,7 +21,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2013-2014 ForgeRock AS.
+ *      Copyright 2013-2015 ForgeRock AS.
  */
 package org.forgerock.opendj.ldap.spi;
 
@@ -29,9 +29,8 @@
 import java.net.InetSocketAddress;
 
 import org.forgerock.opendj.ldap.LDAPClientContext;
-import org.forgerock.opendj.ldap.LDAPListenerOptions;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.ServerConnectionFactory;
+import org.forgerock.util.Options;
 
 /**
  * Provides an basic implementation of a transport provider doing nothing.
@@ -48,18 +47,14 @@
  */
 public class BasicTransportProvider implements TransportProvider {
 
-    /** {@inheritDoc} */
     @Override
-    public LDAPConnectionFactoryImpl getLDAPConnectionFactory(String host, int port, LDAPOptions options) {
+    public LDAPConnectionFactoryImpl getLDAPConnectionFactory(String host, int port, Options options) {
         return new BasicLDAPConnectionFactory(host, port, options);
     }
 
-    /** {@inheritDoc} */
     @Override
     public LDAPListenerImpl getLDAPListener(
-            InetSocketAddress address,
-            ServerConnectionFactory<LDAPClientContext, Integer> factory,
-            LDAPListenerOptions options)
+            InetSocketAddress address, ServerConnectionFactory<LDAPClientContext, Integer> factory, Options options)
             throws IOException {
         return new BasicLDAPListener(address, factory, options);
     }
diff --git a/opendj-grizzly/src/main/java/com/forgerock/opendj/grizzly/GrizzlyTransportProvider.java b/opendj-grizzly/src/main/java/com/forgerock/opendj/grizzly/GrizzlyTransportProvider.java
index 8e75c6a..3050a07 100644
--- a/opendj-grizzly/src/main/java/com/forgerock/opendj/grizzly/GrizzlyTransportProvider.java
+++ b/opendj-grizzly/src/main/java/com/forgerock/opendj/grizzly/GrizzlyTransportProvider.java
@@ -31,12 +31,11 @@
 import org.forgerock.opendj.grizzly.GrizzlyLDAPConnectionFactory;
 import org.forgerock.opendj.grizzly.GrizzlyLDAPListener;
 import org.forgerock.opendj.ldap.LDAPClientContext;
-import org.forgerock.opendj.ldap.LDAPListenerOptions;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.ServerConnectionFactory;
 import org.forgerock.opendj.ldap.spi.LDAPConnectionFactoryImpl;
 import org.forgerock.opendj.ldap.spi.LDAPListenerImpl;
 import org.forgerock.opendj.ldap.spi.TransportProvider;
+import org.forgerock.util.Options;
 
 /**
  * Grizzly transport provider implementation.
@@ -44,13 +43,13 @@
 public class GrizzlyTransportProvider implements TransportProvider {
 
     @Override
-    public LDAPConnectionFactoryImpl getLDAPConnectionFactory(String host, int port, LDAPOptions options) {
+    public LDAPConnectionFactoryImpl getLDAPConnectionFactory(String host, int port, Options options) {
         return new GrizzlyLDAPConnectionFactory(host, port, options);
     }
 
     @Override
     public LDAPListenerImpl getLDAPListener(InetSocketAddress address,
-            ServerConnectionFactory<LDAPClientContext, Integer> factory, LDAPListenerOptions options)
+            ServerConnectionFactory<LDAPClientContext, Integer> factory, Options options)
             throws IOException {
         return new GrizzlyLDAPListener(address, factory, options);
     }
diff --git a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnection.java b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnection.java
index 38f7b67..6115c7b 100644
--- a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnection.java
+++ b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnection.java
@@ -31,7 +31,6 @@
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -45,7 +44,6 @@
 import org.forgerock.opendj.ldap.ConnectionEventListener;
 import org.forgerock.opendj.ldap.Connections;
 import org.forgerock.opendj.ldap.IntermediateResponseHandler;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.ldap.LdapPromise;
 import org.forgerock.opendj.ldap.ResultCode;
@@ -75,6 +73,7 @@
 import org.forgerock.opendj.ldap.spi.ExtendedResultLdapPromiseImpl;
 import org.forgerock.opendj.ldap.spi.ResultLdapPromiseImpl;
 import org.forgerock.opendj.ldap.spi.SearchResultLdapPromiseImpl;
+import org.forgerock.util.Options;
 import org.forgerock.util.Reject;
 import org.glassfish.grizzly.CompletionHandler;
 import org.glassfish.grizzly.filterchain.Filter;
@@ -82,6 +81,8 @@
 import org.glassfish.grizzly.ssl.SSLEngineConfigurator;
 import org.glassfish.grizzly.ssl.SSLFilter;
 
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
+import static org.forgerock.opendj.ldap.LDAPListener.*;
 import static org.forgerock.opendj.ldap.LdapException.*;
 import static org.forgerock.opendj.ldap.spi.LdapPromises.*;
 
@@ -550,7 +551,7 @@
 
     @Override
     public long handleTimeout(final long currentTime) {
-        final long timeout = factory.getLDAPOptions().getTimeout(TimeUnit.MILLISECONDS);
+        final long timeout = factory.getLDAPOptions().get(TIMEOUT_IN_MILLISECONDS);
         if (timeout <= 0) {
             return 0;
         }
@@ -609,7 +610,7 @@
 
     @Override
     public long getTimeout() {
-        return factory.getLDAPOptions().getTimeout(TimeUnit.MILLISECONDS);
+        return factory.getLDAPOptions().get(TIMEOUT_IN_MILLISECONDS);
     }
 
     /**
@@ -712,7 +713,7 @@
         return newMsgID;
     }
 
-    LDAPOptions getLDAPOptions() {
+    Options getLDAPOptions() {
         return factory.getLDAPOptions();
     }
 
diff --git a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactory.java b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactory.java
index 21d89e0..13135c1 100644
--- a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactory.java
+++ b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactory.java
@@ -22,15 +22,15 @@
  *
  *
  *      Copyright 2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2014 ForgeRock AS
+ *      Portions Copyright 2011-2015 ForgeRock AS
  */
 
 package org.forgerock.opendj.grizzly;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
+import java.util.List;
 import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -38,7 +38,6 @@
 
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.ldap.Connection;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.TimeoutChecker;
@@ -47,6 +46,7 @@
 import org.forgerock.opendj.ldap.requests.StartTLSExtendedRequest;
 import org.forgerock.opendj.ldap.responses.ExtendedResult;
 import org.forgerock.opendj.ldap.spi.LDAPConnectionFactoryImpl;
+import org.forgerock.util.Options;
 import org.forgerock.util.promise.ExceptionHandler;
 import org.forgerock.util.promise.Promise;
 import org.forgerock.util.promise.PromiseImpl;
@@ -62,6 +62,7 @@
 
 import static org.forgerock.opendj.grizzly.DefaultTCPNIOTransport.*;
 import static org.forgerock.opendj.grizzly.GrizzlyUtils.*;
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
 import static org.forgerock.opendj.ldap.LdapException.*;
 import static org.forgerock.opendj.ldap.TimeoutChecker.*;
 
@@ -100,7 +101,7 @@
             final GrizzlyLDAPConnection connection = adaptConnection(result);
 
             // Plain connection.
-            if (options.getSSLContext() == null) {
+            if (options.get(SSL_CONTEXT) == null) {
                 thenOnResult(connection);
                 return;
             }
@@ -114,14 +115,14 @@
                 return;
             }
 
-            if (options.useStartTLS()) {
+            List<String> protocols = options.get(ENABLED_PROTOCOLS);
+            List<String> suites = options.get(ENABLED_CIPHER_SUITES);
+            if (options.get(USE_STARTTLS)) {
                 // Chain StartTLS extended request.
                 final StartTLSExtendedRequest startTLS =
-                        Requests.newStartTLSExtendedRequest(options.getSSLContext());
-                startTLS.addEnabledCipherSuite(options.getEnabledCipherSuites().toArray(
-                    new String[options.getEnabledCipherSuites().size()]));
-                startTLS.addEnabledProtocol(options.getEnabledProtocols().toArray(
-                    new String[options.getEnabledProtocols().size()]));
+                        Requests.newStartTLSExtendedRequest(options.get(SSL_CONTEXT));
+                startTLS.addEnabledCipherSuite(suites.toArray(new String[suites.size()]));
+                startTLS.addEnabledProtocol(protocols.toArray(new String[protocols.size()]));
 
                 connection.extendedRequestAsync(startTLS).thenOnResult(new ResultHandler<ExtendedResult>() {
                     @Override
@@ -137,8 +138,8 @@
             } else {
                 // Install SSL/TLS layer.
                 try {
-                    connection.startTLS(options.getSSLContext(), options.getEnabledProtocols(),
-                        options.getEnabledCipherSuites(), new EmptyCompletionHandler<SSLEngine>() {
+                    connection.startTLS(options.get(SSL_CONTEXT), protocols, suites,
+                        new EmptyCompletionHandler<SSLEngine>() {
                             @Override
                             public void completed(final SSLEngine result) {
                                 thenOnResult(connection);
@@ -170,8 +171,7 @@
 
         private GrizzlyLDAPConnection adaptConnection(
                 final org.glassfish.grizzly.Connection<?> connection) {
-            configureConnection(connection, options.isTCPNoDelay(), options.isKeepAlive(), options
-                    .isReuseAddress(), options.getLinger(), logger);
+            configureConnection(connection, logger, options);
 
             final GrizzlyLDAPConnection ldapConnection =
                     new GrizzlyLDAPConnection(connection, GrizzlyLDAPConnectionFactory.this);
@@ -222,13 +222,13 @@
 
         @Override
         public long getTimeout() {
-            return options.getConnectTimeout(TimeUnit.MILLISECONDS);
+            return options.get(CONNECT_TIMEOUT_IN_MILLISECONDS);
         }
     }
 
     private final LDAPClientFilter clientFilter;
     private final FilterChain defaultFilterChain;
-    private final LDAPOptions options;
+    private final Options options;
     private final String host;
     private final int port;
 
@@ -252,15 +252,14 @@
      * Creates a new LDAP connection factory based on Grizzly which can be used
      * to create connections to the Directory Server at the provided host and
      * port address using provided connection options.
-     *
-     * @param host
+     *  @param host
      *            The hostname of the Directory Server to connect to.
      * @param port
      *            The port number of the Directory Server to connect to.
      * @param options
      *            The LDAP connection options to use when creating connections.
      */
-    public GrizzlyLDAPConnectionFactory(final String host, final int port, final LDAPOptions options) {
+    public GrizzlyLDAPConnectionFactory(final String host, final int port, final Options options) {
         this(host, port, options, null);
     }
 
@@ -269,24 +268,23 @@
      * to create connections to the Directory Server at the provided host and
      * port address using provided connection options and provided TCP
      * transport.
-     *
-     * @param host
+     *  @param host
      *            The hostname of the Directory Server to connect to.
      * @param port
      *            The port number of the Directory Server to connect to.
      * @param options
-     *            The LDAP connection options to use when creating connections.
+ *            The LDAP connection options to use when creating connections.
      * @param transport
-     *            Grizzly TCP Transport NIO implementation to use for
-     *            connections. If {@code null}, default transport will be used.
+*            Grizzly TCP Transport NIO implementation to use for
+*            connections. If {@code null}, default transport will be used.
      */
-    public GrizzlyLDAPConnectionFactory(final String host, final int port, final LDAPOptions options,
+    public GrizzlyLDAPConnectionFactory(final String host, final int port, final Options options,
                                         TCPNIOTransport transport) {
         this.transport = DEFAULT_TRANSPORT.acquireIfNull(transport);
         this.host = host;
         this.port = port;
-        this.options = new LDAPOptions(options);
-        this.clientFilter = new LDAPClientFilter(this.options.getDecodeOptions(), 0);
+        this.options = options;
+        this.clientFilter = new LDAPClientFilter(options.get(DECODE_OPTIONS), 0);
         this.defaultFilterChain =
                 buildFilterChain(this.transport.get().getProcessor(), clientFilter);
     }
@@ -342,7 +340,7 @@
         return timeoutChecker.get();
     }
 
-    LDAPOptions getLDAPOptions() {
+    Options getLDAPOptions() {
         return options;
     }
 
diff --git a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPListener.java b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPListener.java
index 992aa4f..837ff42 100644
--- a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPListener.java
+++ b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPListener.java
@@ -22,11 +22,12 @@
  *
  *
  *      Copyright 2010 Sun Microsystems, Inc.
- *      Portions copyright 2011-2014 ForgeRock AS
+ *      Portions copyright 2011-2015 ForgeRock AS
  */
 package org.forgerock.opendj.grizzly;
 
 import static org.forgerock.opendj.grizzly.DefaultTCPNIOTransport.DEFAULT_TRANSPORT;
+import static org.forgerock.opendj.ldap.LDAPListener.*;
 
 import java.io.IOException;
 import java.net.InetSocketAddress;
@@ -36,9 +37,9 @@
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.ldap.Connections;
 import org.forgerock.opendj.ldap.LDAPClientContext;
-import org.forgerock.opendj.ldap.LDAPListenerOptions;
 import org.forgerock.opendj.ldap.ServerConnectionFactory;
 import org.forgerock.opendj.ldap.spi.LDAPListenerImpl;
+import org.forgerock.util.Options;
 import org.glassfish.grizzly.filterchain.FilterChain;
 import org.glassfish.grizzly.nio.transport.TCPNIOBindingHandler;
 import org.glassfish.grizzly.nio.transport.TCPNIOServerConnection;
@@ -56,7 +57,7 @@
     private final TCPNIOServerConnection serverConnection;
     private final AtomicBoolean isClosed = new AtomicBoolean();
     private final InetSocketAddress socketAddress;
-    private final LDAPListenerOptions options;
+    private final Options options;
 
     /**
      * Creates a new LDAP listener implementation which will listen for LDAP
@@ -75,7 +76,7 @@
      */
     public GrizzlyLDAPListener(final InetSocketAddress address,
             final ServerConnectionFactory<LDAPClientContext, Integer> factory,
-            final LDAPListenerOptions options) throws IOException {
+            final Options options) throws IOException {
         this(address, factory, options, null);
     }
 
@@ -100,18 +101,17 @@
      */
     public GrizzlyLDAPListener(final InetSocketAddress address,
             final ServerConnectionFactory<LDAPClientContext, Integer> factory,
-            final LDAPListenerOptions options, TCPNIOTransport transport) throws IOException {
+            final Options options, TCPNIOTransport transport) throws IOException {
         this.transport = DEFAULT_TRANSPORT.acquireIfNull(transport);
         this.connectionFactory = factory;
-        this.options = new LDAPListenerOptions(options);
+        this.options = Options.copyOf(options);
         final LDAPServerFilter serverFilter =
-                new LDAPServerFilter(this, this.options.getDecodeOptions(), this.options
-                        .getMaxRequestSize());
+                new LDAPServerFilter(this, options.get(DECODE_OPTIONS), options.get(MAX_REQUEST_SIZE_BYTES));
         final FilterChain ldapChain =
                 GrizzlyUtils.buildFilterChain(this.transport.get().getProcessor(), serverFilter);
         final TCPNIOBindingHandler bindingHandler =
                 TCPNIOBindingHandler.builder(this.transport.get()).processor(ldapChain).build();
-        this.serverConnection = bindingHandler.bind(address, options.getBacklog());
+        this.serverConnection = bindingHandler.bind(address, options.get(BACKLOG));
 
         /*
          * Get the socket address now, ensuring that the host is the same as the
@@ -156,7 +156,7 @@
         return connectionFactory;
     }
 
-    LDAPListenerOptions getLDAPListenerOptions() {
+    Options getLDAPListenerOptions() {
         return options;
     }
 }
diff --git a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyUtils.java b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyUtils.java
index 6b37b0f..5b4012a 100644
--- a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyUtils.java
+++ b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyUtils.java
@@ -21,7 +21,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2013 ForgeRock AS.
+ *      Copyright 2013-2015 ForgeRock AS.
  */
 package org.forgerock.opendj.grizzly;
 
@@ -34,6 +34,7 @@
 import org.forgerock.opendj.io.LDAPReader;
 import org.forgerock.opendj.io.LDAPWriter;
 import org.forgerock.opendj.ldap.DecodeOptions;
+import org.forgerock.util.Options;
 import org.glassfish.grizzly.Connection;
 import org.glassfish.grizzly.Processor;
 import org.glassfish.grizzly.ThreadCache;
@@ -45,6 +46,8 @@
 import org.glassfish.grizzly.nio.transport.TCPNIOConnection;
 import org.glassfish.grizzly.ssl.SSLFilter;
 
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
+
 /**
  * Common utility methods.
  */
@@ -184,9 +187,7 @@
         ThreadCache.putToCache(WRITER_INDEX, writer);
     }
 
-    static void configureConnection(final Connection<?> connection, final boolean tcpNoDelay,
-            final boolean keepAlive, final boolean reuseAddress, final int linger,
-            final LocalizedLogger logger) {
+    static void configureConnection(final Connection<?> connection, final LocalizedLogger logger, Options options) {
         /*
          * Test shows that its much faster with non block writes but risk
          * running out of memory if the server is slow.
@@ -196,6 +197,10 @@
         // Configure socket options.
         final SocketChannel channel = (SocketChannel) ((TCPNIOConnection) connection).getChannel();
         final Socket socket = channel.socket();
+        final boolean tcpNoDelay = options.get(TCP_NO_DELAY);
+        final boolean keepAlive = options.get(KEEPALIVE);
+        final boolean reuseAddress = options.get(REUSE_ADDRESS);
+        final int linger = options.get(LINGER);
         try {
             socket.setTcpNoDelay(tcpNoDelay);
         } catch (final SocketException e) {
diff --git a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPClientFilter.java b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPClientFilter.java
index bf98a32..d84c3e6 100644
--- a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPClientFilter.java
+++ b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPClientFilter.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2010 Sun Microsystems, Inc.
- *      Portions Copyright 2012-2014 ForgeRock AS.
+ *      Portions Copyright 2012-2015 ForgeRock AS.
  */
 
 package org.forgerock.opendj.grizzly;
@@ -70,6 +70,7 @@
 import org.glassfish.grizzly.filterchain.FilterChainContext;
 import org.glassfish.grizzly.filterchain.NextAction;
 
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
 import static org.forgerock.opendj.ldap.ResultCode.*;
 import static org.forgerock.opendj.ldap.responses.Responses.*;
 
@@ -367,7 +368,7 @@
         private <R extends ExtendedResult> void handleExtendedResult0(
                 final GrizzlyLDAPConnection conn, final ExtendedResultLdapPromiseImpl<R> promise,
                 final ExtendedResult result) throws DecodeException {
-            final R decodedResponse = promise.decodeResult(result, conn.getLDAPOptions().getDecodeOptions());
+            final R decodedResponse = promise.decodeResult(result, conn.getLDAPOptions().get(DECODE_OPTIONS));
 
             if (result.getResultCode() == ResultCode.SUCCESS
                     && promise.getRequest() instanceof StartTLSExtendedRequest) {
diff --git a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPServerFilter.java b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPServerFilter.java
index c0147de..a502f11 100644
--- a/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPServerFilter.java
+++ b/opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/LDAPServerFilter.java
@@ -46,7 +46,6 @@
 import org.forgerock.opendj.ldap.DecodeOptions;
 import org.forgerock.opendj.ldap.IntermediateResponseHandler;
 import org.forgerock.opendj.ldap.LDAPClientContext;
-import org.forgerock.opendj.ldap.LDAPListenerOptions;
 import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.LdapResultHandler;
@@ -74,6 +73,7 @@
 import org.forgerock.opendj.ldap.responses.Result;
 import org.forgerock.opendj.ldap.responses.SearchResultEntry;
 import org.forgerock.opendj.ldap.responses.SearchResultReference;
+import org.forgerock.util.Options;
 import org.forgerock.util.Reject;
 import org.glassfish.grizzly.Connection;
 import org.glassfish.grizzly.Grizzly;
@@ -842,9 +842,8 @@
     @Override
     public NextAction handleAccept(final FilterChainContext ctx) throws IOException {
         final Connection<?> connection = ctx.getConnection();
-        LDAPListenerOptions options = listener.getLDAPListenerOptions();
-        configureConnection(connection, options.isTCPNoDelay(), options.isKeepAlive(), options
-                .isReuseAddress(), options.getLinger(), logger);
+        Options options = listener.getLDAPListenerOptions();
+        configureConnection(connection, logger, options);
         try {
             final ClientContextImpl clientContext = new ClientContextImpl(connection);
             final ServerConnection<Integer> serverConn =
diff --git a/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/ConnectionFactoryTestCase.java b/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/ConnectionFactoryTestCase.java
index eeecf33..ae87862 100644
--- a/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/ConnectionFactoryTestCase.java
+++ b/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/ConnectionFactoryTestCase.java
@@ -28,6 +28,7 @@
 package org.forgerock.opendj.grizzly;
 
 import java.net.InetSocketAddress;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
@@ -52,7 +53,6 @@
 import org.forgerock.opendj.ldap.LDAPClientContext;
 import org.forgerock.opendj.ldap.LDAPConnectionFactory;
 import org.forgerock.opendj.ldap.LDAPListener;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.LDAPServer;
 import org.forgerock.opendj.ldap.MockConnectionEventListener;
 import org.forgerock.opendj.ldap.ResultCode;
@@ -74,6 +74,7 @@
 import org.forgerock.opendj.ldap.responses.SearchResultEntry;
 import org.forgerock.opendj.ldap.schema.Schema;
 import org.forgerock.opendj.ldap.schema.SchemaBuilder;
+import org.forgerock.util.Options;
 import org.forgerock.util.promise.ExceptionHandler;
 import org.forgerock.util.promise.Promise;
 import org.forgerock.util.promise.PromiseImpl;
@@ -88,6 +89,7 @@
 import static org.fest.assertions.Assertions.*;
 import static org.forgerock.opendj.ldap.Connections.*;
 import static org.forgerock.opendj.ldap.LdapException.*;
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.ENABLED_CIPHER_SUITES;
 import static org.forgerock.opendj.ldap.TestCaseUtils.*;
 import static org.forgerock.opendj.ldap.spi.LdapPromises.*;
 import static org.mockito.Matchers.*;
@@ -171,14 +173,15 @@
         // LDAPConnectionFactory with startTLS
         SSLContext sslContext =
                 new SSLContextBuilder().setTrustManager(TrustManagers.trustAll()).getSSLContext();
-        LDAPOptions options = new LDAPOptions().setSSLContext(sslContext).setUseStartTLS(true)
-                        .addEnabledCipherSuite(
-                                new String[] { "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
-                                    "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5",
-                                    "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA",
-                                    "SSL_DH_anon_WITH_DES_CBC_SHA", "SSL_DH_anon_WITH_RC4_128_MD5",
-                                    "TLS_DH_anon_WITH_AES_128_CBC_SHA",
-                                    "TLS_DH_anon_WITH_AES_256_CBC_SHA" });
+        Options options = Options.defaultOptions().set(ENABLED_CIPHER_SUITES,
+            new ArrayList<String>(Arrays.asList(
+                "SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
+                "SSL_DH_anon_EXPORT_WITH_RC4_40_MD5",
+                "SSL_DH_anon_WITH_3DES_EDE_CBC_SHA",
+                "SSL_DH_anon_WITH_DES_CBC_SHA",
+                "SSL_DH_anon_WITH_RC4_128_MD5",
+                "TLS_DH_anon_WITH_AES_128_CBC_SHA",
+                "TLS_DH_anon_WITH_AES_256_CBC_SHA")));
         factories[5][0] = new LDAPConnectionFactory(serverAddress.getHostName(), serverAddress.getPort(), options);
 
         // startTLS + SASL confidentiality
diff --git a/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactoryTestCase.java b/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactoryTestCase.java
index 1ac8717..5916ae4 100644
--- a/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactoryTestCase.java
+++ b/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactoryTestCase.java
@@ -37,13 +37,12 @@
 import org.forgerock.opendj.ldap.ConnectionFactory;
 import org.forgerock.opendj.ldap.Connections;
 import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.LDAPConnectionFactory;
 import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.ldap.LdapPromise;
 import org.forgerock.opendj.ldap.IntermediateResponseHandler;
 import org.forgerock.opendj.ldap.LDAPClientContext;
-import org.forgerock.opendj.ldap.LDAPConnectionFactory;
 import org.forgerock.opendj.ldap.LDAPListener;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.MockConnectionEventListener;
 import org.forgerock.opendj.ldap.ProviderNotFoundException;
 import org.forgerock.opendj.ldap.ResultCode;
@@ -59,6 +58,7 @@
 import org.forgerock.opendj.ldap.requests.UnbindRequest;
 import org.forgerock.opendj.ldap.responses.BindResult;
 import org.forgerock.opendj.ldap.responses.SearchResultEntry;
+import org.forgerock.util.Options;
 import org.forgerock.util.promise.ExceptionHandler;
 import org.forgerock.util.promise.NeverThrowsException;
 import org.forgerock.util.promise.Promise;
@@ -73,6 +73,7 @@
 import static org.fest.assertions.Fail.*;
 import static org.forgerock.opendj.ldap.TestCaseUtils.*;
 import static org.forgerock.opendj.ldap.requests.Requests.*;
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
 import static org.mockito.Matchers.*;
 import static org.mockito.Mockito.*;
 
@@ -106,8 +107,8 @@
     private final AtomicReference<LDAPClientContext> context = new AtomicReference<>();
     private final LDAPListener server = createServer();
     private final InetSocketAddress socketAddress = server.getSocketAddress();
-    private final ConnectionFactory factory = new LDAPConnectionFactory(socketAddress.getHostName(),
-            socketAddress.getPort(), new LDAPOptions().setTimeout(1, TimeUnit.MILLISECONDS));
+    public final ConnectionFactory factory = new LDAPConnectionFactory(socketAddress.getHostName(),
+            socketAddress.getPort(), Options.defaultOptions().set(TIMEOUT_IN_MILLISECONDS, 1L));
     private final ConnectionFactory pool = Connections.newFixedConnectionPool(factory, 10);
     private volatile ServerConnection<Integer> serverConnection;
 
@@ -122,7 +123,7 @@
     public void testClientSideConnectTimeout() throws Exception {
         // Use an non-local unreachable network address.
         final ConnectionFactory factory = new LDAPConnectionFactory("10.20.30.40", 1389,
-                new LDAPOptions().setConnectTimeout(1, TimeUnit.MILLISECONDS));
+            Options.defaultOptions().set(CONNECT_TIMEOUT_IN_MILLISECONDS, 1L));
         try {
             for (int i = 0; i < ITERATIONS; i++) {
                 final PromiseImpl<LdapException, NeverThrowsException> promise = PromiseImpl.create();
@@ -306,7 +307,7 @@
     @Test(expectedExceptions = { ProviderNotFoundException.class },
             expectedExceptionsMessageRegExp = "^The requested provider 'unknown' .*")
     public void testCreateLDAPConnectionFactoryFailureProviderNotFound() throws Exception {
-        LDAPOptions options = new LDAPOptions().setTransportProvider("unknown");
+        Options options = Options.defaultOptions().set(TRANSPORT_PROVIDER, "unknown");
         InetSocketAddress socketAddress = findFreeSocketAddress();
         LDAPConnectionFactory factory = new LDAPConnectionFactory(socketAddress.getHostName(),
                 socketAddress.getPort(), options);
@@ -316,7 +317,8 @@
     @Test
     public void testCreateLDAPConnectionFactoryWithCustomClassLoader() throws Exception {
         // test no exception is thrown, which means transport provider is correctly loaded
-        LDAPOptions options = new LDAPOptions().setProviderClassLoader(Thread.currentThread().getContextClassLoader());
+        Options options =
+                Options.defaultOptions().set(PROVIDER_CLASS_LOADER, Thread.currentThread().getContextClassLoader());
         InetSocketAddress socketAddress = findFreeSocketAddress();
         LDAPConnectionFactory factory = new LDAPConnectionFactory(socketAddress.getHostName(),
                 socketAddress.getPort(), options);
diff --git a/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionTestCase.java b/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionTestCase.java
index 8c8471a..dae54fd 100644
--- a/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionTestCase.java
+++ b/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionTestCase.java
@@ -21,7 +21,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2013-2014 ForgeRock AS.
+ *      Copyright 2013-2015 ForgeRock AS.
  */
 
 package org.forgerock.opendj.grizzly;
@@ -31,6 +31,7 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
 
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.TIMEOUT_IN_MILLISECONDS;
 import java.net.InetSocketAddress;
 import java.util.concurrent.TimeUnit;
 
@@ -38,7 +39,6 @@
 import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.ldap.LDAPConnectionFactory;
 import org.forgerock.opendj.ldap.LDAPListener;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.RequestHandler;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SdkTestCase;
@@ -49,6 +49,7 @@
 import org.forgerock.opendj.ldap.controls.PersistentSearchRequestControl;
 import org.forgerock.opendj.ldap.requests.Requests;
 import org.forgerock.opendj.ldap.requests.SearchRequest;
+import org.forgerock.util.Options;
 import org.forgerock.util.promise.ExceptionHandler;
 import org.mockito.ArgumentCaptor;
 import org.testng.annotations.Test;
@@ -93,7 +94,8 @@
          * triggering the timeout.
          */
         LDAPConnectionFactory factory = new LDAPConnectionFactory(address.getHostName(),
-                address.getPort(), new LDAPOptions().setTimeout(100, TimeUnit.SECONDS));
+                address.getPort(), Options.defaultOptions().set(
+                    TIMEOUT_IN_MILLISECONDS, TimeUnit.SECONDS.toMillis((long) 100)));
         GrizzlyLDAPConnection connection = (GrizzlyLDAPConnection) factory.getConnection();
         try {
             SearchRequest request =
diff --git a/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPListenerTestCase.java b/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPListenerTestCase.java
index 918c0d7..672f48f 100644
--- a/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPListenerTestCase.java
+++ b/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPListenerTestCase.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2010 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2014 ForgeRock AS.
+ *      Portions Copyright 2011-2015 ForgeRock AS.
  */
 package org.forgerock.opendj.grizzly;
 
@@ -41,7 +41,6 @@
 import org.forgerock.opendj.ldap.LDAPClientContext;
 import org.forgerock.opendj.ldap.LDAPConnectionFactory;
 import org.forgerock.opendj.ldap.LDAPListener;
-import org.forgerock.opendj.ldap.LDAPListenerOptions;
 import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.ldap.ProviderNotFoundException;
 import org.forgerock.opendj.ldap.ResultCode;
@@ -67,6 +66,7 @@
 import org.forgerock.opendj.ldap.responses.ExtendedResult;
 import org.forgerock.opendj.ldap.responses.Responses;
 import org.forgerock.opendj.ldap.responses.Result;
+import org.forgerock.util.Options;
 import org.forgerock.util.promise.PromiseImpl;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
@@ -75,6 +75,7 @@
 import static org.fest.assertions.Assertions.*;
 import static org.fest.assertions.Fail.*;
 import static org.forgerock.opendj.ldap.LdapException.*;
+import static org.forgerock.opendj.ldap.LDAPListener.*;
 import static org.forgerock.opendj.ldap.TestCaseUtils.*;
 import static org.mockito.Mockito.*;
 
@@ -240,10 +241,9 @@
     @SuppressWarnings("unchecked")
     @Test
     public void testCreateLDAPListenerWithCustomClassLoader() throws Exception {
-        // test no exception is thrown, which means transport provider is
-        // correctly loaded
-        LDAPListenerOptions options = new LDAPListenerOptions().
-                setProviderClassLoader(Thread.currentThread().getContextClassLoader());
+        // test no exception is thrown, which means transport provider is correctly loaded
+        Options options = Options.defaultOptions().set(PROVIDER_CLASS_LOADER,
+                Thread.currentThread().getContextClassLoader());
         LDAPListener listener = new LDAPListener(findFreeSocketAddress(),
                 mock(ServerConnectionFactory.class), options);
         listener.close();
@@ -256,7 +256,7 @@
     @Test(expectedExceptions = { ProviderNotFoundException.class },
         expectedExceptionsMessageRegExp = "^The requested provider 'unknown' .*")
     public void testCreateLDAPListenerFailureProviderNotFound() throws Exception {
-        LDAPListenerOptions options = new LDAPListenerOptions().setTransportProvider("unknown");
+        Options options = Options.defaultOptions().set(TRANSPORT_PROVIDER, "unknown");
         LDAPListener listener = new LDAPListener(findFreeSocketAddress(), mock(ServerConnectionFactory.class), options);
         listener.close();
     }
@@ -644,7 +644,7 @@
         final MockServerConnection serverConnection = new MockServerConnection();
         final MockServerConnectionFactory factory =
                 new MockServerConnectionFactory(serverConnection);
-        final LDAPListenerOptions options = new LDAPListenerOptions().setMaxRequestSize(2048);
+        final Options options = Options.defaultOptions().set(MAX_REQUEST_SIZE_BYTES, 2048);
         final LDAPListener listener = new LDAPListener(findFreeSocketAddress(), factory, options);
 
         Connection connection = null;
diff --git a/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPReaderWriterTestCase.java b/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPReaderWriterTestCase.java
index 3461892..a0888a7 100644
--- a/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPReaderWriterTestCase.java
+++ b/opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPReaderWriterTestCase.java
@@ -21,7 +21,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2013 ForgeRock AS.
+ *      Copyright 2013-2015 ForgeRock AS.
  */
 package org.forgerock.opendj.grizzly;
 
@@ -30,8 +30,9 @@
 import org.forgerock.opendj.io.LDAPReader;
 import org.forgerock.opendj.io.LDAPReaderWriterTestCase;
 import org.forgerock.opendj.io.LDAPWriter;
-import org.forgerock.opendj.ldap.LDAPOptions;
+import org.forgerock.util.Options;
 import org.glassfish.grizzly.memory.HeapMemoryManager;
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.DECODE_OPTIONS;
 
 /**
  * Tests for LDAPWriter / LDAPReader classes using specific implementations of
@@ -46,8 +47,7 @@
 
     @Override
     protected LDAPReader<? extends ASN1Reader> getLDAPReader() {
-        return GrizzlyUtils.createReader(new LDAPOptions().getDecodeOptions(),
-                0, new HeapMemoryManager());
+        return GrizzlyUtils.createReader(Options.defaultOptions().get(DECODE_OPTIONS), 0, new HeapMemoryManager());
     }
 
     @Override
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/PasswordResetForAD.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/PasswordResetForAD.java
index 3b75ce3..1ea39c2 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/PasswordResetForAD.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/PasswordResetForAD.java
@@ -26,17 +26,19 @@
 
 package org.forgerock.opendj.examples;
 
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
+
 import org.forgerock.opendj.ldap.Connection;
 import org.forgerock.opendj.ldap.DN;
 import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.ldap.LDAPConnectionFactory;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.ModificationType;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SSLContextBuilder;
 import org.forgerock.opendj.ldap.TrustManagers;
 import org.forgerock.opendj.ldap.requests.ModifyRequest;
 import org.forgerock.opendj.ldap.requests.Requests;
+import org.forgerock.util.Options;
 
 import javax.net.ssl.SSLContext;
 import java.nio.charset.Charset;
@@ -162,13 +164,12 @@
      * For SSL the connection factory needs SSL context options. This
      * implementation simply trusts all server certificates.
      */
-    private static LDAPOptions getTrustAllOptions() throws GeneralSecurityException {
-        LDAPOptions lo = new LDAPOptions();
-        SSLContext sslContext =
-                new SSLContextBuilder().setTrustManager(TrustManagers.trustAll())
-                        .getSSLContext();
-        lo.setSSLContext(sslContext);
-        return lo;
+    private static Options getTrustAllOptions() throws GeneralSecurityException {
+        Options options = Options.defaultOptions();
+        SSLContext sslContext = new SSLContextBuilder()
+              .setTrustManager(TrustManagers.trustAll()).getSSLContext();
+        options.set(SSL_CONTEXT, sslContext);
+        return options;
     }
 
     /**
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java
index 41c413f..84d0e6a 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java
@@ -27,6 +27,8 @@
 
 package org.forgerock.opendj.examples;
 
+import static org.forgerock.opendj.ldap.LDAPListener.*;
+
 import java.io.IOException;
 import java.util.LinkedList;
 import java.util.List;
@@ -37,12 +39,12 @@
 import org.forgerock.opendj.ldap.LDAPClientContext;
 import org.forgerock.opendj.ldap.LDAPConnectionFactory;
 import org.forgerock.opendj.ldap.LDAPListener;
-import org.forgerock.opendj.ldap.LDAPListenerOptions;
 import org.forgerock.opendj.ldap.RequestContext;
 import org.forgerock.opendj.ldap.RequestHandlerFactory;
 import org.forgerock.opendj.ldap.RoundRobinLoadBalancingAlgorithm;
 import org.forgerock.opendj.ldap.ServerConnectionFactory;
 import org.forgerock.opendj.ldap.requests.Requests;
+import org.forgerock.util.Options;
 
 /**
  * An LDAP load balancing proxy which forwards requests to one or more remote
@@ -133,7 +135,7 @@
 
         // --- JCite listener ---
         // Create listener.
-        final LDAPListenerOptions options = new LDAPListenerOptions().setBacklog(4096);
+        final Options options = Options.defaultOptions().set(BACKLOG, 4096);
         LDAPListener listener = null;
         try {
             listener = new LDAPListener(localAddress, localPort, connectionHandler, options);
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/RewriterProxy.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/RewriterProxy.java
index 8efd1dc..90cb493 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/RewriterProxy.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/RewriterProxy.java
@@ -27,6 +27,8 @@
 
 package org.forgerock.opendj.examples;
 
+import static org.forgerock.opendj.ldap.LDAPListener.*;
+
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.List;
@@ -44,7 +46,6 @@
 import org.forgerock.opendj.ldap.LDAPClientContext;
 import org.forgerock.opendj.ldap.LDAPConnectionFactory;
 import org.forgerock.opendj.ldap.LDAPListener;
-import org.forgerock.opendj.ldap.LDAPListenerOptions;
 import org.forgerock.opendj.ldap.Modification;
 import org.forgerock.opendj.ldap.RequestContext;
 import org.forgerock.opendj.ldap.RequestHandler;
@@ -69,6 +70,7 @@
 import org.forgerock.opendj.ldap.responses.SearchResultEntry;
 import org.forgerock.opendj.ldap.responses.SearchResultReference;
 import org.forgerock.opendj.ldap.schema.AttributeType;
+import org.forgerock.util.Options;
 
 /**
  * This example is based on the {@link Proxy}. This example does no load
@@ -191,8 +193,8 @@
 
         @Override
         public void handleSearch(final RequestContext requestContext, final SearchRequest request,
-            final IntermediateResponseHandler intermediateResponseHandler, final SearchResultHandler entryHandler,
-            final LdapResultHandler<Result> resultHandler) {
+            final IntermediateResponseHandler intermediateResponseHandler,
+            final SearchResultHandler entryHandler, final LdapResultHandler<Result> resultHandler) {
             nextHandler.handleSearch(requestContext, rewrite(request), intermediateResponseHandler,
                 new SearchResultHandler() {
                     @Override
@@ -421,7 +423,7 @@
                 Connections.newServerConnectionFactory(proxyFactory);
 
         // Create listener.
-        final LDAPListenerOptions options = new LDAPListenerOptions().setBacklog(4096);
+        final Options options = Options.defaultOptions().set(BACKLOG, 4096);
         LDAPListener listener = null;
         try {
             listener = new LDAPListener(localAddress, localPort, connectionHandler, options);
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java
index 7567ff8..f0e7b19 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java
@@ -32,6 +32,10 @@
  */
 package org.forgerock.opendj.examples;
 
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.USE_STARTTLS;
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.SSL_CONTEXT;
+
+
 import java.security.GeneralSecurityException;
 
 import javax.net.ssl.SSLContext;
@@ -39,12 +43,12 @@
 import org.forgerock.opendj.ldap.Connection;
 import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.ldap.LDAPConnectionFactory;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SSLContextBuilder;
 import org.forgerock.opendj.ldap.TrustManagers;
 import org.forgerock.opendj.ldap.requests.PlainSASLBindRequest;
 import org.forgerock.opendj.ldap.requests.Requests;
+import org.forgerock.util.Options;
 
 /**
  * An example client application which performs SASL PLAIN authentication to a
@@ -120,13 +124,13 @@
      * certificate that is not in the system trust store. To simplify this
      * implementation trusts all server certificates.
      */
-    private static LDAPOptions getTrustAllOptions() throws GeneralSecurityException {
-        LDAPOptions lo = new LDAPOptions();
+    private static Options getTrustAllOptions() throws GeneralSecurityException {
+        Options options = Options.defaultOptions();
         SSLContext sslContext =
                 new SSLContextBuilder().setTrustManager(TrustManagers.trustAll()).getSSLContext();
-        lo.setSSLContext(sslContext);
-        lo.setUseStartTLS(true);
-        return lo;
+        options.set(SSL_CONTEXT, sslContext);
+        options.set(USE_STARTTLS, true);
+        return options;
     }
 
     private static String host;
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Server.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Server.java
index 64ef308..0f5a843 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Server.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Server.java
@@ -27,6 +27,8 @@
 
 package org.forgerock.opendj.examples;
 
+import static org.forgerock.opendj.ldap.LDAPListener.BACKLOG;
+
 import java.io.FileInputStream;
 import java.io.IOException;
 
@@ -37,7 +39,6 @@
 import org.forgerock.opendj.ldap.KeyManagers;
 import org.forgerock.opendj.ldap.LDAPClientContext;
 import org.forgerock.opendj.ldap.LDAPListener;
-import org.forgerock.opendj.ldap.LDAPListenerOptions;
 import org.forgerock.opendj.ldap.MemoryBackend;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SSLContextBuilder;
@@ -45,6 +46,7 @@
 import org.forgerock.opendj.ldap.ServerConnectionFactory;
 import org.forgerock.opendj.ldap.TrustManagers;
 import org.forgerock.opendj.ldif.LDIFEntryReader;
+import org.forgerock.util.Options;
 
 /**
  * An LDAP directory server which exposes data contained in an LDIF file. This
@@ -101,7 +103,7 @@
         // Create listener.
         LDAPListener listener = null;
         try {
-            final LDAPListenerOptions options = new LDAPListenerOptions().setBacklog(4096);
+            final Options options = Options.defaultOptions().set(BACKLOG, 4096);
 
             if (keyStoreFileName != null) {
                 // Configure SSL/TLS and enable it when connections are
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java
index 60d9456..69ff5a4 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java
@@ -21,11 +21,13 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2011-2014 ForgeRock AS
+ *      Copyright 2011-2015 ForgeRock AS
  */
 
 package org.forgerock.opendj.examples;
 
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
+
 import java.io.File;
 import java.io.IOException;
 import java.security.GeneralSecurityException;
@@ -36,10 +38,10 @@
 import org.forgerock.opendj.ldap.Connection;
 import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.ldap.LDAPConnectionFactory;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SSLContextBuilder;
 import org.forgerock.opendj.ldap.TrustManagers;
+import org.forgerock.util.Options;
 
 /**
  * An example client application which performs simple authentication to a
@@ -128,11 +130,11 @@
      * @return SSL context options
      * @throws GeneralSecurityException Could not load the trust store
      */
-    private static LDAPOptions getTrustOptions(final String hostname,
-                                               final String truststore,
-                                               final String storepass)
+    private static Options getTrustOptions(final String hostname,
+                                           final String truststore,
+                                           final String storepass)
             throws GeneralSecurityException {
-        LDAPOptions lo = new LDAPOptions();
+        Options options = Options.defaultOptions();
 
         TrustManager trustManager = null;
         try {
@@ -148,12 +150,12 @@
         if (trustManager != null) {
             SSLContext sslContext = new SSLContextBuilder()
                     .setTrustManager(trustManager).getSSLContext();
-            lo.setSSLContext(sslContext);
+            options.set(SSL_CONTEXT, sslContext);
         }
 
-        lo.setUseStartTLS(useStartTLS);
+        options.set(USE_STARTTLS, useStartTLS);
 
-        return lo;
+        return options;
     }
     // --- JCite trust options ---
 
@@ -200,14 +202,14 @@
      * certificate that is not in the system trust store. To simplify this
      * implementation trusts all server certificates.
      */
-    private static LDAPOptions getTrustAllOptions() throws GeneralSecurityException {
-        LDAPOptions lo = new LDAPOptions();
+    private static Options getTrustAllOptions() throws GeneralSecurityException {
+        Options options = Options.defaultOptions();
         SSLContext sslContext =
                 new SSLContextBuilder().setTrustManager(TrustManagers.trustAll())
                         .getSSLContext();
-        lo.setSSLContext(sslContext);
-        lo.setUseStartTLS(useStartTLS);
-        return lo;
+        options.set(SSL_CONTEXT, sslContext);
+        options.set(USE_STARTTLS, useStartTLS);
+        return options;
     }
     // --- JCite trust all ---
 
diff --git a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuthAsync.java b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuthAsync.java
index c82c3d6..f354445 100644
--- a/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuthAsync.java
+++ b/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuthAsync.java
@@ -27,9 +27,11 @@
 package org.forgerock.opendj.examples;
 
 import static org.forgerock.util.Utils.closeSilently;
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.USE_STARTTLS;
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.SSL_CONTEXT;
+
 import org.forgerock.opendj.ldap.Connection;
 import org.forgerock.opendj.ldap.LDAPConnectionFactory;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SSLContextBuilder;
@@ -38,6 +40,7 @@
 import org.forgerock.opendj.ldap.responses.BindResult;
 import org.forgerock.opendj.ldap.responses.Result;
 import org.forgerock.util.AsyncFunction;
+import org.forgerock.util.Options;
 import org.forgerock.util.promise.ExceptionHandler;
 import org.forgerock.util.promise.Promise;
 import org.forgerock.util.promise.ResultHandler;
@@ -150,10 +153,10 @@
      * @param storepass     Password for the trust store
      * @return SSL context options if SSL or StartTLS is used.
      */
-    private static LDAPOptions getTrustOptions(final String hostname,
-                                               final String truststore,
-                                               final String storepass) {
-        LDAPOptions lo = new LDAPOptions();
+    private static Options getTrustOptions(final String hostname,
+                                           final String truststore,
+                                           final String storepass) {
+        Options options = Options.defaultOptions();
         if (useSSL || useStartTLS) {
             TrustManager trustManager = null;
             try {
@@ -164,15 +167,15 @@
                 if (trustManager != null) {
                     SSLContext sslContext = new SSLContextBuilder()
                             .setTrustManager(trustManager).getSSLContext();
-                    lo.setSSLContext(sslContext);
+                    options.set(SSL_CONTEXT, sslContext);
                 }
             } catch (Exception e) {
                 System.err.println(e.getMessage());
                 System.exit(ResultCode.CLIENT_SIDE_CONNECT_ERROR.intValue());
             }
-            lo.setUseStartTLS(useStartTLS);
+            options.set(USE_STARTTLS, useStartTLS);
         }
-        return lo;
+        return options;
     }
 
     /**
@@ -187,19 +190,19 @@
      *
      * @return SSL context options to trust all certificates without checking.
      */
-    private static LDAPOptions getTrustAllOptions() {
-        LDAPOptions lo = new LDAPOptions();
+    private static Options getTrustAllOptions() {
+        Options options = Options.defaultOptions();
         try {
             SSLContext sslContext =
                     new SSLContextBuilder().setTrustManager(TrustManagers.trustAll())
                             .getSSLContext();
-            lo.setSSLContext(sslContext);
-            lo.setUseStartTLS(useStartTLS);
+            options.set(SSL_CONTEXT, sslContext);
+            options.set(USE_STARTTLS, useStartTLS);
         } catch (GeneralSecurityException e) {
             System.err.println(e.getMessage());
             System.exit(ResultCode.CLIENT_SIDE_CONNECT_ERROR.intValue());
         }
-        return lo;
+        return options;
     }
 
     private static String  host;
diff --git a/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java b/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java
index a6e3501..de1d031 100644
--- a/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java
+++ b/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java
@@ -19,6 +19,8 @@
 import static org.forgerock.opendj.ldap.schema.CoreSchema.getEntryUUIDAttributeType;
 import static org.forgerock.opendj.rest2ldap.ReadOnUpdatePolicy.CONTROLS;
 import static org.forgerock.opendj.rest2ldap.Utils.ensureNotNull;
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
+import static org.forgerock.opendj.ldap.LDAPListener.*;
 
 import java.io.IOException;
 import java.security.GeneralSecurityException;
@@ -52,7 +54,6 @@
 import org.forgerock.opendj.ldap.FailoverLoadBalancingAlgorithm;
 import org.forgerock.opendj.ldap.Filter;
 import org.forgerock.opendj.ldap.LDAPConnectionFactory;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.ldap.LinkedAttribute;
 import org.forgerock.opendj.ldap.MultipleEntriesFoundException;
@@ -68,6 +69,7 @@
 import org.forgerock.opendj.ldap.requests.SearchRequest;
 import org.forgerock.opendj.ldap.schema.AttributeType;
 import org.forgerock.opendj.ldap.schema.Schema;
+import org.forgerock.util.Options;
 
 /**
  * Provides core factory methods and builders for constructing LDAP resource
@@ -1017,8 +1019,7 @@
         final ConnectionSecurity connectionSecurity =
                 configuration.get("connectionSecurity").defaultTo(ConnectionSecurity.NONE).asEnum(
                         ConnectionSecurity.class);
-        final LDAPOptions options = new LDAPOptions();
-        options.setProviderClassLoader(providerClassLoader);
+        final Options options = Options.defaultOptions().set(PROVIDER_CLASS_LOADER, providerClassLoader);
         if (connectionSecurity != ConnectionSecurity.NONE) {
             try {
                 // Configure SSL.
@@ -1045,8 +1046,9 @@
                             password != null ? password.toCharArray() : null, type));
                     break;
                 }
-                options.setSSLContext(builder.getSSLContext());
-                options.setUseStartTLS(connectionSecurity == ConnectionSecurity.STARTTLS);
+                options.set(SSL_CONTEXT, builder.getSSLContext());
+                options.set(USE_STARTTLS,
+                    connectionSecurity == ConnectionSecurity.STARTTLS);
             } catch (GeneralSecurityException | IOException e) {
                 // Rethrow as unchecked exception.
                 throw new IllegalArgumentException(e);
@@ -1117,7 +1119,7 @@
     private static ConnectionFactory parseLDAPServers(final JsonValue config,
             final BindRequest bindRequest, final int connectionPoolSize,
             final int heartBeatIntervalSeconds, final int heartBeatTimeoutMilliSeconds,
-            final LDAPOptions options) {
+            final Options options) {
         final List<ConnectionFactory> servers = new ArrayList<>(config.size());
         for (final JsonValue server : config) {
             final String host = server.get("hostname").required().asString();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
index 5998e49..a92f077 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
@@ -29,8 +29,9 @@
 import static com.forgerock.opendj.cli.ArgumentConstants.*;
 import static com.forgerock.opendj.cli.CliMessages.*;
 import static com.forgerock.opendj.cli.Utils.*;
-
+import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
 import static org.forgerock.util.Utils.*;
+
 import static org.opends.messages.AdminToolMessages.*;
 import static org.opends.messages.QuickSetupMessages.INFO_ERROR_READING_SERVER_CONFIGURATION;
 import static org.opends.messages.QuickSetupMessages.INFO_NOT_AVAILABLE_LABEL;
@@ -65,11 +66,11 @@
 import org.forgerock.opendj.ldap.AuthorizationException;
 import org.forgerock.opendj.ldap.Connection;
 import org.forgerock.opendj.ldap.LDAPConnectionFactory;
-import org.forgerock.opendj.ldap.LDAPOptions;
 import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SSLContextBuilder;
 import org.forgerock.opendj.ldap.TrustManagers;
+import org.forgerock.util.Options;
 import org.opends.admin.ads.util.ApplicationTrustManager;
 import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
 import org.opends.guitools.controlpanel.datamodel.BaseDNDescriptor;
@@ -1167,8 +1168,9 @@
 
     // This connection should always be secure. useSSL = true.
     Connection connection = null;
-    final LDAPOptions options = new LDAPOptions();
-    options.setConnectTimeout(ci.getConnectTimeout(), TimeUnit.MILLISECONDS);
+    final Options options = Options.defaultOptions();
+    options.set(CONNECT_TIMEOUT_IN_MILLISECONDS,
+        TimeUnit.MILLISECONDS.toMillis((long) ci.getConnectTimeout()));
     LDAPConnectionFactory factory = null;
     while (true)
     {
@@ -1177,8 +1179,8 @@
         final SSLContextBuilder sslBuilder = new SSLContextBuilder();
         sslBuilder.setTrustManager(trustManager == null ? TrustManagers.trustAll() : trustManager);
         sslBuilder.setKeyManager(keyManager);
-        options.setUseStartTLS(ci.useStartTLS());
-        options.setSSLContext(sslBuilder.getSSLContext());
+        options.set(USE_STARTTLS, ci.useStartTLS());
+        options.set(SSL_CONTEXT, sslBuilder.getSSLContext());
 
         factory = new LDAPConnectionFactory(hostName, portNumber, options);
         connection = factory.getConnection();

--
Gitblit v1.10.0