| | |
| | | { |
| | | return defaultValue; |
| | | } |
| | | else |
| | | |
| | | try |
| | | { |
| | | try |
| | | int i = Integer.parseInt(ninput); |
| | | if (i < 1) |
| | | { |
| | | int i = Integer.parseInt(ninput); |
| | | if (i < 1) |
| | | { |
| | | throw new NumberFormatException(); |
| | | } |
| | | return i; |
| | | throw new NumberFormatException(); |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | // Try again... |
| | | app.println(); |
| | | app.println(ERR_BAD_INTEGER.get(ninput)); |
| | | app.println(); |
| | | return null; |
| | | } |
| | | return i; |
| | | } |
| | | catch (NumberFormatException e) |
| | | { |
| | | // Try again... |
| | | app.println(); |
| | | app.println(ERR_BAD_INTEGER.get(ninput)); |
| | | app.println(); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | |
| | | new PreExternalInitializationUserData(); |
| | | if (argParser.isInteractive()) |
| | | { |
| | | if (promptIfRequired(uData)) |
| | | if (promptIfRequiredForPreOrPost(uData)) |
| | | { |
| | | return preExternalInitialization(uData); |
| | | } |
| | |
| | | new PostExternalInitializationUserData(); |
| | | if (argParser.isInteractive()) |
| | | { |
| | | if (promptIfRequired(uData)) |
| | | if (promptIfRequiredForPreOrPost(uData)) |
| | | { |
| | | return postExternalInitialization(uData); |
| | | } |
| | |
| | | |
| | | private InitialLdapContext createAdministrativeContext(MonoServerReplicationUserData uData) |
| | | { |
| | | final String bindDn = ADSContext.getAdministratorDN(uData.getAdminUid()); |
| | | final String bindDn = getAdministratorDN(uData.getAdminUid()); |
| | | return createAdministrativeContext(uData, bindDn); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the provided PreExternalInitializationUserData |
| | | * object with the information provided in the command-line. If some |
| | | * information is missing, ask the user to provide valid data. |
| | | * Updates the contents of the provided user data |
| | | * object with the information provided in the command-line. |
| | | * If some information is missing, ask the user to provide valid data. |
| | | * We assume that if this method is called we are in interactive mode. |
| | | * @param uData the object to be updated. |
| | | * @return <CODE>true</CODE> if the object was successfully updated and |
| | | * <CODE>false</CODE> if the user cancelled the operation. |
| | | */ |
| | | private boolean promptIfRequired(PreExternalInitializationUserData uData) |
| | | { |
| | | boolean cancelled = false; |
| | | |
| | | String adminPwd = argParser.getBindPasswordAdmin(); |
| | | String adminUid = argParser.getAdministratorUID(); |
| | | |
| | | String host = argParser.getHostNameToInitializeAll(); |
| | | int port = argParser.getPortToInitializeAll(); |
| | | |
| | | /* |
| | | * Try to connect to the server. |
| | | */ |
| | | InitialLdapContext ctx = null; |
| | | |
| | | while (ctx == null && !cancelled) |
| | | { |
| | | try |
| | | { |
| | | ci.run(); |
| | | host = ci.getHostName(); |
| | | port = ci.getPortNumber(); |
| | | adminUid = ci.getAdministratorUID(); |
| | | adminPwd = ci.getBindPassword(); |
| | | |
| | | ctx = createInitialLdapContextInteracting(ci); |
| | | |
| | | if (ctx == null) |
| | | { |
| | | cancelled = true; |
| | | } |
| | | } |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Client exception "+ce)); |
| | | println(); |
| | | println(ce.getMessageObject()); |
| | | println(); |
| | | ci.resetConnectionArguments(); |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Argument exception "+ae)); |
| | | println(); |
| | | println(ae.getMessageObject()); |
| | | println(); |
| | | cancelled = true; |
| | | } |
| | | } |
| | | if (!cancelled) |
| | | { |
| | | uData.setHostName(host); |
| | | uData.setPort(port); |
| | | uData.setAdminUid(adminUid); |
| | | uData.setAdminPwd(adminPwd); |
| | | } |
| | | |
| | | if (!cancelled) |
| | | { |
| | | LinkedList<String> suffixes = argParser.getBaseDNs(); |
| | | checkSuffixesForInitializeReplication(suffixes, ctx, true); |
| | | cancelled = suffixes.isEmpty(); |
| | | |
| | | uData.setBaseDNs(suffixes); |
| | | } |
| | | |
| | | close(ctx); |
| | | return !cancelled; |
| | | } |
| | | |
| | | /** |
| | | * Updates the contents of the provided PostExternalInitializationUserData |
| | | * object with the information provided in the command-line. If some |
| | | * information is missing, ask the user to provide valid data. |
| | | * We assume that if this method is called we are in interactive mode. |
| | | * @param uData the object to be updated. |
| | | * @return <CODE>true</CODE> if the object was successfully updated and |
| | | * <CODE>false</CODE> if the user cancelled the operation. |
| | | */ |
| | | private boolean promptIfRequired(PostExternalInitializationUserData uData) |
| | | private boolean promptIfRequiredForPreOrPost(MonoServerReplicationUserData uData) |
| | | { |
| | | boolean cancelled = false; |
| | | |
| | |
| | | |
| | | if (!cancelled) |
| | | { |
| | | LinkedList<String> suffixes = argParser.getBaseDNs(); |
| | | uData.setBaseDNs(suffixes); |
| | | uData.setBaseDNs(argParser.getBaseDNs()); |
| | | } |
| | | |
| | | close(ctx); |
| | |
| | | println(); |
| | | cancelled = true; |
| | | } |
| | | } if (!cancelled) |
| | | } |
| | | if (!cancelled) |
| | | { |
| | | uData.setHostNameDestination(hostDestination); |
| | | uData.setPortDestination(portDestination); |
| | |
| | | if (!cancelled) |
| | | { |
| | | LinkedList<String> suffixes = argParser.getBaseDNs(); |
| | | checkSuffixesForInitializeReplication(suffixes, ctxSource, ctxDestination, |
| | | true); |
| | | checkSuffixesForInitializeReplication(suffixes, ctxSource, ctxDestination, true); |
| | | cancelled = suffixes.isEmpty(); |
| | | |
| | | uData.setBaseDNs(suffixes); |
| | |
| | | */ |
| | | private void initializeWithArgParser(EnableReplicationUserData uData) |
| | | { |
| | | uData.setBaseDNs(new LinkedList<String>(argParser.getBaseDNs())); |
| | | String adminUid = getValue(argParser.getAdministratorUID(), |
| | | argParser.getDefaultAdministratorUID()); |
| | | uData.setAdminUid(adminUid); |
| | | String adminPwd = argParser.getBindPasswordAdmin(); |
| | | uData.setAdminPwd(adminPwd); |
| | | initialize(uData); |
| | | String adminUid = uData.getAdminUid(); |
| | | String adminPwd = uData.getAdminPwd(); |
| | | |
| | | final String adminDN = getAdministratorDN(adminUid); |
| | | String host1Name = getValue(argParser.getHostName1(), |
| | | argParser.getDefaultHostName1()); |
| | | uData.setHostName1(host1Name); |
| | |
| | | String pwd1 = argParser.getBindPassword1(); |
| | | if (pwd1 == null) |
| | | { |
| | | uData.setBindDn1(ADSContext.getAdministratorDN(adminUid)); |
| | | uData.setBindDn1(adminDN); |
| | | uData.setPwd1(adminPwd); |
| | | } |
| | | else |
| | |
| | | try |
| | | { |
| | | InitialLdapContext ctx = createAdministrativeContext( |
| | | uData.getHostName1(), uData.getPort1(), useSSL, |
| | | useStartTLS, ADSContext.getAdministratorDN(adminUid), |
| | | adminPwd, getConnectTimeout(), getTrustManager()); |
| | | uData.setBindDn1(ADSContext.getAdministratorDN(adminUid)); |
| | | uData.getHostName1(), uData.getPort1(), useSSL, useStartTLS, |
| | | adminDN, adminPwd, getConnectTimeout(), getTrustManager()); |
| | | uData.setBindDn1(adminDN); |
| | | uData.setPwd1(adminPwd); |
| | | ctx.close(); |
| | | } |
| | |
| | | String pwd2 = argParser.getBindPassword2(); |
| | | if (pwd2 == null) |
| | | { |
| | | uData.setBindDn2(ADSContext.getAdministratorDN(adminUid)); |
| | | uData.setBindDn2(adminDN); |
| | | uData.setPwd2(adminPwd); |
| | | } |
| | | else |
| | |
| | | try |
| | | { |
| | | InitialLdapContext ctx = createAdministrativeContext( |
| | | uData.getHostName2(), uData.getPort2(), useSSL, |
| | | useStartTLS, ADSContext.getAdministratorDN(adminUid), |
| | | adminPwd, getConnectTimeout(), getTrustManager()); |
| | | uData.setBindDn2(ADSContext.getAdministratorDN(adminUid)); |
| | | uData.getHostName2(), uData.getPort2(), useSSL, useStartTLS, |
| | | adminDN, adminPwd, getConnectTimeout(), getTrustManager()); |
| | | uData.setBindDn2(adminDN); |
| | | uData.setPwd2(adminPwd); |
| | | ctx.close(); |
| | | } |
| | |
| | | */ |
| | | private void initializeWithArgParser(InitializeReplicationUserData uData) |
| | | { |
| | | uData.setBaseDNs(new LinkedList<String>(argParser.getBaseDNs())); |
| | | String adminUid = getValue(argParser.getAdministratorUID(), |
| | | argParser.getDefaultAdministratorUID()); |
| | | uData.setAdminUid(adminUid); |
| | | String adminPwd = argParser.getBindPasswordAdmin(); |
| | | uData.setAdminPwd(adminPwd); |
| | | initialize(uData); |
| | | |
| | | String hostNameSource = getValue(argParser.getHostNameSource(), |
| | | argParser.getDefaultHostNameSource()); |
| | |
| | | if (bindDn == null && adminUid == null) |
| | | { |
| | | adminUid = argParser.getDefaultAdministratorUID(); |
| | | bindDn = ADSContext.getAdministratorDN(adminUid); |
| | | bindDn = getAdministratorDN(adminUid); |
| | | } |
| | | uData.setAdminUid(adminUid); |
| | | uData.setBindDn(bindDn); |
| | | String adminPwd = argParser.getBindPasswordAdmin(); |
| | | uData.setAdminPwd(adminPwd); |
| | | uData.setAdminPwd(argParser.getBindPasswordAdmin()); |
| | | |
| | | String hostName = getValue(argParser.getHostNameToDisable(), |
| | | argParser.getDefaultHostNameToDisable()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Initializes the contents of the provided initialize all replication user |
| | | * data object with what was provided in the command-line without prompting to |
| | | * the user. |
| | | * @param uData the initialize all replication user data object to be |
| | | * initialized. |
| | | * Initializes the contents of the provided user data object with what was |
| | | * provided in the command-line without prompting to the user. |
| | | * @param uData the user data object to be initialized. |
| | | */ |
| | | private void initializeWithArgParser(InitializeAllReplicationUserData uData) |
| | | private void initializeWithArgParser(MonoServerReplicationUserData uData) |
| | | { |
| | | uData.setBaseDNs(new LinkedList<String>(argParser.getBaseDNs())); |
| | | String adminUid = getValue(argParser.getAdministratorUID(), |
| | | argParser.getDefaultAdministratorUID()); |
| | | uData.setAdminUid(adminUid); |
| | | String adminPwd = argParser.getBindPasswordAdmin(); |
| | | uData.setAdminPwd(adminPwd); |
| | | initialize(uData); |
| | | |
| | | String hostName = getValue(argParser.getHostNameToInitializeAll(), |
| | | argParser.getDefaultHostNameToInitializeAll()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Initializes the contents of the provided pre external replication user |
| | | * data object with what was provided in the command-line without prompting to |
| | | * the user. |
| | | * @param uData the pre external replication user data object to be |
| | | * initialized. |
| | | */ |
| | | private void initializeWithArgParser(PreExternalInitializationUserData uData) |
| | | { |
| | | uData.setBaseDNs(new LinkedList<String>(argParser.getBaseDNs())); |
| | | String adminUid = getValue(argParser.getAdministratorUID(), |
| | | argParser.getDefaultAdministratorUID()); |
| | | uData.setAdminUid(adminUid); |
| | | String adminPwd = argParser.getBindPasswordAdmin(); |
| | | uData.setAdminPwd(adminPwd); |
| | | |
| | | String hostName = getValue(argParser.getHostNameToInitializeAll(), |
| | | argParser.getDefaultHostNameToInitializeAll()); |
| | | uData.setHostName(hostName); |
| | | int port = getValue(argParser.getPortToInitializeAll(), |
| | | argParser.getDefaultPortToInitializeAll()); |
| | | uData.setPort(port); |
| | | } |
| | | |
| | | /** |
| | | * Initializes the contents of the provided post external replication user |
| | | * data object with what was provided in the command-line without prompting to |
| | | * the user. |
| | | * @param uData the pre external replication user data object to be |
| | | * initialized. |
| | | */ |
| | | private void initializeWithArgParser(PostExternalInitializationUserData uData) |
| | | { |
| | | uData.setBaseDNs(new LinkedList<String>(argParser.getBaseDNs())); |
| | | String adminUid = getValue(argParser.getAdministratorUID(), |
| | | argParser.getDefaultAdministratorUID()); |
| | | uData.setAdminUid(adminUid); |
| | | String adminPwd = argParser.getBindPasswordAdmin(); |
| | | uData.setAdminPwd(adminPwd); |
| | | |
| | | String hostName = getValue(argParser.getHostNameToInitializeAll(), |
| | | argParser.getDefaultHostNameToInitializeAll()); |
| | | uData.setHostName(hostName); |
| | | int port = getValue(argParser.getPortToInitializeAll(), |
| | | argParser.getDefaultPortToInitializeAll()); |
| | | uData.setPort(port); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Initializes the contents of the provided status replication user data |
| | | * object with what was provided in the command-line without prompting to the |
| | | * user. |
| | |
| | | */ |
| | | private void initializeWithArgParser(StatusReplicationUserData uData) |
| | | { |
| | | uData.setBaseDNs(new LinkedList<String>(argParser.getBaseDNs())); |
| | | String adminUid = getValue(argParser.getAdministratorUID(), |
| | | argParser.getDefaultAdministratorUID()); |
| | | uData.setAdminUid(adminUid); |
| | | String adminPwd = argParser.getBindPasswordAdmin(); |
| | | uData.setAdminPwd(adminPwd); |
| | | initialize(uData); |
| | | |
| | | String hostName = getValue(argParser.getHostNameToStatus(), |
| | | argParser.getDefaultHostNameToStatus()); |
| | |
| | | uData.setScriptFriendly(argParser.isScriptFriendly()); |
| | | } |
| | | |
| | | private void initialize(ReplicationUserData uData) |
| | | { |
| | | uData.setBaseDNs(new LinkedList<String>(argParser.getBaseDNs())); |
| | | String adminUid = getValue(argParser.getAdministratorUID(), argParser.getDefaultAdministratorUID()); |
| | | uData.setAdminUid(adminUid); |
| | | uData.setAdminPwd(argParser.getBindPasswordAdmin()); |
| | | } |
| | | |
| | | /** |
| | | * Tells whether the server to which the LdapContext is connected has a |
| | | * replication port or not. |
| | |
| | | { |
| | | break; |
| | | } |
| | | |
| | | switch (e.getType()) |
| | | { |
| | | case NOT_GLOBAL_ADMINISTRATOR: |
| | |
| | | try |
| | | { |
| | | ctx[0] = createAdministrativeContext(host, port, isSSL, |
| | | isStartTLS, ADSContext.getAdministratorDN(adminUid), |
| | | isStartTLS, getAdministratorDN(adminUid), |
| | | adminPwd, getConnectTimeout(), getTrustManager()); |
| | | adsContext = new ADSContext(ctx[0]); |
| | | cache = new TopologyCache(adsContext, getTrustManager(), |
| | |
| | | (EnableReplicationUserData)uData; |
| | | if (isFirstOrSourceServer) |
| | | { |
| | | enableData.setBindDn1( |
| | | ADSContext.getAdministratorDN(adminUid)); |
| | | enableData.setBindDn1(getAdministratorDN(adminUid)); |
| | | enableData.setPwd1(adminPwd); |
| | | } |
| | | else |
| | | { |
| | | enableData.setBindDn2( |
| | | ADSContext.getAdministratorDN(adminUid)); |
| | | enableData.setBindDn2(getAdministratorDN(adminUid)); |
| | | enableData.setPwd2(adminPwd); |
| | | } |
| | | } |
| | |
| | | DisableReplicationUserData uData) |
| | | { |
| | | print(formatter.getFormattedWithPoints(INFO_REPLICATION_CONNECTING.get())); |
| | | String bindDn = uData.getAdminUid() == null ? uData.getBindDn() : |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()); |
| | | String bindDn = uData.getAdminUid() != null |
| | | ? getAdministratorDN(uData.getAdminUid()) |
| | | : uData.getBindDn(); |
| | | |
| | | InitialLdapContext ctx = createAdministrativeContext(uData, bindDn); |
| | | if (ctx != null) |
| | |
| | | { |
| | | return createAdministrativeContext( |
| | | host, port, useSSL, useStartTLS, |
| | | ADSContext.getAdministratorDN(uData.getAdminUid()), uData.getAdminPwd(), |
| | | getAdministratorDN(uData.getAdminUid()), uData.getAdminPwd(), |
| | | getConnectTimeout(), getTrustManager()); |
| | | } |
| | | catch (NamingException ne) |
| | |
| | | catch (Throwable t) |
| | | { |
| | | logger.error(LocalizableMessage.raw("Error seeding truststores: "+t, t)); |
| | | String arg = (t instanceof OpenDsException) ? |
| | | ((OpenDsException)t).getMessageObject().toString() : t.toString(); |
| | | throw new ReplicationCliException( |
| | | ERR_REPLICATION_ENABLE_SEEDING_TRUSTSTORE.get(getHostPort(ctxDestination), |
| | | getHostPort(adsCtxSource.getDirContext()), arg), |
| | | getHostPort(adsCtxSource.getDirContext()), toString(t)), |
| | | ERROR_SEEDING_TRUSTORE, t); |
| | | } |
| | | } |
| | |
| | | (DisableReplicationUserData)uData; |
| | | if (disableData.disableAll()) |
| | | { |
| | | commandBuilder.addArgument(new BooleanArgument( |
| | | argParser.disableAllArg.getName(), |
| | | argParser.disableAllArg.getShortIdentifier(), |
| | | argParser.disableAllArg.getLongIdentifier(), |
| | | INFO_DESCRIPTION_DISABLE_ALL.get())); |
| | | commandBuilder.addArgument(newBooleanArgument( |
| | | argParser.disableAllArg, INFO_DESCRIPTION_DISABLE_ALL)); |
| | | } |
| | | else if (disableData.disableReplicationServer()) |
| | | { |
| | | commandBuilder.addArgument(new BooleanArgument( |
| | | argParser.disableReplicationServerArg.getName(), |
| | | argParser.disableReplicationServerArg.getShortIdentifier(), |
| | | argParser.disableReplicationServerArg.getLongIdentifier(), |
| | | INFO_DESCRIPTION_DISABLE_REPLICATION_SERVER.get())); |
| | | commandBuilder.addArgument(newBooleanArgument( |
| | | argParser.disableReplicationServerArg, INFO_DESCRIPTION_DISABLE_REPLICATION_SERVER)); |
| | | } |
| | | } |
| | | |
| | |
| | | CommandBuilder interactionBuilder = ci.getCommandBuilder(); |
| | | for (Argument arg : interactionBuilder.getArguments()) |
| | | { |
| | | if (arg.getLongIdentifier().equals(OPTION_LONG_BINDPWD)) |
| | | if (OPTION_LONG_BINDPWD.equals(arg.getLongIdentifier())) |
| | | { |
| | | StringArgument bindPasswordArg = new StringArgument("adminPassword", |
| | | OPTION_SHORT_BINDPWD, "adminPassword", false, false, true, |
| | | INFO_BINDPWD_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_BINDPASSWORD.get()); |
| | | bindPasswordArg.addValue(arg.getValue()); |
| | | commandBuilder.addObfuscatedArgument(bindPasswordArg); |
| | | commandBuilder.addObfuscatedArgument(getAdminPasswordArg(arg)); |
| | | } |
| | | else if (OPTION_LONG_BINDPWD_FILE.equals(arg.getLongIdentifier())) |
| | | { |
| | | FileBasedArgument bindPasswordFileArg = new FileBasedArgument( |
| | | "adminPasswordFile", |
| | | OPTION_SHORT_BINDPWD_FILE, "adminPasswordFile", false, false, |
| | | INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_BINDPASSWORDFILE.get()); |
| | | bindPasswordFileArg.getNameToValueMap().putAll( |
| | | ((FileBasedArgument)arg).getNameToValueMap()); |
| | | commandBuilder.addArgument(bindPasswordFileArg); |
| | | } |
| | | else if (interactionBuilder.isObfuscated(arg)) |
| | | { |
| | | commandBuilder.addObfuscatedArgument(arg); |
| | | commandBuilder.addArgument(getAdminPasswordFileArg(arg)); |
| | | } |
| | | else |
| | | { |
| | | commandBuilder.addArgument(arg); |
| | | addArgument(commandBuilder, arg, interactionBuilder.isObfuscated(arg)); |
| | | } |
| | | } |
| | | } |
| | |
| | | ArrayList<Argument> toMoveArgs = new ArrayList<Argument>(); |
| | | for (String longID : identifiersToMove) |
| | | { |
| | | for (Argument arg : commandBuilder.getArguments()) |
| | | final Argument arg = findArg(commandBuilder, longID); |
| | | if (arg != null) |
| | | { |
| | | if (longID.equals(arg.getLongIdentifier())) |
| | | { |
| | | toMoveArgs.add(arg); |
| | | break; |
| | | } |
| | | toMoveArgs.add(arg); |
| | | } |
| | | } |
| | | for (Argument argToMove : toMoveArgs) |
| | |
| | | } |
| | | } |
| | | |
| | | private Argument findArg(CommandBuilder commandBuilder, String longIdentifier) |
| | | { |
| | | for (Argument arg : commandBuilder.getArguments()) |
| | | { |
| | | if (longIdentifier.equals(arg.getLongIdentifier())) |
| | | { |
| | | return arg; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private boolean existsArg(CommandBuilder commandBuilder, String longIdentifier) |
| | | { |
| | | return findArg(commandBuilder, longIdentifier) != null; |
| | | } |
| | | |
| | | private void addArgument(CommandBuilder commandBuilder, Argument arg, boolean isObfuscated) |
| | | { |
| | | if (isObfuscated) |
| | | { |
| | | commandBuilder.addObfuscatedArgument(arg); |
| | | } |
| | | else |
| | | { |
| | | commandBuilder.addArgument(arg); |
| | | } |
| | | } |
| | | |
| | | private void updateCommandBuilder(CommandBuilder commandBuilder, |
| | | EnableReplicationUserData uData) |
| | | throws ArgumentException |
| | |
| | | |
| | | if (firstServerCommandBuilder != null) |
| | | { |
| | | boolean useAdminUID = false; |
| | | for (Argument arg : firstServerCommandBuilder.getArguments()) |
| | | { |
| | | if (OPTION_LONG_ADMIN_UID.equals(arg.getLongIdentifier())) |
| | | { |
| | | useAdminUID = true; |
| | | break; |
| | | } |
| | | } |
| | | boolean useAdminUID = existsArg(firstServerCommandBuilder, OPTION_LONG_ADMIN_UID); |
| | | // This is required when both the bindDN and the admin UID are provided |
| | | // in the command-line. |
| | | boolean forceAddBindDN1 = false; |
| | |
| | | String adminUID = uData.getAdminUid(); |
| | | if (bindDN1 != null |
| | | && adminUID != null |
| | | && !areDnsEqual(ADSContext.getAdministratorDN(adminUID), bindDN1)) |
| | | && !areDnsEqual(getAdministratorDN(adminUID), bindDN1)) |
| | | { |
| | | forceAddBindDN1 = true; |
| | | for (Argument arg : firstServerCommandBuilder.getArguments()) |
| | | { |
| | | if (OPTION_LONG_BINDPWD_FILE.equals(arg.getLongIdentifier())) |
| | | { |
| | | forceAddBindPwdFile1 = true; |
| | | break; |
| | | } |
| | | } |
| | | forceAddBindPwdFile1 = existsArg(firstServerCommandBuilder, OPTION_LONG_BINDPWD_FILE); |
| | | } |
| | | } |
| | | for (Argument arg : firstServerCommandBuilder.getArguments()) |
| | | { |
| | | if (OPTION_LONG_HOST.equals(arg.getLongIdentifier())) |
| | | { |
| | | StringArgument host = new StringArgument("host1", OPTION_SHORT_HOST, |
| | | "host1", false, false, true, INFO_HOST_PLACEHOLDER.get(), |
| | | null, |
| | | null, INFO_DESCRIPTION_ENABLE_REPLICATION_HOST1.get()); |
| | | host.addValue(uData.getHostName1()); |
| | | commandBuilder.addArgument(host); |
| | | commandBuilder.addArgument(getHostArg("host1", OPTION_SHORT_HOST, uData.getHostName1(), |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_HOST1)); |
| | | } |
| | | else if (OPTION_LONG_PORT.equals(arg.getLongIdentifier())) |
| | | { |
| | | IntegerArgument port = new IntegerArgument("port1", OPTION_SHORT_PORT, |
| | | "port1", |
| | | false, false, true, INFO_PORT_PLACEHOLDER.get(), 4444, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_SERVER_PORT1.get()); |
| | | port.addValue(String.valueOf(uData.getPort1())); |
| | | commandBuilder.addArgument(port); |
| | | commandBuilder.addArgument(getPortArg("port1", OPTION_SHORT_PORT, uData.getPort1(), |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_SERVER_PORT1)); |
| | | |
| | | if (forceAddBindDN1) |
| | | { |
| | | StringArgument bindDN = new StringArgument("bindDN1", |
| | | OPTION_SHORT_BINDDN, |
| | | "bindDN1", false, false, true, INFO_BINDDN_PLACEHOLDER.get(), |
| | | "cn=Directory Manager", null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDDN1.get()); |
| | | bindDN.addValue(uData.getBindDn1()); |
| | | commandBuilder.addArgument(bindDN); |
| | | commandBuilder.addArgument(getBindDN1Arg(uData)); |
| | | if (forceAddBindPwdFile1) |
| | | { |
| | | FileBasedArgument bindPasswordFileArg = new FileBasedArgument( |
| | | "bindPasswordFile1", |
| | | null, "bindPasswordFile1", false, false, |
| | | INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORDFILE1.get()); |
| | | FileBasedArgument bindPasswordFileArg = getBindPasswordFile1Arg(); |
| | | bindPasswordFileArg.getNameToValueMap().put("{password file}", |
| | | "{password file}"); |
| | | commandBuilder.addArgument(bindPasswordFileArg); |
| | | } |
| | | else |
| | | { |
| | | StringArgument bindPasswordArg = new StringArgument( |
| | | "bindPassword1", |
| | | null, "bindPassword1", false, false, true, |
| | | INFO_BINDPWD_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORD1.get()); |
| | | bindPasswordArg.addValue(arg.getValue()); |
| | | commandBuilder.addObfuscatedArgument(bindPasswordArg); |
| | | commandBuilder.addObfuscatedArgument(getBindPassword1Arg(arg)); |
| | | } |
| | | } |
| | | } |
| | | else if (OPTION_LONG_BINDDN.equals(arg.getLongIdentifier())) |
| | | { |
| | | StringArgument bindDN = new StringArgument("bindDN1", |
| | | OPTION_SHORT_BINDDN, |
| | | "bindDN1", false, false, true, INFO_BINDDN_PLACEHOLDER.get(), |
| | | "cn=Directory Manager", null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDDN1.get()); |
| | | bindDN.addValue(uData.getBindDn1()); |
| | | commandBuilder.addArgument(bindDN); |
| | | commandBuilder.addArgument(getBindDN1Arg(uData)); |
| | | } |
| | | else if (OPTION_LONG_BINDPWD.equals(arg.getLongIdentifier())) |
| | | { |
| | | if (useAdminUID) |
| | | { |
| | | adminInformationAdded = true; |
| | | StringArgument bindPasswordArg = new StringArgument("adminPassword", |
| | | OPTION_SHORT_BINDPWD, "adminPassword", false, false, true, |
| | | INFO_BINDPWD_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_BINDPASSWORD.get()); |
| | | bindPasswordArg.addValue(arg.getValue()); |
| | | commandBuilder.addObfuscatedArgument(bindPasswordArg); |
| | | commandBuilder.addObfuscatedArgument(getAdminPasswordArg(arg)); |
| | | } |
| | | else |
| | | { |
| | | StringArgument bindPasswordArg = new StringArgument("bindPassword1", |
| | | null, "bindPassword1", false, false, true, |
| | | INFO_BINDPWD_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORD1.get()); |
| | | bindPasswordArg.addValue(arg.getValue()); |
| | | commandBuilder.addObfuscatedArgument(bindPasswordArg); |
| | | commandBuilder.addObfuscatedArgument(getBindPassword1Arg(arg)); |
| | | } |
| | | } |
| | | else if (OPTION_LONG_BINDPWD_FILE.equals(arg.getLongIdentifier())) |
| | | { |
| | | if (useAdminUID) |
| | | { |
| | | FileBasedArgument bindPasswordFileArg = new FileBasedArgument( |
| | | "adminPasswordFile", |
| | | OPTION_SHORT_BINDPWD_FILE, "adminPasswordFile", false, false, |
| | | INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_BINDPASSWORDFILE.get()); |
| | | bindPasswordFileArg.getNameToValueMap().putAll( |
| | | ((FileBasedArgument)arg).getNameToValueMap()); |
| | | commandBuilder.addArgument(bindPasswordFileArg); |
| | | commandBuilder.addArgument(getAdminPasswordFileArg(arg)); |
| | | } |
| | | else |
| | | { |
| | | FileBasedArgument bindPasswordFileArg = new FileBasedArgument( |
| | | "bindPasswordFile1", |
| | | null, "bindPasswordFile1", false, false, |
| | | INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORDFILE1.get()); |
| | | FileBasedArgument bindPasswordFileArg = getBindPasswordFile1Arg(); |
| | | bindPasswordFileArg.getNameToValueMap().putAll( |
| | | ((FileBasedArgument)arg).getNameToValueMap()); |
| | | commandBuilder.addArgument(bindPasswordFileArg); |
| | |
| | | adminInformationAdded = true; |
| | | } |
| | | |
| | | if (firstServerCommandBuilder.isObfuscated(arg)) |
| | | { |
| | | commandBuilder.addObfuscatedArgument(arg); |
| | | } |
| | | else |
| | | { |
| | | commandBuilder.addArgument(arg); |
| | | } |
| | | addArgument(commandBuilder, arg, firstServerCommandBuilder.isObfuscated(arg)); |
| | | } |
| | | } |
| | | } |
| | |
| | | if (ci != null && ci.getCommandBuilder() != null) |
| | | { |
| | | CommandBuilder interactionBuilder = ci.getCommandBuilder(); |
| | | boolean useAdminUID = false; |
| | | boolean hasBindDN = false; |
| | | for (Argument arg : interactionBuilder.getArguments()) |
| | | { |
| | | if (OPTION_LONG_ADMIN_UID.equals(arg.getLongIdentifier())) |
| | | { |
| | | useAdminUID = true; |
| | | } |
| | | else if (OPTION_LONG_BINDDN.equals(arg.getLongIdentifier())) |
| | | { |
| | | hasBindDN = true; |
| | | } |
| | | if (useAdminUID && hasBindDN) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | boolean useAdminUID = existsArg(interactionBuilder, OPTION_LONG_ADMIN_UID); |
| | | boolean hasBindDN = existsArg(interactionBuilder, OPTION_LONG_BINDDN); |
| | | // This is required when both the bindDN and the admin UID are provided |
| | | // in the command-line. |
| | | boolean forceAddBindDN2 = false; |
| | |
| | | String adminUID = uData.getAdminUid(); |
| | | if (bindDN2 != null |
| | | && adminUID != null |
| | | && !areDnsEqual(ADSContext.getAdministratorDN(adminUID), bindDN2)) |
| | | && !areDnsEqual(getAdministratorDN(adminUID), bindDN2)) |
| | | { |
| | | forceAddBindDN2 = true; |
| | | for (Argument arg : interactionBuilder.getArguments()) |
| | | { |
| | | if (arg.getLongIdentifier().equals(OPTION_LONG_BINDPWD_FILE)) |
| | | { |
| | | forceAddBindPwdFile2 = true; |
| | | break; |
| | | } |
| | | } |
| | | forceAddBindPwdFile2 = existsArg(interactionBuilder, OPTION_LONG_BINDPWD_FILE); |
| | | } |
| | | } |
| | | ArrayList<Argument> argsToAnalyze = new ArrayList<Argument>(); |
| | |
| | | { |
| | | if (OPTION_LONG_HOST.equals(arg.getLongIdentifier())) |
| | | { |
| | | StringArgument host = new StringArgument("host2", 'O', |
| | | "host2", false, false, true, INFO_HOST_PLACEHOLDER.get(), |
| | | null, |
| | | null, INFO_DESCRIPTION_ENABLE_REPLICATION_HOST2.get()); |
| | | host.addValue(uData.getHostName2()); |
| | | commandBuilder.addArgument(host); |
| | | commandBuilder.addArgument(getHostArg("host2", 'O', uData.getHostName2(), |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_HOST2)); |
| | | } |
| | | else if (OPTION_LONG_PORT.equals(arg.getLongIdentifier())) |
| | | { |
| | | IntegerArgument port = new IntegerArgument("port2", null, "port2", |
| | | false, false, true, INFO_PORT_PLACEHOLDER.get(), 4444, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_SERVER_PORT2.get()); |
| | | port.addValue(String.valueOf(uData.getPort2())); |
| | | commandBuilder.addArgument(port); |
| | | commandBuilder.addArgument(getPortArg("port2", null, uData.getPort2(), |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_SERVER_PORT2)); |
| | | |
| | | if (forceAddBindDN2) |
| | | { |
| | | StringArgument bindDN = new StringArgument("bindDN2", |
| | | OPTION_SHORT_BINDDN, |
| | | "bindDN2", false, false, true, INFO_BINDDN_PLACEHOLDER.get(), |
| | | "cn=Directory Manager", null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDDN2.get()); |
| | | bindDN.addValue(uData.getBindDn2()); |
| | | commandBuilder.addArgument(bindDN); |
| | | commandBuilder.addArgument(getBindDN2Arg(uData, OPTION_SHORT_BINDDN)); |
| | | if (forceAddBindPwdFile2) |
| | | { |
| | | FileBasedArgument bindPasswordFileArg = new FileBasedArgument( |
| | | "bindPasswordFile2", |
| | | null, "bindPasswordFile2", false, false, |
| | | INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORDFILE2.get()); |
| | | FileBasedArgument bindPasswordFileArg = getBindPasswordFile2Arg(); |
| | | bindPasswordFileArg.getNameToValueMap().put("{password file}", |
| | | "{password file}"); |
| | | commandBuilder.addArgument(bindPasswordFileArg); |
| | | } |
| | | else |
| | | { |
| | | StringArgument bindPasswordArg = new StringArgument( |
| | | "bindPassword2", |
| | | null, "bindPassword2", false, false, true, |
| | | INFO_BINDPWD_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORD2.get()); |
| | | bindPasswordArg.addValue(arg.getValue()); |
| | | commandBuilder.addObfuscatedArgument(bindPasswordArg); |
| | | commandBuilder.addObfuscatedArgument(getBindPassword2Arg(arg)); |
| | | } |
| | | } |
| | | } |
| | | else if (OPTION_LONG_BINDDN.equals(arg.getLongIdentifier())) |
| | | { |
| | | StringArgument bindDN = new StringArgument("bindDN2", null, |
| | | "bindDN2", false, false, true, INFO_BINDDN_PLACEHOLDER.get(), |
| | | "cn=Directory Manager", null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDDN2.get()); |
| | | bindDN.addValue(uData.getBindDn2()); |
| | | commandBuilder.addArgument(bindDN); |
| | | commandBuilder.addArgument(getBindDN2Arg(uData, null)); |
| | | } |
| | | else if (OPTION_LONG_BINDPWD.equals(arg.getLongIdentifier())) |
| | | { |
| | | if (useAdminUID && !adminInformationAdded) |
| | | { |
| | | adminInformationAdded = true; |
| | | StringArgument bindPasswordArg = new StringArgument("adminPassword", |
| | | OPTION_SHORT_BINDPWD, "adminPassword", false, false, true, |
| | | INFO_BINDPWD_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_BINDPASSWORD.get()); |
| | | bindPasswordArg.addValue(arg.getValue()); |
| | | commandBuilder.addObfuscatedArgument(bindPasswordArg); |
| | | commandBuilder.addObfuscatedArgument(getAdminPasswordArg(arg)); |
| | | } |
| | | else if (hasBindDN) |
| | | { |
| | | StringArgument bindPasswordArg = new StringArgument("bindPassword2", |
| | | null, "bindPassword2", false, false, true, |
| | | INFO_BINDPWD_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORD2.get()); |
| | | bindPasswordArg.addValue(arg.getValue()); |
| | | commandBuilder.addObfuscatedArgument(bindPasswordArg); |
| | | commandBuilder.addObfuscatedArgument(getBindPassword2Arg(arg)); |
| | | } |
| | | } |
| | | else if (OPTION_LONG_BINDPWD_FILE.equals(arg.getLongIdentifier())) |
| | |
| | | if (useAdminUID && !adminInformationAdded) |
| | | { |
| | | adminInformationAdded = true; |
| | | FileBasedArgument bindPasswordFileArg = new FileBasedArgument( |
| | | "adminPasswordFile", |
| | | OPTION_SHORT_BINDPWD_FILE, "adminPasswordFile", false, false, |
| | | INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_BINDPASSWORDFILE.get()); |
| | | bindPasswordFileArg.getNameToValueMap().putAll( |
| | | ((FileBasedArgument)arg).getNameToValueMap()); |
| | | commandBuilder.addArgument(bindPasswordFileArg); |
| | | commandBuilder.addArgument(getAdminPasswordFileArg(arg)); |
| | | } |
| | | else if (hasBindDN) |
| | | { |
| | | FileBasedArgument bindPasswordFileArg = new FileBasedArgument( |
| | | "bindPasswordFile2", |
| | | null, "bindPasswordFile2", false, false, |
| | | INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORDFILE2.get()); |
| | | FileBasedArgument bindPasswordFileArg = getBindPasswordFile2Arg(); |
| | | bindPasswordFileArg.getNameToValueMap().putAll( |
| | | ((FileBasedArgument)arg).getNameToValueMap()); |
| | | commandBuilder.addArgument(bindPasswordFileArg); |
| | |
| | | for (Argument arg : argsToAnalyze) |
| | | { |
| | | // Just check that the arguments have not already been added. |
| | | boolean found = false; |
| | | for (Argument a : commandBuilder.getArguments()) |
| | | if (!existsArg(commandBuilder, arg.getLongIdentifier())) |
| | | { |
| | | if (a.getLongIdentifier().equals(arg.getLongIdentifier())) |
| | | { |
| | | found = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (!found) |
| | | { |
| | | if (interactionBuilder.isObfuscated(arg)) |
| | | { |
| | | commandBuilder.addObfuscatedArgument(arg); |
| | | } |
| | | else |
| | | { |
| | | commandBuilder.addArgument(arg); |
| | | } |
| | | addArgument(commandBuilder, arg, interactionBuilder.isObfuscated(arg)); |
| | | } |
| | | } |
| | | } |
| | |
| | | // Try to add the new administration information. |
| | | if (!adminInformationAdded) |
| | | { |
| | | StringArgument adminUID = new StringArgument(OPTION_LONG_ADMIN_UID, 'I', |
| | | OPTION_LONG_ADMIN_UID, false, false, true, |
| | | INFO_ADMINUID_PLACEHOLDER.get(), |
| | | Constants.GLOBAL_ADMIN_UID, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_UID.get(ENABLE_REPLICATION_SUBCMD_NAME)); |
| | | if (uData.getAdminUid() != null) |
| | | { |
| | | StringArgument adminUID = new StringArgument(OPTION_LONG_ADMIN_UID, 'I', |
| | | OPTION_LONG_ADMIN_UID, false, false, true, |
| | | INFO_ADMINUID_PLACEHOLDER.get(), |
| | | Constants.GLOBAL_ADMIN_UID, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_UID.get(ENABLE_REPLICATION_SUBCMD_NAME)); |
| | | adminUID.addValue(uData.getAdminUid()); |
| | | commandBuilder.addArgument(adminUID); |
| | | } |
| | |
| | | { |
| | | commandBuilder.addArgument(userProvidedAdminPwdFile); |
| | | } |
| | | else |
| | | else if (uData.getAdminPwd() != null) |
| | | { |
| | | Argument bindPasswordArg = new StringArgument("adminPassword", |
| | | OPTION_SHORT_BINDPWD, "adminPassword", false, false, true, |
| | | INFO_BINDPWD_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_BINDPASSWORD.get()); |
| | | if (uData.getAdminPwd() != null) |
| | | { |
| | | bindPasswordArg.addValue(uData.getAdminPwd()); |
| | | commandBuilder.addObfuscatedArgument(bindPasswordArg); |
| | | } |
| | | Argument bindPasswordArg = getAdminPasswordArg(); |
| | | bindPasswordArg.addValue(uData.getAdminPwd()); |
| | | commandBuilder.addObfuscatedArgument(bindPasswordArg); |
| | | } |
| | | } |
| | | |
| | | if (uData.configureReplicationServer1() && |
| | | !uData.configureReplicationDomain1()) |
| | | { |
| | | commandBuilder.addArgument(new BooleanArgument( |
| | | argParser.onlyReplicationServer1Arg.getName(), |
| | | argParser.onlyReplicationServer1Arg.getShortIdentifier(), |
| | | argParser.onlyReplicationServer1Arg.getLongIdentifier(), |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_ONLY_REPLICATION_SERVER1.get())); |
| | | commandBuilder.addArgument(newBooleanArgument( |
| | | argParser.onlyReplicationServer1Arg, INFO_DESCRIPTION_ENABLE_REPLICATION_ONLY_REPLICATION_SERVER1)); |
| | | } |
| | | |
| | | if (!uData.configureReplicationServer1() && |
| | | uData.configureReplicationDomain1()) |
| | | { |
| | | commandBuilder.addArgument(new BooleanArgument( |
| | | argParser.noReplicationServer1Arg.getName(), |
| | | argParser.noReplicationServer1Arg.getShortIdentifier(), |
| | | argParser.noReplicationServer1Arg.getLongIdentifier(), |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_NO_REPLICATION_SERVER1.get())); |
| | | commandBuilder.addArgument(newBooleanArgument( |
| | | argParser.noReplicationServer1Arg, INFO_DESCRIPTION_ENABLE_REPLICATION_NO_REPLICATION_SERVER1)); |
| | | } |
| | | |
| | | if (uData.configureReplicationServer1() && |
| | |
| | | if (uData.configureReplicationServer2() && |
| | | !uData.configureReplicationDomain2()) |
| | | { |
| | | commandBuilder.addArgument(new BooleanArgument( |
| | | argParser.onlyReplicationServer2Arg.getName(), |
| | | argParser.onlyReplicationServer2Arg.getShortIdentifier(), |
| | | argParser.onlyReplicationServer2Arg.getLongIdentifier(), |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_ONLY_REPLICATION_SERVER2.get())); |
| | | commandBuilder.addArgument(newBooleanArgument( |
| | | argParser.onlyReplicationServer2Arg, INFO_DESCRIPTION_ENABLE_REPLICATION_ONLY_REPLICATION_SERVER2)); |
| | | } |
| | | |
| | | if (!uData.configureReplicationServer2() && |
| | | uData.configureReplicationDomain2()) |
| | | { |
| | | commandBuilder.addArgument(new BooleanArgument( |
| | | argParser.noReplicationServer2Arg.getName(), |
| | | argParser.noReplicationServer2Arg.getShortIdentifier(), |
| | | argParser.noReplicationServer2Arg.getLongIdentifier(), |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_NO_REPLICATION_SERVER2.get())); |
| | | commandBuilder.addArgument(newBooleanArgument( |
| | | argParser.noReplicationServer2Arg, INFO_DESCRIPTION_ENABLE_REPLICATION_NO_REPLICATION_SERVER2)); |
| | | } |
| | | if (uData.configureReplicationServer2() && |
| | | uData.getReplicationPort2() > 0) |
| | |
| | | } |
| | | } |
| | | |
| | | private BooleanArgument newBooleanArgument(BooleanArgument arg, Arg0 msg) throws ArgumentException |
| | | { |
| | | return new BooleanArgument(arg.getName(), arg.getShortIdentifier(), arg.getLongIdentifier(), msg.get()); |
| | | } |
| | | |
| | | private StringArgument getBindPassword1Arg(Argument arg) throws ArgumentException |
| | | { |
| | | StringArgument bindPasswordArg = new StringArgument( |
| | | "bindPassword1", null, "bindPassword1", false, false, true, |
| | | INFO_BINDPWD_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORD1.get()); |
| | | bindPasswordArg.addValue(arg.getValue()); |
| | | return bindPasswordArg; |
| | | } |
| | | |
| | | private StringArgument getBindPassword2Arg(Argument arg) throws ArgumentException |
| | | { |
| | | StringArgument bindPasswordArg = new StringArgument( |
| | | "bindPassword2", null, "bindPassword2", false, false, true, |
| | | INFO_BINDPWD_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORD2.get()); |
| | | bindPasswordArg.addValue(arg.getValue()); |
| | | return bindPasswordArg; |
| | | } |
| | | |
| | | private FileBasedArgument getBindPasswordFile1Arg() throws ArgumentException |
| | | { |
| | | return new FileBasedArgument( |
| | | "bindPasswordFile1", null, "bindPasswordFile1", false, false, |
| | | INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORDFILE1.get()); |
| | | } |
| | | |
| | | private FileBasedArgument getBindPasswordFile2Arg() throws ArgumentException |
| | | { |
| | | return new FileBasedArgument( |
| | | "bindPasswordFile2", null, "bindPasswordFile2", false, false, |
| | | INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDPASSWORDFILE2.get()); |
| | | } |
| | | |
| | | private StringArgument getBindDN1Arg(EnableReplicationUserData uData) throws ArgumentException |
| | | { |
| | | StringArgument bindDN = new StringArgument("bindDN1", OPTION_SHORT_BINDDN, "bindDN1", false, false, true, |
| | | INFO_BINDDN_PLACEHOLDER.get(), "cn=Directory Manager", null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDDN1.get()); |
| | | bindDN.addValue(uData.getBindDn1()); |
| | | return bindDN; |
| | | } |
| | | |
| | | private StringArgument getBindDN2Arg(EnableReplicationUserData uData, Character shortIdentifier) |
| | | throws ArgumentException |
| | | { |
| | | StringArgument bindDN = new StringArgument("bindDN2", shortIdentifier, "bindDN2", false, false, true, |
| | | INFO_BINDDN_PLACEHOLDER.get(), "cn=Directory Manager", null, |
| | | INFO_DESCRIPTION_ENABLE_REPLICATION_BINDDN2.get()); |
| | | bindDN.addValue(uData.getBindDn2()); |
| | | return bindDN; |
| | | } |
| | | |
| | | private void updateCommandBuilder(CommandBuilder commandBuilder, |
| | | InitializeReplicationUserData uData) |
| | | throws ArgumentException |
| | |
| | | { |
| | | if (OPTION_LONG_HOST.equals(arg.getLongIdentifier())) |
| | | { |
| | | StringArgument host = new StringArgument("hostSource", 'O', |
| | | "hostSource", false, false, true, |
| | | INFO_HOST_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_INITIALIZE_REPLICATION_HOST_SOURCE.get()); |
| | | host.addValue(uData.getHostNameSource()); |
| | | commandBuilder.addArgument(host); |
| | | commandBuilder.addArgument(getHostArg("hostSource", 'O', uData.getHostNameSource(), |
| | | INFO_DESCRIPTION_INITIALIZE_REPLICATION_HOST_SOURCE)); |
| | | } |
| | | else if (OPTION_LONG_PORT.equals(arg.getLongIdentifier())) |
| | | { |
| | | IntegerArgument port = new IntegerArgument("portSource", null, |
| | | "portSource", false, false, true, |
| | | INFO_PORT_PLACEHOLDER.get(), |
| | | 4444, |
| | | null, |
| | | INFO_DESCRIPTION_INITIALIZE_REPLICATION_SERVER_PORT_SOURCE.get()); |
| | | port.addValue(String.valueOf(uData.getPortSource())); |
| | | commandBuilder.addArgument(port); |
| | | commandBuilder.addArgument(getPortArg("portSource", null, uData.getPortSource(), |
| | | INFO_DESCRIPTION_INITIALIZE_REPLICATION_SERVER_PORT_SOURCE)); |
| | | } |
| | | else if (OPTION_LONG_BINDPWD.equals(arg.getLongIdentifier())) |
| | | { |
| | | StringArgument bindPasswordArg = new StringArgument("adminPassword", |
| | | OPTION_SHORT_BINDPWD, "adminPassword", false, false, true, |
| | | INFO_BINDPWD_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_BINDPASSWORD.get()); |
| | | bindPasswordArg.addValue(arg.getValue()); |
| | | commandBuilder.addObfuscatedArgument(bindPasswordArg); |
| | | commandBuilder.addObfuscatedArgument(getAdminPasswordArg(arg)); |
| | | } |
| | | else if (OPTION_LONG_BINDPWD_FILE.equals(arg.getLongIdentifier())) |
| | | { |
| | | FileBasedArgument bindPasswordFileArg = new FileBasedArgument( |
| | | "adminPasswordFile", |
| | | OPTION_SHORT_BINDPWD_FILE, "adminPasswordFile", false, false, |
| | | INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_BINDPASSWORDFILE.get()); |
| | | bindPasswordFileArg.getNameToValueMap().putAll( |
| | | ((FileBasedArgument)arg).getNameToValueMap()); |
| | | commandBuilder.addArgument(bindPasswordFileArg); |
| | | } |
| | | else if (firstServerCommandBuilder.isObfuscated(arg)) |
| | | { |
| | | commandBuilder.addObfuscatedArgument(arg); |
| | | commandBuilder.addArgument(getAdminPasswordFileArg(arg)); |
| | | } |
| | | else |
| | | { |
| | | commandBuilder.addArgument(arg); |
| | | addArgument(commandBuilder, arg, firstServerCommandBuilder.isObfuscated(arg)); |
| | | } |
| | | } |
| | | } |
| | |
| | | CommandBuilder interactionBuilder = ci.getCommandBuilder(); |
| | | for (Argument arg : interactionBuilder.getArguments()) |
| | | { |
| | | if (arg.getLongIdentifier().equals(OPTION_LONG_HOST)) |
| | | if (OPTION_LONG_HOST.equals(arg.getLongIdentifier())) |
| | | { |
| | | StringArgument host = new StringArgument("hostDestination", 'O', |
| | | "hostDestination", false, false, true, |
| | | INFO_HOST_PLACEHOLDER.get(), |
| | | null, null, |
| | | INFO_DESCRIPTION_INITIALIZE_REPLICATION_HOST_DESTINATION.get()); |
| | | host.addValue(uData.getHostNameDestination()); |
| | | commandBuilder.addArgument(host); |
| | | commandBuilder.addArgument(getHostArg("hostDestination", 'O', uData.getHostNameDestination(), |
| | | INFO_DESCRIPTION_INITIALIZE_REPLICATION_HOST_DESTINATION)); |
| | | } |
| | | else if (OPTION_LONG_PORT.equals(arg.getLongIdentifier())) |
| | | { |
| | | IntegerArgument port = new IntegerArgument("portDestination", null, |
| | | "portDestination", false, false, true, |
| | | INFO_PORT_PLACEHOLDER.get(), |
| | | 4444, |
| | | null, |
| | | INFO_DESCRIPTION_INITIALIZE_REPLICATION_SERVER_PORT_DESTINATION.get()); |
| | | port.addValue(String.valueOf(uData.getPortDestination())); |
| | | commandBuilder.addArgument(port); |
| | | commandBuilder.addArgument(getPortArg("portDestination", null, uData.getPortDestination(), |
| | | INFO_DESCRIPTION_INITIALIZE_REPLICATION_SERVER_PORT_DESTINATION)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private StringArgument getAdminPasswordArg(Argument arg) throws ArgumentException |
| | | { |
| | | StringArgument sArg = getAdminPasswordArg(); |
| | | sArg.addValue(arg.getValue()); |
| | | return sArg; |
| | | } |
| | | |
| | | private StringArgument getAdminPasswordArg() throws ArgumentException |
| | | { |
| | | return new StringArgument("adminPassword", |
| | | OPTION_SHORT_BINDPWD, "adminPassword", false, false, true, |
| | | INFO_BINDPWD_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_BINDPASSWORD.get()); |
| | | } |
| | | |
| | | private FileBasedArgument getAdminPasswordFileArg(Argument arg) throws ArgumentException |
| | | { |
| | | FileBasedArgument fbArg = new FileBasedArgument( |
| | | "adminPasswordFile", OPTION_SHORT_BINDPWD_FILE, "adminPasswordFile", false, false, |
| | | INFO_BINDPWD_FILE_PLACEHOLDER.get(), null, null, |
| | | INFO_DESCRIPTION_REPLICATION_ADMIN_BINDPASSWORDFILE.get()); |
| | | fbArg.getNameToValueMap().putAll(((FileBasedArgument) arg).getNameToValueMap()); |
| | | return fbArg; |
| | | } |
| | | |
| | | private IntegerArgument getPortArg(String longIdentifier, Character shortIdentifier, int value, Arg0 arg) |
| | | throws ArgumentException |
| | | { |
| | | IntegerArgument iArg = new IntegerArgument(longIdentifier, shortIdentifier, longIdentifier, false, false, true, |
| | | INFO_PORT_PLACEHOLDER.get(), 4444, null, arg.get()); |
| | | iArg.addValue(String.valueOf(value)); |
| | | return iArg; |
| | | } |
| | | |
| | | private StringArgument getHostArg(String longIdentifier, char shortIdentifier, String value, |
| | | Arg0 description) throws ArgumentException |
| | | { |
| | | StringArgument sArg = new StringArgument(longIdentifier, shortIdentifier, longIdentifier, false, false, true, |
| | | INFO_HOST_PLACEHOLDER.get(), null, null, description.get()); |
| | | sArg.addValue(value); |
| | | return sArg; |
| | | } |
| | | |
| | | private void updateAvailableAndReplicatedSuffixesForOneDomain( |
| | | InitialLdapContext ctxDomain, InitialLdapContext ctxOther, |
| | | Collection<String> availableSuffixes, |
| | | Collection<String> alreadyReplicatedSuffixes) |
| | | Set<String> availableSuffixes, Set<String> alreadyReplicatedSuffixes) |
| | | { |
| | | Collection<ReplicaDescriptor> replicas = getReplicas(ctxDomain); |
| | | int replicationPort = getReplicationPort(ctxOther); |
| | |
| | | } |
| | | availableSuffixes.add(replica.getSuffix().getDN()); |
| | | } |
| | | |
| | | if (!isReplicationServerConfigured) |
| | | { |
| | | availableSuffixes.add(replica.getSuffix().getDN()); |
| | |
| | | |
| | | private void updateAvailableAndReplicatedSuffixesForNoDomain( |
| | | InitialLdapContext ctx1, InitialLdapContext ctx2, |
| | | Collection<String> availableSuffixes, |
| | | Collection<String> alreadyReplicatedSuffixes) |
| | | Set<String> availableSuffixes, Set<String> alreadyReplicatedSuffixes) |
| | | { |
| | | int replicationPort1 = getReplicationPort(ctx1); |
| | | boolean isReplicationServer1Configured = replicationPort1 != -1; |
| | |
| | | private void updateAvailableAndReplicatedSuffixesForNoDomainOneSense( |
| | | TopologyCache cache1, TopologyCache cache2, String replicationServer1, |
| | | String replicationServer2, |
| | | Collection<String> availableSuffixes, |
| | | Collection<String> alreadyReplicatedSuffixes) |
| | | Set<String> availableSuffixes, Set<String> alreadyReplicatedSuffixes) |
| | | { |
| | | for (SuffixDescriptor suffix : cache1.getSuffixes()) |
| | | { |
| | |
| | | print(INFO_REPLICATION_MERGING_REGISTRIES_PROGRESS.get()); |
| | | pointAdder.start(); |
| | | |
| | | Collection<LocalizableMessage> cache1Errors = cache1.getErrorMessages(); |
| | | Set<LocalizableMessage> cache1Errors = cache1.getErrorMessages(); |
| | | if (!cache1Errors.isEmpty()) |
| | | { |
| | | throw new ReplicationCliException( |
| | |
| | | ERROR_READING_ADS, null); |
| | | } |
| | | |
| | | Collection<LocalizableMessage> cache2Errors = cache2.getErrorMessages(); |
| | | Set<LocalizableMessage> cache2Errors = cache2.getErrorMessages(); |
| | | if (!cache2Errors.isEmpty()) |
| | | { |
| | | throw new ReplicationCliException( |
| | |
| | | catch (Throwable t) |
| | | { |
| | | logger.error(LocalizableMessage.raw("Error seeding truststore: "+t, t)); |
| | | String arg = (t instanceof OpenDsException) ? |
| | | ((OpenDsException)t).getMessageObject().toString() : t.toString(); |
| | | LocalizableMessage msg = ERR_REPLICATION_ENABLE_SEEDING_TRUSTSTORE.get( |
| | | getHostPort(adsCtx2.getDirContext()), getHostPort(adsCtx1.getDirContext()), arg); |
| | | getHostPort(adsCtx2.getDirContext()), getHostPort(adsCtx1.getDirContext()), toString(t)); |
| | | throw new ReplicationCliException(msg, ERROR_SEEDING_TRUSTORE, t); |
| | | } |
| | | pointAdder.stop(); |
| | |
| | | } |
| | | } |
| | | |
| | | private String toString(Throwable t) |
| | | { |
| | | return (t instanceof OpenDsException) ? |
| | | ((OpenDsException) t).getMessageObject().toString() : t.toString(); |
| | | } |
| | | |
| | | private TopologyCache createTopologyCache(ADSContext adsCtx, Set<PreferredConnection> cnx) |
| | | throws ReplicationCliException |
| | | { |
| | |
| | | } |
| | | |
| | | private String binDir; |
| | | |
| | | /** |
| | | * Returns the binary/script directory. |
| | | * @return the binary/script directory. |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Class used to compare replication servers. |
| | | */ |
| | | /** Class used to compare replication servers. */ |
| | | class ReplicationServerComparator implements Comparator<ServerDescriptor> |
| | | { |
| | | /** {@inheritDoc} */ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Class used to compare suffixes. |
| | | * |
| | | */ |
| | | /** Class used to compare suffixes. */ |
| | | class SuffixComparator implements Comparator<SuffixDescriptor> |
| | | { |
| | | /** {@inheritDoc} */ |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Class used to compare servers. |
| | | */ |
| | | /** Class used to compare servers. */ |
| | | class ServerComparator implements Comparator<ServerDescriptor> |
| | | { |
| | | /** {@inheritDoc} */ |