Class EmbeddedOpenDS


  • public class EmbeddedOpenDS
    extends Object
    This class encapsulates all OpenDJ dependencies. All the interfaces are invoked from AMSetupServlet class at different points : initial installation, normal startup and normal shutdown of the embedded OpenDJ instance.
    • Constructor Detail

      • EmbeddedOpenDS

        public EmbeddedOpenDS()
    • Method Detail

      • isStarted

        public static boolean isStarted()
        Returns true if the server has already been started.
        Returns:
        true if the server has already been started.
      • setup

        public static void setup​(Map map,
                                 jakarta.servlet.ServletContext servletCtx)
                          throws Exception
        Sets up embedded OpenDJ during initial installation :
        • lays out the filesystem directory structure needed by OpenDJ
        • sets up port numbers for ldap and replication
        • invokes EmbeddedUtils to start the embedded server.
        Parameters:
        map - Map of properties collected by the configurator.
        servletCtx - Servlet Context to read deployed war contents.
        Throws:
        Exception - on encountering errors.
      • setupOpenDS

        public static void setupOpenDS​(Map map)
                                throws Exception
        Runs the OpenDJ setup command to create our instance
        Parameters:
        map - The map of configuration options
        Throws:
        Exception - upon encountering errors.
      • runOpenDSSetup

        public static int runOpenDSSetup​(Map map)
        Runs the OpenDJ setup command like this: $ ./setup --cli --adminConnectorPort 4444 --baseDN dc=openam,dc=openidentityplatform,dc=org --rootUserDN "cn=directory manager" --doNotStart --ldapPort 50389 --skipPortCheck --rootUserPassword xxxxxxx --jmxPort 1689 --no-prompt
        Parameters:
        map - Map of properties collected by the configurator.
        Returns:
        status : 0 == success, !0 == failure
      • startServer

        public static void startServer​(String odsRoot)
                                throws Exception
        Starts the embedded OpenDJ instance.
        Parameters:
        odsRoot - File system directory where OpenDJ is installed.
        Throws:
        Exception - upon encountering errors.
      • shutdownServer

        public static void shutdownServer​(String reason)
                                   throws Exception
        Gracefully shuts down the embedded OpenDJ instance.
        Parameters:
        reason - string representing reason why shutdown was called.
        Throws:
        Exception - on encountering errors.
      • setupReplicationEnable

        public static int setupReplicationEnable​(Map map)
        Setups replication between two OpenDJ sms and user stores. $ dsreplication enable --no-prompt --host1 host1 --port1 1389 --bindDN1 "cn=Directory Manager" --bindPassword1 password --replicationPort1 8989 --host2 host2 --port2 2389 --bindDN2 "cn=Directory Manager" --bindPassword2 password --replicationPort2 8990 --adminUID admin --adminPassword password --baseDN "dc=example,dc=com"
        Parameters:
        map - Map of properties collected by the configurator.
        Returns:
        status : 0 == success, !0 == failure
      • setupReplicationInitialize

        public static int setupReplicationInitialize​(Map map)
        Syncs replication data between two OpenDJ sms and user stores. $ dsreplication initialize --baseDN "dc=example,dc=com" --adminUID admin --adminPassword pass --hostSource host1 --portSource 1389 --hostDestination host2 --portDestination 2389 --trustAll
        Parameters:
        map - Map of properties collected by the configurator.
        Returns:
        status : 0 == success, !0 == failure
      • getReplicationStatus

        public static int getReplicationStatus​(String port,
                                               String passwd,
                                               OutputStream oo,
                                               OutputStream err)
        Returns Replication Status by invoking OpenDJ dsreplication CLI
        Parameters:
        port - LDAP port number of embedded OpenDJ
        passwd - Directory Manager password
        oo - Standard output
        err - : Standard error
        Returns:
        dsreplication CLI exit code.
      • isMultiServer

        public static boolean isMultiServer​(Map map)
        Returns:
        true if multi server option is selected in the configurator.
      • loadLDIF

        public static int loadLDIF​(Map map,
                                   String odsRoot,
                                   String ldif)
        Utility function to preload data in the embedded instance. Must be called when the directory instance is shutdown.
        Parameters:
        odsRoot - Local directory where OpenDJ is installed.
        ldif - Full path of the ldif file to be loaded.
      • hash

        public static String hash​(String p)
        Returns a one-way hash for passwd using SSHA512 scheme.
        Parameters:
        p - Clear password string
        Returns:
        hash value
      • getReplicationPort

        public static String getReplicationPort​(String username,
                                                String password,
                                                String hostname,
                                                String port)
        Get replication port
        Parameters:
        username -
        password -
        hostname -
        port -
        Returns:
        port number if replication is setup, null if not or on error.
      • getAdminPort

        public static String getAdminPort​(String username,
                                          String password,
                                          String hostname,
                                          String port)
        Get admin port of the OpenDJ server
        Parameters:
        username - The username of the directory admin
        password - The password of the directory admin
        hostname - The hostname of the directory server
        port - The port of the directory server
        Returns:
        The admin port
      • syncReplicatedServers

        public static boolean syncReplicatedServers​(Set currServerSet,
                                                    String port,
                                                    String passwd)
        Synchronizes replication server info with current list of OpenAM servers.
      • syncReplicatedDomains

        public static boolean syncReplicatedDomains​(Set currServerSet,
                                                    String port,
                                                    String passwd)
        Synchronizes replication domain info with current list of OpenAM servers.
      • syncReplicatedServerList

        public static boolean syncReplicatedServerList​(Set currServerSet,
                                                       String port,
                                                       String passwd)
        Synchronizes replication domain info with current list of OpenAM servers.
      • delOpenDSServer

        public static void delOpenDSServer​(org.forgerock.opendj.ldap.Connection lc,
                                           String delServer)
        Removes host:port from OpenDJ replication
      • getServerSet

        public static Set getServerSet​(org.forgerock.opendj.ldap.Connection lc)
        Gets list of replicated servers from local OpenDJ directory.
      • rebuildSMSIndex

        public static int rebuildSMSIndex()
                                   throws Exception
        Rebuilds SMS indexes for the embedded DJ config store.
        Returns:
        the status code.
        Throws:
        Exception
      • rebuildIndex

        public static int rebuildIndex​(String baseDir,
                                       String baseDN)
                                throws Exception
        Rebuilds indexes for the given base DN and installation directory.
        Parameters:
        baseDir - the base installation directory.
        baseDN - the base DN to rebuild indexes for.
        Returns:
        the status code
        Throws:
        Exception
      • isOpenDSVer1Installed

        public static boolean isOpenDSVer1Installed()
        Returns:
        true if installed OpenDS is version 1.0.2
      • isOpenDSVer230Installed

        public static boolean isOpenDSVer230Installed()
        Returns:
        true if installed OpenDS is version 2.3.0BACKPORT2
      • getOpenDSVersion

        public static String getOpenDSVersion()
      • initializeForClientUse

        public static void initializeForClientUse()
        Initialises OpenDJ for client use, used by the CLI tools