Package com.sun.identity.setup
Class EmbeddedOpenDS
- java.lang.Object
-
- com.sun.identity.setup.EmbeddedOpenDS
-
public class EmbeddedOpenDS extends Object
This class encapsulates allOpenDJ
dependencies. All the interfaces are invoked fromAMSetupServlet
class at different points : initial installation, normal startup and normal shutdown of the embeddedOpenDJ
instance.
-
-
Constructor Summary
Constructors Constructor Description EmbeddedOpenDS()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static void
channelCopy(ReadableByteChannel from, WritableByteChannel to)
Helper Method to Copy from one Byte Channel to another.static void
delOpenDSServer(org.forgerock.opendj.ldap.Connection lc, String delServer)
Removes host:port from OpenDJ replicationstatic String
getAdminPort(String username, String password, String hostname, String port)
Get admin port of the OpenDJ serverstatic String
getOpenDSVersion()
static String
getReplicationPort(String username, String password, String hostname, String port)
Get replication portstatic int
getReplicationStatus(String port, String passwd, OutputStream oo, OutputStream err)
Returns Replication Status by invoking OpenDJdsreplication
CLIstatic Set
getServerSet(org.forgerock.opendj.ldap.Connection lc)
Gets list of replicated servers from local OpenDJ directory.static String
hash(String p)
Returns a one-way hash for passwd using SSHA512 scheme.static void
initializeForClientUse()
Initialises OpenDJ for client use, used by the CLI toolsstatic boolean
isMultiServer(Map map)
static boolean
isOpenDSVer1Installed()
static boolean
isOpenDSVer230Installed()
static boolean
isStarted()
Returnstrue
if the server has already been started.static int
loadLDIF(Map map, String odsRoot, String ldif)
Utility function to preload data in the embedded instance.static int
rebuildIndex(String baseDir, String baseDN)
Rebuilds indexes for the given base DN and installation directory.static int
rebuildIndex(Map map)
static int
rebuildSMSIndex()
Rebuilds SMS indexes for the embedded DJ config store.static int
runOpenDSSetup(Map map)
Runs the OpenDJ setup command like this: $ .static void
setup(Map map, jakarta.servlet.ServletContext servletCtx)
Sets up embedded OpenDJ during initial installation : lays out the filesystem directory structure needed by OpenDJ sets up port numbers for ldap and replication invokesEmbeddedUtils
to start the embedded server.static void
setupOpenDS(Map map)
Runs the OpenDJ setup command to create our instancestatic void
setupReplication(Map map)
static int
setupReplicationEnable(Map map)
Setups replication between two OpenDJ sms and user storesstatic int
setupReplicationInitialize(Map map)
Syncs replication data between two OpenDJ sms and user storesstatic void
shutdownServer(String reason)
Gracefully shuts down the embedded OpenDJ instance.static void
startServer(String odsRoot)
Starts the embeddedOpenDJ
instance.static boolean
syncReplicatedDomains(Set currServerSet, String port, String passwd)
Synchronizes replication domain info with current list of OpenAM servers.static boolean
syncReplicatedServerList(Set currServerSet, String port, String passwd)
Synchronizes replication domain info with current list of OpenAM servers.static boolean
syncReplicatedServers(Set currServerSet, String port, String passwd)
Synchronizes replication server info with current list of OpenAM servers.
-
-
-
Method Detail
-
isStarted
public static boolean isStarted()
Returnstrue
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.
-
channelCopy
protected static void channelCopy(ReadableByteChannel from, WritableByteChannel to) throws IOException
Helper Method to Copy from one Byte Channel to another.- Parameters:
from
-to
-- Throws:
IOException
-
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 embeddedOpenDJ
instance.- Parameters:
odsRoot
- File system directory whereOpenDJ
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 OpenDJdsreplication
CLI- Parameters:
port
- LDAP port number of embedded OpenDJpasswd
- Directory Manager passwordoo
- Standard outputerr
- : 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 whereOpenDJ
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 adminpassword
- The password of the directory adminhostname
- The hostname of the directory serverport
- 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
-
-