opendj-cli/src/main/java/com/forgerock/opendj/cli/AbstractAuthenticatedConnectionFactory.java
File was deleted opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentException.java
@@ -63,9 +63,7 @@ this.message = message; } /** * {@inheritDoc} */ /** {@inheritDoc} */ public LocalizableMessage getMessageObject() { return this.message; } opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentGroup.java
@@ -63,9 +63,7 @@ this.args = new LinkedList<Argument>(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ public int compareTo(final ArgumentGroup o) { // Groups with higher priority numbers appear before // those with lower priority in the usage output opendj-cli/src/main/java/com/forgerock/opendj/cli/AuthenticatedConnectionFactory.java
File was renamed from opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/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("); opendj-cli/src/main/java/com/forgerock/opendj/cli/BooleanArgument.java
@@ -64,9 +64,7 @@ .valueOf(false), null, description); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override final public void addValue(final String valueString) { if (valueString != null) { @@ -76,9 +74,7 @@ } } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override final public void setPresent(final boolean isPresent) { addValue(String.valueOf(isPresent)); opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java
@@ -47,7 +47,6 @@ import javax.net.ssl.X509TrustManager; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.ConnectionFactory; import org.forgerock.opendj.ldap.KeyManagers; import org.forgerock.opendj.ldap.LDAPConnectionFactory; @@ -67,7 +66,7 @@ /** * A connection factory designed for use with command line tools. */ public class ConnectionFactoryProvider extends AbstractAuthenticatedConnectionFactory { public class ConnectionFactoryProvider { /** * The Logger. */ @@ -312,11 +311,41 @@ } /** * Returns the connection factory. * Returns the host name. * * @return The host name value. */ public String getHostname() { if (hostNameArg.isPresent()) { return hostNameArg.getValue(); } return hostNameArg.getDefaultValue(); } /** * Get the port which has to be used for the command. * * @return The port specified by the command line argument, or the default value, if not specified. */ public int getPort() { if (portArg.isPresent()) { try { return portArg.getIntValue(); } catch (ArgumentException e) { return Integer.valueOf(portArg.getDefaultValue()); } } return Integer.valueOf(portArg.getDefaultValue()); } /** * Checks if any conflicting arguments are present, build the connection with * selected arguments and returns the connection factory. * * @return The connection factory. * @throws ArgumentException * If an error occurs during the parsing of the arguments. * If an error occurs during the parsing of the arguments. (conflicting * arguments or if an error occurs during building SSL context). */ public ConnectionFactory getConnectionFactory() throws ArgumentException { if (connFactory == null) { @@ -437,7 +466,7 @@ authenticatedConnFactory = getConnectionFactory(); final BindRequest bindRequest = getBindRequest(); if (bindRequest != null) { authenticatedConnFactory = newAuthenticatedConnectionFactory(authenticatedConnFactory, bindRequest); authenticatedConnFactory = new AuthenticatedConnectionFactory(authenticatedConnFactory, bindRequest); } } return authenticatedConnFactory; @@ -771,11 +800,4 @@ return option.substring(equalPos + 1, option.length()); } /** {@inheritDoc} */ @Override public ConnectionFactory newAuthenticatedConnectionFactory(final ConnectionFactory connection, final BindRequest request) throws ArgumentException { return null; } } opendj-cli/src/main/java/com/forgerock/opendj/cli/MenuBuilder.java
@@ -68,9 +68,7 @@ this.callbacks = callbacks; } /** * {@inheritDoc} */ /** {@inheritDoc} */ public MenuResult<T> invoke(ConsoleApplication app) throws ClientException { List<T> values = new ArrayList<T>(); for (MenuCallback<T> callback : callbacks) { @@ -149,9 +147,7 @@ this.nMaxTries = nMaxTries; } /** * {@inheritDoc} */ /** {@inheritDoc} */ public MenuResult<T> run() throws ClientException { // The validation call-back which will be used to determine the // action call-back. @@ -296,9 +292,7 @@ this.result = result; } /** * {@inheritDoc} */ /** {@inheritDoc} */ public MenuResult<T> invoke(ConsoleApplication app) throws ClientException { return result; } opendj-cli/src/main/java/com/forgerock/opendj/cli/PromptingTrustManager.java
@@ -54,7 +54,7 @@ * A trust manager which prompts the user for the length of time that they would * like to trust a server certificate. */ final class PromptingTrustManager implements X509TrustManager { public final class PromptingTrustManager implements X509TrustManager { /** * Enumeration description server certificate trust option. */ @@ -119,7 +119,27 @@ private final ConsoleApplication app; PromptingTrustManager(final ConsoleApplication app, final String acceptedStorePath, /** * Creates a prompting trust manager based on these arguments. * * @param app * The linked console application. * @param acceptedStorePath * The store path. * @param sourceTrustManager * The source of the trust manager. * @throws KeyStoreException * If no Provider supports a KeyStoreSpi implementation for the specified type. * @throws IOException * If there is an I/O or format problem with the keystore data, if a password is required but not given, * or if the given password was incorrect. If the error is due to a wrong password, the cause of the * IOException should be an UnrecoverableKeyException. * @throws NoSuchAlgorithmException * If no provider supports a trust manager factory spi implementation for the specified algorithm. * @throws CertificateException * If any of the certificates in the key store could not be loaded */ public PromptingTrustManager(final ConsoleApplication app, final String acceptedStorePath, final X509TrustManager sourceTrustManager) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException { Reject.ifNull(app, acceptedStorePath); @@ -170,11 +190,30 @@ this.onDiskTrustManager = x509tm; } PromptingTrustManager(final ConsoleApplication app, final X509TrustManager sourceTrustManager) /** * Creates a prompting trust manager based on these arguments. * * @param app * The linked console application. * @param sourceTrustManager * The source of the trust manager. * @throws KeyStoreException * If no Provider supports a KeyStoreSpi implementation for the specified type. * @throws IOException * If there is an I/O or format problem with the keystore data, if a password is required but not given, * or if the given password was incorrect. If the error is due to a wrong password, the cause of the * IOException should be an UnrecoverableKeyException. * @throws NoSuchAlgorithmException * If no provider supports a trust manager factory spi implementation for the specified algorithm. * @throws CertificateException * If any of the certificates in the key store could not be loaded */ public PromptingTrustManager(final ConsoleApplication app, final X509TrustManager sourceTrustManager) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException { this(app, DEFAULT_PATH, sourceTrustManager); } /** {@inheritDoc} */ public void checkClientTrusted(final X509Certificate[] x509Certificates, final String s) throws CertificateException { try { @@ -196,6 +235,7 @@ } } /** {@inheritDoc} */ public void checkServerTrusted(final X509Certificate[] x509Certificates, final String s) throws CertificateException { try { @@ -217,6 +257,7 @@ } } /** {@inheritDoc} */ public X509Certificate[] getAcceptedIssuers() { if (nestedTrustManager != null) { return nestedTrustManager.getAcceptedIssuers(); opendj-cli/src/main/java/com/forgerock/opendj/cli/TabSeparatedTablePrinter.java
@@ -59,9 +59,7 @@ // No implementation required. } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void addCell(String s) { // Avoid printing tab separators for trailing empty cells. @@ -79,9 +77,7 @@ column++; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void addHeading(String s) { if (displayHeadings) { @@ -89,9 +85,7 @@ } } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void endHeader() { if (displayHeadings) { @@ -99,34 +93,26 @@ } } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void endRow() { writer.println(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void endTable() { writer.flush(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void startHeader() { column = 0; requiredSeparators = 0; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void startRow() { column = 0; @@ -171,9 +157,7 @@ this.displayHeadings = displayHeadings; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override protected TableSerializer getSerializer() { return new Serializer(); opendj-cli/src/main/java/com/forgerock/opendj/cli/TextTablePrinter.java
@@ -74,27 +74,21 @@ this.indentPadding = builder.toString(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void addCell(String s) { currentRow.add(s); column++; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void addColumn(int width) { columnWidths.add(width); totalColumns++; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void addHeading(String s) { if (displayHeadings) { @@ -102,9 +96,7 @@ } } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void endHeader() { if (displayHeadings) { @@ -145,9 +137,7 @@ } } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void endRow() { boolean isRemainingText; @@ -222,17 +212,13 @@ } while (isRemainingText); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void endTable() { writer.flush(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void startHeader() { determineColumnWidths(); @@ -241,9 +227,7 @@ currentRow.clear(); } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override public void startRow() { column = 0; @@ -487,9 +471,7 @@ this.totalWidth = totalWidth; } /** * {@inheritDoc} */ /** {@inheritDoc} */ @Override protected TableSerializer getSerializer() { return new Serializer(); opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
@@ -51,6 +51,8 @@ import javax.net.ssl.SSLHandshakeException; import org.forgerock.i18n.LocalizableMessage; import org.forgerock.opendj.ldap.DN; import org.forgerock.opendj.ldap.RDN; /** * This class provides utility functions for all the client side tools. @@ -510,4 +512,31 @@ private Utils() { // Do nothing. } /** * Returns {@code true} if the the provided string is a DN and {@code false} otherwise. * * @param dn * the String we are analyzing. * @return {@code true} if the the provided string is a DN and {@code false} otherwise. */ public static boolean isDN(String dn) { try { DN.valueOf(dn); } catch (Exception ex) { return false; } return true; } /** * Returns the DN of the global administrator for a given UID. * * @param uid * The UID to be used to generate the DN. * @return The DN of the administrator for the given UID. */ private static String getAdministratorDN(String uid) { return "cn=" + RDN.valueOf(uid) + ",cn=Administrators, cn=admin data"; } } opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java
@@ -394,14 +394,7 @@ try { setDefaultPerfToolProperties(); connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this) { @Override public ConnectionFactory newAuthenticatedConnectionFactory(final ConnectionFactory connection, final BindRequest request) throws ArgumentException { return new AuthenticatedConnectionFactory(connection, request); } }; connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this); runner = new BindPerformanceRunner(argParser, this); propertiesFileArgument = CommonArguments.getPropertiesFile(); opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java
@@ -50,7 +50,6 @@ import org.forgerock.opendj.ldap.controls.AssertionRequestControl; import org.forgerock.opendj.ldap.controls.Control; import org.forgerock.opendj.ldap.controls.ProxiedAuthV2RequestControl; import org.forgerock.opendj.ldap.requests.BindRequest; import org.forgerock.opendj.ldap.requests.CompareRequest; import org.forgerock.opendj.ldap.requests.Requests; import org.forgerock.opendj.ldap.responses.Result; @@ -147,14 +146,7 @@ BooleanArgument noPropertiesFileArgument; try { connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this) { @Override public ConnectionFactory newAuthenticatedConnectionFactory(final ConnectionFactory connection, final BindRequest request) throws ArgumentException { return new AuthenticatedConnectionFactory(connection, request); } }; connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this); propertiesFileArgument = CommonArguments.getPropertiesFile(); argParser.addArgument(propertiesFileArgument); opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
@@ -56,7 +56,6 @@ import org.forgerock.opendj.ldap.controls.PreReadResponseControl; import org.forgerock.opendj.ldap.controls.ProxiedAuthV2RequestControl; import org.forgerock.opendj.ldap.requests.AddRequest; import org.forgerock.opendj.ldap.requests.BindRequest; import org.forgerock.opendj.ldap.requests.DeleteRequest; import org.forgerock.opendj.ldap.requests.ModifyDNRequest; import org.forgerock.opendj.ldap.requests.ModifyRequest; @@ -267,14 +266,7 @@ BooleanArgument noPropertiesFileArgument; try { connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this) { @Override public ConnectionFactory newAuthenticatedConnectionFactory(final ConnectionFactory connection, final BindRequest request) throws ArgumentException { return new AuthenticatedConnectionFactory(connection, request); } }; connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this); propertiesFileArgument = CommonArguments.getPropertiesFile(); argParser.addArgument(propertiesFileArgument); opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
@@ -37,7 +37,6 @@ import org.forgerock.opendj.ldap.ErrorResultException; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.controls.Control; import org.forgerock.opendj.ldap.requests.BindRequest; import org.forgerock.opendj.ldap.requests.PasswordModifyExtendedRequest; import org.forgerock.opendj.ldap.requests.Requests; import org.forgerock.opendj.ldap.responses.PasswordModifyExtendedResult; @@ -113,14 +112,7 @@ BooleanArgument noPropertiesFileArgument; try { connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this) { @Override public ConnectionFactory newAuthenticatedConnectionFactory(final ConnectionFactory connection, final BindRequest request) throws ArgumentException { return new AuthenticatedConnectionFactory(connection, request); } }; connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this); propertiesFileArgument = CommonArguments.getPropertiesFile(); argParser.addArgument(propertiesFileArgument); opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
@@ -68,7 +68,6 @@ import org.forgerock.opendj.ldap.controls.SimplePagedResultsControl; import org.forgerock.opendj.ldap.controls.VirtualListViewRequestControl; import org.forgerock.opendj.ldap.controls.VirtualListViewResponseControl; import org.forgerock.opendj.ldap.requests.BindRequest; import org.forgerock.opendj.ldap.requests.Requests; import org.forgerock.opendj.ldap.requests.SearchRequest; import org.forgerock.opendj.ldap.responses.Result; @@ -263,14 +262,7 @@ StringArgument assertionFilter; IntegerArgument sizeLimit; try { connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this) { @Override public ConnectionFactory newAuthenticatedConnectionFactory(final ConnectionFactory connection, final BindRequest request) throws ArgumentException { return new AuthenticatedConnectionFactory(connection, request); } }; connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this); final StringArgument propertiesFileArgument = CommonArguments.getPropertiesFile(); argParser.addArgument(propertiesFileArgument); opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ModRate.java
@@ -36,7 +36,6 @@ import org.forgerock.opendj.ldap.FutureResult; import org.forgerock.opendj.ldap.ModificationType; import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.requests.BindRequest; import org.forgerock.opendj.ldap.requests.ModifyRequest; import org.forgerock.opendj.ldap.requests.Requests; import org.forgerock.opendj.ldap.responses.Result; @@ -174,14 +173,7 @@ try { Utils.setDefaultPerfToolProperties(); connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this) { @Override public ConnectionFactory newAuthenticatedConnectionFactory(final ConnectionFactory connection, final BindRequest request) throws ArgumentException { return new AuthenticatedConnectionFactory(connection, request); } }; connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this); runner = new ModifyPerformanceRunner(argParser, this); propertiesFileArgument = CommonArguments.getPropertiesFile(); opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PerformanceRunner.java
@@ -58,7 +58,7 @@ import com.forgerock.opendj.cli.IntegerArgument; import com.forgerock.opendj.cli.MultiColumnPrinter; import com.forgerock.opendj.cli.StringArgument; import com.forgerock.opendj.ldap.tools.AuthenticatedConnectionFactory.AuthenticatedConnection; import com.forgerock.opendj.cli.AuthenticatedConnectionFactory.AuthenticatedConnection; import com.forgerock.opendj.util.StaticUtils; /** opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/SearchRate.java
@@ -43,7 +43,6 @@ import org.forgerock.opendj.ldap.ResultCode; import org.forgerock.opendj.ldap.SearchResultHandler; import org.forgerock.opendj.ldap.SearchScope; import org.forgerock.opendj.ldap.requests.BindRequest; import org.forgerock.opendj.ldap.requests.Requests; import org.forgerock.opendj.ldap.requests.SearchRequest; import org.forgerock.opendj.ldap.responses.Result; @@ -217,14 +216,7 @@ try { Utils.setDefaultPerfToolProperties(); connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this) { @Override public ConnectionFactory newAuthenticatedConnectionFactory(final ConnectionFactory connection, final BindRequest request) throws ArgumentException { return new AuthenticatedConnectionFactory(connection, request); } }; connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this); runner = new SearchPerformanceRunner(argParser, this); propertiesFileArgument = CommonArguments.getPropertiesFile(); opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/Utils.java
@@ -51,7 +51,7 @@ import com.forgerock.opendj.cli.ConsoleApplication; import com.forgerock.opendj.ldap.controls.AccountUsabilityRequestControl; import com.forgerock.opendj.ldap.tools.AuthenticatedConnectionFactory.AuthenticatedConnection; import com.forgerock.opendj.cli.AuthenticatedConnectionFactory.AuthenticatedConnection; import com.forgerock.opendj.util.StaticUtils; /**