| | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.io.PrintStream; |
| | | import java.net.InetAddress; |
| | | import java.net.UnknownHostException; |
| | | import java.security.GeneralSecurityException; |
| | |
| | | } |
| | | return host; |
| | | } |
| | | |
| | | /** |
| | | * Prints the provided string on the provided stream. |
| | | * |
| | | * @param stream |
| | | * The stream to print the message. |
| | | * @param message |
| | | * The message to print. |
| | | */ |
| | | public static void printWrappedText(final PrintStream stream, final String message) { |
| | | if (stream != null && message != null) { |
| | | stream.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Print the provided message on the provided stream. |
| | | * |
| | | * @param stream |
| | | * The stream to print the message. |
| | | * @param message |
| | | * The message to print. |
| | | */ |
| | | public static void printWrappedText(final PrintStream stream, final LocalizableMessage message) { |
| | | printWrappedText(stream, message != null ? message.toString() : null); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessageBuilder buf = new LocalizableMessageBuilder(); |
| | | int returnValue = validateGlobalOptions(buf); |
| | | if (buf.length() > 0) |
| | | { |
| | | err.println(wrapText(buf.toString(), MAX_LINE_WIDTH)); |
| | | } |
| | | printWrappedText(err, buf.toString()); |
| | | return returnValue; |
| | | } |
| | | |
| | |
| | | */ |
| | | package org.opends.server.backends.jeb; |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.text.ParseException; |
| | |
| | | this.parser.setVersionHandler(new DirectoryServerVersionHandler()); |
| | | } |
| | | |
| | | /** Displays the provided message followed by a help usage reference. */ |
| | | private void displayMessageAndUsageReference(LocalizableMessage message) { |
| | | printErrorMessage(message); |
| | | printErrorMessage(LocalizableMessage.EMPTY); |
| | | printErrorMessage(parser.getHelpUsageReference()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Registers the global arguments with the argument parser. |
| | | * |
| | |
| | | initializeGlobalArguments(); |
| | | initializeSubCommands(); |
| | | } catch (ArgumentException e) { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(e.getMessage()); |
| | | printErrorMessage(message); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | try { |
| | | parser.parseArguments(args); |
| | | } catch (ArgumentException ae) { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | displayMessageAndUsageReference(message); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(parser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | printErrorMessage(e.getMessageObject()); |
| | | printWrappedText(err, e.getMessageObject()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_SERVER_BOOTSTRAP_ERROR.get( |
| | | getExceptionMessage(e)); |
| | | printErrorMessage(message); |
| | | printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get( |
| | | ie.getMessage()); |
| | | printErrorMessage(message); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get( |
| | | getExceptionMessage(e)); |
| | | printErrorMessage(message); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()); |
| | | printErrorMessage(message); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)); |
| | | printErrorMessage(message); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage()); |
| | | printErrorMessage(message); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e)); |
| | | printErrorMessage(message); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage()); |
| | | printErrorMessage(message); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e)); |
| | | printErrorMessage(message); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | // Make sure that we have a sub-command. |
| | | if (parser.getSubCommand() == null) |
| | | { |
| | | LocalizableMessage message = ERR_DBTEST_MISSING_SUBCOMMAND.get(); |
| | | displayMessageAndUsageReference(message); |
| | | printWrappedText(err, ERR_DBTEST_MISSING_SUBCOMMAND.get()); |
| | | err.println(parser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | return 0; |
| | | } catch (Exception e) { |
| | | printErrorMessage(LocalizableMessage.raw(StaticUtils.stackTraceToString(e))); |
| | | printWrappedText(err, LocalizableMessage.raw(StaticUtils.stackTraceToString(e))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | StringBuilder failureReason = new StringBuilder(); |
| | | if (! LockFileManager.acquireSharedLock(lockFile, failureReason)) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason)); |
| | | printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason)); |
| | | return 1; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get( |
| | | backend.getBackendID(), |
| | | StaticUtils.stackTraceToSingleLineString(e))); |
| | | printWrappedText( |
| | | err, ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get(backend.getBackendID(), stackTraceToSingleLineString(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch(DatabaseException de) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_ERROR_READING_DATABASE.get( |
| | | StaticUtils.stackTraceToSingleLineString(de))); |
| | | printWrappedText(err, ERR_DBTEST_ERROR_READING_DATABASE.get(stackTraceToSingleLineString(de))); |
| | | return 1; |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch(DirectoryException de) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_DECODE_BASE_DN.get(baseDN.getValue(), |
| | | getExceptionMessage(de))); |
| | | printWrappedText(err, ERR_DBTEST_DECODE_BASE_DN.get(baseDN.getValue(), getExceptionMessage(de))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | StringBuilder failureReason = new StringBuilder(); |
| | | if (! LockFileManager.acquireSharedLock(lockFile, failureReason)) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason)); |
| | | printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason)); |
| | | return 1; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get( |
| | | backend.getBackendID(), |
| | | StaticUtils.stackTraceToSingleLineString(e))); |
| | | printWrappedText( |
| | | err, ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get(backend.getBackendID(), stackTraceToSingleLineString(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | EntryContainer ec = rc.getEntryContainer(base); |
| | | if(ec == null) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_NO_ENTRY_CONTAINERS_FOR_BASE_DN.get( |
| | | base, backend.getBackendID())); |
| | | printWrappedText(err, ERR_DBTEST_NO_ENTRY_CONTAINERS_FOR_BASE_DN.get(base, backend.getBackendID())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch(DatabaseException de) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_ERROR_READING_DATABASE.get( |
| | | StaticUtils.stackTraceToSingleLineString(de))); |
| | | printWrappedText(err, ERR_DBTEST_ERROR_READING_DATABASE.get(stackTraceToSingleLineString(de))); |
| | | return 1; |
| | | } |
| | | finally |
| | |
| | | StringBuilder failureReason = new StringBuilder(); |
| | | if (!LockFileManager.releaseLock(lockFile, failureReason)) |
| | | { |
| | | printErrorMessage(WARN_DBTEST_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), failureReason)); |
| | | printWrappedText(err, WARN_DBTEST_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), failureReason)); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | printErrorMessage(WARN_DBTEST_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e))); |
| | | printWrappedText(err, WARN_DBTEST_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e))); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | if (b.getBackendID().equalsIgnoreCase(backendID)) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_NOT_JE_BACKEND.get(backendID)); |
| | | printWrappedText(err, ERR_DBTEST_NOT_JE_BACKEND.get(backendID)); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | printErrorMessage(ERR_DBTEST_NO_BACKENDS_FOR_ID.get(backendID)); |
| | | printWrappedText(err, ERR_DBTEST_NO_BACKENDS_FOR_ID.get(backendID)); |
| | | return null; |
| | | } |
| | | |
| | |
| | | } |
| | | catch(DirectoryException de) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_DECODE_BASE_DN.get(baseDN.getValue(), |
| | | getExceptionMessage(de))); |
| | | printWrappedText(err, ERR_DBTEST_DECODE_BASE_DN.get(baseDN.getValue(), getExceptionMessage(de))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | StringBuilder failureReason = new StringBuilder(); |
| | | if (! LockFileManager.acquireSharedLock(lockFile, failureReason)) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason)); |
| | | printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason)); |
| | | return 1; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get( |
| | | backend.getBackendID(), |
| | | StaticUtils.stackTraceToSingleLineString(e))); |
| | | printWrappedText( |
| | | err, ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get(backend.getBackendID(), stackTraceToSingleLineString(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | EntryContainer ec = rc.getEntryContainer(base); |
| | | if(ec == null) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_NO_ENTRY_CONTAINERS_FOR_BASE_DN.get(base, backend.getBackendID())); |
| | | printWrappedText(err, ERR_DBTEST_NO_ENTRY_CONTAINERS_FOR_BASE_DN.get(base, backend.getBackendID())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch(DatabaseException de) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_ERROR_READING_DATABASE.get( |
| | | StaticUtils.stackTraceToSingleLineString(de))); |
| | | printWrappedText(err, ERR_DBTEST_ERROR_READING_DATABASE.get(stackTraceToSingleLineString(de))); |
| | | return 1; |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch(DirectoryException de) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_DECODE_BASE_DN.get(baseDN.getValue(), |
| | | getExceptionMessage(de))); |
| | | printWrappedText(err, ERR_DBTEST_DECODE_BASE_DN.get(baseDN.getValue(), getExceptionMessage(de))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | StringBuilder failureReason = new StringBuilder(); |
| | | if (! LockFileManager.acquireSharedLock(lockFile, failureReason)) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason)); |
| | | printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason)); |
| | | return 1; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get( |
| | | backend.getBackendID(), |
| | | StaticUtils.stackTraceToSingleLineString(e))); |
| | | printWrappedText( |
| | | err, ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get(backend.getBackendID(), stackTraceToSingleLineString(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | EntryContainer ec = rc.getEntryContainer(base); |
| | | if(ec == null) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_NO_ENTRY_CONTAINERS_FOR_BASE_DN.get(base, backend.getBackendID())); |
| | | printWrappedText(err, ERR_DBTEST_NO_ENTRY_CONTAINERS_FOR_BASE_DN.get(base, backend.getBackendID())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | |
| | | if(databaseContainer == null) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_NO_DATABASE_CONTAINERS_FOR_NAME.get( |
| | | databaseName.getValue(), base, backend.getBackendID())); |
| | | printWrappedText( |
| | | err, ERR_DBTEST_NO_DATABASE_CONTAINERS_FOR_NAME.get(databaseName.getValue(), base, backend.getBackendID())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_CANNOT_DECODE_SIZE.get( |
| | | maxDataSize.getValue(), getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_DBTEST_CANNOT_DECODE_SIZE.get(maxDataSize.getValue(), getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_CANNOT_DECODE_SIZE.get( |
| | | minDataSize.getValue(), getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_DBTEST_CANNOT_DECODE_SIZE.get(minDataSize.getValue(), getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_CANNOT_DECODE_KEY.get( |
| | | minKeyValue.getValue(), getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_DBTEST_CANNOT_DECODE_KEY.get(minKeyValue.getValue(), getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_CANNOT_DECODE_KEY.get( |
| | | maxKeyValue.getValue(), getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_DBTEST_CANNOT_DECODE_KEY.get(maxKeyValue.getValue(), getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e))); |
| | | } |
| | | formatedData = String.valueOf( |
| | | JebFormat.entryIDFromDatabase(data.getData())); |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e))); |
| | | } |
| | | } |
| | | else if(databaseContainer instanceof DN2URI) |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e))); |
| | | } |
| | | formatedData = new String(key.getData()); |
| | | dataLabel = INFO_LABEL_DBTEST_URI.get(); |
| | |
| | | } |
| | | catch(Exception e) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e))); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | catch(DatabaseException de) |
| | | { |
| | | printErrorMessage(ERR_DBTEST_ERROR_READING_DATABASE.get( |
| | | StaticUtils.stackTraceToSingleLineString(de))); |
| | | printWrappedText(err, ERR_DBTEST_ERROR_READING_DATABASE.get(stackTraceToSingleLineString(de))); |
| | | return 1; |
| | | } |
| | | finally |
| | |
| | | } |
| | | return jeBackends; |
| | | } |
| | | |
| | | private final void printErrorMessage(LocalizableMessage msg) { |
| | | err.println(wrapText(msg.toString(), MAX_LINE_WIDTH)); |
| | | } |
| | | } |
| | |
| | | import java.util.List; |
| | | import java.util.TimeZone; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.util.Utils; |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | catch (ClientException ce) |
| | | { |
| | | // No need to display the usage since the problem comes with a provided |
| | | // value. |
| | | err.println(wrapText(ce.getMessageObject(), MAX_LINE_WIDTH)); |
| | | // No need to display the usage since the problem comes with a provided value. |
| | | printWrappedText(err, ce.getMessageObject()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | if (backendID.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID.get( |
| | | backUpAll.getLongIdentifier(), |
| | | backendID.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID.get( |
| | | backUpAll.getLongIdentifier(), backendID.getLongIdentifier())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | } |
| | | else if (! backendID.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_BACKUPDB_NEED_BACKUP_ALL_OR_BACKEND_ID.get( |
| | | backUpAll.getLongIdentifier(), |
| | | backendID.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_BACKUPDB_NEED_BACKUP_ALL_OR_BACKEND_ID.get( |
| | | backUpAll.getLongIdentifier(), backendID.getLongIdentifier())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | |
| | | } |
| | | if (!repeatedBackendIds.isEmpty()) |
| | | { |
| | | String repeatedBackends = Utils.joinAsString(", ", repeatedBackendIds); |
| | | LocalizableMessage message = ERR_BACKUPDB_REPEATED_BACKEND_ID.get(repeatedBackends); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_BACKUPDB_REPEATED_BACKEND_ID.get(Utils.joinAsString(", ", repeatedBackendIds))); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | |
| | | // incremental backup. |
| | | if (incrementalBaseID.isPresent() && ! incremental.isPresent()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_BACKUPDB_INCREMENTAL_BASE_REQUIRES_INCREMENTAL.get( |
| | | incrementalBaseID.getLongIdentifier(), |
| | | incremental.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_BACKUPDB_INCREMENTAL_BASE_REQUIRES_INCREMENTAL.get( |
| | | incrementalBaseID.getLongIdentifier(), incremental.getLongIdentifier())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | |
| | | // are present, infer an offline backup. |
| | | if ((encrypt.isPresent() || signHash.isPresent()) |
| | | && ! argParser.connectionArgumentsPresent()) { |
| | | LocalizableMessage message = |
| | | ERR_BACKUPDB_ENCRYPT_OR_SIGN_REQUIRES_ONLINE.get( |
| | | encrypt.getLongIdentifier(), |
| | | signHash.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_BACKUPDB_ENCRYPT_OR_SIGN_REQUIRES_ONLINE.get( |
| | | encrypt.getLongIdentifier(), signHash.getLongIdentifier())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | |
| | | // was given. |
| | | if (signHash.isPresent() && !hash.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_BACKUPDB_SIGN_REQUIRES_HASH.get( |
| | | signHash.getLongIdentifier(), |
| | | hash.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText( |
| | | err, ERR_BACKUPDB_SIGN_REQUIRES_HASH.get(signHash.getLongIdentifier(), hash.getLongIdentifier())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_BACKUPDB_CANNOT_CREATE_BACKUP_DIR.get( |
| | | backupDirectory.getValue(), |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText( |
| | | err, ERR_BACKUPDB_CANNOT_CREATE_BACKUP_DIR.get(backupDirectory.getValue(), getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_SERVER_BOOTSTRAP_ERROR.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | err.println(argParser.getUsage()); |
| | | } |
| | | err.println(e.getErrorMessage()); |
| | | printWrappedText(err, e.getErrorMessage()); |
| | | return e.getErrorCode(); |
| | | } |
| | | finally |
| | |
| | | try |
| | | { |
| | | configHandler.writeUpdatedConfig(); |
| | | out.println(wrapText(INFO_CONFIGDS_WROTE_UPDATED_CONFIG.get(), MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_CONFIGDS_WROTE_UPDATED_CONFIG.get()); |
| | | } |
| | | catch (final DirectoryException de) |
| | | { |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return ERROR; |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = nArgs == 0 ? ERR_CONFIGURE_WINDOWS_SERVICE_TOO_FEW_ARGS.get() |
| | | : ERR_CONFIGURE_WINDOWS_SERVICE_TOO_MANY_ARGS.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, message); |
| | | err.println(argParser.getUsage()); |
| | | return ERROR; |
| | | } |
| | |
| | | */ |
| | | public static int enableService(PrintStream out, PrintStream err, String serviceName, String serviceDescription) |
| | | { |
| | | LocalizableMessage msg; |
| | | String serverRoot = getServerRoot(); |
| | | |
| | | String[] cmd; |
| | | |
| | | if (hasUAC()) |
| | |
| | | final int returnValue = StartWindowsService.startWindowsService(out, err); |
| | | if (returnValue == 0) |
| | | { |
| | | msg = INFO_WINDOWS_SERVICE_SUCCESSULLY_ENABLED.get(); |
| | | out.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_WINDOWS_SERVICE_SUCCESSULLY_ENABLED.get()); |
| | | return SERVICE_ENABLE_SUCCESS; |
| | | } |
| | | else |
| | | { |
| | | msg = ERR_WINDOWS_SERVICE_ENABLING_ERROR_STARTING_SERVER.get(returnValue); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_ENABLING_ERROR_STARTING_SERVER.get(SERVICE_ENABLE_ERROR)); |
| | | return SERVICE_ENABLE_ERROR; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | msg = INFO_WINDOWS_SERVICE_SUCCESSULLY_ENABLED.get(); |
| | | out.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_WINDOWS_SERVICE_SUCCESSULLY_ENABLED.get()); |
| | | return SERVICE_ENABLE_SUCCESS; |
| | | } |
| | | case 1: |
| | | msg = INFO_WINDOWS_SERVICE_ALREADY_ENABLED.get(); |
| | | out.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_WINDOWS_SERVICE_ALREADY_ENABLED.get()); |
| | | return SERVICE_ALREADY_ENABLED; |
| | | case 2: |
| | | msg = ERR_WINDOWS_SERVICE_NAME_ALREADY_IN_USE.get(); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_NAME_ALREADY_IN_USE.get()); |
| | | return SERVICE_NAME_ALREADY_IN_USE; |
| | | case 3: |
| | | msg = ERR_WINDOWS_SERVICE_ENABLE_ERROR.get(); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_ENABLE_ERROR.get()); |
| | | return SERVICE_ENABLE_ERROR; |
| | | default: |
| | | msg = ERR_WINDOWS_SERVICE_ENABLE_ERROR.get(); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_ENABLE_ERROR.get()); |
| | | return SERVICE_ENABLE_ERROR; |
| | | } |
| | | } |
| | |
| | | { |
| | | err.println("Unexpected throwable: "+t); |
| | | t.printStackTrace(); |
| | | msg = ERR_WINDOWS_SERVICE_ENABLE_ERROR.get(); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_ENABLE_ERROR.get()); |
| | | return SERVICE_ENABLE_ERROR; |
| | | } |
| | | } |
| | |
| | | */ |
| | | public static int disableService(PrintStream out, PrintStream err) |
| | | { |
| | | LocalizableMessage msg; |
| | | String serverRoot = getServerRoot(); |
| | | String[] cmd; |
| | | if (hasUAC()) |
| | |
| | | switch (resultCode) |
| | | { |
| | | case 0: |
| | | msg = INFO_WINDOWS_SERVICE_SUCCESSULLY_DISABLED.get(); |
| | | out.println(msg); |
| | | printWrappedText(out, INFO_WINDOWS_SERVICE_SUCCESSULLY_DISABLED.get()); |
| | | return SERVICE_DISABLE_SUCCESS; |
| | | case 1: |
| | | msg = INFO_WINDOWS_SERVICE_ALREADY_DISABLED.get(); |
| | | out.println(msg); |
| | | printWrappedText(out, INFO_WINDOWS_SERVICE_ALREADY_DISABLED.get()); |
| | | return SERVICE_ALREADY_DISABLED; |
| | | case 2: |
| | | msg = WARN_WINDOWS_SERVICE_MARKED_FOR_DELETION.get(); |
| | | out.println(msg); |
| | | printWrappedText(out, WARN_WINDOWS_SERVICE_MARKED_FOR_DELETION.get()); |
| | | return SERVICE_MARKED_FOR_DELETION; |
| | | case 3: |
| | | msg = ERR_WINDOWS_SERVICE_DISABLE_ERROR.get(); |
| | | err.println(msg); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_DISABLE_ERROR.get()); |
| | | return SERVICE_DISABLE_ERROR; |
| | | default: |
| | | msg = ERR_WINDOWS_SERVICE_DISABLE_ERROR.get(); |
| | | err.println(msg); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_DISABLE_ERROR.get()); |
| | | return SERVICE_DISABLE_ERROR; |
| | | } |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | t.printStackTrace(); |
| | | msg = ERR_WINDOWS_SERVICE_DISABLE_ERROR.get(); |
| | | err.println(msg); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_DISABLE_ERROR.get()); |
| | | return SERVICE_DISABLE_ERROR; |
| | | } |
| | | } |
| | |
| | | public static int cleanupService(String serviceName, PrintStream out, |
| | | PrintStream err) |
| | | { |
| | | LocalizableMessage msg; |
| | | String[] cmd; |
| | | if (hasUAC()) |
| | | { |
| | |
| | | switch (resultCode) |
| | | { |
| | | case 0: |
| | | msg = INFO_WINDOWS_SERVICE_CLEANUP_SUCCESS.get(serviceName); |
| | | out.println(msg); |
| | | printWrappedText(out, INFO_WINDOWS_SERVICE_CLEANUP_SUCCESS.get(serviceName)); |
| | | return SERVICE_CLEANUP_SUCCESS; |
| | | case 1: |
| | | msg = ERR_WINDOWS_SERVICE_CLEANUP_NOT_FOUND.get(serviceName); |
| | | err.println(msg); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_CLEANUP_NOT_FOUND.get(serviceName)); |
| | | return SERVICE_NOT_FOUND; |
| | | case 2: |
| | | msg = WARN_WINDOWS_SERVICE_CLEANUP_MARKED_FOR_DELETION.get(serviceName); |
| | | out.println(msg); |
| | | printWrappedText(out, WARN_WINDOWS_SERVICE_CLEANUP_MARKED_FOR_DELETION.get(serviceName)); |
| | | return SERVICE_CLEANUP_MARKED_FOR_DELETION; |
| | | case 3: |
| | | msg = ERR_WINDOWS_SERVICE_CLEANUP_ERROR.get(serviceName); |
| | | err.println(msg); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_CLEANUP_ERROR.get(serviceName)); |
| | | return SERVICE_CLEANUP_ERROR; |
| | | default: |
| | | msg = ERR_WINDOWS_SERVICE_CLEANUP_ERROR.get(serviceName); |
| | | err.println(msg); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_CLEANUP_ERROR.get(serviceName)); |
| | | return SERVICE_CLEANUP_ERROR; |
| | | } |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | msg = ERR_WINDOWS_SERVICE_CLEANUP_ERROR.get(serviceName); |
| | | err.println(msg); |
| | | err.println("Exception:" + t); |
| | | err.println(ERR_WINDOWS_SERVICE_CLEANUP_ERROR.get(serviceName)); |
| | | printWrappedText(err, "Exception:" + t); |
| | | return SERVICE_CLEANUP_ERROR; |
| | | } |
| | | } |
| | |
| | | */ |
| | | public static int serviceState(PrintStream out, PrintStream err) |
| | | { |
| | | LocalizableMessage msg; |
| | | String serviceName = null; |
| | | |
| | | String serverRoot = getServerRoot(); |
| | |
| | | switch (resultCode) |
| | | { |
| | | case 0: |
| | | msg = INFO_WINDOWS_SERVICE_ENABLED.get(serviceName); |
| | | out.println(msg); |
| | | printWrappedText(out, INFO_WINDOWS_SERVICE_ENABLED.get(serviceName)); |
| | | return SERVICE_STATE_ENABLED; |
| | | case 1: |
| | | msg = INFO_WINDOWS_SERVICE_DISABLED.get(); |
| | | out.println(msg); |
| | | printWrappedText(out, INFO_WINDOWS_SERVICE_DISABLED.get()); |
| | | return SERVICE_STATE_DISABLED; |
| | | case 2: |
| | | msg = ERR_WINDOWS_SERVICE_STATE_ERROR.get(); |
| | | err.println(msg); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_STATE_ERROR.get()); |
| | | return SERVICE_STATE_ERROR; |
| | | default: |
| | | msg = ERR_WINDOWS_SERVICE_STATE_ERROR.get(); |
| | | err.println(msg); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_STATE_ERROR.get()); |
| | | return SERVICE_STATE_ERROR; |
| | | } |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | msg = ERR_WINDOWS_SERVICE_STATE_ERROR.get(); |
| | | err.println(msg); |
| | | err.println(wrapText(t.toString(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_STATE_ERROR.get()); |
| | | printWrappedText(err, t.toString()); |
| | | return SERVICE_STATE_ERROR; |
| | | } |
| | | } |
| | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | |
| | | |
| | | if (! OperatingSystem.isUnixBased()) |
| | | { |
| | | err.println(ERR_CREATERC_ONLY_RUNS_ON_UNIX.get()); |
| | | printWrappedText(err, ERR_CREATERC_ONLY_RUNS_ON_UNIX.get()); |
| | | return 1; |
| | | } |
| | | |
| | | File serverRoot = DirectoryServer.getEnvironmentConfig().getServerRoot(); |
| | | if (serverRoot == null) |
| | | { |
| | | err.println(ERR_CREATERC_UNABLE_TO_DETERMINE_SERVER_ROOT.get( |
| | | PROPERTY_SERVER_ROOT, ENV_VAR_INSTALL_ROOT)); |
| | | printWrappedText( |
| | | err, ERR_CREATERC_UNABLE_TO_DETERMINE_SERVER_ROOT.get(PROPERTY_SERVER_ROOT, ENV_VAR_INSTALL_ROOT)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | err.println(ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | err.println(ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | File f = new File(javaHome.getValue()); |
| | | if (!f.exists() || !f.isDirectory()) |
| | | { |
| | | err.println(ERR_CREATERC_JAVA_HOME_DOESNT_EXIST.get(javaHome.getValue())); |
| | | printWrappedText(err, ERR_CREATERC_JAVA_HOME_DOESNT_EXIST.get(javaHome.getValue())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_CREATERC_CANNOT_WRITE.get(getExceptionMessage(e))); |
| | | printWrappedText(err, ERR_CREATERC_CANNOT_WRITE.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | | // Check for conflicting arguments. |
| | | if (clearPassword.isPresent() && clearPasswordFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(), |
| | | clearPasswordFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, |
| | | ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(), clearPasswordFile.getLongIdentifier())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | | if (clearPassword.isPresent() && interactivePassword.isPresent()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(), |
| | | interactivePassword.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, |
| | | ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(), interactivePassword.getLongIdentifier())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | | if (clearPasswordFile.isPresent() && interactivePassword.isPresent()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_TOOL_CONFLICTING_ARGS.get( |
| | | clearPasswordFile.getLongIdentifier(), |
| | | interactivePassword.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(clearPasswordFile.getLongIdentifier(), |
| | | interactivePassword.getLongIdentifier())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | | if (encodedPassword.isPresent() && encodedPasswordFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_TOOL_CONFLICTING_ARGS.get(encodedPassword.getLongIdentifier(), |
| | | encodedPasswordFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, |
| | | ERR_TOOL_CONFLICTING_ARGS.get(encodedPassword.getLongIdentifier(), encodedPasswordFile.getLongIdentifier())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | && !encodedPasswordFile.isPresent() |
| | | && !schemeName.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_NO_SCHEME.get(schemeName.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_NO_SCHEME.get(schemeName.getLongIdentifier())); |
| | | err.println(argParser.getUsage()); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e))); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e))); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e))); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e))); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_CANNOT_INITIALIZE_STORAGE_SCHEMES.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_CANNOT_INITIALIZE_STORAGE_SCHEMES.get(e.getMessage())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_CANNOT_INITIALIZE_STORAGE_SCHEMES.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_CANNOT_INITIALIZE_STORAGE_SCHEMES.get(getExceptionMessage(e))); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_INVALID_ENCODED_AUTHPW.get( |
| | | de.getMessageObject()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_INVALID_ENCODED_AUTHPW.get(de.getMessageObject())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(wrapText(ERR_ENCPW_INVALID_ENCODED_AUTHPW.get(e), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_INVALID_ENCODED_AUTHPW.get(e)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | DirectoryServer.getAuthPasswordStorageScheme(scheme); |
| | | if (storageScheme == null) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_NO_SUCH_AUTH_SCHEME.get( |
| | | scheme); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_NO_SUCH_AUTH_SCHEME.get(scheme)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | DirectoryServer.getPasswordStorageScheme(userPWElements[0]); |
| | | if (storageScheme == null) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_NO_SUCH_SCHEME.get(userPWElements[0]); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_NO_SUCH_SCHEME.get(userPWElements[0])); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_INVALID_ENCODED_USERPW.get( |
| | | de.getMessageObject()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_INVALID_ENCODED_USERPW.get(de.getMessageObject())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(wrapText(ERR_ENCPW_INVALID_ENCODED_USERPW.get(e), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_INVALID_ENCODED_USERPW.get(e)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | } |
| | |
| | | { |
| | | if (! schemeName.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_NO_SCHEME.get( |
| | | schemeName.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_NO_SCHEME.get(schemeName.getLongIdentifier())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | storageScheme = DirectoryServer.getPasswordStorageScheme(scheme); |
| | | if (storageScheme == null) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_NO_SUCH_SCHEME.get(scheme); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_NO_SUCH_SCHEME.get(scheme)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | } |
| | |
| | | storageScheme = DirectoryServer.getAuthPasswordStorageScheme(scheme); |
| | | if (storageScheme == null) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_NO_SUCH_AUTH_SCHEME.get(scheme); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_NO_SUCH_AUTH_SCHEME.get(scheme)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | } |
| | |
| | | storageScheme = DirectoryServer.getPasswordStorageScheme(scheme); |
| | | if (storageScheme == null) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_NO_SUCH_SCHEME.get(scheme); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_NO_SUCH_SCHEME.get(scheme)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_CANNOT_ENCODE.get(de.getMessageObject()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_CANNOT_ENCODE.get(de.getMessageObject())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_CANNOT_ENCODE.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_CANNOT_ENCODE.get(getExceptionMessage(e))); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_CANNOT_ENCODE.get(de.getMessageObject()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_CANNOT_ENCODE.get(de.getMessageObject())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_CANNOT_ENCODE.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_CANNOT_ENCODE.get(getExceptionMessage(e))); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | } |
| | |
| | | { |
| | | if (storageSchemes.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_NO_STORAGE_SCHEMES.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_NO_STORAGE_SCHEMES.get()); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage())); |
| | | return false; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e))); |
| | | return false; |
| | | } |
| | | //Attempt to bring up enough of the server to process schemes requiring |
| | |
| | | directoryServer.initializeAuthenticatedUsers(); |
| | | new CryptoManagerSync(); |
| | | } catch (InitializationException | ConfigException e) { |
| | | LocalizableMessage message = ERR_ENCPW_CANNOT_INITIALIZE_SERVER_COMPONENTS.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_CANNOT_INITIALIZE_SERVER_COMPONENTS.get(getExceptionMessage(e))); |
| | | return false; |
| | | } |
| | | return true; |
| | |
| | | backendClass = DirectoryServer.loadClass(className); |
| | | backend = (Backend<BackendCfg>) backendClass.newInstance(); |
| | | } catch (Exception e) { |
| | | LocalizableMessage msg = ERR_CONFIG_BACKEND_CANNOT_INSTANTIATE.get(className, backendCfg.dn(), |
| | | stackTraceToSingleLineString(e)); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, |
| | | ERR_CONFIG_BACKEND_CANNOT_INSTANTIATE.get(className, backendCfg.dn(), stackTraceToSingleLineString(e))); |
| | | continue; |
| | | } |
| | | backend.setBackendID(backendID); |
| | |
| | | backend.configureBackend(backendCfg, directoryServer.getServerContext()); |
| | | backend.openBackend(); |
| | | } catch (Exception e) { |
| | | LocalizableMessage msg = ERR_CONFIG_BACKEND_CANNOT_INITIALIZE.get(className, backendCfg.dn(), |
| | | stackTraceToSingleLineString(e)); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, |
| | | ERR_CONFIG_BACKEND_CANNOT_INITIALIZE.get(className, backendCfg.dn(), stackTraceToSingleLineString(e))); |
| | | } |
| | | try { |
| | | DirectoryServer.registerBackend(backend); |
| | | } catch (Exception e) |
| | | { |
| | | LocalizableMessage msg = WARN_CONFIG_BACKEND_CANNOT_REGISTER_BACKEND.get(backendCfg.getBackendId(), |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText( |
| | | err, WARN_CONFIG_BACKEND_CANNOT_REGISTER_BACKEND.get(backendCfg.getBackendId(), getExceptionMessage(e))); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_NOT_SAME_PW.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_NOT_SAME_PW.get()); |
| | | return null; |
| | | } |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_CANNOT_READ_PW.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_CANNOT_READ_PW.get(e.getMessage())); |
| | | return null; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_ENCPW_NO_CLEAR_PW.get(clearPassword |
| | | .getLongIdentifier(), clearPasswordFile.getLongIdentifier(), |
| | | interactivePassword.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ENCPW_NO_CLEAR_PW.get(clearPassword.getLongIdentifier(), |
| | | clearPasswordFile.getLongIdentifier(), interactivePassword.getLongIdentifier())); |
| | | err.println(argParser.getUsage()); |
| | | return null; |
| | | } |
| | |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.opends.server.admin.std.server.BackendCfg; |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | catch (ClientException ce) |
| | | { |
| | | // No need to display the usage since the problem comes with a provided |
| | | // value. |
| | | err.println(wrapText(ce.getMessageObject(), MAX_LINE_WIDTH)); |
| | | // No need to display the usage since the problem comes with a provided value. |
| | | printWrappedText(err, ce.getMessageObject()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | catch (ClientException ce) |
| | | { |
| | | // No need to display the usage since the problem comes with a provided |
| | | // value. |
| | | err.println(wrapText(ce.getMessageObject(), MAX_LINE_WIDTH)); |
| | | // No need to display the usage since the problem comes with a provided value. |
| | | printWrappedText(err, ce.getMessageObject()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | if (templateFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFIMPORT_CONFLICTING_OPTIONS.get( |
| | | ldifFiles.getLongIdentifier(), |
| | | templateFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, |
| | | ERR_LDIFIMPORT_CONFLICTING_OPTIONS.get(ldifFiles.getLongIdentifier(), templateFile.getLongIdentifier())); |
| | | return 1; |
| | | } |
| | | } |
| | | else if (! templateFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFIMPORT_MISSING_REQUIRED_ARGUMENT.get( |
| | | ldifFiles.getLongIdentifier(), |
| | | templateFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDIFIMPORT_MISSING_REQUIRED_ARGUMENT.get( |
| | | ldifFiles.getLongIdentifier(), templateFile.getLongIdentifier())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | // "backendID" argument was provided. |
| | | if(!includeBranchStrings.isPresent() && !backendID.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFIMPORT_MISSING_BACKEND_ARGUMENT.get( |
| | | includeBranchStrings.getLongIdentifier(), |
| | | backendID.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDIFIMPORT_MISSING_BACKEND_ARGUMENT.get( |
| | | includeBranchStrings.getLongIdentifier(), backendID.getLongIdentifier())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | | // Count rejects option requires the ability to return result codes |
| | | // which are potentially greater than 1. This is not supported by |
| | | // the task framework. |
| | | if (countRejects.isPresent() |
| | | && argParser.connectionArgumentsPresent()) |
| | | if (countRejects.isPresent() && argParser.connectionArgumentsPresent()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDIFIMPORT_COUNT_REJECTS_REQUIRES_OFFLINE |
| | | .get(countRejects.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDIFIMPORT_COUNT_REJECTS_REQUIRES_OFFLINE.get(countRejects.getLongIdentifier())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_SERVER_BOOTSTRAP_ERROR.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ROOTDN_MANAGER.get(getMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ROOTDN_MANAGER.get(getMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(getMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(getMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_SUBENTRY_MANAGER.get( |
| | | ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_SUBENTRY_MANAGER.get(ie.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY.get(getMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY.get(getMessage(e))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(getMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(getMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | !clearBackend.isPresent()) |
| | | { |
| | | StringBuilder builder = join(backend.getBaseDNs(), " / "); |
| | | LocalizableMessage message = ERR_LDIFIMPORT_MISSING_CLEAR_BACKEND.get( |
| | | builder, clearBackend.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDIFIMPORT_MISSING_CLEAR_BACKEND.get(builder, clearBackend.getLongIdentifier())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage msg = INFO_OPERATION_FAILED.get("COMPARE"); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, INFO_OPERATION_FAILED.get("COMPARE")); |
| | | printWrappedText(err, ae.getMessage()); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | } |
| | |
| | | argParser.setUsageArgument(showUsage, out); |
| | | } catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | |
| | | if(bindPassword.isPresent() && bindPasswordFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | bindPassword.getLongIdentifier(), |
| | | bindPasswordFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText( |
| | | err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | |
| | | if(attrAndDNStrings.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPCOMPARE_NO_ATTR.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPCOMPARE_NO_ATTR.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | // If no DNs were provided, then exit with an error. |
| | | if (dnStrings.isEmpty() && !filename.isPresent()) |
| | | { |
| | | err.println(wrapText(ERR_LDAPCOMPARE_NO_DNS.get(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPCOMPARE_NO_DNS.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | // provided, exit with an error. |
| | | if (!dnStrings.isEmpty() && filename.isPresent()) |
| | | { |
| | | err.println(wrapText(ERR_LDAPCOMPARE_FILENAME_AND_DNS.get(), |
| | | MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPCOMPARE_FILENAME_AND_DNS.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | int idx = attributeString.indexOf(":"); |
| | | if(idx == -1) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPCOMPARE_INVALID_ATTR_STRING.get(attributeString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPCOMPARE_INVALID_ATTR_STRING.get(attributeString)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | attributeType = attributeString.substring(0, idx); |
| | |
| | | } |
| | | catch (ParseException e) |
| | | { |
| | | err.println(wrapText( |
| | | INFO_COMPARE_CANNOT_BASE64_DECODE_ASSERTION_VALUE.get(), |
| | | MAX_LINE_WIDTH)); |
| | | err.println(wrapText(e.getLocalizedMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, INFO_COMPARE_CANNOT_BASE64_DECODE_ASSERTION_VALUE.get()); |
| | | printWrappedText(err, e.getLocalizedMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } else if(nextChar == '<') |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(wrapText( |
| | | INFO_COMPARE_CANNOT_READ_ASSERTION_VALUE_FROM_FILE.get(e), |
| | | MAX_LINE_WIDTH)); |
| | | printWrappedText(err, INFO_COMPARE_CANNOT_READ_ASSERTION_VALUE_FROM_FILE.get(e)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } else |
| | |
| | | portNumber = port.getIntValue(); |
| | | } catch (ArgumentException ae) |
| | | { |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ae.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | int versionNumber = version.getIntValue(); |
| | | if(versionNumber != 2 && versionNumber != 3) |
| | | { |
| | | err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | connectionOptions.setVersionNumber(versionNumber); |
| | | } catch(ArgumentException ae) |
| | | { |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ae.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ClientException ex) |
| | | { |
| | | err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ex.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | Control ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString)); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_ASSERTION_INVALID_FILTER.get( |
| | | le.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | { |
| | | if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | if(keyStorePathValue == null) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | { |
| | | details = t.toString(); |
| | | } |
| | | err.println(wrapText(ERR_LDAPCOMPARE_ERROR_READING_FILE.get( |
| | | fileNameValue, details), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPCOMPARE_ERROR_READING_FILE.get(fileNameValue, details)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | return lce.getResultCode(); |
| | | } catch(Exception e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return OPERATIONS_ERROR; |
| | | } finally |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage msg = INFO_OPERATION_FAILED.get("DELETE"); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, INFO_OPERATION_FAILED.get("DELETE")); |
| | | printWrappedText(err, ae.getMessage()); |
| | | return; |
| | | } |
| | | } |
| | |
| | | argParser.setUsageArgument(showUsage, out); |
| | | } catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | |
| | | if(bindPassword.isPresent() && bindPasswordFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | bindPassword.getLongIdentifier(), |
| | | bindPasswordFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText( |
| | | err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | } catch(ArgumentException ae) |
| | | { |
| | | logger.traceException(ae); |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ae.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | int versionNumber = version.getIntValue(); |
| | | if(versionNumber != 2 && versionNumber != 3) |
| | | { |
| | | err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | connectionOptions.setVersionNumber(versionNumber); |
| | | } catch(ArgumentException ae) |
| | | { |
| | | logger.traceException(ae); |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ae.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | catch (Exception ex) |
| | | { |
| | | logger.traceException(ex); |
| | | err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ex.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | Control ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString)); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | { |
| | | if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | if(keyStorePathValue == null) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | } catch(Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } finally |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDIF_FILE_INVALID_LDIF_ENTRY.get( |
| | | le.getLineNumber(), fileNameValue, le); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDIF_FILE_INVALID_LDIF_ENTRY.get(le.getLineNumber(), fileNameValue, le)); |
| | | continue; |
| | | } |
| | | } catch (Exception e) |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDIF_FILE_READ_ERROR.get(fileNameValue, e); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDIF_FILE_READ_ERROR.get(fileNameValue, e)); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | } catch(DecodeException ae) |
| | | { |
| | | logger.traceException(ae); |
| | | LocalizableMessage message = INFO_OPERATION_FAILED.get(operationType); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, INFO_OPERATION_FAILED.get(operationType)); |
| | | printWrappedText(err, ae.getMessage()); |
| | | if (!modifyOptions.continueOnError()) |
| | | { |
| | | String msg = LDAPToolUtils.getMessageForConnectionException(ae); |
| | |
| | | |
| | | if (errorMessage != null) |
| | | { |
| | | out.println(wrapText(errorMessage, MAX_LINE_WIDTH)); |
| | | printWrappedText(out, errorMessage); |
| | | } |
| | | |
| | | if (referralURLs != null) |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | err.println(wrapText( |
| | | ERR_LDAPMODIFY_PREREAD_CANNOT_DECODE_VALUE.get( |
| | | de.getMessage()), |
| | | MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPMODIFY_PREREAD_CANNOT_DECODE_VALUE.get(de.getMessage())); |
| | | continue; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | err.println(wrapText( |
| | | ERR_LDAPMODIFY_POSTREAD_CANNOT_DECODE_VALUE.get( |
| | | de.getMessage()), |
| | | MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPMODIFY_POSTREAD_CANNOT_DECODE_VALUE.get(de.getMessage())); |
| | | continue; |
| | | } |
| | | |
| | |
| | | argParser.setUsageArgument(showUsage, out); |
| | | } catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | |
| | | if(bindPassword.isPresent() && bindPasswordFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | bindPassword.getLongIdentifier(), |
| | | bindPasswordFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText( |
| | | err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | } catch(ArgumentException ae) |
| | | { |
| | | logger.traceException(ae); |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ae.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | int versionNumber = version.getIntValue(); |
| | | if(versionNumber != 2 && versionNumber != 3) |
| | | { |
| | | err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | connectionOptions.setVersionNumber(versionNumber); |
| | | } catch(ArgumentException ae) |
| | | { |
| | | logger.traceException(ae); |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ae.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | catch (Exception ex) |
| | | { |
| | | logger.traceException(ex); |
| | | err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ex.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | Control ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString)); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_ASSERTION_INVALID_FILTER.get( |
| | | le.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | { |
| | | if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | if(keyStorePathValue == null) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | } catch (FileNotFoundException fe) |
| | | { |
| | | logger.traceException(fe); |
| | | err.println(wrapText(fe.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, fe.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } catch(Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return OPERATIONS_ERROR; |
| | | } finally |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.extensions.ExtensionsConstants.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.ArrayList; |
| | |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.controls.PasswordPolicyErrorType; |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | // Make sure that the user didn't specify any conflicting arguments. |
| | | if (bindPW.isPresent() && bindPWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_CONFLICTING_ARGS.get( |
| | | bindPW.getLongIdentifier(), |
| | | bindPWFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText( |
| | | err, ERR_LDAPPWMOD_CONFLICTING_ARGS.get(bindPW.getLongIdentifier(), bindPWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (newPW.isPresent() && newPWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_CONFLICTING_ARGS.get( |
| | | newPW.getLongIdentifier(), |
| | | newPWFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText( |
| | | err, ERR_LDAPPWMOD_CONFLICTING_ARGS.get(newPW.getLongIdentifier(), newPWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (currentPW.isPresent() && currentPWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_CONFLICTING_ARGS.get( |
| | | currentPW.getLongIdentifier(), |
| | | currentPWFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, |
| | | ERR_LDAPPWMOD_CONFLICTING_ARGS.get(currentPW.getLongIdentifier(), currentPWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (useSSL.isPresent() && useStartTLS.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_CONFLICTING_ARGS.get( |
| | | useSSL.getLongIdentifier(), |
| | | useStartTLS.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText( |
| | | err, ERR_LDAPPWMOD_CONFLICTING_ARGS.get(useSSL.getLongIdentifier(), useStartTLS.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (sslKeyStorePIN.isPresent() && sslKeyStorePINFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | sslKeyStorePIN.getLongIdentifier(), |
| | | sslKeyStorePINFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, |
| | | ERR_TOOL_CONFLICTING_ARGS.get(sslKeyStorePIN.getLongIdentifier(), sslKeyStorePINFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (sslTrustStorePIN.isPresent() && sslTrustStorePINFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | sslTrustStorePIN.getLongIdentifier(), |
| | | sslTrustStorePINFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(sslTrustStorePIN.getLongIdentifier(), |
| | | sslTrustStorePINFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | { |
| | | if (!bindPW.isPresent() && !bindPWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_BIND_DN_AND_PW_MUST_BE_TOGETHER.get(); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPPWMOD_BIND_DN_AND_PW_MUST_BE_TOGETHER.get()); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | else if (bindPW.isPresent() || bindPWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_BIND_DN_AND_PW_MUST_BE_TOGETHER.get(); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPPWMOD_BIND_DN_AND_PW_MUST_BE_TOGETHER.get()); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | { |
| | | if (provideDNForAuthzID.isPresent()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPPWMOD_DEPENDENT_ARGS.get( |
| | | provideDNForAuthzID.getLongIdentifier(), |
| | | bindDN.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText( |
| | | err, ERR_LDAPPWMOD_DEPENDENT_ARGS.get(provideDNForAuthzID.getLongIdentifier(), bindDN.getLongIdentifier())); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (!authzID.isPresent() || (!currentPW.isPresent() && !currentPWFile.isPresent())) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPPWMOD_ANON_REQUIRES_AUTHZID_AND_CURRENTPW.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPPWMOD_ANON_REQUIRES_AUTHZID_AND_CURRENTPW.get()); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | catch (Exception e) |
| | | { |
| | | // This should never happen. |
| | | err.println(e); |
| | | printWrappedText(err, e.toString()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString)); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_ERROR_INITIALIZING_SSL.get(e); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPPWMOD_ERROR_INITIALIZING_SSL.get(e)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | //an empty password to the server. |
| | | while(pwChars.length==0) |
| | | { |
| | | err.println(wrapText( |
| | | INFO_LDAPAUTH_NON_EMPTY_PASSWORD.get(), |
| | | MAX_LINE_WIDTH)); |
| | | printWrappedText(err, INFO_LDAPAUTH_NON_EMPTY_PASSWORD.get()); |
| | | out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(dn)); |
| | | pwChars = ConsoleApplication.readPassword(); |
| | | } |
| | | pw = new String(pwChars); |
| | | } catch(Exception ex) |
| | | { |
| | | err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ex.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (LDAPConnectionException lce) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_CANNOT_CONNECT.get(lce.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPPWMOD_CANNOT_CONNECT.get(lce.getMessage())); |
| | | return lce.getResultCode(); |
| | | } |
| | | catch (ArgumentException e) |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_CANNOT_SEND_PWMOD_REQUEST.get(e); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | |
| | | printWrappedText(err, ERR_LDAPPWMOD_CANNOT_SEND_PWMOD_REQUEST.get(e)); |
| | | unbind(nextMessageID, writer); |
| | | close(reader, writer); |
| | | return 1; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_CANNOT_READ_PWMOD_RESPONSE.get(e); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | |
| | | printWrappedText(err, ERR_LDAPPWMOD_CANNOT_READ_PWMOD_RESPONSE.get(e)); |
| | | unbind(nextMessageID, writer); |
| | | close(reader, writer); |
| | | return 1; |
| | |
| | | int resultCode = extendedResponse.getResultCode(); |
| | | if (resultCode != LDAPResultCode.SUCCESS) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_FAILED.get(resultCode); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPPWMOD_FAILED.get(resultCode)); |
| | | |
| | | LocalizableMessage errorMessage = extendedResponse.getErrorMessage(); |
| | | if (errorMessage != null && errorMessage.length() > 0) |
| | | { |
| | | message = ERR_LDAPPWMOD_FAILURE_ERROR_MESSAGE.get(errorMessage); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPPWMOD_FAILURE_ERROR_MESSAGE.get(errorMessage)); |
| | | } |
| | | |
| | | DN matchedDN = extendedResponse.getMatchedDN(); |
| | | if (matchedDN != null) |
| | | { |
| | | message = ERR_LDAPPWMOD_FAILURE_MATCHED_DN.get(matchedDN); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPPWMOD_FAILURE_MATCHED_DN.get(matchedDN)); |
| | | } |
| | | |
| | | unbind(nextMessageID, writer); |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = INFO_LDAPPWMOD_SUCCESSFUL.get(); |
| | | out.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | |
| | | printWrappedText(out, INFO_LDAPPWMOD_SUCCESSFUL.get()); |
| | | LocalizableMessage additionalInfo = extendedResponse.getErrorMessage(); |
| | | if (additionalInfo != null && additionalInfo.length() > 0) |
| | | { |
| | | message = INFO_LDAPPWMOD_ADDITIONAL_INFO.get(additionalInfo); |
| | | out.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_LDAPPWMOD_ADDITIONAL_INFO.get(additionalInfo)); |
| | | } |
| | | } |
| | | |
| | |
| | | pwPolicyControl.getWarningType(); |
| | | if (pwPolicyWarningType != null) |
| | | { |
| | | LocalizableMessage message = INFO_LDAPPWMOD_PWPOLICY_WARNING.get( |
| | | pwPolicyWarningType, |
| | | pwPolicyControl.getWarningValue()); |
| | | out.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText( |
| | | out, INFO_LDAPPWMOD_PWPOLICY_WARNING.get(pwPolicyWarningType, pwPolicyControl.getWarningValue())); |
| | | } |
| | | |
| | | PasswordPolicyErrorType pwPolicyErrorType = |
| | | pwPolicyControl.getErrorType(); |
| | | if (pwPolicyErrorType != null) |
| | | { |
| | | LocalizableMessage message = INFO_LDAPPWMOD_PWPOLICY_ERROR.get(pwPolicyErrorType); |
| | | out.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_LDAPPWMOD_PWPOLICY_ERROR.get(pwPolicyErrorType)); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_CANNOT_DECODE_PWPOLICY_CONTROL.get(e); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPPWMOD_CANNOT_DECODE_PWPOLICY_CONTROL.get(e)); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | if (asn1Reader.peekType() == TYPE_PASSWORD_MODIFY_GENERATED_PASSWORD) |
| | | { |
| | | LocalizableMessage message = INFO_LDAPPWMOD_GENERATED_PASSWORD.get( |
| | | asn1Reader.readOctetStringAsString()); |
| | | out.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_LDAPPWMOD_GENERATED_PASSWORD.get(asn1Reader.readOctetStringAsString())); |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_UNRECOGNIZED_VALUE_TYPE.get( |
| | | asn1Reader.readOctetStringAsString()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPPWMOD_UNRECOGNIZED_VALUE_TYPE.get(asn1Reader.readOctetStringAsString())); |
| | | } |
| | | } |
| | | asn1Reader.readEndSequence(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPPWMOD_COULD_NOT_DECODE_RESPONSE_VALUE.get(e); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | |
| | | printWrappedText(err, ERR_LDAPPWMOD_COULD_NOT_DECODE_RESPONSE_VALUE.get(e)); |
| | | unbind(nextMessageID, writer); |
| | | close(reader, writer); |
| | | return 1; |
| | |
| | | } |
| | | } |
| | | // FIXME - throw exception? |
| | | LocalizableMessage msg = INFO_SEARCH_OPERATION_INVALID_PROTOCOL.get(opType); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, INFO_SEARCH_OPERATION_INVALID_PROTOCOL.get(opType)); |
| | | } |
| | | |
| | | if(resultCode != SUCCESS) |
| | |
| | | else if (errorMessage != null) |
| | | { |
| | | out.println(); |
| | | out.println(wrapText(errorMessage, MAX_LINE_WIDTH)); |
| | | printWrappedText(out, errorMessage); |
| | | } |
| | | |
| | | } while(opType != OP_TYPE_SEARCH_RESULT_DONE); |
| | |
| | | argParser.setUsageArgument(showUsage, out); |
| | | } catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | } catch (LDAPException le) |
| | | { |
| | | logger.traceException(le); |
| | | err.println(wrapText(le.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, le.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | |
| | | if(bindPassword.isPresent() && bindPasswordFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_TOOL_CONFLICTING_ARGS.get( |
| | | bindPassword.getLongIdentifier(), |
| | | bindPasswordFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, |
| | | ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (useSSL.isPresent() && startTLS.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | useSSL.getLongIdentifier(), |
| | | startTLS.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(useSSL.getLongIdentifier(), startTLS.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (keyStorePassword.isPresent() && keyStorePasswordFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | keyStorePassword.getLongIdentifier(), |
| | | keyStorePasswordFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get( |
| | | keyStorePassword.getLongIdentifier(), keyStorePasswordFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | if (trustStorePassword.isPresent() && trustStorePasswordFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | trustStorePassword.getLongIdentifier(), |
| | | trustStorePasswordFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get( |
| | | trustStorePassword.getLongIdentifier(), trustStorePasswordFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | } catch(ArgumentException ae) |
| | | { |
| | | logger.traceException(ae); |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ae.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | int versionNumber = version.getIntValue(); |
| | | if(versionNumber != 2 && versionNumber != 3) |
| | | { |
| | | err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | connectionOptions.setVersionNumber(versionNumber); |
| | | } catch(ArgumentException ae) |
| | | { |
| | | logger.traceException(ae); |
| | | err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ae.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | catch (Exception ex) |
| | | { |
| | | logger.traceException(ex); |
| | | err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ex.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | searchOptions.setSizeLimit(sizeLimit.getIntValue()); |
| | | } catch(ArgumentException ex1) |
| | | { |
| | | err.println(wrapText(ex1.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ex1.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | if (!searchOptions.setSearchScope(searchScope.getValue(), err) |
| | |
| | | Control ctrl = LDAPToolUtils.getControl(ctrlString, err); |
| | | if(ctrl == null) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString)); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | if(effectiveRightsUser.isPresent()) { |
| | | String authzID=effectiveRightsUser.getValue(); |
| | | if (!authzID.startsWith("dn:")) { |
| | | LocalizableMessage message = ERR_EFFECTIVERIGHTS_INVALID_AUTHZID.get(authzID); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_EFFECTIVERIGHTS_INVALID_AUTHZID.get(authzID)); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | |
| | | if (! tokenizer.hasMoreTokens()) |
| | | { |
| | | LocalizableMessage message = ERR_PSEARCH_MISSING_DESCRIPTOR.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PSEARCH_MISSING_DESCRIPTOR.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | else |
| | |
| | | String token = tokenizer.nextToken(); |
| | | if (! token.equals("ps")) |
| | | { |
| | | LocalizableMessage message = ERR_PSEARCH_DOESNT_START_WITH_PS.get(infoString); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PSEARCH_DOESNT_START_WITH_PS.get(infoString)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PSEARCH_INVALID_CHANGE_TYPE.get(token); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PSEARCH_INVALID_CHANGE_TYPE.get(token)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PSEARCH_INVALID_CHANGESONLY.get(token); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PSEARCH_INVALID_CHANGESONLY.get(token)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PSEARCH_INVALID_RETURN_ECS.get(token); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PSEARCH_INVALID_RETURN_ECS.get(token)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_ASSERTION_INVALID_FILTER.get( |
| | | le.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_MATCHEDVALUES_INVALID_FILTER.get( |
| | | le.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAP_MATCHEDVALUES_INVALID_FILTER.get(le.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAP_SORTCONTROL_INVALID_ORDER.get( |
| | | le.getErrorMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAP_SORTCONTROL_INVALID_ORDER.get(le.getErrorMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | { |
| | | if (! sortOrder.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPSEARCH_VLV_REQUIRES_SORT.get( |
| | | vlvDescriptor.getLongIdentifier(), |
| | | sortOrder.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, |
| | | ERR_LDAPSEARCH_VLV_REQUIRES_SORT.get(vlvDescriptor.getLongIdentifier(), sortOrder.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | { |
| | | if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | if(keyStorePathValue == null) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | |
| | | } catch(Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | finally |
| | |
| | | |
| | | if(filters.isEmpty()) |
| | | { |
| | | err.println(wrapText(ERR_SEARCH_NO_FILTERS.get(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_SEARCH_NO_FILTERS.get()); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | if (code == REFERRAL) |
| | | { |
| | | out.println(); |
| | | out.println(wrapText(le.getErrorMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(out, le.getErrorMessage()); |
| | | } |
| | | else |
| | | { |
| | |
| | | } catch(Exception e) |
| | | { |
| | | logger.traceException(e); |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } finally |
| | | { |
| | |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | import static org.forgerock.opendj.ldap.DereferenceAliasesPolicy.*; |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import java.io.PrintStream; |
| | | |
| | | import org.forgerock.opendj.ldap.DereferenceAliasesPolicy; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.forgerock.opendj.ldap.DereferenceAliasesPolicy.*; |
| | | import static org.forgerock.opendj.ldap.SearchScope.*; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | searchScope = SUBORDINATES; |
| | | } else |
| | | { |
| | | err.println(ERR_SEARCH_INVALID_SEARCH_SCOPE.get(scope)); |
| | | printWrappedText(err, ERR_SEARCH_INVALID_SEARCH_SCOPE.get(scope)); |
| | | return false; |
| | | } |
| | | return true; |
| | |
| | | dereferencePolicy = FINDING_BASE; |
| | | } else |
| | | { |
| | | err.println("Invalid deref alias specified:" + policy); |
| | | printWrappedText(err, ERR_SEARCH_INVALID_DEREFERENCE_POLICY.get(policy)); |
| | | return false; |
| | | } |
| | | return true; |
| | |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | |
| | | import java.io.PrintStream; |
| | | import java.net.SocketTimeoutException; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DecodeException; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.DN; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | |
| | | |
| | |
| | | controlCriticality = false; |
| | | } else |
| | | { |
| | | err.println("Invalid format for criticality value:" + remainder); |
| | | printWrappedText(err, "Invalid format for criticality value:" + remainder); |
| | | return null; |
| | | } |
| | | return new LDAPControl(controlOID, controlCriticality); |
| | |
| | | controlCriticality = false; |
| | | } else |
| | | { |
| | | err.println("Invalid format for criticality value:" + critical); |
| | | printWrappedText(err, "Invalid format for criticality value:" + critical); |
| | | return null; |
| | | } |
| | | |
| | |
| | | // Ensure all the bytes have been read in |
| | | if (offset < val.length) |
| | | { |
| | | err.println("Could not completely read file "+filePath); |
| | | printWrappedText(err, ERR_FILE_NOT_FULLY_READABLE.get(filePath)); |
| | | return null; |
| | | } |
| | | |
| | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static com.forgerock.opendj.cli.Utils.filterExitCode; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | /** |
| | | * This class provides a program that may be used to determine the differences |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | err.println(message); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | err.println(message); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFDIFF_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage())); |
| | | printWrappedText(err, ERR_LDIFDIFF_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFDIFF_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage())); |
| | | printWrappedText(err, ERR_LDIFDIFF_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFDIFF_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage())); |
| | | printWrappedText(err, ERR_LDIFDIFF_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage())); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFDIFF_CANNOT_READ_FILE_IGNORE_ATTRIBS.get(ignoreAttrsFile.getValue(), e)); |
| | | printWrappedText(err, ERR_LDIFDIFF_CANNOT_READ_FILE_IGNORE_ATTRIBS.get(ignoreAttrsFile.getValue(), e)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFDIFF_CANNOT_READ_FILE_IGNORE_ENTRIES.get(ignoreEntriesFile.getValue(), e)); |
| | | printWrappedText(err, ERR_LDIFDIFF_CANNOT_READ_FILE_IGNORE_ENTRIES.get(ignoreEntriesFile.getValue(), e)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFDIFF_CANNOT_OPEN_SOURCE_LDIF.get(sourceLDIF.getValue(), e)); |
| | | printWrappedText(err, ERR_LDIFDIFF_CANNOT_OPEN_SOURCE_LDIF.get(sourceLDIF.getValue(), e)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFDIFF_ERROR_READING_SOURCE_LDIF.get(sourceLDIF.getValue(), e)); |
| | | printWrappedText(err, ERR_LDIFDIFF_ERROR_READING_SOURCE_LDIF.get(sourceLDIF.getValue(), e)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFDIFF_CANNOT_OPEN_TARGET_LDIF.get(targetLDIF.getValue(), e)); |
| | | printWrappedText(err, ERR_LDIFDIFF_CANNOT_OPEN_TARGET_LDIF.get(targetLDIF.getValue(), e)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFDIFF_ERROR_READING_TARGET_LDIF.get(targetLDIF.getValue(), e)); |
| | | printWrappedText(err, ERR_LDIFDIFF_ERROR_READING_TARGET_LDIF.get(targetLDIF.getValue(), e)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | finally |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFDIFF_CANNOT_OPEN_OUTPUT.get(e)); |
| | | printWrappedText(err, ERR_LDIFDIFF_CANNOT_OPEN_OUTPUT.get(e)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | err.println(ERR_LDIFDIFF_ERROR_WRITING_OUTPUT.get(e)); |
| | | printWrappedText(err, ERR_LDIFDIFF_ERROR_WRITING_OUTPUT.get(e)); |
| | | return OPERATIONS_ERROR; |
| | | } |
| | | finally |
| | |
| | | */ |
| | | package org.opends.server.tools; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import static com.forgerock.opendj.cli.ArgumentConstants.*; |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | |
| | | import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler; |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | err.println(message); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(message); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFMODIFY_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage())); |
| | | printWrappedText(err, ERR_LDIFMODIFY_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFMODIFY_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage())); |
| | | printWrappedText(err, ERR_LDIFMODIFY_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFMODIFY_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage())); |
| | | printWrappedText(err, ERR_LDIFMODIFY_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage())); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | File source = new File(sourceFile.getValue()); |
| | | if (! source.exists()) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFMODIFY_SOURCE_DOES_NOT_EXIST.get( |
| | | sourceFile.getValue()); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_LDIFMODIFY_SOURCE_DOES_NOT_EXIST.get(sourceFile.getValue())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | LDIFImportConfig importConfig = new LDIFImportConfig(sourceFile.getValue()); |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | err.println(ERR_LDIFMODIFY_CANNOT_OPEN_SOURCE.get(sourceFile.getValue(), ioe)); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | printWrappedText(err, ERR_LDIFMODIFY_CANNOT_OPEN_SOURCE.get(sourceFile.getValue(), ioe)); |
| | | return CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | | |
| | | File changes = new File(changesFile.getValue()); |
| | | if (! changes.exists()) |
| | | { |
| | | err.println(ERR_LDIFMODIFY_CHANGES_DOES_NOT_EXIST.get(changesFile.getValue())); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_LDIFMODIFY_CHANGES_DOES_NOT_EXIST.get(changesFile.getValue())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | importConfig = new LDIFImportConfig(changesFile.getValue()); |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFMODIFY_CANNOT_OPEN_CHANGES.get( |
| | | sourceFile.getValue(), ioe.getMessage()); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | printWrappedText(err, ERR_LDIFMODIFY_CANNOT_OPEN_CHANGES.get(sourceFile.getValue(), ioe.getMessage())); |
| | | return CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFMODIFY_CANNOT_OPEN_TARGET.get( |
| | | sourceFile.getValue(), ioe.getMessage()); |
| | | err.println(message); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | printWrappedText(err, ERR_LDIFMODIFY_CANNOT_OPEN_TARGET.get(sourceFile.getValue(), ioe.getMessage())); |
| | | return CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | | import java.io.BufferedReader; |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | err.println(message); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(message); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | } catch(Exception e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } |
| | | finally |
| | |
| | | ArrayList<String> trailingArguments = argParser.getTrailingArguments(); |
| | | if (trailingArguments == null || trailingArguments.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFSEARCH_NO_FILTER.get(); |
| | | err.println(message); |
| | | printWrappedText(err, ERR_LDIFSEARCH_NO_FILTER.get()); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | // schema. |
| | | boolean checkSchema = configFile.isPresent(); |
| | | |
| | | if(initializeServer) { |
| | | DirectoryServer.bootstrapClient(); |
| | | |
| | | if (checkSchema) |
| | | if (initializeServer) |
| | | { |
| | | try |
| | | { |
| | | DirectoryServer.initializeJMX(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFSEARCH_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage())); |
| | | return 1; |
| | | } |
| | | DirectoryServer.bootstrapClient(); |
| | | |
| | | try |
| | | if (checkSchema) |
| | | { |
| | | directoryServer.initializeConfiguration(configClass.getValue(), |
| | | configFile.getValue()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFSEARCH_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage())); |
| | | return 1; |
| | | } |
| | | try |
| | | { |
| | | DirectoryServer.initializeJMX(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | printWrappedText(err, ERR_LDIFSEARCH_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | | try |
| | | { |
| | | directoryServer.initializeSchema(); |
| | | try |
| | | { |
| | | directoryServer.initializeConfiguration(configClass.getValue(), configFile.getValue()); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | printWrappedText(err, ERR_LDIFSEARCH_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | | try |
| | | { |
| | | directoryServer.initializeSchema(); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | printWrappedText(err, ERR_LDIFSEARCH_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage())); |
| | | return 1; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFSEARCH_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage())); |
| | | return 1; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // Choose the desired search scope. |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFSEARCH_CANNOT_PARSE_FILTER.get( |
| | | filterString, e.getMessage()); |
| | | err.println(message); |
| | | printWrappedText(err, ERR_LDIFSEARCH_CANNOT_PARSE_FILTER.get(filterString, e.getMessage())); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDIFSEARCH_CANNOT_PARSE_BASE_DN.get( |
| | | dnString, e.getMessage()); |
| | | err.println(message); |
| | | printWrappedText(err, ERR_LDIFSEARCH_CANNOT_PARSE_BASE_DN.get(dnString, e.getMessage())); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFSEARCH_CANNOT_PARSE_TIME_LIMIT.get(e)); |
| | | printWrappedText(err, ERR_LDIFSEARCH_CANNOT_PARSE_TIME_LIMIT.get(e)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFSEARCH_CANNOT_PARSE_SIZE_LIMIT.get(e)); |
| | | printWrappedText(err, ERR_LDIFSEARCH_CANNOT_PARSE_SIZE_LIMIT.get(e)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(ERR_LDIFSEARCH_CANNOT_CREATE_READER.get(e)); |
| | | printWrappedText(err, ERR_LDIFSEARCH_CANNOT_CREATE_READER.get(e)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | catch (Exception e) |
| | | { |
| | | close(reader); |
| | | err.println(ERR_LDIFSEARCH_CANNOT_CREATE_WRITER.get(e)); |
| | | printWrappedText(err, ERR_LDIFSEARCH_CANNOT_CREATE_WRITER.get(e)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | |
| | | // arguments. |
| | | if (backendID.isPresent() && baseDN.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get( |
| | | backendID.getLongIdentifier(), |
| | | baseDN.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(backendID.getLongIdentifier(), baseDN.getLongIdentifier())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_SERVER_BOOTSTRAP_ERROR.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (ConfigException ce) |
| | | { |
| | | LocalizableMessage message = ERR_LISTBACKENDS_CANNOT_GET_BACKENDS.get( |
| | | ce.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LISTBACKENDS_CANNOT_GET_BACKENDS.get(ce.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LISTBACKENDS_CANNOT_GET_BACKENDS.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LISTBACKENDS_CANNOT_GET_BACKENDS.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | LocalizableMessage message = ERR_LISTBACKENDS_INVALID_DN.get( |
| | | dnStr, de.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LISTBACKENDS_INVALID_DN.get(dnStr, de.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LISTBACKENDS_INVALID_DN.get( |
| | | dnStr, getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LISTBACKENDS_INVALID_DN.get(dnStr, getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | TreeSet<DN> baseDNs = backends.get(id); |
| | | if (baseDNs == null) |
| | | { |
| | | LocalizableMessage message = ERR_LISTBACKENDS_NO_SUCH_BACKEND.get(id); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LISTBACKENDS_NO_SUCH_BACKEND.get(id)); |
| | | iterator.remove(); |
| | | } |
| | | else |
| | |
| | | |
| | | if (backendIDs.isEmpty()) |
| | | { |
| | | LocalizableMessage message = ERR_LISTBACKENDS_NO_VALID_BACKENDS.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LISTBACKENDS_NO_VALID_BACKENDS.get()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.extensions.PasswordPolicyStateExtendedOperation.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_SEND_REQUEST_EXTOP.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN; |
| | | printWrappedText(err, ERR_PWPSTATE_CANNOT_SEND_REQUEST_EXTOP.get(getExceptionMessage(e))); |
| | | return CLIENT_SIDE_SERVER_DOWN; |
| | | } |
| | | |
| | | |
| | |
| | | LDAPMessage responseMessage = ldapReader.readMessage(); |
| | | if (responseMessage == null) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_PWPSTATE_CONNECTION_CLOSED_READING_RESPONSE.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN; |
| | | printWrappedText(err, ERR_PWPSTATE_CONNECTION_CLOSED_READING_RESPONSE.get()); |
| | | return CLIENT_SIDE_SERVER_DOWN; |
| | | } |
| | | |
| | | ExtendedResponseProtocolOp extendedResponse = |
| | |
| | | int resultCode = extendedResponse.getResultCode(); |
| | | if (resultCode != LDAPResultCode.SUCCESS) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_PWPSTATE_REQUEST_FAILED.get(resultCode, |
| | | LDAPResultCode.toString(resultCode), |
| | | extendedResponse.getErrorMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PWPSTATE_REQUEST_FAILED.get( |
| | | resultCode, LDAPResultCode.toString(resultCode), extendedResponse.getErrorMessage())); |
| | | return resultCode; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_RESPONSE_OP.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PWPSTATE_CANNOT_DECODE_RESPONSE_OP.get(getExceptionMessage(e))); |
| | | continue; |
| | | } |
| | | |
| | |
| | | |
| | | default: |
| | | message = ERR_PWPSTATE_INVALID_RESPONSE_OP_TYPE.get(opType); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, message); |
| | | break; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_RESPONSE_MESSAGE.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN; |
| | | printWrappedText(err, ERR_PWPSTATE_CANNOT_DECODE_RESPONSE_MESSAGE.get(getExceptionMessage(e))); |
| | | return CLIENT_SIDE_SERVER_DOWN; |
| | | } |
| | | |
| | | // If we've gotten here, then everything completed successfully. |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | | try |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | // return an error. |
| | | if (bindPW.isPresent() && bindPWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | bindPW.getLongIdentifier(), |
| | | bindPWFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, |
| | | ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(bindPW.getLongIdentifier(), bindPWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | // If both a key store password and key store password file were provided, |
| | | // then return an error. |
| | | if (keyStorePW.isPresent() && keyStorePWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | keyStorePW.getLongIdentifier(), |
| | | keyStorePWFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | keyStorePW.getLongIdentifier(), keyStorePWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | // provided, then return an error. |
| | | if (trustStorePW.isPresent() && trustStorePWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | trustStorePW.getLongIdentifier(), |
| | | trustStorePWFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | trustStorePW.getLongIdentifier(), trustStorePWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | connectionOptions.setSSLConnectionFactory(sslConnectionFactory); |
| | | } catch (SSLConnectionException sce) { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_INITIALIZE_SSL.get( |
| | | sce.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_CANNOT_INITIALIZE_SSL.get(sce.getMessage())); |
| | | return CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | int equalPos = s.indexOf('='); |
| | | if (equalPos <= 0) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_PARSE_SASL_OPTION.get(s); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_CANNOT_PARSE_SASL_OPTION.get(s)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | if (mechanism == null) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_NO_SASL_MECHANISM.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_NO_SASL_MECHANISM.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | connectionOptions.setSASLMechanism(mechanism); |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_CANNOT_DETERMINE_PORT.get( |
| | | port.getLongIdentifier(), |
| | | ae.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_CANNOT_DETERMINE_PORT.get(port.getLongIdentifier(), ae.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | catch (LDAPConnectionException lce) |
| | | { |
| | |
| | | message = ERR_PWPSTATE_CANNOT_CONNECT.get(hostPort, |
| | | lce.getMessage()); |
| | | } |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR; |
| | | printWrappedText(err, message); |
| | | return CLIENT_SIDE_CONNECT_ERROR; |
| | | } |
| | | |
| | | ldapReader = connection.getLDAPReader(); |
| | | ldapWriter = connection.getLDAPWriter(); |
| | | |
| | | return LDAPResultCode.SUCCESS; |
| | | return SUCCESS; |
| | | } |
| | | |
| | | |
| | |
| | | SubCommand subCommand = argParser.getSubCommand(); |
| | | if (subCommand == null) |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_NO_SUBCOMMAND.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PWPSTATE_NO_SUBCOMMAND.get()); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | String subCommandName = subCommand.getName(); |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_INVALID_BOOLEAN_VALUE.get(valueStr); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_INVALID_BOOLEAN_VALUE.get(valueStr)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_NO_BOOLEAN_VALUE.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_NO_BOOLEAN_VALUE.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | else if (subCommandName.equals(SC_CLEAR_ACCOUNT_DISABLED_STATE)) |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_INVALID_BOOLEAN_VALUE.get(valueStr); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_INVALID_BOOLEAN_VALUE.get(valueStr)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_NO_BOOLEAN_VALUE.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_PWPSTATE_NO_BOOLEAN_VALUE.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | else if(subCommandName.equals(SC_CLEAR_PASSWORD_RESET_STATE)) |
| | |
| | | } |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_PWPSTATE_INVALID_SUBCOMMAND.get(subCommandName); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_PWPSTATE_INVALID_SUBCOMMAND.get(subCommandName)); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | return LDAPResultCode.SUCCESS; |
| | | return SUCCESS; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | final LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | final LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | |
| | | && !rebuildAll.isPresent() |
| | | && !rebuildDegraded.isPresent()) |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_REBUILDINDEX_REQUIRES_AT_LEAST_ONE_INDEX.get(); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_REBUILDINDEX_REQUIRES_AT_LEAST_ONE_INDEX.get()); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | | if (rebuildAll.isPresent() && indexList.isPresent()) |
| | | { |
| | | final LocalizableMessage msg = ERR_REBUILDINDEX_REBUILD_ALL_ERROR.get(); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_REBUILDINDEX_REBUILD_ALL_ERROR.get()); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | | if (rebuildDegraded.isPresent() && indexList.isPresent()) |
| | | { |
| | | final LocalizableMessage msg = ERR_REBUILDINDEX_REBUILD_DEGRADED_ERROR.get("index"); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_REBUILDINDEX_REBUILD_DEGRADED_ERROR.get("index")); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | | if (rebuildDegraded.isPresent() && clearDegradedState.isPresent()) |
| | | { |
| | | final LocalizableMessage msg = |
| | | ERR_REBUILDINDEX_REBUILD_DEGRADED_ERROR.get("clearDegradedState"); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_REBUILDINDEX_REBUILD_DEGRADED_ERROR.get("clearDegradedState")); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | | if (rebuildAll.isPresent() && rebuildDegraded.isPresent()) |
| | | { |
| | | final LocalizableMessage msg = |
| | | ERR_REBUILDINDEX_REBUILD_ALL_DEGRADED_ERROR.get("rebuildDegraded"); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_REBUILDINDEX_REBUILD_ALL_DEGRADED_ERROR.get("rebuildDegraded")); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | |
| | | if (rebuildAll.isPresent() && clearDegradedState.isPresent()) |
| | | { |
| | | final LocalizableMessage msg = |
| | | ERR_REBUILDINDEX_REBUILD_ALL_DEGRADED_ERROR.get("clearDegradedState"); |
| | | err.println(wrapText(msg, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_REBUILDINDEX_REBUILD_ALL_DEGRADED_ERROR.get("clearDegradedState")); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } |
| | | return process(argParser, initializeServer, out, err); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | final LocalizableMessage message = |
| | | ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | err.println(toErrorMsg(ERR_CANNOT_LOAD_CONFIG, ex)); |
| | | printWrappedText(err, toErrorMsg(ERR_CANNOT_LOAD_CONFIG, ex)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(toErrorMsg(ERR_CANNOT_LOAD_SCHEMA, e)); |
| | | printWrappedText(err, toErrorMsg(ERR_CANNOT_LOAD_SCHEMA, e)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | err.println(toErrorMsg(ERR_CANNOT_INITIALIZE_CORE_CONFIG, ex)); |
| | | printWrappedText(err, toErrorMsg(ERR_CANNOT_INITIALIZE_CORE_CONFIG, ex)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | err.println(toErrorMsg(ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER, ex)); |
| | | printWrappedText(err, toErrorMsg(ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER, ex)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | final LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | out.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(out, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | final LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | out.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(out, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | catch (ClientException ce) |
| | | { |
| | | // No need to display the usage since the problem comes with a provided |
| | | // value. |
| | | err.println(wrapText(ce.getMessageObject(), MAX_LINE_WIDTH)); |
| | | // No need to display the usage since the problem comes with a provided value. |
| | | printWrappedText(err, ce.getMessageObject()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | if (listBackups.isPresent() && argParser.connectionArgumentsPresent()) { |
| | | LocalizableMessage message = ERR_LDAP_CONN_INCOMPATIBLE_ARGS.get( |
| | | listBackups.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAP_CONN_INCOMPATIBLE_ARGS.get(listBackups.getLongIdentifier())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_SERVER_BOOTSTRAP_ERROR.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.tools; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.*; |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.types.NullOutputStream; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.hasUAC; |
| | | import static com.forgerock.opendj.cli.Utils.filterExitCode; |
| | | |
| | | /** |
| | | * This class is used to start the Windows service associated with this |
| | | * instance on this machine. |
| | |
| | | String serviceName = ConfigureWindowsService.getServiceName(); |
| | | if (serviceName == null) |
| | | { |
| | | LocalizableMessage message = ERR_WINDOWS_SERVICE_NOT_FOUND.get(); |
| | | err.println(message); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_NOT_FOUND.get()); |
| | | return SERVICE_NOT_FOUND; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | LocalizableMessage message = ERR_WINDOWS_SERVICE_START_ERROR.get(); |
| | | err.println(message); |
| | | err.println("Exception:" + t); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_START_ERROR.get()); |
| | | printWrappedText(err, "Exception:" + t); |
| | | return SERVICE_START_ERROR; |
| | | } |
| | | } |
| | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | // an error. |
| | | if (bindPW.isPresent() && bindPWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | bindPW.getLongIdentifier(), |
| | | bindPWFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, |
| | | ERR_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(bindPW.getLongIdentifier(), bindPWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | // then return an error. |
| | | if (keyStorePW.isPresent() && keyStorePWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | keyStorePW.getLongIdentifier(), |
| | | keyStorePWFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | keyStorePW.getLongIdentifier(), keyStorePWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | // provided, then return an error. |
| | | if (trustStorePW.isPresent() && trustStorePWFile.isPresent()) |
| | | { |
| | | LocalizableMessage message = ERR_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | trustStorePW.getLongIdentifier(), |
| | | trustStorePWFile.getLongIdentifier()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS.get( |
| | | trustStorePW.getLongIdentifier(), trustStorePWFile.getLongIdentifier())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_STOPDS_CANNOT_DECODE_STOP_TIME.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_STOPDS_CANNOT_DECODE_STOP_TIME.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | // Check that the provided date is not previous to the current date. |
| | | Date currentDate = new Date(System.currentTimeMillis()); |
| | | if (currentDate.after(stopTime)) |
| | | { |
| | | LocalizableMessage message = ERR_STOPDS_DATETIME_ALREADY_PASSED.get( |
| | | timeStr); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_STOPDS_DATETIME_ALREADY_PASSED.get(timeStr)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | connectionOptions.setSSLConnectionFactory(sslConnectionFactory); |
| | | } catch (SSLConnectionException sce) { |
| | | LocalizableMessage message = |
| | | ERR_STOPDS_CANNOT_INITIALIZE_SSL.get(sce.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | printWrappedText(err, ERR_STOPDS_CANNOT_INITIALIZE_SSL.get(sce.getMessage())); |
| | | return CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | int equalPos = s.indexOf('='); |
| | | if (equalPos <= 0) |
| | | { |
| | | LocalizableMessage message = ERR_STOPDS_CANNOT_PARSE_SASL_OPTION.get(s); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_STOPDS_CANNOT_PARSE_SASL_OPTION.get(s)); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | if (mechanism == null) |
| | | { |
| | | LocalizableMessage message = ERR_STOPDS_NO_SASL_MECHANISM.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_STOPDS_NO_SASL_MECHANISM.get()); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | |
| | | connectionOptions.setSASLMechanism(mechanism); |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_STOPDS_CANNOT_DETERMINE_PORT.get( |
| | | port.getLongIdentifier(), |
| | | ae.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR; |
| | | printWrappedText(err, ERR_STOPDS_CANNOT_DETERMINE_PORT.get(port.getLongIdentifier(), ae.getMessage())); |
| | | return CLIENT_SIDE_PARAM_ERROR; |
| | | } |
| | | catch (LDAPConnectionException lce) |
| | | { |
| | |
| | | message = ERR_STOPDS_CANNOT_CONNECT.get(hostPort, |
| | | lce.getMessage()); |
| | | } |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR; |
| | | printWrappedText(err, message); |
| | | return CLIENT_SIDE_CONNECT_ERROR; |
| | | } |
| | | |
| | | LDAPReader reader = connection.getLDAPReader(); |
| | |
| | | responseMessage = reader.readMessage(); |
| | | if (responseMessage == null) |
| | | { |
| | | LocalizableMessage message = ERR_STOPDS_UNEXPECTED_CONNECTION_CLOSURE.get(); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN; |
| | | printWrappedText(err, ERR_STOPDS_UNEXPECTED_CONNECTION_CLOSURE.get()); |
| | | return CLIENT_SIDE_SERVER_DOWN; |
| | | } |
| | | } |
| | | catch (DecodeException | LDAPException e) |
| | | { |
| | | LocalizableMessage message = ERR_STOPDS_DECODE_ERROR.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_DECODING_ERROR; |
| | | printWrappedText(err, ERR_STOPDS_DECODE_ERROR.get(e.getMessage())); |
| | | return CLIENT_SIDE_DECODING_ERROR; |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | err.println(wrapText(ERR_STOPDS_IO_ERROR.get(ioe), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_STOPDS_IO_ERROR.get(ioe)); |
| | | return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN; |
| | | } |
| | | |
| | |
| | | String responseOID = extendedResponse.getOID(); |
| | | if (LDAPConstants.OID_NOTICE_OF_DISCONNECTION.equals(responseOID)) |
| | | { |
| | | LocalizableMessage message = extendedResponse.getErrorMessage(); |
| | | if (message != null) |
| | | { |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | } |
| | | |
| | | printWrappedText(err, extendedResponse.getErrorMessage()); |
| | | return extendedResponse.getResultCode(); |
| | | } |
| | | } |
| | | |
| | | |
| | | LocalizableMessage message = ERR_STOPDS_INVALID_RESPONSE_TYPE.get( |
| | | responseMessage.getProtocolOpName()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR; |
| | | printWrappedText(err, ERR_STOPDS_INVALID_RESPONSE_TYPE.get(responseMessage.getProtocolOpName())); |
| | | |
| | | |
| | | return CLIENT_SIDE_LOCAL_ERROR; |
| | | } |
| | | |
| | | |
| | | AddResponseProtocolOp addResponse = |
| | | responseMessage.getAddResponseProtocolOp(); |
| | | LocalizableMessage errorMessage = addResponse.getErrorMessage(); |
| | | if (errorMessage != null) |
| | | { |
| | | err.println(wrapText(errorMessage, MAX_LINE_WIDTH)); |
| | | } |
| | | |
| | | AddResponseProtocolOp addResponse = responseMessage.getAddResponseProtocolOp(); |
| | | printWrappedText(err, addResponse.getErrorMessage()); |
| | | return addResponse.getResultCode(); |
| | | } |
| | | |
| | |
| | | * Portions Copyright 2012-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | |
| | | import static com.forgerock.opendj.cli.Utils.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.*; |
| | | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | |
| | | import org.opends.server.loggers.JDKLogging; |
| | | import org.opends.server.types.NullOutputStream; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static com.forgerock.opendj.util.OperatingSystem.hasUAC; |
| | | import static com.forgerock.opendj.cli.Utils.filterExitCode; |
| | | |
| | | /** |
| | | * This class is used to stop the Windows service associated with this |
| | | * instance on this machine. |
| | |
| | | String serviceName = ConfigureWindowsService.getServiceName(); |
| | | if (serviceName == null) |
| | | { |
| | | LocalizableMessage message = ERR_WINDOWS_SERVICE_NOT_FOUND.get(); |
| | | err.println(message); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_NOT_FOUND.get()); |
| | | return SERVICE_NOT_FOUND; |
| | | } |
| | | String[] cmd; |
| | |
| | | } |
| | | catch (Throwable t) |
| | | { |
| | | LocalizableMessage message = ERR_WINDOWS_SERVICE_STOP_ERROR.get(); |
| | | err.println(message); |
| | | err.println("Exception:" + t); |
| | | printWrappedText(err, ERR_WINDOWS_SERVICE_STOP_ERROR.get()); |
| | | printWrappedText(err, "Exception:" + t); |
| | | return SERVICE_STOP_ERROR; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | |
| | | |
| | | if (cleanMode.isPresent() && indexList.getValues().size() != 1) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_VERIFYINDEX_VERIFY_CLEAN_REQUIRES_SINGLE_INDEX.get(); |
| | | |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_VERIFYINDEX_VERIFY_CLEAN_REQUIRES_SINGLE_INDEX.get()); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException ie) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ConfigException | InitializationException e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (DirectoryException de) |
| | | { |
| | | err.println(wrapText(ERR_CANNOT_DECODE_BASE_DN.get(baseDNString.getValue(), |
| | | de.getMessageObject()), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_DECODE_BASE_DN.get(baseDNString.getValue(), de.getMessageObject())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(wrapText(ERR_CANNOT_DECODE_BASE_DN.get(baseDNString.getValue(), |
| | | getExceptionMessage(e)), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_DECODE_BASE_DN.get(baseDNString.getValue(), getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | err.println(wrapText(ERR_MULTIPLE_BACKENDS_FOR_BASE.get(baseDNString.getValue()), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_MULTIPLE_BACKENDS_FOR_BASE.get(baseDNString.getValue())); |
| | | return 1; |
| | | } |
| | | break; |
| | |
| | | |
| | | if (backend == null) |
| | | { |
| | | err.println(wrapText(ERR_NO_BACKENDS_FOR_BASE.get(baseDNString.getValue()), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_NO_BACKENDS_FOR_BASE.get(baseDNString.getValue())); |
| | | return 1; |
| | | } |
| | | |
| | | if (!backend.supports(BackendOperation.INDEXING)) |
| | | { |
| | | err.println(wrapText(ERR_BACKEND_NO_INDEXING_SUPPORT.get(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_BACKEND_NO_INDEXING_SUPPORT.get()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | StringBuilder failureReason = new StringBuilder(); |
| | | if (! LockFileManager.acquireSharedLock(lockFile, failureReason)) |
| | | { |
| | | err.println(wrapText(ERR_VERIFYINDEX_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), |
| | | failureReason), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_VERIFYINDEX_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason)); |
| | | return 1; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(wrapText(ERR_VERIFYINDEX_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), |
| | | getExceptionMessage(e)), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_VERIFYINDEX_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | err.println(wrapText(ERR_VERIFYINDEX_ERROR_DURING_VERIFY.get(e.getMessage()), |
| | | MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_VERIFYINDEX_ERROR_DURING_VERIFY.get(e.getMessage())); |
| | | returnCode = 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(wrapText(ERR_VERIFYINDEX_ERROR_DURING_VERIFY.get(stackTraceToSingleLineString(e)), |
| | | MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_VERIFYINDEX_ERROR_DURING_VERIFY.get(stackTraceToSingleLineString(e))); |
| | | returnCode = 1; |
| | | } |
| | | |
| | |
| | | StringBuilder failureReason = new StringBuilder(); |
| | | if (! LockFileManager.releaseLock(lockFile, failureReason)) |
| | | { |
| | | err.println(wrapText(WARN_VERIFYINDEX_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), |
| | | failureReason), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, WARN_VERIFYINDEX_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), failureReason)); |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | err.println(wrapText(WARN_VERIFYINDEX_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), |
| | | getExceptionMessage(e)), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, WARN_VERIFYINDEX_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e))); |
| | | } |
| | | |
| | | return returnCode; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (ArgumentException ae) |
| | | { |
| | | LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage())); |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | |
| | | } |
| | | catch (InitializationException e) |
| | | { |
| | | err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, e.getMessage()); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_MAKELDIF_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_MAKELDIF_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage())); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage()); |
| | | System.err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_MAKELDIF_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage())); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | File resourceDir = new File(resourcePath.getValue()); |
| | | if (! resourceDir.exists()) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_NO_SUCH_RESOURCE_DIRECTORY.get( |
| | | resourcePath.getValue()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_MAKELDIF_NO_SUCH_RESOURCE_DIRECTORY.get(resourcePath.getValue())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_IOEXCEPTION_DURING_PARSE.get(ioe.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_MAKELDIF_IOEXCEPTION_DURING_PARSE.get(ioe.getMessage())); |
| | | return 1; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_EXCEPTION_DURING_PARSE.get(e.getMessage()); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_MAKELDIF_EXCEPTION_DURING_PARSE.get(e.getMessage())); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | { |
| | | for (LocalizableMessage s : warnings) |
| | | { |
| | | err.println(wrapText(s, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, s); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_UNABLE_TO_CREATE_LDIF.get(ldifFile.getValue(), ioe); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_MAKELDIF_UNABLE_TO_CREATE_LDIF.get(ldifFile.getValue(), ioe)); |
| | | return 1; |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_MAKELDIF_ERROR_WRITING_LDIF.get( |
| | | ldifFile.getValue(), stackTraceToSingleLineString(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_MAKELDIF_ERROR_WRITING_LDIF.get(ldifFile.getValue(), stackTraceToSingleLineString(e))); |
| | | return 1; |
| | | } |
| | | finally |
| | |
| | | |
| | | if ((++entriesWritten % 1000) == 0) |
| | | { |
| | | LocalizableMessage message = |
| | | INFO_MAKELDIF_PROCESSED_N_ENTRIES.get(entriesWritten); |
| | | out.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_MAKELDIF_PROCESSED_N_ENTRIES.get(entriesWritten)); |
| | | } |
| | | } |
| | | else |
| | |
| | | break ; |
| | | } |
| | | } |
| | | LocalizableMessage message = |
| | | ERR_MAKELDIF_CANNOT_WRITE_ENTRY_WITHOUT_DN.get(nullRdn); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_MAKELDIF_CANNOT_WRITE_ENTRY_WITHOUT_DN.get(nullRdn)); |
| | | return true; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public void closeEntryWriter() |
| | | { |
| | | LocalizableMessage message = INFO_MAKELDIF_PROCESSING_COMPLETE.get(entriesWritten); |
| | | out.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_MAKELDIF_PROCESSING_COMPLETE.get(entriesWritten)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_SERVER_BOOTSTRAP_ERROR.get( |
| | | getExceptionMessage(e)); |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e))); |
| | | return 1; |
| | | } |
| | | } |
| | |
| | | TaskEntry taskEntry = tc.schedule(this); |
| | | LocalizableMessage startTime = taskEntry.getScheduledStartTime(); |
| | | if (taskEntry.getTaskState() == TaskState.RECURRING) { |
| | | out.println( |
| | | wrapText(INFO_TASK_TOOL_RECURRING_TASK_SCHEDULED.get( |
| | | taskEntry.getType(), |
| | | taskEntry.getId()), |
| | | MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_TASK_TOOL_RECURRING_TASK_SCHEDULED.get(taskEntry.getType(), taskEntry.getId())); |
| | | } else if (startTime == null || startTime.length() == 0) { |
| | | out.println( |
| | | wrapText(INFO_TASK_TOOL_TASK_SCHEDULED_NOW.get( |
| | | taskEntry.getType(), |
| | | taskEntry.getId()), |
| | | MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_TASK_TOOL_TASK_SCHEDULED_NOW.get(taskEntry.getType(), taskEntry.getId())); |
| | | } else { |
| | | out.println( |
| | | wrapText(INFO_TASK_TOOL_TASK_SCHEDULED_FUTURE.get( |
| | | taskEntry.getType(), |
| | | taskEntry.getId(), |
| | | taskEntry.getScheduledStartTime()), |
| | | MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_TASK_TOOL_TASK_SCHEDULED_FUTURE.get( |
| | | taskEntry.getType(), taskEntry.getId(), taskEntry.getScheduledStartTime())); |
| | | } |
| | | if (!taskScheduleArgs.startArg.isPresent()) { |
| | | |
| | |
| | | } while (!taskEntry.isDone()); |
| | | if (TaskState.isSuccessful(taskEntry.getTaskState())) { |
| | | if (taskEntry.getTaskState() != TaskState.RECURRING) { |
| | | out.println( |
| | | wrapText(INFO_TASK_TOOL_TASK_SUCESSFULL.get( |
| | | taskEntry.getType(), |
| | | taskEntry.getId()), |
| | | MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_TASK_TOOL_TASK_SUCESSFULL.get(taskEntry.getType(), taskEntry.getId())); |
| | | } |
| | | return 0; |
| | | } else { |
| | | out.println( |
| | | wrapText(INFO_TASK_TOOL_TASK_NOT_SUCESSFULL.get( |
| | | taskEntry.getType(), |
| | | taskEntry.getId()), |
| | | MAX_LINE_WIDTH)); |
| | | printWrappedText(out, INFO_TASK_TOOL_TASK_NOT_SUCESSFULL.get(taskEntry.getType(), taskEntry.getId())); |
| | | return 1; |
| | | } |
| | | } |
| | | ret = 0; |
| | | } catch (LDAPConnectionException e) { |
| | | LocalizableMessage message; |
| | | if (isWrongPortException(e, |
| | | Integer.valueOf(argParser.getArguments().getPort()))) |
| | | { |
| | | message = ERR_TASK_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get( |
| | | argParser.getArguments().getHostName(), |
| | | argParser.getArguments().getPort()); |
| | | printWrappedText(err, ERR_TASK_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get( |
| | | argParser.getArguments().getHostName(), argParser.getArguments().getPort())); |
| | | } else { |
| | | message = ERR_TASK_TOOL_START_TIME_NO_LDAP.get(e.getMessage()); |
| | | } |
| | | if (err != null) |
| | | { |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_TASK_TOOL_START_TIME_NO_LDAP.get(e.getMessage())); |
| | | } |
| | | ret = 1; |
| | | } catch (DecodeException ae) { |
| | | LocalizableMessage message = ERR_TASK_TOOL_DECODE_ERROR.get(ae.getMessage()); |
| | | if (err != null) |
| | | { |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | } |
| | | printWrappedText(err, ERR_TASK_TOOL_DECODE_ERROR.get(ae.getMessage())); |
| | | ret = 1; |
| | | } catch (IOException ioe) { |
| | | LocalizableMessage message = ERR_TASK_TOOL_IO_ERROR.get(ioe); |
| | | if (err != null) |
| | | { |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | } |
| | | printWrappedText(err, ERR_TASK_TOOL_IO_ERROR.get(ioe)); |
| | | ret = 1; |
| | | } catch (LDAPException le) { |
| | | LocalizableMessage message = ERR_TASK_TOOL_LDAP_ERROR.get(le.getMessage()); |
| | | if (err != null) |
| | | { |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | } |
| | | printWrappedText(err, ERR_TASK_TOOL_LDAP_ERROR.get(le.getMessage())); |
| | | ret = 1; |
| | | } catch (ArgumentException | OpenDsException e) { |
| | | LocalizableMessage message = e.getMessageObject(); |
| | | if (err != null) |
| | | { |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | } |
| | | printWrappedText(err, e.getMessageObject()); |
| | | ret = 1; |
| | | } finally |
| | | { |
| | |
| | | } |
| | | catch (SSLConnectionException sce) |
| | | { |
| | | err.println(wrapText(ERR_LDAP_CONN_CANNOT_INITIALIZE_SSL.get(sce.getMessage()), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ERR_LDAP_CONN_CANNOT_INITIALIZE_SSL.get(sce.getMessage())); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | private void printAndThrowException(PrintStream err, LocalizableMessage message) throws ArgumentException |
| | | { |
| | | err.println(wrapText(message, MAX_LINE_WIDTH)); |
| | | printWrappedText(err, message); |
| | | throw new ArgumentException(message); |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, ex.getMessage()); |
| | | return null; |
| | | } |
| | | } |
| | |
| | | // an empty password to the server. |
| | | while (pwChars.length == 0) |
| | | { |
| | | err.println(wrapText(INFO_LDAPAUTH_NON_EMPTY_PASSWORD.get(), MAX_LINE_WIDTH)); |
| | | printWrappedText(err, INFO_LDAPAUTH_NON_EMPTY_PASSWORD.get()); |
| | | out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(bindDNValue)); |
| | | pwChars = ConsoleApplication.readPassword(); |
| | | } |
| | |
| | | by this version of the tool |
| | | ERR_INSTANCE_NOT_CONFIGURED_20013=The local instance is not configured or you do not \ |
| | | have permissions to access it. |
| | | ERR_SEARCH_INVALID_DEREFERENCE_POLICY_20014=Invalid deref alias specified: %s |
| | | ERR_FILE_NOT_FULLY_READABLE_20015=Could not completely read file '%s' |