Code cleanup
Uses new com.forgerock.opendj.cli.Utils methods to handle command line
arguments conflicts.
| | |
| | | } |
| | | |
| | | private void checkForConflictingArguments() throws ArgumentException { |
| | | throwIfConflictingArgsSet(quietArgument, verboseArgument); |
| | | throwIfConflictingArgsSet(batchArgument, batchFileArgument); |
| | | throwIfArgumentsConflict(quietArgument, verboseArgument); |
| | | throwIfArgumentsConflict(batchArgument, batchFileArgument); |
| | | |
| | | throwIfSetInInteractiveMode(batchFileArgument); |
| | | throwIfSetInInteractiveMode(batchArgument); |
| | | throwIfSetInInteractiveMode(quietArgument); |
| | | |
| | | throwIfConflictingArgsSet(scriptFriendlyArgument, verboseArgument); |
| | | throwIfConflictingArgsSet(noPropertiesFileArgument, propertiesFileArgument); |
| | | throwIfArgumentsConflict(scriptFriendlyArgument, verboseArgument); |
| | | throwIfArgumentsConflict(noPropertiesFileArgument, propertiesFileArgument); |
| | | } |
| | | |
| | | private void throwIfSetInInteractiveMode(Argument arg) throws ArgumentException { |
| | |
| | | } |
| | | } |
| | | |
| | | private void throwIfConflictingArgsSet(Argument arg1, Argument arg2) throws ArgumentException { |
| | | if (arg1.isPresent() && arg2.isPresent()) { |
| | | throw new ArgumentException(ERR_TOOL_CONFLICTING_ARGS.get( |
| | | arg1.getLongIdentifier(), arg2.getLongIdentifier())); |
| | | } |
| | | } |
| | | |
| | | /** Run the top-level interactive console. */ |
| | | private int runInteractiveMode() { |
| | | ConsoleApplication app = this; |
| | |
| | | */ |
| | | package org.opends.guitools.controlpanel; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.addErrorMessageIfArgumentsConflict; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | |
| | | import java.util.LinkedHashSet; |
| | | |
| | |
| | | { |
| | | errorMessages.add(ae.getMessageObject()); |
| | | } |
| | | |
| | | if (bindPasswordArg.isPresent() && bindPasswordFileArg.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | bindPasswordArg.getLongIdentifier(), |
| | | bindPasswordFileArg.getLongIdentifier()); |
| | | errorMessages.add(message); |
| | | } |
| | | addErrorMessageIfArgumentsConflict(errorMessages, bindPasswordArg, bindPasswordArg); |
| | | |
| | | if (!errorMessages.isEmpty()) |
| | | { |
| | |
| | | } |
| | | buf.append(message); |
| | | } |
| | | if (removeAllArg.isPresent()) |
| | | { |
| | | BooleanArgument[] removeArgs = { |
| | | removeServerLibrariesArg, |
| | | removeDatabasesArg, |
| | | removeLogFilesArg, |
| | | removeConfigurationFilesArg, |
| | | removeBackupFilesArg, |
| | | removeLDIFFilesArg |
| | | }; |
| | | for (BooleanArgument removeArg : removeArgs) |
| | | { |
| | | if (removeArg.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | removeAllArg.getLongIdentifier(), |
| | | removeArg.getLongIdentifier()); |
| | | if (buf.length() > 0) |
| | | { |
| | | buf.append(LINE_SEPARATOR); |
| | | } |
| | | buf.append(message); |
| | | } |
| | | } |
| | | } |
| | | |
| | | appendErrorMessageIfArgumentsConflict(buf, removeAllArg, removeServerLibrariesArg); |
| | | appendErrorMessageIfArgumentsConflict(buf, removeAllArg, removeDatabasesArg); |
| | | appendErrorMessageIfArgumentsConflict(buf, removeAllArg, removeLogFilesArg); |
| | | appendErrorMessageIfArgumentsConflict(buf, removeAllArg, removeConfigurationFilesArg); |
| | | appendErrorMessageIfArgumentsConflict(buf, removeAllArg, removeBackupFilesArg); |
| | | appendErrorMessageIfArgumentsConflict(buf, removeAllArg, removeLDIFFilesArg); |
| | | super.validateGlobalOptions(buf); |
| | | if (buf.length() > 0) |
| | | { |
| | |
| | | import static com.forgerock.opendj.cli.ReturnCode.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | | |
| | |
| | | */ |
| | | public int validateGlobalOptions(LocalizableMessageBuilder buf) |
| | | { |
| | | List<LocalizableMessage> errors = new ArrayList<>(); |
| | | |
| | | addIfArgsAreConflicting(errors, bindPasswordArg, bindPasswordFileArg); |
| | | |
| | | // Couldn't have at the same time trustAll and trustStore related args |
| | | addIfArgsAreConflicting(errors, trustAllArg, trustStorePathArg); |
| | | addIfArgsAreConflicting(errors, trustAllArg, trustStorePasswordArg); |
| | | addIfArgsAreConflicting(errors, trustAllArg, trustStorePasswordFileArg); |
| | | |
| | | addIfArgsAreConflicting(errors, trustStorePasswordArg, trustStorePasswordFileArg); |
| | | final List<LocalizableMessage> errors = new ArrayList<>(); |
| | | addErrorMessageIfArgumentsConflict(errors, bindPasswordArg, bindPasswordFileArg); |
| | | addErrorMessageIfArgumentsConflict(errors, trustAllArg, trustStorePathArg); |
| | | addErrorMessageIfArgumentsConflict(errors, trustAllArg, trustStorePasswordArg); |
| | | addErrorMessageIfArgumentsConflict(errors, trustAllArg, trustStorePasswordFileArg); |
| | | addErrorMessageIfArgumentsConflict(errors, trustStorePasswordArg, trustStorePasswordFileArg); |
| | | addErrorMessageIfArgumentsConflict(errors, useStartTLSArg, useSSLArg); |
| | | |
| | | checkIfPathArgumentIsReadable(errors, trustStorePathArg, ERR_CANNOT_READ_TRUSTSTORE); |
| | | checkIfPathArgumentIsReadable(errors, keyStorePathArg, ERR_CANNOT_READ_KEYSTORE); |
| | | |
| | | addIfArgsAreConflicting(errors, useStartTLSArg, useSSLArg); |
| | | |
| | | if (!errors.isEmpty()) |
| | | { |
| | | for (LocalizableMessage error : errors) |
| | |
| | | return SUCCESS.get(); |
| | | } |
| | | |
| | | private void addIfArgsAreConflicting(List<LocalizableMessage> errors, Argument arg1, Argument arg2) |
| | | { |
| | | if (arg1.isPresent() && arg2.isPresent()) |
| | | { |
| | | errors.add(ERR_TOOL_CONFLICTING_ARGS.get(arg1.getLongIdentifier(), arg2.getLongIdentifier())); |
| | | } |
| | | } |
| | | |
| | | private void checkIfPathArgumentIsReadable(List<LocalizableMessage> errors, StringArgument pathArg, Arg1<Object> msg) |
| | | { |
| | | if (pathArg.isPresent() && !canRead(pathArg.getValue())) |
| | |
| | | */ |
| | | public int validateGlobalOptions(final LocalizableMessageBuilder buf) |
| | | { |
| | | int ret = secureArgsList.validateGlobalOptions(buf) ; |
| | | |
| | | // Couldn't have at the same time properties file arg and |
| | | // propertiesFileArg |
| | | if (noPropertiesFileArg.isPresent() |
| | | && propertiesFileArg.isPresent()) |
| | | final int ret = secureArgsList.validateGlobalOptions(buf) ; |
| | | if (appendErrorMessageIfArgumentsConflict(buf, noPropertiesFileArg, propertiesFileArg)) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | noPropertiesFileArg.getLongIdentifier(), propertiesFileArg |
| | | .getLongIdentifier()); |
| | | if (buf.length() > 0) |
| | | { |
| | | buf.append(LINE_SEPARATOR); |
| | | } |
| | | buf.append(message); |
| | | return CONFLICTING_ARGS.get(); |
| | | } |
| | | |
| | | return ret; |
| | | } |
| | | |
| | |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.CliMessages.INFO_FILE_PLACEHOLDER; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | |
| | |
| | | } |
| | | |
| | | // Check for conflicting arguments. |
| | | if (clearPassword.isPresent() && clearPasswordFile.isPresent()) |
| | | try |
| | | { |
| | | printWrappedText(err, |
| | | ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(), clearPasswordFile.getLongIdentifier())); |
| | | throwIfArgumentsConflict(clearPassword, clearPasswordFile); |
| | | throwIfArgumentsConflict(clearPassword, interactivePassword); |
| | | throwIfArgumentsConflict(clearPasswordFile, interactivePassword); |
| | | throwIfArgumentsConflict(encodedPassword, encodedPasswordFile); |
| | | } |
| | | catch (final ArgumentException conflict) |
| | | { |
| | | printWrappedText(err, conflict.getMessageObject()); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | | if (clearPassword.isPresent() && interactivePassword.isPresent()) |
| | | { |
| | | printWrappedText(err, |
| | | ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(), interactivePassword.getLongIdentifier())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | | if (clearPasswordFile.isPresent() && interactivePassword.isPresent()) |
| | | { |
| | | printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(clearPasswordFile.getLongIdentifier(), |
| | | interactivePassword.getLongIdentifier())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | | if (encodedPassword.isPresent() && encodedPasswordFile.isPresent()) |
| | | { |
| | | printWrappedText(err, |
| | | ERR_TOOL_CONFLICTING_ARGS.get(encodedPassword.getLongIdentifier(), encodedPasswordFile.getLongIdentifier())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | | |
| | | // If we are not going to just list the storage schemes, then the clear-text |
| | | // password must have been provided. If we're going to encode a password, |
| | | // then the scheme must have also been provided. |
| | |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | |
| | | import java.io.File; |
| | | import java.io.OutputStream; |
| | |
| | | { |
| | | if (templateFile.isPresent()) |
| | | { |
| | | printWrappedText(err, |
| | | ERR_TOOL_CONFLICTING_ARGS.get(ldifFiles.getLongIdentifier(), templateFile.getLongIdentifier())); |
| | | printWrappedText(err, conflictingArgsErrorMessage(ldifFiles, templateFile)); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | import static com.forgerock.opendj.cli.CliMessages.INFO_NUM_ENTRIES_PLACEHOLDER; |
| | | import static com.forgerock.opendj.cli.CliMessages.INFO_PORT_PLACEHOLDER; |
| | | import static com.forgerock.opendj.cli.CliMessages.INFO_ROOT_USER_PWD_FILE_PLACEHOLDER; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.addErrorMessageIfArgumentsConflict; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | |
| | | */ |
| | | private void checkServerPassword(Collection<LocalizableMessage> errorMessages) |
| | | { |
| | | if (directoryManagerPwdStringArg.isPresent() && |
| | | directoryManagerPwdFileArg.isPresent()) |
| | | { |
| | | errorMessages.add(ERR_TOOL_CONFLICTING_ARGS.get( |
| | | directoryManagerPwdStringArg.getLongIdentifier(), |
| | | directoryManagerPwdFileArg.getLongIdentifier())); |
| | | } |
| | | addErrorMessageIfArgumentsConflict(errorMessages, directoryManagerPwdStringArg, directoryManagerPwdFileArg); |
| | | |
| | | if (noPromptArg.isPresent() && !directoryManagerPwdStringArg.isPresent() && |
| | | !directoryManagerPwdFileArg.isPresent()) |
| | |
| | | private void checkImportDataArguments(Collection<LocalizableMessage> errorMessages) |
| | | { |
| | | // Make sure that the user didn't provide conflicting arguments. |
| | | if (addBaseEntryArg.isPresent()) |
| | | { |
| | | if (importLDIFArg.isPresent()) |
| | | { |
| | | errorMessages.add(conflictingArgs(addBaseEntryArg, importLDIFArg)); |
| | | } |
| | | else if (sampleDataArg.isPresent()) |
| | | { |
| | | errorMessages.add(conflictingArgs(addBaseEntryArg, sampleDataArg)); |
| | | } |
| | | } |
| | | else if (importLDIFArg.isPresent() && sampleDataArg.isPresent()) |
| | | { |
| | | errorMessages.add(conflictingArgs(importLDIFArg, sampleDataArg)); |
| | | } |
| | | |
| | | if (rejectedImportFileArg.isPresent() && addBaseEntryArg.isPresent()) |
| | | { |
| | | errorMessages.add(conflictingArgs(addBaseEntryArg, rejectedImportFileArg)); |
| | | } |
| | | else if (rejectedImportFileArg.isPresent() && sampleDataArg.isPresent()) |
| | | { |
| | | errorMessages.add(conflictingArgs(rejectedImportFileArg, sampleDataArg)); |
| | | } |
| | | |
| | | if (skippedImportFileArg.isPresent() && addBaseEntryArg.isPresent()) |
| | | { |
| | | errorMessages.add(conflictingArgs(addBaseEntryArg, skippedImportFileArg)); |
| | | } |
| | | else if (skippedImportFileArg.isPresent() && sampleDataArg.isPresent()) |
| | | { |
| | | errorMessages.add(conflictingArgs(skippedImportFileArg, sampleDataArg)); |
| | | } |
| | | addErrorMessageIfArgumentsConflict(errorMessages, addBaseEntryArg, importLDIFArg); |
| | | addErrorMessageIfArgumentsConflict(errorMessages, addBaseEntryArg, sampleDataArg); |
| | | addErrorMessageIfArgumentsConflict(errorMessages, importLDIFArg, sampleDataArg); |
| | | addErrorMessageIfArgumentsConflict(errorMessages, addBaseEntryArg, rejectedImportFileArg); |
| | | addErrorMessageIfArgumentsConflict(errorMessages, rejectedImportFileArg, sampleDataArg); |
| | | addErrorMessageIfArgumentsConflict(errorMessages, addBaseEntryArg, skippedImportFileArg); |
| | | addErrorMessageIfArgumentsConflict(errorMessages, skippedImportFileArg, sampleDataArg); |
| | | |
| | | final boolean noBaseDNProvided = !baseDNArg.isPresent() && baseDNArg.getDefaultValue() == null; |
| | | if (noPromptArg.isPresent() && noBaseDNProvided) |
| | |
| | | } |
| | | } |
| | | |
| | | private LocalizableMessage conflictingArgs(Argument arg1, Argument arg2) |
| | | { |
| | | return ERR_TOOL_CONFLICTING_ARGS.get(arg1.getLongIdentifier(), arg2.getLongIdentifier()); |
| | | } |
| | | |
| | | /** |
| | | * Checks that there are no conflicts with the security arguments. |
| | | * If we are in no prompt mode, check that all the information required has |
| | |
| | | { |
| | | if (!generateSelfSignedCertificateArg.isPresent()) |
| | | { |
| | | // Check that we have only a password. |
| | | if (keyStorePasswordArg.isPresent() && |
| | | keyStorePasswordFileArg.isPresent()) |
| | | { |
| | | errorMessages.add(ERR_TOOL_CONFLICTING_ARGS.get( |
| | | keyStorePasswordArg.getLongIdentifier(), |
| | | keyStorePasswordFileArg.getLongIdentifier())); |
| | | } |
| | | addErrorMessageIfArgumentsConflict(errorMessages, keyStorePasswordArg, keyStorePasswordFileArg); |
| | | |
| | | // Check that we have one password in no prompt mode. |
| | | if (noPromptArg.isPresent() && !keyStorePasswordArg.isPresent() && |
| | |
| | | import static com.forgerock.opendj.cli.CliMessages.INFO_DESCRIPTION_BINDPASSWORDFILE; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | |
| | | |
| | | if(bindPassword.isPresent() && bindPasswordFile.isPresent()) |
| | | { |
| | | printWrappedText( |
| | | err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier())); |
| | | printWrappedText(err, conflictingArgsErrorMessage(bindPassword, bindPasswordFile)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.CliMessages.INFO_DESCRIPTION_BINDPASSWORDFILE; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | |
| | |
| | | |
| | | if(bindPassword.isPresent() && bindPasswordFile.isPresent()) |
| | | { |
| | | printWrappedText( |
| | | err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier())); |
| | | printWrappedText(err, conflictingArgsErrorMessage(bindPassword, bindPasswordFile)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | import static com.forgerock.opendj.cli.CliMessages.INFO_DESCRIPTION_BINDPASSWORDFILE; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | |
| | | |
| | | if(bindPassword.isPresent() && bindPasswordFile.isPresent()) |
| | | { |
| | | printWrappedText( |
| | | err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier())); |
| | | printWrappedText(err, conflictingArgsErrorMessage(bindPassword, bindPasswordFile)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | |
| | | import java.io.OutputStream; |
| | |
| | | |
| | | |
| | | // Make sure that the user didn't specify any conflicting arguments. |
| | | if (bindPW.isPresent() && bindPWFile.isPresent()) |
| | | try |
| | | { |
| | | printWrappedText( |
| | | err, ERR_TOOL_CONFLICTING_ARGS.get(bindPW.getLongIdentifier(), bindPWFile.getLongIdentifier())); |
| | | throwIfArgumentsConflict(bindPW, bindPWFile); |
| | | throwIfArgumentsConflict(newPW, newPWFile); |
| | | throwIfArgumentsConflict(currentPW, currentPWFile); |
| | | throwIfArgumentsConflict(useSSL, useStartTLS); |
| | | throwIfArgumentsConflict(sslKeyStorePIN, sslKeyStorePINFile); |
| | | throwIfArgumentsConflict(sslTrustStorePIN, sslTrustStorePINFile); |
| | | } |
| | | catch(final ArgumentException conflict) |
| | | { |
| | | printWrappedText(err, conflict.getMessageObject()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (newPW.isPresent() && newPWFile.isPresent()) |
| | | { |
| | | printWrappedText( |
| | | err, ERR_TOOL_CONFLICTING_ARGS.get(newPW.getLongIdentifier(), newPWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (currentPW.isPresent() && currentPWFile.isPresent()) |
| | | { |
| | | printWrappedText(err, |
| | | ERR_TOOL_CONFLICTING_ARGS.get(currentPW.getLongIdentifier(), currentPWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (useSSL.isPresent() && useStartTLS.isPresent()) |
| | | { |
| | | printWrappedText( |
| | | err, ERR_TOOL_CONFLICTING_ARGS.get(useSSL.getLongIdentifier(), useStartTLS.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (sslKeyStorePIN.isPresent() && sslKeyStorePINFile.isPresent()) |
| | | { |
| | | printWrappedText(err, |
| | | ERR_TOOL_CONFLICTING_ARGS.get(sslKeyStorePIN.getLongIdentifier(), sslKeyStorePINFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (sslTrustStorePIN.isPresent() && sslTrustStorePINFile.isPresent()) |
| | | { |
| | | printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(sslTrustStorePIN.getLongIdentifier(), |
| | | sslTrustStorePINFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | | // If a bind DN was provided, make sure that a password was given. If a |
| | | // password was given, make sure a bind DN was provided. If neither were |
| | | // given, then make sure that an authorization ID and the current password |
| | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPConstants.*; |
| | |
| | | attributes.addAll(filterAndAttributeStrings); |
| | | } |
| | | |
| | | if(bindPassword.isPresent() && bindPasswordFile.isPresent()) |
| | | try |
| | | { |
| | | printWrappedText(err, |
| | | ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | throwIfArgumentsConflict(bindPassword, bindPasswordFile); |
| | | throwIfArgumentsConflict(useSSL, startTLS); |
| | | throwIfArgumentsConflict(keyStorePassword, keyStorePasswordFile); |
| | | throwIfArgumentsConflict(trustStorePassword, trustStorePasswordFile); |
| | | } |
| | | |
| | | if (useSSL.isPresent() && startTLS.isPresent()) |
| | | catch (final ArgumentException conflict) |
| | | { |
| | | printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(useSSL.getLongIdentifier(), startTLS.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (keyStorePassword.isPresent() && keyStorePasswordFile.isPresent()) |
| | | { |
| | | printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get( |
| | | keyStorePassword.getLongIdentifier(), keyStorePasswordFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (trustStorePassword.isPresent() && trustStorePasswordFile.isPresent()) |
| | | { |
| | | printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get( |
| | | trustStorePassword.getLongIdentifier(), trustStorePasswordFile.getLongIdentifier())); |
| | | printWrappedText(err, conflict.getMessageObject()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | |
| | | // arguments. |
| | | if (backendID.isPresent() && baseDN.isPresent()) |
| | | { |
| | | printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(backendID.getLongIdentifier(), baseDN.getLongIdentifier())); |
| | | printWrappedText(err, conflictingArgsErrorMessage(backendID, baseDN)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.CliMessages.INFO_BINDPWD_FILE_PLACEHOLDER; |
| | | import static com.forgerock.opendj.cli.CliMessages.INFO_PORT_PLACEHOLDER; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CommonArguments.*; |
| | | |
| | |
| | | { |
| | | int returnValue; |
| | | super.validateGlobalOptions(buf); |
| | | ArrayList<LocalizableMessage> errors = new ArrayList<>(); |
| | | if (secureArgsList.getBindPasswordArg().isPresent() && |
| | | secureArgsList.getBindPasswordFileArg().isPresent()) { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | secureArgsList.getBindPasswordArg().getLongIdentifier(), |
| | | secureArgsList.getBindPasswordFileArg().getLongIdentifier()); |
| | | errors.add(message); |
| | | } |
| | | final List<LocalizableMessage> errors = new ArrayList<>(); |
| | | addErrorMessageIfArgumentsConflict( |
| | | errors, secureArgsList.getBindPasswordArg(), secureArgsList.getBindPasswordFileArg()); |
| | | |
| | | // Check that we can write on the provided path where we write the |
| | | // equivalent non-interactive commands. |
| | |
| | | } |
| | | } |
| | | |
| | | if (noPromptArg.isPresent() && advancedArg.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | noPromptArg.getLongIdentifier(), |
| | | advancedArg.getLongIdentifier()); |
| | | errors.add(message); |
| | | } |
| | | addErrorMessageIfArgumentsConflict(errors, noPromptArg, advancedArg); |
| | | |
| | | if (!isInteractive()) |
| | | { |
| | |
| | | */ |
| | | private void validateEnableReplicationOptions(LocalizableMessageBuilder buf) |
| | | { |
| | | Argument[][] conflictingPairs = |
| | | { |
| | | { server1.bindPasswordArg, server1.bindPasswordFileArg }, |
| | | { server2.bindPasswordArg, server2.bindPasswordFileArg }, |
| | | { server1.replicationPortArg, server1.noReplicationServerArg }, |
| | | { server1.noReplicationServerArg, server1.onlyReplicationServerArg }, |
| | | { server2.replicationPortArg, server2.noReplicationServerArg }, |
| | | { server2.noReplicationServerArg, server2.onlyReplicationServerArg }, |
| | | {noSchemaReplicationArg, useSecondServerAsSchemaSourceArg} |
| | | }; |
| | | |
| | | for (Argument[] conflictingPair : conflictingPairs) |
| | | { |
| | | Argument arg1 = conflictingPair[0]; |
| | | Argument arg2 = conflictingPair[1]; |
| | | if (arg1.isPresent() && arg2.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | arg1.getLongIdentifier(), arg2.getLongIdentifier()); |
| | | addMessage(buf, message); |
| | | } |
| | | } |
| | | appendErrorMessageIfArgumentsConflict(buf, server1.bindPasswordArg, server1.bindPasswordFileArg ); |
| | | appendErrorMessageIfArgumentsConflict(buf, server2.bindPasswordArg, server2.bindPasswordFileArg ); |
| | | appendErrorMessageIfArgumentsConflict(buf, server1.replicationPortArg, server1.noReplicationServerArg ); |
| | | appendErrorMessageIfArgumentsConflict(buf, server1.noReplicationServerArg, server1.onlyReplicationServerArg ); |
| | | appendErrorMessageIfArgumentsConflict(buf, server2.replicationPortArg, server2.noReplicationServerArg ); |
| | | appendErrorMessageIfArgumentsConflict(buf, server2.noReplicationServerArg, server2.onlyReplicationServerArg ); |
| | | appendErrorMessageIfArgumentsConflict(buf,noSchemaReplicationArg, useSecondServerAsSchemaSourceArg); |
| | | |
| | | if (server1.hostNameArg.getValue().equalsIgnoreCase(server2.hostNameArg.getValue()) |
| | | && !isInteractive() |
| | |
| | | */ |
| | | private void validateDisableReplicationOptions(LocalizableMessageBuilder buf) |
| | | { |
| | | Argument[][] conflictingPairs = |
| | | { |
| | | {getAdminUidArg(), secureArgsList.getBindDnArg() }, |
| | | {disableAllArg, disableReplicationServerArg}, |
| | | {disableAllArg, baseDNsArg} |
| | | }; |
| | | |
| | | for (Argument[] conflictingPair : conflictingPairs) |
| | | { |
| | | Argument arg1 = conflictingPair[0]; |
| | | Argument arg2 = conflictingPair[1]; |
| | | if (arg1.isPresent() && arg2.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | arg1.getLongIdentifier(), arg2.getLongIdentifier()); |
| | | addMessage(buf, message); |
| | | } |
| | | } |
| | | appendErrorMessageIfArgumentsConflict(buf, getAdminUidArg(), secureArgsList.getBindDnArg()); |
| | | appendErrorMessageIfArgumentsConflict(buf, disableAllArg, disableReplicationServerArg); |
| | | appendErrorMessageIfArgumentsConflict(buf, disableAllArg, baseDNsArg); |
| | | } |
| | | |
| | | /** |
| | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS; |
| | | |
| | | import java.io.PrintStream; |
| | | import java.util.LinkedList; |
| | |
| | | private LDAPConnection connect(SecureConnectionCliArgs args, PrintStream out, PrintStream err) |
| | | throws LDAPConnectionException, ArgumentException |
| | | { |
| | | // Checks for conflicting arguments |
| | | throwIfArgumentsConflict(err, args.getBindPasswordArg(), args.getBindPasswordArg()); |
| | | throwIfArgumentsConflict(err, args.getKeyStorePasswordArg(), args.getKeyStorePasswordFileArg()); |
| | | throwIfArgumentsConflict(err, args.getTrustStorePasswordArg(), args.getTrustStorePasswordFileArg()); |
| | | throwIfArgumentsConflict(err, args.getUseSSLArg(), args.getUseStartTLSArg()); |
| | | throwIfArgumentsConflict(args.getBindPasswordArg(), args.getBindPasswordArg()); |
| | | throwIfArgumentsConflict(args.getKeyStorePasswordArg(), args.getKeyStorePasswordFileArg()); |
| | | throwIfArgumentsConflict(args.getTrustStorePasswordArg(), args.getTrustStorePasswordFileArg()); |
| | | throwIfArgumentsConflict(args.getUseSSLArg(), args.getUseStartTLSArg()); |
| | | |
| | | // Create the LDAP connection options object, which will be used to |
| | | // customize the way that we connect to the server and specify a set of |
| | |
| | | ae.printStackTrace(); // Should never happen |
| | | } |
| | | } |
| | | |
| | | private void throwIfArgumentsConflict(final PrintStream err, final Argument arg1, final Argument arg2) |
| | | throws ArgumentException |
| | | { |
| | | if (arg1.isPresent() && arg2.isPresent()) |
| | | { |
| | | printAndThrowException(err, ERR_TOOL_CONFLICTING_ARGS.get(arg1.getLongIdentifier(), arg2.getLongIdentifier())); |
| | | } |
| | | } |
| | | } |