EmbeddedOpenDS.java revision a82d04bc19fee9d5e34b41ccd7641da1f62ab634
// OpenDS, now OpenDJ, does not have APIs to install and setup replication yet * This class encapsulates all <code>OpenDJ</code> dependencies. * All the interfaces are invoked from <code>AMSetupServlet</code> class * at different points : initial installation, normal startup and * normal shutdown of the embedded <code>OpenDJ</code> instance. * Returns <code>true</code> if the server has already been started. * @return <code>true</code> if the server has already been started. * Sets up embedded OpenDJ during initial installation : * <li>lays out the filesystem directory structure needed by OpenDJ * <li>sets up port numbers for ldap and replication * <li>invokes <code>EmbeddedUtils</code> to start the embedded server. * @param map Map of properties collected by the configurator. * @param servletCtx Servlet Context to read deployed war contents. * @throws Exception on encountering errors. // Determine Cipher to be used throw new Exception(
"No transformation found");
"EmbeddedOpenDS.setup(): Error copying zip file",
ioe);
// Process the OpenDJ Archive File. "EmbeddedOpenDS.setup(): Error loading ldifs",
ioe);
}
// End of Inner Finally. }
// End of File Elements from Zip for OpenDJ. // create tag swapped files char[]
cbuf =
new char[
1024];
"EmbeddedOpenDS.setup(): Error tag swapping files", e);
// Check: If adding a new server to a existing cluster // Default: single / first server. "EmbeddedOpenDS.setupOpenDS. Error loading OpenAM suffix");
"emb.creatingfamsuffix.failure");
}
// End of single / first server check. * Helper Method to Copy from one Byte Channel to another. // Handle In Channel Closure // Handle Out Channel Closure "RSA/ /OAEPPADDINGSHA-1",
// IBMJCE * Traverses <code>preferredTransforms</code> list in order to * find a Cipher supported by underlying JCE providers.` * @returns transformation available. * Runs the OpenDJ setup command to create our instance * @param map The map of configuration options * @throws Exception upon encountering errors. "EmbeddedOpenDS.setupOpenDS: OpenDS setup succeeded.");
"EmbeddedOpenDS.setupOpenDS. Error setting up OpenDS");
"configurator.embsetupopendsfailed");
* Runs the OpenDJ setup command like this: * $ ./setup --cli --adminConnectorPort 4444 * --baseDN dc=openam,dc=forgerock,dc=org --rootUserDN "cn=directory manager" * --doNotStart --ldapPort 50389 --skipPortCheck --rootUserPassword xxxxxxx * --jmxPort 1689 --no-prompt * @param map Map of properties collected by the configurator. * @return status : 0 == success, !0 == failure "--adminConnectorPort",
// 1 "cn=Directory Manager",
// 6 "--rootUserPassword",
// 10 "--noPropertiesFile" // 18 * Starts the embedded <code>OpenDJ</code> instance. * @param odsRoot File system directory where <code>OpenDJ</code> * @throws Exception upon encountering errors. debug.
message(
"EmbeddedOpenDS.startServer:starting DS Server...");
debug.
message(
"...EmbeddedOpenDS.startServer:DS Server started.");
debug.
error(
"EmbeddedOpenDS:shutdown hook failed",
* Gracefully shuts down the embedded OpenDJ instance. * @param reason string representing reason why shutdown was called. * @throws Exception on encountering errors. "com.sun.identity.setup.EmbeddedOpenDS",
"EmbeddedOpenDS.setupReplication: replication setup succeeded.");
"EmbeddedOpenDS.setupReplication. Error setting up replication");
"configurator.embreplfailed");
* Setups replication between two OpenDJ sms and user stores. * --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" * @param map Map of properties collected by the configurator. * @return status : 0 == success, !0 == failure "cn=Directory Manager",
// 7 "--replicationPort1",
// 10 "cn=Directory Manager",
// 17 "--replicationPort2",
// 20 "dc=example,dc=com",
// 27 "--noPropertiesFile" // 31 * 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 * @param map Map of properties collected by the configurator. * @return status : 0 == success, !0 == failure "--hostDestination",
// 12 "--portDestination",
// 14 "--noPropertiesFile" // 19 * Returns Replication Status by invoking OpenDJ <code>dsreplication</code> * @param port LDAP port number of embedded OpenDJ * @param passwd Directory Manager password * @param oo Standard output * @param err : Standard error * @return <code>dsreplication</code> CLI exit code. debug.
message(
"EmbeddedOpenDS:getReplicationStatus:exec dsreplication :" debug.
message(
"EmbeddedOpenDS:getReplicationStatus:dsreplication ret:" * @return true if multi server option is selected in the configurator. * Utility function to preload data in the embedded instance. * Must be called when the directory instance is shutdown. * @param odsRoot Local directory where <code>OpenDJ</code> is installed. * @param ldif Full path of the ldif file to be loaded. "cn=Directory Manager",
// 10 "--noPropertiesFile" // 13 * Returns a one-way hash for passwd using SSHA512 scheme. * @param p Clear password string * @return port number if replication is setup, null if not or on error. "cn=replication server,cn=Multimaster Synchronization,cn=Synchronization Providers,cn=config";
// We'll use Directory Manager .
error(
"EmbeddedOpenDS.getReplicationPort(). Error getting replication port:",
ex);
* Get admin port of the OpenDJ server * @param username The username of the directory admin * @param password The password of the directory admin * @param hostname The hostname of the directory server * @param port The port of the directory server .
error(
"EmbeddedOpenDS.getAdminPort(). Error getting admin port:",
ex);
* Synchronizes replication server info with current list of OpenAM servers. debug.
message(
"EmbeddedOPenDS:syncReplication:start processing.");
"-p",
port,
// 1 : ds port num "-D",
"cn=directory manager",
"list-replication-server",
"--provider-name",
"Multimaster Synchronization",
"--property",
"replication-server",
"--property",
"replication-port",
"--no-prompt",
"--trustAll",
debug.
message(
"EmbeddedOpenDS:syncReplication:exec dsconfig:" !
stre.
contains(
"Unable to continue since there are no Replication Server currently")) {
debug.
error(
"EmbeddedOpenDS:syncReplication: stderr is not empty:" debug.
message(
"EmbeddedOpenDS:syncReplication: stderr is not empty:" Replication Server : replication-server : replication-port -------------------:----------------------------------------------:----------------- replication-server : dj1.example.com:58989, dj2.example.com:50889 : 50889 // Check if this server is part of server list debug.
error(
"EmbeddedOpenDS:syncReplication:cmd stderr:" * Synchronizes replication domain info with current list of OpenAM servers. debug.
message(
"EmbeddedOpenDS:syncReplication:Domains:started");
"-p",
port,
// 1 : ds port num "-D",
"cn=directory manager",
"list-replication-domains",
"--provider-name",
"Multimaster Synchronization",
"--property",
"replication-server",
debug.
message(
"EmbeddedOpenDS:syncReplication:exec dsconfig:" Replication Domain : replication-server ------------------------------:--------------------------------------------- cn=admin data : dj1.example.com:58989, dj2.example.com:50889 cn=schema : dj1.example.com:58989, dj2.example.com:50889 dc=openam,dc=forgerock,dc=org : dj1.example.com:58989, dj2.example.com:50889 // Check if this server is part of server list * Synchronizes replication domain info with current list of OpenAM servers. * Helper method to return Ldap connection to a embedded OpenDJ * @return Ldap connection .
error(
"EmbeddedOpenDS.setup(). Error getting LDAPConnection:",
ex);
// All connections will use authentication static final String replDN =
"cn=all-servers,cn=Server Groups,cn=admin data";
* Removes host:port from OpenDJ replication "cn=" +
delServer +
",cn=Servers,cn=admin data";
debug.
error(
"EmbeddedOpenDS:syncOpenDSServer():" +
"Could not connect to local OpenDJ instance." +
replServerDN);
",cn=instance keys,cn=admin data";
debug.
error(
"EmbeddedOpenDS:syncOpenDSServer():" +
debug.
error(
"EmbeddedOpenDS.syncOpenDSServer()." +
" Error getting replication key:",
ex);
debug.
error(
"EmbeddedOpenDS.syncOpenDSServer()." +
debug.
error(
"EmbeddedOpenDS.syncOpenDSServer()." +
" Error getting removing :" +
replDN,
ex);
* Gets list of replicated servers from local OpenDJ directory. debug.
error(
"EmbeddedOpenDS:syncOpenDSServer():" +
"Could not find trustkey for:" +
replDN);
debug.
error(
"EmbeddedOpenDS:syncOpenDSServer():" +
"Could not connect to local opends instance.");
debug.
error(
"EmbeddedOpenDS.syncOpenDSServer()." +
" Error getting replication key:",
ex);
* Rebuilds SMS indexes for the embedded DJ config store. * @return the status code. * Rebuilds indexes for the given base DN and installation directory. * @param baseDir the base installation directory. * @param baseDN the base DN to rebuild indexes for. * @return the status code // Programmatic way of rebuilding indexes in OpenDJ. // This method simulates the OpenDJ cli command rebuild-index. // eg., rebuild-index -b dc=example,dc=com -i uid -i mail debug.
error(
"EmbeddedOpenDS:rebuildIndex:stderr=" +
* @return true if installed OpenDS is version 1.0.2 * @return true if installed OpenDS is version 2.3.0BACKPORT2 //@Override -- Not Allowed Here. debug.
error(
"Unable to determine OpenDJ version");
debug.
error(
"Unable to determine OpenDJ version");
debug.
warning(
"Unable to determine OpenDJ version; could be pre-config");
* Initialises OpenDJ for client use, used by the CLI tools // Returns the installation directory for the embedded OpenDJ. // Returns the configuration file name for the embedded OpenDJ. // Returns the host name for the embedded OpenDJ. // Helper Method to return the first line of the OpenDJ buildInfo file. // Simply Ignore this Exception and Allow UpStream to Handle Null.