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

Violette Roche-Montane
03.21.2014 7efc6f92f5937fb085bb0b72b09214cd79600b8f
opendj-sdk/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";
    }
}