mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
20 hours ago 4bba57225bdd211d9ca8129ba7ef7a3883069a53
Fix CodeQL note-severity alerts: uncaught NumberFormatException in the examples (#831)
28 files modified
1 files added
219 ■■■■ changed files
opendj-embedded-server-examples/src/main/java/org/forgerock/opendj/examples/ConfigureServer.java 19 ●●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/src/main/java/org/forgerock/opendj/examples/SetupServer.java 23 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Controls.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ExampleUtils.java 47 ●●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ExtendedOperations.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetADChangeNotifications.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Modify.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ModifyAsync.java 4 ●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ParseAttributes.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/PasswordResetForAD.java 4 ●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java 5 ●●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ReadSchema.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/RewriterProxy.java 6 ●●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java 6 ●●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchAsync.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchBind.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchBindAsync.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Server.java 3 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ShortLife.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ShortLifeAsync.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java 4 ●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuthAsync.java 8 ●●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UpdateGroup.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UpdateGroupAsync.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UseGenericControl.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UseSchema.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UseSchemaAsync.java 5 ●●●● patch | view | raw | blame | history
opendj-embedded-server-examples/src/main/java/org/forgerock/opendj/examples/ConfigureServer.java
@@ -12,6 +12,7 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
@@ -55,7 +56,7 @@
        }
        final String serverRootDir = args[0];
        final String newBaseDn = args[1];
        final int ldapPort = args.length > 2 ? Integer.parseInt(args[2]) : 1500;
        final int ldapPort = args.length > 2 ? parsePort(args[2]) : 1500;
        EmbeddedDirectoryServer server =
                manageEmbeddedDirectoryServer(
@@ -82,6 +83,22 @@
        }
    }
    /**
     * Returns the port number held by the provided command line argument.
     * <p>
     * Like the other command line argument checks of this example, a value which is not a port
     * number is reported on standard error and stops the example.
     */
    private static int parsePort(final String arg) {
        try {
            return Integer.parseInt(arg);
        } catch (final NumberFormatException e) {
            System.err.println("Invalid port number: " + arg);
            System.exit(1);
            return -1; // Never reached: System.exit() does not return.
        }
    }
    private ConfigureServer() {
        // Not used.
    }
opendj-embedded-server-examples/src/main/java/org/forgerock/opendj/examples/SetupServer.java
@@ -12,6 +12,7 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
@@ -61,9 +62,9 @@
        final String serverRootDir = args[i++];
        final String baseDn = (args.length > i) ? args[i++] : "o=example";
        final String backendType = (args.length > i) ? args[i++] : "pdb";
        final int ldapPort = (args.length > i) ? Integer.parseInt(args[i++]) : 1500;
        final int adminPort = (args.length > i) ? Integer.parseInt(args[i++]) : 4500;
        final int jmxPort = (args.length > i) ? Integer.parseInt(args[i++]) : 1600;
        final int ldapPort = (args.length > i) ? parsePort(args[i++]) : 1500;
        final int adminPort = (args.length > i) ? parsePort(args[i++]) : 4500;
        final int jmxPort = (args.length > i) ? parsePort(args[i++]) : 1600;
        performSetup(openDJArchive, serverRootDir, baseDn, backendType, ldapPort, adminPort, jmxPort);
    }
@@ -94,6 +95,22 @@
                    .jmxPort(jmxPort));
    }
    /**
     * Returns the port number held by the provided command line argument.
     * <p>
     * Like the other command line argument checks of this example, a value which is not a port
     * number is reported on standard error and stops the example.
     */
    private static int parsePort(final String arg) {
        try {
            return Integer.parseInt(arg);
        } catch (final NumberFormatException e) {
            System.err.println("Invalid port number: " + arg);
            System.exit(1);
            return -1; // Never reached: System.exit() does not return.
        }
    }
    private SetupServer() {
        // Not used.
    }
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Controls.java
@@ -12,10 +12,13 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2012-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import java.io.IOException;
import java.util.Collection;
@@ -100,7 +103,7 @@
            System.exit(1);
        }
        final String host = args[0];
        final int port = Integer.parseInt(args[1]);
        final int port = parsePort(args[1]);
        final LDAPConnectionFactory factory = new LDAPConnectionFactory(host, port);
        try (Connection connection = factory.getConnection()) {
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ExampleUtils.java
New file
@@ -0,0 +1,47 @@
/*
 * The contents of this file are subject to the terms of the Common Development and
 * Distribution License (the License). You may not use this file except in compliance with the
 * License.
 *
 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
 * specific language governing permission and limitations under the License.
 *
 * When distributing Covered Software, include this CDDL Header Notice in each file and include
 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
 * Header, with the fields enclosed by brackets [] replaced by your own identifying
 * information: "Portions copyright [year] [name of copyright owner]".
 *
 * Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import org.forgerock.opendj.ldap.ResultCode;
/** Utility methods shared by the example client applications. */
final class ExampleUtils {
    /**
     * Returns the port number held by the provided command line argument.
     * <p>
     * Like the other command line argument checks of the examples, a value which is not a port
     * number is reported on standard error and stops the example, rather than failing it with a
     * {@code NumberFormatException} stack trace.
     *
     * @param arg
     *            The command line argument holding the port number.
     * @return The port number held by the provided argument.
     */
    static int parsePort(final String arg) {
        try {
            return Integer.parseInt(arg);
        } catch (final NumberFormatException e) {
            System.err.println("Invalid port number: " + arg);
            System.exit(ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue());
            return -1; // Never reached: System.exit() does not return.
        }
    }
    private ExampleUtils() {
        // Prevent instantiation.
    }
}
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ExtendedOperations.java
@@ -12,10 +12,13 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2012-2014 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import java.util.Collection;
import org.forgerock.opendj.ldap.Connection;
@@ -55,7 +58,7 @@
            System.exit(1);
        }
        final String host = args[0];
        final int port = Integer.parseInt(args[1]);
        final int port = parsePort(args[1]);
        final LDAPConnectionFactory factory = new LDAPConnectionFactory(host, port);
        Connection connection = null;
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetADChangeNotifications.java
@@ -13,10 +13,13 @@
 *
 * Copyright 2009-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import java.io.IOException;
import org.forgerock.opendj.ldap.Connection;
@@ -66,7 +69,7 @@
        // Parse command line arguments.
        final String hostName = args[0];
        final int port = Integer.parseInt(args[1]);
        final int port = parsePort(args[1]);
        final String userName = args[2];
        final String password = args[3];
        final String baseDN = args[4];
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java
@@ -12,9 +12,12 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2012-2014 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import java.io.IOException;
import org.forgerock.opendj.ldap.Connection;
@@ -113,7 +116,7 @@
        }
        host = args[0];
        port = Integer.parseInt(args[1]);
        port = parsePort(args[1]);
        infoType = args[2];
        final String infoTypeLc = infoType.toLowerCase();
        if (!"all".equals(infoTypeLc)
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Modify.java
@@ -13,10 +13,13 @@
 *
 * Copyright 2009-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -57,7 +60,7 @@
        // Parse command line arguments.
        final String hostName = args[0];
        final int port = Integer.parseInt(args[1]);
        final int port = parsePort(args[1]);
        final String userName = args[2];
        final String password = args[3];
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ModifyAsync.java
@@ -17,7 +17,9 @@
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import static org.forgerock.util.Utils.closeSilently;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
import org.forgerock.opendj.ldap.LdapException;
@@ -75,7 +77,7 @@
        // Parse command line arguments.
        final String hostName = args[0];
        final int port = Integer.parseInt(args[1]);
        final int port = parsePort(args[1]);
        final String userName = args[2];
        final char[] password = args[3].toCharArray();
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ParseAttributes.java
@@ -12,10 +12,13 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2012-2014 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import java.io.IOException;
import java.util.Calendar;
import java.util.Set;
@@ -57,7 +60,7 @@
            System.exit(1);
        }
        final String host = args[0];
        final int port = Integer.parseInt(args[1]);
        final int port = parsePort(args[1]);
        // --- JCite ---
        final LDAPConnectionFactory factory = new LDAPConnectionFactory(host, port);
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/PasswordResetForAD.java
@@ -12,10 +12,12 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2013-2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
import org.forgerock.opendj.ldap.Connection;
@@ -67,7 +69,7 @@
            System.exit(1);
        }
        final String host = args[0];
        final int port = Integer.parseInt(args[1]);
        final int port = parsePort(args[1]);
        final String mode = args[2];
        final String bindDN = args[3];
        final String bindPassword = args[4];
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java
@@ -18,6 +18,7 @@
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
import static org.forgerock.opendj.ldap.LDAPListener.*;
import static org.forgerock.opendj.ldap.requests.Requests.newSimpleBindRequest;
@@ -91,7 +92,7 @@
        }
        final String localAddress = args[i++];
        final int localPort = Integer.parseInt(args[i++]);
        final int localPort = parsePort(args[i++]);
        final String proxyDN = args[i++];
        final String proxyPassword = args[i++];
@@ -109,7 +110,7 @@
        for (; i < args.length; i += 2) {
            final String remoteAddress = args[i];
            final int remotePort = Integer.parseInt(args[i + 1]);
            final int remotePort = parsePort(args[i + 1]);
            factories.add(Connections.newCachedConnectionPool(new LDAPConnectionFactory(remoteAddress,
                                                                                        remotePort,
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ReadSchema.java
@@ -13,10 +13,13 @@
 *
 * Copyright 2009-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.DN;
@@ -52,7 +55,7 @@
        // Parse command line arguments.
        final String hostName = args[0];
        final int port = Integer.parseInt(args[1]);
        final int port = parsePort(args[1]);
        final String userName = args[2];
        final String password = args[3];
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/RewriterProxy.java
@@ -13,10 +13,12 @@
 *
 * Copyright 2009-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import static org.forgerock.opendj.ldap.Connections.newCachedConnectionPool;
import static org.forgerock.opendj.ldap.LDAPListener.*;
import static org.forgerock.opendj.ldap.requests.Requests.newSimpleBindRequest;
@@ -384,11 +386,11 @@
        }
        final String localAddress = args[0];
        final int localPort = Integer.parseInt(args[1]);
        final int localPort = parsePort(args[1]);
        final String proxyDN = args[2];
        final String proxyPassword = args[3];
        final String remoteAddress = args[4];
        final int remotePort = Integer.parseInt(args[5]);
        final int remotePort = parsePort(args[5]);
        // Create connection factories.
        final Options factoryOptions = Options.defaultOptions()
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java
@@ -12,6 +12,7 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2011-2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
/**
@@ -22,8 +23,9 @@
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.SSL_USE_STARTTLS;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.SSL_CONTEXT;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.SSL_USE_STARTTLS;
import java.security.GeneralSecurityException;
@@ -141,7 +143,7 @@
        }
        host = args[0];
        port = Integer.parseInt(args[1]);
        port = parsePort(args[1]);
        if (args.length == 5) {
            authzid = args[2];
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java
@@ -13,10 +13,13 @@
 *
 * Copyright 2009-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import java.io.IOException;
import java.util.Arrays;
@@ -57,7 +60,7 @@
        // Parse command line arguments.
        final String hostName = args[0];
        final int port = Integer.parseInt(args[1]);
        final int port = parsePort(args[1]);
        final String userName = args[2];
        final String password = args[3];
        final String baseDN = args[4];
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchAsync.java
@@ -12,9 +12,12 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2015-2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.CountDownLatch;
@@ -141,7 +144,7 @@
        // Parse command line arguments.
        final String hostName = args[0];
        final int port = Integer.parseInt(args[1]);
        final int port = parsePort(args[1]);
        userName = args[2];
        password = args[3];
        baseDN = args[4];
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchBind.java
@@ -12,10 +12,13 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2012-2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import java.io.Console;
import org.forgerock.opendj.ldap.Connection;
@@ -53,7 +56,7 @@
            System.exit(1);
        }
        String host = args[0];
        int port = Integer.parseInt(args[1]);
        int port = parsePort(args[1]);
        String baseDN = args[2];
        // --- JCite ---
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchBindAsync.java
@@ -12,11 +12,14 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import static org.forgerock.util.Utils.closeSilently;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.Filter;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
@@ -80,7 +83,7 @@
            System.exit(1);
        }
        final String host   = args[0];
        final int    port   = Integer.parseInt(args[1]);
        final int    port   = parsePort(args[1]);
        final String baseDn = args[2];
        // Prompt for email address and password.
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Server.java
@@ -18,6 +18,7 @@
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import static org.forgerock.opendj.ldap.LDAPListener.*;
import java.io.FileInputStream;
@@ -73,7 +74,7 @@
        // Parse command line arguments.
        final String localAddress = args[0];
        final int localPort = Integer.parseInt(args[1]);
        final int localPort = parsePort(args[1]);
        final String ldifFileName = args[2];
        final String keyStoreFileName = (args.length == 6) ? args[3] : null;
        final String keyStorePassword = (args.length == 6) ? args[4] : null;
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ShortLife.java
@@ -12,10 +12,13 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2012-2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import java.io.IOException;
import org.forgerock.opendj.ldap.Connection;
@@ -59,7 +62,7 @@
            System.exit(1);
        }
        String host = args[0];
        int port = Integer.parseInt(args[1]);
        int port = parsePort(args[1]);
        // User credentials of a "Directory Administrators" group member.
        // Kirsten Vaughan is authorized to create, update, and delete
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ShortLifeAsync.java
@@ -12,11 +12,14 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import static org.forgerock.util.Utils.closeSilently;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.Entries;
import org.forgerock.opendj.ldap.Entry;
@@ -79,7 +82,7 @@
            System.exit(1);
        }
        final String host = args[0];
        final int    port = Integer.parseInt(args[1]);
        final int    port = parsePort(args[1]);
        // User credentials of a "Directory Administrators" group member.
        // Kirsten Vaughan is authorized to create, update, and delete entries.
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java
@@ -12,10 +12,12 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2011-2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.*;
import java.io.File;
@@ -269,7 +271,7 @@
        }
        host = args[0];
        port = Integer.parseInt(args[1]);
        port = parsePort(args[1]);
        bindDN = args[2];
        bindPassword = args[3];
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuthAsync.java
@@ -12,14 +12,16 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.SSL_CONTEXT;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.SSL_USE_STARTTLS;
import static org.forgerock.opendj.ldap.TrustManagers.checkHostName;
import static org.forgerock.util.Utils.closeSilently;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.SSL_USE_STARTTLS;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.SSL_CONTEXT;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
@@ -218,7 +220,7 @@
        }
        host = args[0];
        port = Integer.parseInt(args[1]);
        port = parsePort(args[1]);
        bindDN = args[2];
        bindPassword = args[3];
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UpdateGroup.java
@@ -12,10 +12,13 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2012-2014 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import java.util.Collection;
import org.forgerock.opendj.ldap.Connection;
@@ -72,7 +75,7 @@
            printUsage();
        }
        final String host = args[0];
        final int port = Integer.parseInt(args[1]);
        final int port = parsePort(args[1]);
        final String groupDN = args[2];
        final String memberDN = args[3];
        final ModificationType modType = getModificationType(args[4]);
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UpdateGroupAsync.java
@@ -12,10 +12,13 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2016 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import static org.forgerock.util.Utils.closeSilently;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
import org.forgerock.opendj.ldap.LdapException;
@@ -83,7 +86,7 @@
            printUsage();
        }
        final String host              = args[0];
        final int port                 = Integer.parseInt(args[1]);
        final int port                 = parsePort(args[1]);
        final String groupDn           = args[2];
        final String memberDn          = args[3];
        final ModificationType modType = getModificationType(args[4]);
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UseGenericControl.java
@@ -13,10 +13,13 @@
 *
 * Copyright 2009-2010 Sun Microsystems, Inc.
 * Portions Copyright 2011-2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteStringBuilder;
@@ -68,7 +71,7 @@
        // Parse command line arguments.
        final String hostName = args[0];
        final int port = Integer.parseInt(args[1]);
        final int port = parsePort(args[1]);
        final String userName = args[2];
        final String password = args[3];
        final String userDN = args[4];
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UseSchema.java
@@ -12,10 +12,13 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.DN;
@@ -65,7 +68,7 @@
        // Parse command line arguments.
        final String host         = args[0];
        final int    port         = Integer.parseInt(args[1]);
        final int    port         = parsePort(args[1]);
        final String bindDn       = args[2];
        final String bindPassword = args[3];
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/UseSchemaAsync.java
@@ -12,11 +12,14 @@
 * information: "Portions Copyright [year] [name of copyright owner]".
 *
 * Copyright 2015 ForgeRock AS.
 * Portions Copyright 2026 3A Systems, LLC.
 */
package org.forgerock.opendj.examples;
import static org.forgerock.opendj.examples.ExampleUtils.parsePort;
import static org.forgerock.util.Utils.closeSilently;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.DN;
@@ -80,7 +83,7 @@
        // Parse command line arguments.
        final String host         = args[0];
        final int    port         = Integer.parseInt(args[1]);
        final int    port         = parsePort(args[1]);
        final String bindDn       = args[2];
        final char[] bindPassword = args[3].toCharArray();