Class Setup

  • All Implemented Interfaces:
    Profile.SetupConfiguration

    public final class Setup
    extends Object
    implements Profile.SetupConfiguration
    Class used to install a new OpenDJ server instance.

    This class is responsible for

    • Collect all parameters (such as port numbers, root user credentials, ...)
    • Copy the content of the template directory from the install path to the instance path
    • Modify the config.ldif configuration template file
    • Performs optional additional actions (configure replication, import sample data, start windows service...)
    • Field Detail

      • JVM_TRUST_MANAGER_PROVIDER

        public static final String JVM_TRUST_MANAGER_PROVIDER
        The name of the JVM trust manager provider provided in the config template.
        See Also:
        Constant Field Values
    • Method Detail

      • newSetup

        public static Setup newSetup()
        Creates a new Setup object to start adding setup parameters.
        Returns:
        a new Setup object to start adding setup parameters.
      • adminPort

        public Setup adminPort​(int adminPort)
                        throws com.forgerock.opendj.cli.ArgumentException
        Specifies the administration port of the instance to setup.

        This method must have been called with a non null parameter before that the setup() method is called since the administration port is a mandatory parameter.

        Parameters:
        adminPort - The administration port number
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided port number is invalid. This exception can be throws if the port is already in use on the running machine, this verification can be disabled using checkPortAvailability(boolean).
      • checkPortAvailability

        public Setup checkPortAvailability​(boolean checkPortAvailability)
        Specifies whether the port availability should be verified during the validation phase.

        This option is enabled by default

        Parameters:
        checkPortAvailability - false if the port availability performed before setup should be disabled
        Returns:
        This Setup object
      • enableWindowsService

        public Setup enableWindowsService​(boolean enableWindowsService)
                                   throws com.forgerock.opendj.cli.ArgumentException
        Specifies whether the OpenDJ windows service should be enabled.

        This option will only have effect if the running OS is windows. By default, the windows service is disabled

        Parameters:
        enableWindowsService - true if the windows service should be enabled
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the running operating system is not windows
      • fullyQualifiedHostName

        public Setup fullyQualifiedHostName​(String fullyQualifiedHostName)
                                     throws com.forgerock.opendj.cli.ArgumentException
        Specifies the fully qualified hostname of the server to setup.

        This method must have been called before that the setup() method is called since the administration port is a mandatory parameter.

        Parameters:
        fullyQualifiedHostName - The fully qualified hostname of the server to setup
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided value is invalid
      • ldapPort

        public Setup ldapPort​(int ldapPort,
                              boolean enableStartTls)
                       throws com.forgerock.opendj.cli.ArgumentException
        Specifies that the ldap connection handler must be enabled and listening on the provided port and whether start TLS should be enabled. By default, the ldap connection handler will be disabled.

        Parameters:
        ldapPort - The ldap port to listen
        enableStartTls - true if startTls must be enabled on the ldap connection handler
        Returns:
        This Setup
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided port number is invalid. This exception can be throws if the port is already in use on the running machine, this verification can be disabled using checkPortAvailability(boolean).
      • ldapPort

        public Setup ldapPort​(int ldapPort)
                       throws com.forgerock.opendj.cli.ArgumentException
        Specifies that the ldap connection handler must be enabled and listening on the provided port. By default, the ldap connection handler will be disabled.
        Parameters:
        ldapPort - The ldap port to listen
        Returns:
        This Setup
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided port number is invalid. This exception can be thrown if the port is already in use on the running machine. This verification can be disabled using checkPortAvailability(boolean).
      • enableStartTls

        public Setup enableStartTls​(boolean enableStartTls)
        Specifies whether start TLS should be enabled on the LDAP connection handler.

        By default, the LDAP connection handler will be disabled.

        Parameters:
        enableStartTls - true if startTls must be enabled on the ldap connection handler
        Returns:
        This Setup
        See Also:
        ldapPort(int, boolean), ldapPort(int)
      • disableLdapConnectionHandler

        public Setup disableLdapConnectionHandler()
        Disables the LDAP connection handler.

        By default, the LDAP connection handler is disabled.

        Returns:
        This Setup
        See Also:
        ldapPort(int, boolean)
      • ldapSecurePort

        public Setup ldapSecurePort​(int ldapSecurePort)
                             throws com.forgerock.opendj.cli.ArgumentException
        Specifies that the ldaps connection handler must be enabled and listening on the provided port. By default or if the provided port is null, the ldaps connection handler will be disabled.
        Parameters:
        ldapSecurePort - The ldaps port to listen
        Returns:
        This Setup
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided port number is invalid. This exception can be throws if the port is already in use on the running machine, this verification can be disabled using checkPortAvailability(boolean).
      • disableLdapSecureConnectionHandler

        public Setup disableLdapSecureConnectionHandler()
        Disables the LDAPS connection handler.

        By default, the LDAPS connection handler is disabled

        Returns:
        This Setup
        See Also:
        ldapSecurePort(int)
      • httpPort

        public Setup httpPort​(int httpPort)
                       throws com.forgerock.opendj.cli.ArgumentException
        Specifies that the http connection handler must be enabled and listening on the provided port.

        By default, the http connection handler will be disabled.

        Parameters:
        httpPort - The http connection handler listen port
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided port number is invalid. This exception can be throws if the port is already in use on the running machine, this verification can be disabled using checkPortAvailability(boolean).
      • disableHttpConnectionHandler

        public Setup disableHttpConnectionHandler()
        Disables the HTTP connection handler.

        By default, the HTTP connection handler is disabled.

        Returns:
        This Setup
        See Also:
        httpPort(int)
      • httpSecurePort

        public Setup httpSecurePort​(int httpSecurePort)
                             throws com.forgerock.opendj.cli.ArgumentException
        Specifies that the https connection handler must be enabled and listening on the provided port.

        By default, the https connection handler will be disabled.

        Parameters:
        httpSecurePort - The https connection handler listen port
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided port number is invalid. This exception can be throws if the port is already in use on the running machine, this verification can be disabled using checkPortAvailability(boolean).
      • disableHttpSecureConnectionHandler

        public Setup disableHttpSecureConnectionHandler()
        Disables the HTTPS connection handler.

        By default, the HTTPS connection handler is disabled.

        Returns:
        This Setup
        See Also:
        httpSecurePort(int)
      • installDirectory

        public Setup installDirectory​(String installDirectory)
                               throws com.forgerock.opendj.cli.ArgumentException
        Specifies the path of the OpenDJ archive to use to setup the server instance.

        By default, the running directory is used

        Parameters:
        installDirectory - Path of the OpenDJ archive to use to setup the server
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided path does not reference an existing directory
      • installDirectory

        public Setup installDirectory​(Path installPath)
                               throws com.forgerock.opendj.cli.ArgumentException
        Specifies the path of the OpenDJ archive to use to setup the server instance.

        By default, the running directory is used

        Parameters:
        installPath - Path of the OpenDJ archive to use to setup the server
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided path does not reference an existing directory
      • instanceDirectory

        public Setup instanceDirectory​(String instanceDirectory)
                                throws com.forgerock.opendj.cli.ArgumentException
        Specifies the path of the OpenDJ instance to setup.

        By default, the install directory will be used

        Parameters:
        instanceDirectory - Path of the instance to setup
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the instance path does not reference a directory or if the parent path is invalid.
      • instanceDirectory

        public Setup instanceDirectory​(Path instancePath)
                                throws com.forgerock.opendj.cli.ArgumentException
        Specifies the path of the opendj instance to setup.

        By default, the install directory will be used. If the instance directory does not exists, it will be created.

        Parameters:
        instancePath - Path of the instance to setup
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the instance path does not reference a directory or if the parent path is invalid.
      • deploymentId

        public Setup deploymentId​(DeploymentId deploymentId)
        Specifies the DeploymentId which should be used for securing the deployment. The deployment ID MUST be the same for all servers in the deployment. Create a new deployment ID for the first server, then re-use it for subsequent servers.
        Parameters:
        deploymentId - The deployment ID
        Returns:
        This Setup object
      • deploymentId

        public Setup deploymentId​(String key,
                                  String password)
                           throws com.forgerock.opendj.cli.ArgumentException
        Specifies the DeploymentId which should be used for securing the deployment. The deployment ID MUST be the same for all servers in the deployment. The decoded deployment ID can be obtained by calling getDeploymentId().
        Parameters:
        key - A string representing the deployment ID
        password - The deployment ID password
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the deployment ID cannot be decoded (i.e is invalid), if the running JVM does not support the security algorithms used by the DeploymentId class or if the password is incorrect
        See Also:
        getDeploymentId()
      • rootUserDn

        public Setup rootUserDn​(String rootUserDn)
                         throws com.forgerock.opendj.cli.ArgumentException
        Specifies the user root distinguish name of the instance to setup.

        By default, "uid=admin" will be used

        Parameters:
        rootUserDn - The distinguish name of the user root of the instance to setup
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided value can not be parsed as a valid Dn
      • rootUserDn

        public Setup rootUserDn​(Dn rootUserDn)
                         throws com.forgerock.opendj.cli.ArgumentException
        Specifies the user root distinguish name of the instance to setup.

        By default, "uid=admin" will be used

        Parameters:
        rootUserDn - The distinguish name of the user root of the instance to setup
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided Dn is invalid
      • rootUserPassword

        public Setup rootUserPassword​(String rootUserPassword)
                               throws com.forgerock.opendj.cli.ArgumentException
        Specifies the user root password of the instance to setup.

        This method must have been called before that the setup() method is called since the root user password is a mandatory parameter.

        Parameters:
        rootUserPassword - The password of the user root of the instance to setup
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided value is not acceptable as a password
      • monitorUserDn

        public Setup monitorUserDn​(Dn monitorUserDn)
                            throws com.forgerock.opendj.cli.ArgumentException
        Specifies the DN of the monitor user, having access to monitor information.

        By default, "uid=Monitor" will be used

        Parameters:
        monitorUserDn - the DN of the user to setup
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided Dn is invalid
      • monitorUserDn

        public Setup monitorUserDn​(String monitorUserDn)
                            throws com.forgerock.opendj.cli.ArgumentException
        Specifies the DN of the monitor user, having access to monitor information.

        By default, "uid=Monitor" will be used

        Parameters:
        monitorUserDn - the DN of the user to setup
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided Dn is invalid
      • monitorUserPassword

        public Setup monitorUserPassword​(String monitorUserPassword)
                                  throws com.forgerock.opendj.cli.ArgumentException
        Specifies the password of the monitor user.
        Parameters:
        monitorUserPassword - The password of the monitor user
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided password is not acceptable as a password
      • disableMonitorUserCreation

        public Setup disableMonitorUserCreation()
        Specifies that a monitor user must not be created in the DS server to be setup.
        Returns:
        This Setup object
      • startServer

        public Setup startServer​(boolean startServer)
        Specifies whether the server should start during the setup process.

        This attribute is true by default Note that depending on the setup options chosen, this parameter may be mandatory

        Parameters:
        startServer - false if the server should not start during the setup process
        Returns:
        This Setup object
      • bootstrapReplicationServers

        public Setup bootstrapReplicationServers​(String... bootstrapReplicationServers)
                                          throws com.forgerock.opendj.cli.ArgumentException
        Specifies the addresses of replication servers to which the server will try to connect at startup time.

        To enable replication in the instance to setup, at least one bootstrap server must have been provided before setup() method is called.

        Parameters:
        bootstrapReplicationServers - Bootstrap replication server addresses. Addresses must be specified using the replication port of the remote replication server(s).
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If one of the provided cannot be HostPort.valueOf(String) as a valid object
      • clearBootstrapReplicationServers

        public Setup clearBootstrapReplicationServers()
        Removes all bootstrapReplicationServers(HostPort...) bootstrap replication servers} registered in this Setup.

        By default, replication is disabled so this method is intended to be used only by interactive applications (when a user can update his choices).

        Returns:
        This Setup object
      • bootstrapReplicationServers

        public Setup bootstrapReplicationServers​(com.forgerock.opendj.util.HostPort... bootstrapReplicationServers)
        Specifies the addresses of replication servers to which the server will try to connect at startup time.

        To enable replication in the instance to setup, at least one bootstrap server must have been provided before setup() method is called.

        Parameters:
        bootstrapReplicationServers - Bootstrap replication server addresses. Addresses must be specified using the replication port of the remote replication server(s).
        Returns:
        This Setup object
      • bootstrapReplicationServers

        public Setup bootstrapReplicationServers​(Collection<com.forgerock.opendj.util.HostPort> bootstrapReplicationServers)
        Specifies the addresses of replication servers to which the server will try to connect at startup time.

        To enable replication in the instance to setup, at least one bootstrap server must have been provided before setup() method is called.

        Parameters:
        bootstrapReplicationServers - Bootstrap server addresses. Addresses must be specified using the replication port of the remote replication server(s).
        Returns:
        This Setup object
      • replicationPort

        public Setup replicationPort​(int replicationPort)
                              throws com.forgerock.opendj.cli.ArgumentException
        Specifies that the instance to setup will be configured with a replication server listening on the provided port number.

        If this method is not called before setup(), no replication server will be configured in the instance. In other words, the server will be configured as a standalone DS, changelog will be disabled so the server must connect to another server with a changelog in order to synchronize changes.

        Parameters:
        replicationPort - The replication port number
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided port number is invalid. This exception can also be thrown if the port is already in use, this verification can be disabled using checkPortAvailability(boolean).
      • serverId

        public Setup serverId​(String serverId)
                       throws com.forgerock.opendj.cli.ArgumentException
        Specifies the server ID.

        If not specified a server ID will be automatically generated.

        Parameters:
        serverId - The server ID.
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If the provided serverId is invalid
      • console

        public Setup console​(SetupConsole console)
        Specifies the SetupConsole which be used to print information issued during setup.

        No console will be used by default

        Parameters:
        console - The setup console
        Returns:
        This Setup object
      • withProfiles

        public Setup withProfiles​(Profile... profiles)
                           throws com.forgerock.opendj.cli.ArgumentException
        Specifies the setup profiles which will be run during the setup.

        Provided profiles parameters values must have been resolved (with a call to Profile.resolveParameterValues(ExecutionContext, SetupConfiguration, ParameterValuesProvider)) before the setup() method is used on this object.

        If this directory server object already contains some profiles with the same name(s) as the provided profiles, they will be replaced by the provided profiles.

        Parameters:
        profiles - The setup profiles
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If a profile with the same name as one of the provided ones has already been registered to be setup
      • withProfiles

        public Setup withProfiles​(Collection<Profile> profilesToAdd)
                           throws com.forgerock.opendj.cli.ArgumentException
        Specifies the setup profiles which will be run during the setup.

        Provided profiles parameters values must have been resolved (with a call to Profile.resolveParameterValues(ExecutionContext, SetupConfiguration, ParameterValuesProvider)) before the setup() method is used on this object.

        If this directory server object already contains some profiles with the same name(s) as the provided profiles, they will be replaced by the provided profiles.

        Parameters:
        profilesToAdd - The setup profiles
        Returns:
        This Setup object
        Throws:
        com.forgerock.opendj.cli.ArgumentException - If a profile with the same name as one of the provided ones has already been registered to be setup
      • clearProfiles

        public Setup clearProfiles()
        Removes all profiles registered in this Setup.
        Returns:
        This Setup object
      • enableCloudBackups

        public Setup enableCloudBackups​(boolean enableCloudBackups)
        Specifies whether the OpenDJ Cloud Backup feature should be enabled. By default, this feature is enabled.
        Parameters:
        enableCloudBackups - true if the cloud backup feature should be enabled
        Returns:
        This Setup object
      • setup

        public void setup()
                   throws SetupException
        Main method which will setup the server instance.

        Note that this method must be called only once all parameters have been set.

        Throws:
        SetupException - If an error occurs while setting up the server
      • getDeploymentId

        public DeploymentId getDeploymentId()
        Returns the deployment ID which will be used for securing the deployment.
        Returns:
        The deployment ID which will be used for securing the deployment
      • getReplicationPort

        public Integer getReplicationPort()
        Returns the replication port set for this server or null if replicationPort(int) has not been called on this setup object.
        Returns:
        An integer representing the replication port set for this server or null when not set