Class SetupUtils

    • Constructor Detail

      • SetupUtils

        public SetupUtils()
    • Method Detail

      • createTemplateFile

        public static File createTemplateFile​(String baseDN,
                                              int numEntries)
                                       throws IOException
        Creates a MakeLDIF template file using the provided information.
        Parameters:
        baseDN - The base DN for the data in the template file.
        numEntries - The number of user entries the template file should create.
        Returns:
        The File object that references the created template file.
        Throws:
        IOException - If a problem occurs while writing the template file.
      • createTemplateFile

        public static File createTemplateFile​(Set<String> baseDNs,
                                              int numEntries)
                                       throws IOException
        Creates a MakeLDIF template file using the provided information.
        Parameters:
        baseDNs - The base DNs for the data in the template file.
        numEntries - The number of user entries the template file should create.
        Returns:
        The File object that references the created template file.
        Throws:
        IOException - If a problem occurs while writing the template file.
      • canUseAsPort

        public static boolean canUseAsPort​(int port)
        Returns true if the provided port is free and we can use it, false otherwise.
        Parameters:
        port - the port we are analyzing.
        Returns:
        true if the provided port is free and we can use it, false otherwise.
      • isPrivilegedPort

        public static boolean isPrivilegedPort​(int port)
        Returns true if the provided port is a privileged port, false otherwise.
        Parameters:
        port - the port we are analyzing.
        Returns:
        true if the provided port is a privileged port, false otherwise.
      • getScriptPath

        public static String getScriptPath​(String script)
        Returns the String that can be used to launch an script using Runtime.exec. This method is required because in Windows the script that contain a "=" in their path must be quoted.
        Parameters:
        script - the script name
        Returns:
        the absolute path for the given parentPath and relativePath.
      • createSelfSignedCertificatePwd

        public static char[] createSelfSignedCertificatePwd()
        Returns a randomly generated password for a self-signed certificate keystore.
        Returns:
        a randomly generated password for a self-signed certificate keystore.
      • exportCertificate

        public static void exportCertificate​(CertificateManager certManager,
                                             String alias,
                                             String path)
                                      throws CertificateEncodingException,
                                             IOException,
                                             KeyStoreException
        Export a certificate in a file. If the certificate alias to export is null, It will export the first certificate defined.
        Parameters:
        certManager - Certificate manager to use.
        alias - Certificate alias to export. If null the first certificate defined will be exported.
        path - Path of the output file.
        Throws:
        CertificateEncodingException - If the certificate manager cannot encode the certificate.
        IOException - If a problem occurs while creating or writing in the output file.
        KeyStoreException - If the certificate manager cannot retrieve the certificate to be exported.
      • getHostNameForCertificate

        public static String getHostNameForCertificate​(String installationRoot)
                                                throws UnknownHostException
        Returns the host name to be used to create self-signed certificates.
        The method will first try to read the host name file written by the setup where the user provided the host name where OpenDJ has been installed. If the file cannot be read, the class InetAddress is used.
        Parameters:
        installationRoot - the path where the server is installed.
        Returns:
        the host name to be used to create self-signed certificates.
        Throws:
        UnknownHostException - if a host name could not be used.