Package com.sun.identity.setup
Class EmbeddedOpenDS
- java.lang.Object
-
- com.sun.identity.setup.EmbeddedOpenDS
-
public class EmbeddedOpenDS extends Object
This class encapsulates allOpenDJdependencies. All the interfaces are invoked fromAMSetupServletclass at different points : initial installation, normal startup and normal shutdown of the embeddedOpenDJinstance.
-
-
Constructor Summary
Constructors Constructor Description EmbeddedOpenDS()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static voidchannelCopy(ReadableByteChannel from, WritableByteChannel to)Helper Method to Copy from one Byte Channel to another.static voiddelOpenDSServer(org.forgerock.opendj.ldap.Connection lc, String delServer)Removes host:port from OpenDJ replicationstatic StringgetAdminPort(String username, String password, String hostname, String port)Get admin port of the OpenDJ serverstatic StringgetOpenDSVersion()static StringgetReplicationPort(String username, String password, String hostname, String port)Get replication portstatic intgetReplicationStatus(String port, String passwd, OutputStream oo, OutputStream err)Returns Replication Status by invoking OpenDJdsreplicationCLIstatic SetgetServerSet(org.forgerock.opendj.ldap.Connection lc)Gets list of replicated servers from local OpenDJ directory.static Stringhash(String p)Returns a one-way hash for passwd using SSHA512 scheme.static voidinitializeForClientUse()Initialises OpenDJ for client use, used by the CLI toolsstatic booleanisMultiServer(Map map)static booleanisOpenDSVer1Installed()static booleanisOpenDSVer230Installed()static booleanisStarted()Returnstrueif the server has already been started.static intloadLDIF(Map map, String odsRoot, String ldif)Utility function to preload data in the embedded instance.static intrebuildIndex(String baseDir, String baseDN)Rebuilds indexes for the given base DN and installation directory.static intrebuildIndex(Map map)static intrebuildSMSIndex()Rebuilds SMS indexes for the embedded DJ config store.static intrunOpenDSSetup(Map map)Runs the OpenDJ setup command like this: $ .static voidsetup(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 invokesEmbeddedUtilsto start the embedded server.static voidsetupOpenDS(Map map)Runs the OpenDJ setup command to create our instancestatic voidsetupReplication(Map map)static intsetupReplicationEnable(Map map)Setups replication between two OpenDJ sms and user storesstatic intsetupReplicationInitialize(Map map)Syncs replication data between two OpenDJ sms and user storesstatic voidshutdownServer(String reason)Gracefully shuts down the embedded OpenDJ instance.static voidstartServer(String odsRoot)Starts the embeddedOpenDJinstance.static booleansyncReplicatedDomains(Set currServerSet, String port, String passwd)Synchronizes replication domain info with current list of OpenAM servers.static booleansyncReplicatedServerList(Set currServerSet, String port, String passwd)Synchronizes replication domain info with current list of OpenAM servers.static booleansyncReplicatedServers(Set currServerSet, String port, String passwd)Synchronizes replication server info with current list of OpenAM servers.
-
-
-
Method Detail
-
isStarted
public static boolean isStarted()
Returnstrueif the server has already been started.- Returns:
trueif 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
EmbeddedUtilsto 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 embeddedOpenDJinstance.- Parameters:
odsRoot- File system directory whereOpenDJis 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 OpenDJdsreplicationCLI- Parameters:
port- LDAP port number of embedded OpenDJpasswd- Directory Manager passwordoo- Standard outputerr- : Standard error- Returns:
dsreplicationCLI 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 whereOpenDJis 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 ExceptionRebuilds 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
-
-