From 7efc6f92f5937fb085bb0b72b09214cd79600b8f Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Thu, 03 Apr 2014 15:21:56 +0000
Subject: [PATCH] Checkpoint for OPENDJ-1303 "opendj-cli" - Moved AuthenticatedConnectionFactory from tools to cli.   -- Undo modifications on tools about abstract authenticated connection factory. (and deleted the file)   -- Deleted the file from the tools. - Added functions to opendj-cli Utils. - Trivial code cleanup.

---
 opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/AuthenticatedConnectionFactory.java |   31 +++++++++++++++++++++++--------
 1 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthenticatedConnectionFactory.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/AuthenticatedConnectionFactory.java
similarity index 91%
rename from opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthenticatedConnectionFactory.java
rename to opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/AuthenticatedConnectionFactory.java
index 9fcce6e..82c61d5 100644
--- a/opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthenticatedConnectionFactory.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/AuthenticatedConnectionFactory.java
@@ -24,8 +24,7 @@
  *      Copyright 2009-2010 Sun Microsystems, Inc.
  *      Portions copyright 2011-2014 ForgeRock AS.
  */
-
-package com.forgerock.opendj.ldap.tools;
+package com.forgerock.opendj.cli;
 
 import org.forgerock.opendj.ldap.Connection;
 import org.forgerock.opendj.ldap.AbstractConnectionWrapper;
@@ -61,13 +60,13 @@
  * the connection attempt will fail and an {@code ErrorResultException} will be
  * thrown.
  */
-final class AuthenticatedConnectionFactory implements ConnectionFactory {
+public final class AuthenticatedConnectionFactory implements ConnectionFactory {
 
     /**
      * An authenticated connection supports all operations except Bind
      * operations.
      */
-    static final class AuthenticatedConnection extends AbstractConnectionWrapper<Connection> {
+    public static final class AuthenticatedConnection extends AbstractConnectionWrapper<Connection> {
 
         private final BindRequest request;
         private volatile BindResult result;
@@ -83,15 +82,17 @@
          * Bind operations are not supported by pre-authenticated connections.
          * These methods will always throw {@code UnsupportedOperationException}.
          */
-
+        /** {@inheritDoc} */
         public BindResult bind(BindRequest request) throws ErrorResultException {
             throw new UnsupportedOperationException();
         }
 
+        /** {@inheritDoc} */
         public BindResult bind(String name, char[] password) throws ErrorResultException {
             throw new UnsupportedOperationException();
         }
 
+        /** {@inheritDoc} */
         public FutureResult<BindResult> bindAsync(BindRequest request,
                 IntermediateResponseHandler intermediateResponseHandler,
                 ResultHandler<? super BindResult> resultHandler) {
@@ -105,7 +106,7 @@
          * @return The Bind result which was returned from the server after
          *         authentication.
          */
-        BindResult getAuthenticatedBindResult() {
+        public BindResult getAuthenticatedBindResult() {
             return result;
         }
 
@@ -125,7 +126,7 @@
          *             If this connection has already been closed, i.e. if
          *             {@code isClosed() == true}.
          */
-        FutureResult<BindResult> rebindAsync(final ResultHandler<? super BindResult> handler) {
+        public FutureResult<BindResult> rebindAsync(final ResultHandler<? super BindResult> handler) {
             if (request == null) {
                 throw new UnsupportedOperationException();
             }
@@ -138,6 +139,7 @@
 
             final ResultHandler<BindResult> handlerWrapper = new ResultHandler<BindResult>() {
 
+                /** {@inheritDoc} */
                 public void handleErrorResult(final ErrorResultException error) {
                     /*
                      * This connection is now unauthenticated so prevent further
@@ -150,6 +152,7 @@
                     }
                 }
 
+                /** {@inheritDoc} */
                 public void handleResult(final BindResult result) {
                     // Save the result.
                     AuthenticatedConnection.this.result = result;
@@ -164,6 +167,11 @@
             return connection.bindAsync(request, null, handlerWrapper);
         }
 
+        /**
+         * Returns the string representation of this authenticated connection.
+         *
+         * @return The string representation of this authenticated connection factory.
+         */
         public String toString() {
             StringBuilder builder = new StringBuilder();
             builder.append("AuthenticatedConnection(");
@@ -238,7 +246,7 @@
      * @throws NullPointerException
      *             If {@code factory} or {@code request} was {@code null}.
      */
-    AuthenticatedConnectionFactory(final ConnectionFactory factory, final BindRequest request) {
+    public AuthenticatedConnectionFactory(final ConnectionFactory factory, final BindRequest request) {
         Reject.ifNull(factory, request);
         this.parentFactory = factory;
 
@@ -251,6 +259,7 @@
         parentFactory.close();
     }
 
+    /** {@inheritDoc} */
     public Connection getConnection() throws ErrorResultException {
         final Connection connection = parentFactory.getConnection();
         BindResult bindResult = null;
@@ -269,6 +278,7 @@
         return new AuthenticatedConnection(connection, request, bindResult);
     }
 
+    /** {@inheritDoc} */
     public FutureResult<Connection> getConnectionAsync(
             final ResultHandler<? super Connection> handler) {
         final FutureResultImpl future = new FutureResultImpl(request, handler);
@@ -310,6 +320,11 @@
         return this;
     }
 
+    /**
+     * Returns the string representation of this authenticated connection factory.
+     *
+     * @return The string representation of this authenticated connection factory.
+     */
     public String toString() {
         final StringBuilder builder = new StringBuilder();
         builder.append("AuthenticatedConnectionFactory(");

--
Gitblit v1.10.0