Checkpoint OPENDJ-1343 Migrate dsconfig / OPENDJ-1303 "opendj-cli"
- removed CLIException for sdk ClientException.
- Change some LDAPReturnCode for ReturnCode in CLIs.
| | |
| | | import org.opends.quicksetup.util.ServerController; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.admin.client.cli.SecureConnectionCliArgs; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode; |
| | | import org.opends.server.tools.ToolConstants; |
| | | import org.opends.server.tools.dsconfig.LDAPManagementContextFactory; |
| | |
| | | import org.opends.server.util.cli.*; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | import static org.forgerock.util.Utils.*; |
| | | import static org.opends.messages.AdminToolMessages.*; |
| | |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | throw new UserDataException(null, ce.getMessageObject(), ce); |
| | |
| | | } |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | throw new UserDataException(null, ce.getMessageObject(), ce); |
| | | } |
| | |
| | | cancelled = !confirmToStopServer(); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | throw new UserDataException(null, ce.getMessageObject(), ce); |
| | | } |
| | |
| | | cancelled = !confirmDeleteFiles(); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | throw new UserDataException(null, ce.getMessageObject(), ce); |
| | | } |
| | |
| | | userData.getStopServer())); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | throw new UserDataException(null, ce.getMessageObject(), ce); |
| | | } |
| | |
| | | { |
| | | cancelled = !confirmDeleteFiles(); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | throw new UserDataException(null, ce.getMessageObject(), ce); |
| | | } |
| | |
| | | * Ask for confirmation to stop server. |
| | | * @return <CODE>true</CODE> if the user wants to continue and stop the |
| | | * server. <CODE>false</CODE> otherwise. |
| | | * @throws CLIException if the user reached the confirmation limit. |
| | | * @throws ClientException if the user reached the confirmation limit. |
| | | */ |
| | | private boolean confirmToStopServer() throws CLIException |
| | | private boolean confirmToStopServer() throws ClientException |
| | | { |
| | | return askConfirmation(INFO_CLI_UNINSTALL_CONFIRM_STOP.get(), true, logger); |
| | | } |
| | |
| | | * Ask for confirmation to delete files. |
| | | * @return <CODE>true</CODE> if the user wants to continue and delete the |
| | | * files. <CODE>false</CODE> otherwise. |
| | | * @throws CLIException if the user reached the confirmation limit. |
| | | * @throws ClientException if the user reached the confirmation limit. |
| | | */ |
| | | private boolean confirmDeleteFiles() throws CLIException |
| | | private boolean confirmDeleteFiles() throws ClientException |
| | | { |
| | | return askConfirmation(INFO_CLI_UNINSTALL_CONFIRM_DELETE_FILES.get(), true, |
| | | logger); |
| | |
| | | * Ask for confirmation to update configuration on remote servers. |
| | | * @return <CODE>true</CODE> if the user wants to continue and stop the |
| | | * server. <CODE>false</CODE> otherwise. |
| | | * @throws CLIException if the user reached the confirmation limit. |
| | | * @throws ClientException if the user reached the confirmation limit. |
| | | */ |
| | | private boolean confirmToUpdateRemote() throws CLIException |
| | | private boolean confirmToUpdateRemote() throws ClientException |
| | | { |
| | | return askConfirmation(INFO_CLI_UNINSTALL_CONFIRM_UPDATE_REMOTE.get(), true, |
| | | logger); |
| | |
| | | * Ask for confirmation to update configuration on remote servers. |
| | | * @return <CODE>true</CODE> if the user wants to continue and stop the |
| | | * server. <CODE>false</CODE> otherwise. |
| | | * @throws CLIException if the user reached the confirmation limit. |
| | | * @throws ClientException if the user reached the confirmation limit. |
| | | */ |
| | | private boolean confirmToUpdateRemoteAndStart() throws CLIException |
| | | private boolean confirmToUpdateRemoteAndStart() throws ClientException |
| | | { |
| | | return askConfirmation( |
| | | INFO_CLI_UNINSTALL_CONFIRM_UPDATE_REMOTE_AND_START.get(), true, logger); |
| | |
| | | * Ask for confirmation to provide again authentication. |
| | | * @return <CODE>true</CODE> if the user wants to provide authentication |
| | | * again. <CODE>false</CODE> otherwise. |
| | | * @throws CLIException if the user reached the confirmation limit. |
| | | * @throws ClientException if the user reached the confirmation limit. |
| | | */ |
| | | private boolean promptToProvideAuthenticationAgain() throws CLIException |
| | | private boolean promptToProvideAuthenticationAgain() throws ClientException |
| | | { |
| | | return askConfirmation( |
| | | INFO_UNINSTALL_CONFIRM_PROVIDE_AUTHENTICATION_AGAIN.get(), true, logger); |
| | |
| | | pwd = null; |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | throw new UserDataException(null, ce.getMessageObject(), ce); |
| | | } |
| | |
| | | s = readInput(INFO_UNINSTALL_CLI_REFERENCED_HOSTNAME_PROMPT.get(), |
| | | defaultHostName); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: %s", ce), ce); |
| | | } |
| | |
| | | ERR_UNINSTALL_NOT_UPDATE_REMOTE_PROMPT.get(), |
| | | false, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | throw new UserDataException(null, ce.getMessageObject(), ce); |
| | | } |
| | |
| | | Utils.getMessageFromCollection(exceptionMsgs, |
| | | Constants.LINE_SEPARATOR)), true, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | throw new UserDataException(null, ce.getMessageObject(), ce); |
| | | } |
| | |
| | | |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.util.StaticUtils; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.Menu; |
| | | import org.opends.server.util.cli.MenuBuilder; |
| | |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | respInt = defInt; |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | |
| | | import org.opends.quicksetup.event.ProgressUpdateListener; |
| | | import org.opends.quicksetup.event.ProgressUpdateEvent; |
| | | import org.opends.server.util.StaticUtils; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | /** |
| | | * Class used by Launcher to start a CLI application. |
| | |
| | | System.err.println(StaticUtils.wrapText(uude.getLocalizedMessage(), |
| | | Utils.getCommandLineMaxLineWidth())); |
| | | System.err.println(); |
| | | if (uude.getCause() instanceof CLIException) |
| | | if (uude.getCause() instanceof ClientException) |
| | | { |
| | | returnValue = ReturnCode.USER_INPUT_ERROR; |
| | | } |
| | |
| | | import org.opends.server.backends.task.RecurringTask; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | /** |
| | | * A class that contains all the arguments related to the task scheduling. |
| | |
| | | * to be launched as a task, the method {@link #validateArgsIfOffline()} |
| | | * should be called instead of this method. |
| | | * @throws ArgumentException if there is a problem with the arguments. |
| | | * @throws CLIException if there is a problem with one of the values provided |
| | | * @throws ClientException if there is a problem with one of the values provided |
| | | * by the user. |
| | | */ |
| | | public void validateArgs() |
| | | throws ArgumentException, CLIException { |
| | | public void validateArgs() throws ArgumentException, ClientException |
| | | { |
| | | if (startArg.isPresent() && !NOW.equals(startArg.getValue())) { |
| | | try { |
| | | Date date = StaticUtils.parseDateTimeString(startArg.getValue()); |
| | |
| | | Date currentDate = new Date(System.currentTimeMillis()); |
| | | if (currentDate.after(date)) |
| | | { |
| | | throw new CLIException(ERR_START_DATETIME_ALREADY_PASSED.get( |
| | | throw new ClientException(ReturnCode.ERROR_USER_DATA, ERR_START_DATETIME_ALREADY_PASSED.get( |
| | | startArg.getValue())); |
| | | } |
| | | } catch (ParseException pe) { |
| | |
| | | * This method covers all the checks done by {@link #validateArgs()}, so it |
| | | * is not necessary to call that method if this method is being called. |
| | | * @throws ArgumentException if there is a problem with the arguments. |
| | | * @throws CLIException if there is a problem with one of the values provided |
| | | * @throws ClientException if there is a problem with one of the values provided |
| | | * by the user. |
| | | */ |
| | | public void validateArgsIfOffline() |
| | | throws ArgumentException, CLIException |
| | | public void validateArgsIfOffline() throws ArgumentException, ClientException |
| | | { |
| | | Argument[] incompatibleArgs = {startArg, recurringArg, |
| | | completionNotificationArg, |
| | |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.args.LDAPConnectionArgumentParser; |
| | | |
| | | import com.forgerock.opendj.cli.*; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | // No need to display the usage since the problem comes with a provided |
| | | // value. |
| | |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.IntegerArgument; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | // No need to display the usage since the problem comes with a provided |
| | | // value. |
| | |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.IntegerArgument; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | |
| | | |
| | |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | // No need to display the usage since the problem comes with a provided |
| | | // value. |
| | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.IntegerArgument; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.Menu; |
| | | import org.opends.server.util.cli.MenuBuilder; |
| | |
| | | throw new InitializationException(LocalizableMessage.EMPTY, null); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.error(LocalizableMessage.raw("Unexpected error: "+ce, ce)); |
| | | throw new InitializationException(LocalizableMessage.EMPTY, null); |
| | |
| | | dns.add(dn); |
| | | prompted = true; |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | } |
| | |
| | | { |
| | | portNumber = readPort(promptMsg, defaultValue); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | portNumber = -1; |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | |
| | | prompt = confirmAction(INFO_INSTALLDS_PROVIDE_BASE_DN_PROMPT.get(), |
| | | true); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | prompt = true; |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | |
| | | importLDIFFiles.add(path); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | } |
| | |
| | | readInput(INFO_INSTALLDS_PROMPT_REJECTED_FILE.get(), |
| | | lastResetRejectedFile); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | } |
| | |
| | | readInput(INFO_INSTALLDS_PROMPT_SKIPPED_FILE.get(), |
| | | lastResetSkippedFile); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | } |
| | |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | populateType = POPULATE_TYPE_BASE_ONLY; |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | |
| | | println(message); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | } |
| | |
| | | rejectedFile = |
| | | readInput(INFO_INSTALLDS_PROMPT_REJECTED_FILE.get(), null); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | } |
| | |
| | | skippedFile = |
| | | readInput(INFO_INSTALLDS_PROMPT_SKIPPED_FILE.get(), null); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | } |
| | |
| | | INFO_INSTALLDS_PROMPT_LDAPSPORT.get(), usedPorts, false); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | } |
| | |
| | | enableStartTLS = confirmAction(INFO_INSTALLDS_ENABLE_STARTTLS.get(), |
| | | defaultValue); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | } |
| | |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | certType = SELF_SIGNED; |
| | |
| | | false : lastResetEnableWindowsService; |
| | | enableService = confirmAction(message, defaultValue); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | } |
| | |
| | | true : lastResetStartServer; |
| | | startServer = confirmAction(message, defaultValue); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | startServer = true; |
| | |
| | | { |
| | | path = readInput(pathPrompt, defaultPathValue); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | path = ""; |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | |
| | | { |
| | | s = readInput(prompt, String.valueOf(defaultValue)); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | s = ""; |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | |
| | | break; |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | } |
| | |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | returnValue = ConfirmCode.CANCEL; |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | |
| | | hostName = readInput(INFO_INSTALLDS_PROMPT_HOST_NAME.get(), |
| | | argParser.hostNameArg.getDefaultValue()); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | | } |
| | |
| | | import java.util.Map; |
| | | import java.util.StringTokenizer; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import javax.security.auth.Subject; |
| | | import javax.security.auth.callback.Callback; |
| | | import javax.security.auth.callback.CallbackHandler; |
| | |
| | | import javax.security.sasl.Sasl; |
| | | import javax.security.sasl.SaslClient; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.ldap.ByteSequence; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | |
| | | import org.opends.server.protocols.ldap.ExtendedRequestProtocolOp; |
| | | import org.opends.server.protocols.ldap.ExtendedResponseProtocolOp; |
| | | import org.opends.server.protocols.ldap.LDAPMessage; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.util.Base64; |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_SEND_SIMPLE_BIND.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_SEND_SIMPLE_BIND.get(getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException( LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException( ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | | responseMessage.getBindResponseProtocolOp(); |
| | | int resultCode = bindResponse.getResultCode(); |
| | | if (resultCode == LDAPResultCode.SUCCESS) |
| | | if (resultCode == ReturnCode.SUCCESS.get()) |
| | | { |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | | // reset notice, etc. |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_NO_SASL_MECHANISM.get(); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNSUPPORTED_SASL_MECHANISM.get(mechanism); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_AUTH_UNKNOWN, message); |
| | | ReturnCode.CLIENT_SIDE_AUTH_UNKNOWN, message); |
| | | } |
| | | } |
| | | |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_TRACE_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get( |
| | | name, SASL_MECHANISM_ANONYMOUS); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_ANONYMOUS, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_ANONYMOUS, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | | responseMessage.getBindResponseProtocolOp(); |
| | | int resultCode = bindResponse.getResultCode(); |
| | | if (resultCode == LDAPResultCode.SUCCESS) |
| | | if (resultCode == ReturnCode.SUCCESS.get()) |
| | | { |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | | // reset notice, etc. |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_CRAM_MD5); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get( |
| | | name, SASL_MECHANISM_CRAM_MD5); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_CRAM_MD5); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage1.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | BindResponseProtocolOp bindResponse1 = |
| | | responseMessage1.getBindResponseProtocolOp(); |
| | | int resultCode1 = bindResponse1.getResultCode(); |
| | | if (resultCode1 != LDAPResultCode.SASL_BIND_IN_PROGRESS) |
| | | if (resultCode1 != ReturnCode.SASL_BIND_IN_PROGRESS.get()) |
| | | { |
| | | LocalizableMessage errorMessage = bindResponse1.getErrorMessage(); |
| | | if (errorMessage == null) |
| | |
| | | |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_INITIAL_BIND_RESPONSE. |
| | | get(SASL_MECHANISM_CRAM_MD5, resultCode1, |
| | | LDAPResultCode.toString(resultCode1), errorMessage); |
| | | ReturnCode.get(resultCode1), errorMessage); |
| | | throw new LDAPException(resultCode1, errorMessage, message, |
| | | bindResponse1.getMatchedDN(), null); |
| | | } |
| | |
| | | if (serverChallenge == null) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_NO_CRAMMD5_SERVER_CREDENTIALS.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_CRAM_MD5, getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage2.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse2 = |
| | | responseMessage2.getBindResponseProtocolOp(); |
| | | int resultCode2 = bindResponse2.getResultCode(); |
| | | if (resultCode2 == LDAPResultCode.SUCCESS) |
| | | if (resultCode2 == ReturnCode.SUCCESS.get()) |
| | | { |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | | // reset notice, etc. |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_INITIALIZE_MD5_DIGEST.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_REALM_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_QOP_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | |
| | |
| | | { |
| | | // FIXME -- Add support for integrity and confidentiality. |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_QOP_NOT_SUPPORTED.get(qop); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | // This is an illegal value. |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_INVALID_QOP.get(qop); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGEST_URI_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHZID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get( |
| | | name, SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_DIGEST_MD5); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_INITIAL_SASL_BIND.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_INITIAL_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage1.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | BindResponseProtocolOp bindResponse1 = |
| | | responseMessage1.getBindResponseProtocolOp(); |
| | | int resultCode1 = bindResponse1.getResultCode(); |
| | | if (resultCode1 != LDAPResultCode.SASL_BIND_IN_PROGRESS) |
| | | if (resultCode1 != ReturnCode.SASL_BIND_IN_PROGRESS.get()) |
| | | { |
| | | LocalizableMessage errorMessage = bindResponse1.getErrorMessage(); |
| | | if (errorMessage == null) |
| | |
| | | |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_INITIAL_BIND_RESPONSE. |
| | | get(SASL_MECHANISM_DIGEST_MD5, resultCode1, |
| | | LDAPResultCode.toString(resultCode1), errorMessage); |
| | | ReturnCode.get(resultCode1), errorMessage); |
| | | throw new LDAPException(resultCode1, errorMessage, message, |
| | | bindResponse1.getMatchedDN(), null); |
| | | } |
| | |
| | | if (serverCredentials == null) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_NO_DIGESTMD5_SERVER_CREDENTIALS.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_TOKEN_IN_CREDENTIALS.get( |
| | | credString, pos); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_CHARSET.get(tokenValue); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | useUTF8 = true; |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_REQUESTED_QOP_NOT_SUPPORTED_BY_SERVER. |
| | | get(qop, tokenValue); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (nonce == null) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_NO_NONCE.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_CANNOT_CREATE_RESPONSE_DIGEST. |
| | | get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SECOND_SASL_BIND.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_SECOND_BIND_RESPONSE.get( |
| | | SASL_MECHANISM_DIGEST_MD5, getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage2.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse2 = |
| | | responseMessage2.getBindResponseProtocolOp(); |
| | | int resultCode2 = bindResponse2.getResultCode(); |
| | | if (resultCode2 != LDAPResultCode.SUCCESS) |
| | | if (resultCode2 != ReturnCode.SUCCESS.get()) |
| | | { |
| | | // FIXME -- Add support for referrals. |
| | | |
| | |
| | | if (rspAuthCreds == null) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_NO_RSPAUTH_CREDS.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | String credStr = toLowerCase(rspAuthCreds.toString()); |
| | | if (! credStr.startsWith("rspauth=")) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_NO_RSPAUTH_CREDS.get(); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_COULD_NOT_DECODE_RSPAUTH.get( |
| | | getExceptionMessage(e)); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, message); |
| | | throw new LDAPException(ReturnCode.PROTOCOL_ERROR.get(), message); |
| | | } |
| | | |
| | | byte[] clientRspAuth; |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_COULD_NOT_CALCULATE_RSPAUTH.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | if (! Arrays.equals(serverRspAuth, clientRspAuth)) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_DIGESTMD5_RSPAUTH_MISMATCH.get(); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | |
| | | // is not fine. |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_DIGESTMD5_INVALID_CLOSING_QUOTE_POS.get((pos-2)); |
| | | throw new LDAPException(LDAPResultCode.INVALID_CREDENTIALS, |
| | | throw new LDAPException(ReturnCode.INVALID_CREDENTIALS.get(), |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_INITIALIZE_MD5_DIGEST.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_ALLOWED_SASL_PROPERTIES.get(SASL_MECHANISM_EXTERNAL); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_EXTERNAL, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_EXTERNAL, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_DECODING_ERROR, message, e); |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | | responseMessage.getBindResponseProtocolOp(); |
| | | int resultCode = bindResponse.getResultCode(); |
| | | if (resultCode == LDAPResultCode.SUCCESS) |
| | | if (resultCode == ReturnCode.SUCCESS.get()) |
| | | { |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | | // reset notice, etc. |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_GSSAPI); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHZID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_KDC_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_QOP_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | |
| | |
| | | // FIXME -- Add support for integrity and confidentiality. |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_DIGESTMD5_QOP_NOT_SUPPORTED.get(gssapiQoP); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | else |
| | | { |
| | | // This is an illegal value. |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_INVALID_QOP.get(gssapiQoP); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_REALM_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get(name, SASL_MECHANISM_GSSAPI); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_GSSAPI); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_CANNOT_CREATE_JAAS_CONFIG.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | System.setProperty(JAAS_PROPERTY_CONFIG_FILE, configFileName); |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_LOCAL_AUTHENTICATION_FAILED.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | try |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_REMOTE_AUTHENTICATION_FAILED.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_NO_SASL_PROPERTIES.get(SASL_MECHANISM_PLAIN); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | Iterator<String> propertyNames = saslProperties.keySet().iterator(); |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | if (iterator.hasNext()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_AUTHZID_SINGLE_VALUED.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_PARAM_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_INVALID_SASL_PROPERTY.get(name, SASL_MECHANISM_PLAIN); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | } |
| | | |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_SASL_AUTHID_REQUIRED.get(SASL_MECHANISM_PLAIN); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_PARAM_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_PLAIN, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_PLAIN, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | | BindResponseProtocolOp bindResponse = |
| | | responseMessage.getBindResponseProtocolOp(); |
| | | int resultCode = bindResponse.getResultCode(); |
| | | if (resultCode == LDAPResultCode.SUCCESS) |
| | | if (resultCode == ReturnCode.SUCCESS.get()) |
| | | { |
| | | // FIXME -- Need to look for things like password expiration warning, |
| | | // reset notice, etc. |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_NONSASL_RUN_INVOCATION.get(getBacktrace()); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | else if (saslMechanism.equals(SASL_MECHANISM_GSSAPI)) |
| | | { |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_CANNOT_CREATE_SASL_CLIENT.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_CANNOT_CREATE_INITIAL_CHALLENGE. |
| | | get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_GSSAPI, getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_GSSAPI, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | BindResponseProtocolOp bindResponse = |
| | | responseMessage.getBindResponseProtocolOp(); |
| | | int resultCode = bindResponse.getResultCode(); |
| | | if (resultCode == LDAPResultCode.SUCCESS) |
| | | if (resultCode == ReturnCode.SUCCESS.get()) |
| | | { |
| | | // We should be done after this, but we still need to look for and |
| | | // handle the server SASL credentials. |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_GSSAPI_CANNOT_VALIDATE_SERVER_CREDS. |
| | | get(getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_GSSAPI_UNEXPECTED_SUCCESS_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message); |
| | | } |
| | | |
| | | break; |
| | | } |
| | | else if (resultCode == LDAPResultCode.SASL_BIND_IN_PROGRESS) |
| | | else if (resultCode == ReturnCode.SASL_BIND_IN_PROGRESS.get()) |
| | | { |
| | | // Read the response and process the server SASL credentials. |
| | | ByteString serverSASLCredentials = |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_GSSAPI_CANNOT_VALIDATE_SERVER_CREDS. |
| | | get(getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_GSSAPI, getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_SEND_SASL_BIND.get( |
| | | SASL_MECHANISM_GSSAPI, getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE |
| | | .get(getExceptionMessage(ae)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, message, ae); |
| | | ReturnCode.CLIENT_SIDE_DECODING_ERROR, message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_BIND_RESPONSE.get( |
| | | getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | else |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_EXTENDED_RESPONSE.get(extendedResponse); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | default: |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | } |
| | | else |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RUN_INVOCATION.get( |
| | | saslMechanism, getBacktrace()); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_SEND_WHOAMI_REQUEST.get(getExceptionMessage(ioe)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message, ioe); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_SEND_WHOAMI_REQUEST.get(getExceptionMessage(e)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_ENCODING_ERROR, |
| | | message, e); |
| | | } |
| | | |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CONNECTION_CLOSED_WITHOUT_BIND_RESPONSE.get(); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE.get(getExceptionMessage(ae)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, ae); |
| | | } |
| | | catch (IOException ioe) |
| | |
| | | LocalizableMessage message = ERR_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE.get( |
| | | getExceptionMessage(ioe)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | ReturnCode.CLIENT_SIDE_SERVER_DOWN, message, ioe); |
| | | } |
| | | catch (LDAPException le) |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE.get(getExceptionMessage(le)); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_DECODING_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_DECODING_ERROR, |
| | | message, le); |
| | | } |
| | | catch (Exception e) |
| | |
| | | LocalizableMessage message = |
| | | ERR_LDAPAUTH_CANNOT_READ_WHOAMI_RESPONSE.get(getExceptionMessage(e)); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message, e); |
| | | } |
| | | |
| | | |
| | |
| | | if (responseMessage.getProtocolOpType() != OP_TYPE_EXTENDED_RESPONSE) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_UNEXPECTED_RESPONSE.get(responseMessage.getProtocolOp()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_LOCAL_ERROR, message); |
| | | } |
| | | |
| | | |
| | |
| | | // response and the value would be the authorization ID. However, first |
| | | // check that it was successful. If it was not, then fail. |
| | | int resultCode = extendedResponse.getResultCode(); |
| | | if (resultCode != LDAPResultCode.SUCCESS) |
| | | if (resultCode != ReturnCode.SUCCESS.get()) |
| | | { |
| | | LocalizableMessage message = ERR_LDAPAUTH_WHOAMI_FAILED.get(); |
| | | throw new LDAPException(resultCode, extendedResponse.getErrorMessage(), |
| | |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.types.LDAPException; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import static org.opends.messages.CoreMessages.*; |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.protocols.ldap.LDAPResultCode.*; |
| | |
| | | } catch(ClientException ce) |
| | | { |
| | | logger.traceException(ce); |
| | | throw new LDAPConnectionException(ce.getMessageObject(), ce.getExitCode(), |
| | | throw new LDAPConnectionException(ce.getMessageObject(), ce.getReturnCode(), |
| | | null, ce); |
| | | } catch (LDAPException le) { |
| | | throw new LDAPConnectionException(le.getMessageObject(), |
| | |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | |
| | | import org.opends.server.util.args.LDAPConnectionArgumentParser; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public MenuResult<Void> invoke(ConsoleApplication app) throws CLIException { |
| | | public MenuResult<Void> invoke(ConsoleApplication app) throws ClientException { |
| | | return invoke((ManageTasks)app); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param app this console application |
| | | * @return MessageResult result of task |
| | | * @throws CLIException if there is a problem |
| | | * @throws ClientException if there is a problem |
| | | */ |
| | | protected abstract MenuResult<Void> invoke(ManageTasks app) |
| | | throws CLIException; |
| | | throws ClientException; |
| | | |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public MenuResult<TaskEntry> invoke(ConsoleApplication app) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | return invoke((ManageTasks)app); |
| | | } |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | protected abstract MenuResult<TaskEntry> invoke(ManageTasks app) |
| | | throws CLIException; |
| | | throws ClientException; |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | public MenuResult<Void> invoke(ManageTasks app) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | // Since the summary table is reprinted every time the |
| | | // user enters the top level this task just returns |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public MenuResult<Void> invoke(ManageTasks app) throws CLIException { |
| | | public MenuResult<Void> invoke(ManageTasks app) throws ClientException { |
| | | MenuResult<TaskEntry> res = new PrintTaskInfo(taskId).invoke(app); |
| | | TaskEntry taskEntry = res.getValue(); |
| | | if (taskEntry != null) { |
| | |
| | | */ |
| | | @Override |
| | | public MenuResult<TaskEntry> invoke(ManageTasks app) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | LocalizableMessage m; |
| | | TaskEntry taskEntry; |
| | |
| | | */ |
| | | @Override |
| | | protected MenuResult<TaskEntry> invoke(ManageTasks app) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | TaskEntry taskEntry = null; |
| | | try { |
| | |
| | | */ |
| | | @Override |
| | | public MenuResult<Void> invoke(ManageTasks app) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | if (taskIds != null && taskIds.size() > 0) { |
| | | if (cancelableIndices != null && cancelableIndices.size() > 0) { |
| | |
| | | */ |
| | | @Override |
| | | public MenuResult<TaskEntry> invoke(ManageTasks app) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | try { |
| | | TaskEntry entry = app.getTaskClient().getTaskEntry(taskId); |
| | |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | |
| | | import org.opends.server.util.args.LDAPConnectionArgumentParser; |
| | |
| | | err.println(argParser.getUsage()); |
| | | return 1; |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | // No need to display the usage since the problem comes with a provided |
| | | // value. |
| | |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.MissingMandatoryPropertiesException; |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.table.TableBuilder; |
| | | import org.opends.server.util.table.TextTablePrinter; |
| | |
| | | public final class ArgumentExceptionFactory { |
| | | |
| | | /** |
| | | * Creates a CLI exception from an illegal managed object name |
| | | * Creates a ClientException exception from an illegal managed object name |
| | | * exception. |
| | | * |
| | | * @param e |
| | | * The illegal managed object name exception. |
| | | * @param d |
| | | * The managed object definition. |
| | | * @return Returns a CLI exception. |
| | | * @return Returns a ClientException exception. |
| | | */ |
| | | public static CLIException adaptIllegalManagedObjectNameException( |
| | | public static ClientException adaptIllegalManagedObjectNameException( |
| | | IllegalManagedObjectNameException e, |
| | | AbstractManagedObjectDefinition<?, ?> d) { |
| | | String illegalName = e.getIllegalName(); |
| | |
| | | if (illegalName.length() == 0) { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_ILLEGAL_NAME_EMPTY.get(d.getUserFriendlyPluralName()); |
| | | return new CLIException(message); |
| | | return new ClientException(ReturnCode.ERROR_USER_DATA, message); |
| | | } else if (illegalName.trim().length() == 0) { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_ILLEGAL_NAME_BLANK.get(d.getUserFriendlyPluralName()); |
| | | return new CLIException(message); |
| | | return new ClientException(ReturnCode.ERROR_USER_DATA, message); |
| | | } else if (pd != null) { |
| | | try { |
| | | pd.decodeValue(illegalName); |
| | |
| | | |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_ILLEGAL_NAME_SYNTAX.get( |
| | | illegalName, d.getUserFriendlyName(), syntax); |
| | | return new CLIException(message); |
| | | return new ClientException(ReturnCode.ERROR_USER_DATA, message); |
| | | } |
| | | } |
| | | |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_ILLEGAL_NAME_UNKNOWN.get( |
| | | illegalName, d.getUserFriendlyName()); |
| | | return new CLIException(message); |
| | | return new ClientException(ReturnCode.ERROR_USER_DATA, message); |
| | | } |
| | | |
| | | |
| | |
| | | * The definition of the managed object that was retrieved. |
| | | * |
| | | * @param subcommandName the sub-command name. |
| | | * @return Returns a CLI exception. |
| | | * @return Returns a Client exception. |
| | | */ |
| | | public static CLIException wrongManagedObjectType(RelationDefinition<?, ?> r, |
| | | public static ClientException wrongManagedObjectType(RelationDefinition<?, ?> r, |
| | | ManagedObjectDefinition<?, ?> d, String subcommandName) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_TYPE_UNRECOGNIZED_FOR_SUBCOMMAND.get( |
| | | d.getUserFriendlyName(), subcommandName); |
| | | return new CLIException(msg); |
| | | return new ClientException(ReturnCode.ERROR_USER_DATA, msg); |
| | | } |
| | | |
| | | |
| | |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | import org.opends.server.admin.condition.Condition; |
| | | import org.opends.server.admin.condition.ContainsCondition; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.tools.ToolConstants; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.SubCommand; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.HelpCallback; |
| | | import org.opends.server.util.cli.MenuBuilder; |
| | |
| | | * @throws ClientException |
| | | * If an unrecoverable client exception occurred whilst |
| | | * interacting with the server. |
| | | * @throws CLIException |
| | | * If an error occurred whilst interacting with the |
| | | * console. |
| | | */ |
| | | public static <C extends ConfigurationClient, S extends Configuration> |
| | | MenuResult<String> createManagedObject( |
| | | ConsoleApplication app, ManagementContext context, |
| | | ManagedObject<?> parent, InstantiableRelationDefinition<C, S> rd) |
| | | throws ClientException, CLIException { |
| | | throws ClientException { |
| | | return createManagedObject(app, context, parent, rd, null); |
| | | } |
| | | |
| | |
| | | * @throws ClientException |
| | | * If an unrecoverable client exception occurred whilst |
| | | * interacting with the server. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If an error occurred whilst interacting with the |
| | | * console. |
| | | */ |
| | |
| | | ConsoleApplication app, ManagementContext context, |
| | | ManagedObject<?> parent, InstantiableRelationDefinition<C, S> rd, |
| | | SubCommandHandler handler) |
| | | throws ClientException, CLIException { |
| | | throws ClientException { |
| | | AbstractManagedObjectDefinition<C, S> d = rd.getChildDefinition(); |
| | | |
| | | // First determine what type of component the user wants to create. |
| | |
| | | // Check that any referenced components are enabled if |
| | | // required. |
| | | private static MenuResult<Void> checkReferences(ConsoleApplication app, |
| | | ManagementContext context, ManagedObject<?> mo, |
| | | SubCommandHandler handler) throws ClientException, |
| | | CLIException { |
| | | ManagementContext context, ManagedObject<?> mo, SubCommandHandler handler) |
| | | throws ClientException, ClientException |
| | | { |
| | | ManagedObjectDefinition<?, ?> d = mo.getManagedObjectDefinition(); |
| | | LocalizableMessage ufn = d.getUserFriendlyName(); |
| | | |
| | |
| | | ref = context.getManagedObject(path); |
| | | } catch (DefinitionDecodingException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_DDE.get(rufn, rufn, rufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectDecodingException e) { |
| | | // FIXME: should not abort here. Instead, display the |
| | | // errors (if verbose) and apply the changes to the |
| | | // partial managed object. |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_MODE.get(rufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg, e); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_MONFE.get(rufn); |
| | | throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg); |
| | | throw new ClientException(ReturnCode.NO_SUCH_OBJECT, msg); |
| | | } |
| | | |
| | | Condition condition = apd.getTargetIsEnabledCondition(); |
| | |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CME.get(ufn); |
| | | throw new ClientException( |
| | | LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (OperationRejectedException e) { |
| | | // Give the user the chance to fix the problems. |
| | | app.println(); |
| | |
| | | } |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } |
| | | |
| | | return MenuResult.success(); |
| | |
| | | // Commit a new managed object's configuration. |
| | | private static MenuResult<Void> commitManagedObject(ConsoleApplication app, |
| | | ManagementContext context, ManagedObject<?> mo, SubCommandHandler handler) |
| | | throws ClientException, |
| | | CLIException { |
| | | throws ClientException { |
| | | ManagedObjectDefinition<?, ?> d = mo.getManagedObjectDefinition(); |
| | | LocalizableMessage ufn = d.getUserFriendlyName(); |
| | | |
| | |
| | | return MenuResult.cancel(); |
| | | } |
| | | } else { |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, e |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, e |
| | | .getMessageObject(), e); |
| | | } |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CME.get(ufn); |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (OperationRejectedException e) { |
| | | if (app.isInteractive()) { |
| | | // If interactive, give the user the chance to fix the |
| | |
| | | return MenuResult.cancel(); |
| | | } |
| | | } else { |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, e |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, e |
| | | .getMessageObject(), e); |
| | | } |
| | | } catch (CommunicationException e) { |
| | |
| | | app.printVerboseMessage(msg); |
| | | return MenuResult.cancel(); |
| | | } else { |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } |
| | | } catch (ManagedObjectAlreadyExistsException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_MOAEE.get(ufn); |
| | |
| | | app.printVerboseMessage(msg); |
| | | return MenuResult.cancel(); |
| | | } else { |
| | | throw new ClientException(LDAPResultCode.ENTRY_ALREADY_EXISTS, msg); |
| | | throw new ClientException(ReturnCode.ENTRY_ALREADY_EXISTS, msg); |
| | | } |
| | | } |
| | | } |
| | |
| | | ConsoleApplication app, final ManagedObject<?> parent, |
| | | final InstantiableRelationDefinition<C, S> irelation, |
| | | final ManagedObjectDefinition<? extends C, ? extends S> d, |
| | | final List<PropertyException> exceptions) throws CLIException { |
| | | final List<PropertyException> exceptions) throws ClientException { |
| | | ValidationCallback<ManagedObject<? extends C>> validator = |
| | | new ValidationCallback<ManagedObject<? extends C>>() { |
| | | |
| | | public ManagedObject<? extends C> validate(ConsoleApplication app, |
| | | String input) throws CLIException { |
| | | String input) throws ClientException { |
| | | ManagedObject<? extends C> child; |
| | | |
| | | // First attempt to create the child, this will guarantee that |
| | |
| | | try { |
| | | child = parent.createChild(irelation, d, input, exceptions); |
| | | } catch (IllegalManagedObjectNameException e) { |
| | | CLIException ae = ArgumentExceptionFactory |
| | | ClientException ae = ArgumentExceptionFactory |
| | | .adaptIllegalManagedObjectNameException(e, d); |
| | | app.println(); |
| | | app.println(ae.getMessageObject()); |
| | |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(irelation |
| | | .getUserFriendlyName()); |
| | | throw new CLIException(msg); |
| | | throw new ClientException(ReturnCode.ERROR_USER_DATA, msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CME.get(irelation |
| | | .getUserFriendlyName()); |
| | | throw new CLIException(msg); |
| | | throw new ClientException(ReturnCode.TODO, msg); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(irelation |
| | | .getUserFriendlyName(), e.getMessage()); |
| | | throw new CLIException(msg); |
| | | throw new ClientException(ReturnCode.TODO, msg); |
| | | } catch (DefinitionDecodingException e) { |
| | | // Do nothing. |
| | | } catch (ManagedObjectDecodingException e) { |
| | |
| | | MenuResult<ManagedObjectDefinition<? extends C, ? extends S>> |
| | | getTypeInteractively(ConsoleApplication app, |
| | | AbstractManagedObjectDefinition<C, S> d, |
| | | Set<String> prohibitedTypes) throws CLIException { |
| | | Set<String> prohibitedTypes) throws ClientException { |
| | | // First get the list of available of sub-types. |
| | | List<ManagedObjectDefinition<? extends C, ? extends S>> filteredTypes = |
| | | new LinkedList<ManagedObjectDefinition<? extends C,? extends S>>( |
| | |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | ClientException, CLIException { |
| | | ClientException { |
| | | LocalizableMessage ufn = relation.getUserFriendlyName(); |
| | | |
| | | // Get the naming argument values. |
| | |
| | | result = getManagedObject(app, context, path, names); |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | } catch (DefinitionDecodingException e) { |
| | | LocalizableMessage pufn = path.getManagedObjectDefinition().getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(pufn, pufn, pufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectDecodingException e) { |
| | | LocalizableMessage pufn = path.getManagedObjectDefinition().getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg, e); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e |
| | | .getMessage()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CME.get(ufn); |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | LocalizableMessage pufn = path.getManagedObjectDefinition().getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MONFE.get(pufn); |
| | |
| | | app.printVerboseMessage(msg); |
| | | return MenuResult.cancel(); |
| | | } else { |
| | | throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg); |
| | | throw new ClientException(ReturnCode.NO_SUCH_OBJECT, msg); |
| | | } |
| | | } |
| | | |
| | |
| | | catch (AuthorizationException e) |
| | | { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | msg); |
| | | } |
| | | catch (ConcurrentModificationException e) |
| | | { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CME.get(ufn); |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } |
| | | catch (CommunicationException e) |
| | | { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e |
| | | .getMessage()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } |
| | | } else { |
| | | // No prohibited types. |
| | |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.MissingMandatoryPropertiesException; |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.EmbeddedUtils; |
| | |
| | | import com.forgerock.opendj.cli.SubCommand; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | | import com.forgerock.opendj.cli.ArgumentGroup; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import org.opends.server.util.cli.CommandBuilder; |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.Menu; |
| | |
| | | */ |
| | | @Override |
| | | public MenuResult<Integer> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | try { |
| | | MenuResult<Integer> result = handler.run(app, factory); |
| | | |
| | |
| | | return MenuResult.success(1); |
| | | } catch (ClientException e) { |
| | | app.println(e.getMessageObject()); |
| | | return MenuResult.success(e.getExitCode()); |
| | | return MenuResult.success(e.getReturnCode()); |
| | | } |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public final MenuResult<Integer> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | try { |
| | | app.println(); |
| | | app.println(); |
| | |
| | | } |
| | | |
| | | return result; |
| | | } catch (CLIException e) { |
| | | } catch (ClientException e) { |
| | | app.println(e.getMessageObject()); |
| | | return MenuResult.success(1); |
| | | } |
| | |
| | | } else { |
| | | return result.getValue(); |
| | | } |
| | | } catch (CLIException e) { |
| | | } catch (ClientException e) { |
| | | app.println(e.getMessageObject()); |
| | | return 1; |
| | | } |
| | |
| | | } catch (ArgumentException e) { |
| | | println(e.getMessageObject()); |
| | | return 1; |
| | | } catch (CLIException e) { |
| | | println(e.getMessageObject()); |
| | | return 1; |
| | | } catch (ClientException e) { |
| | | Throwable cause = e.getCause(); |
| | | if (cause instanceof ManagedObjectDecodingException) { |
| | |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.ClientException; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.SubCommand; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.MenuResult; |
| | | import org.opends.server.util.table.TableBuilder; |
| | |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | ClientException, CLIException { |
| | | ClientException { |
| | | // Get the naming argument values. |
| | | List<String> names = getNamingArgValues(app, namingArgs); |
| | | |
| | |
| | | result = getManagedObject(app, context, path, names); |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | } catch (DefinitionDecodingException e) { |
| | | LocalizableMessage pufn = path.getManagedObjectDefinition().getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(pufn, pufn, pufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectDecodingException e) { |
| | | LocalizableMessage pufn = path.getManagedObjectDefinition().getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg, e); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CME.get(ufn); |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | // Ignore the error if the deletion is being forced. |
| | | if (!forceArgument.isPresent()) { |
| | |
| | | app.printVerboseMessage(msg); |
| | | return MenuResult.cancel(); |
| | | } else { |
| | | throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg); |
| | | throw new ClientException(ReturnCode.NO_SUCH_OBJECT, msg); |
| | | } |
| | | } else { |
| | | return MenuResult.success(0); |
| | |
| | | } |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | } catch (OperationRejectedException e) { |
| | | LocalizableMessage msg; |
| | | if (e.getMessages().size() == 1) { |
| | |
| | | builder.print(printer); |
| | | return MenuResult.cancel(); |
| | | } else { |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, |
| | | msg, e); |
| | | } |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | // Ignore the error if the deletion is being forced. |
| | | if (!forceArgument.isPresent()) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_MONFE.get(ufn); |
| | | throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg); |
| | | throw new ClientException(ReturnCode.NO_SUCH_OBJECT, msg); |
| | | } |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CME.get(ufn); |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_DELETE_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } |
| | | |
| | | // Add the naming arguments if they were provided. |
| | |
| | | |
| | | |
| | | // Confirm deletion. |
| | | private boolean confirmDeletion(ConsoleApplication app) throws CLIException { |
| | | private boolean confirmDeletion(ConsoleApplication app) throws ClientException { |
| | | if (app.isInteractive()) { |
| | | LocalizableMessage prompt = INFO_DSCFG_CONFIRM_DELETE.get(relation |
| | | .getUserFriendlyName()); |
| | |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.tools.ToolConstants; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.SubCommand; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.MenuResult; |
| | | import org.opends.server.util.table.TableBuilder; |
| | |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | ClientException, CLIException { |
| | | ClientException { |
| | | // Get the property names. |
| | | Set<String> propertyNames = getPropertyNames(); |
| | | PropertyValuePrinter valuePrinter = new PropertyValuePrinter(getSizeUnit(), |
| | |
| | | result = getManagedObject(app, context, path, names); |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | } catch (DefinitionDecodingException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_DDE.get(ufn, ufn, ufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectDecodingException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_MODE.get(ufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg, e); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_CME.get(ufn); |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_MONFE.get(ufn); |
| | | throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg); |
| | | throw new ClientException(ReturnCode.NO_SUCH_OBJECT, msg); |
| | | } |
| | | |
| | | if (result.isQuit()) { |
| | |
| | | import org.opends.server.admin.Tag; |
| | | import org.opends.server.admin.UndefinedDefaultBehaviorProvider; |
| | | import org.opends.server.admin.PropertyException; |
| | | import org.opends.server.tools.ClientException; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.SubCommand; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.MenuResult; |
| | | import org.opends.server.util.cli.OutputStreamConsoleApplication; |
| | |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | ClientException, CLIException { |
| | | ClientException { |
| | | |
| | | String categoryName = categoryArgument.getValue(); |
| | | String typeName = typeArgument.getValue(); |
| | |
| | | |
| | | |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.tools.ClientException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | | import org.opends.server.util.cli.CommandBuilder; |
| | |
| | | import org.opends.server.admin.client.ldap.LDAPConnection; |
| | | import org.opends.server.admin.client.ldap.LDAPManagementContext; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.ClientException; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | import org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode; |
| | | import org.opends.server.tools.ToolConstants; |
| | | import org.opends.server.util.cli.CommandBuilder; |
| | |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | | |
| | | import java.util.LinkedHashSet; |
| | |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED.get(hostName, portNumber); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | if (e.getRootCause() instanceof SSLException) { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get(hostName, portNumber); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get( |
| | | hostName, portNumber); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get( |
| | | hostName, portNumber); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_SIMPLE_BIND_NOT_SUPPORTED |
| | | .get(); |
| | | throw new ClientException(LDAPResultCode.AUTH_METHOD_NOT_SUPPORTED, |
| | | throw new ClientException(ReturnCode.AUTH_METHOD_NOT_SUPPORTED, |
| | | message); |
| | | } |
| | | catch (AuthenticationException e) |
| | | { |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_SIMPLE_BIND_FAILED |
| | | .get(bindDN); |
| | | throw new ClientException(LDAPResultCode.INVALID_CREDENTIALS, |
| | | throw new ClientException(ReturnCode.INVALID_CREDENTIALS, |
| | | message); |
| | | } |
| | | catch (CommunicationException e) |
| | | { |
| | | LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get( |
| | | hostName, portNumber); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.tools.ToolConstants; |
| | | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.SubCommand; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.MenuResult; |
| | | import org.opends.server.util.table.TableBuilder; |
| | |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | ClientException, CLIException { |
| | | ClientException { |
| | | // Get the property names. |
| | | Set<String> propertyNames = getPropertyNames(); |
| | | |
| | |
| | | result = getManagedObject(app, context, path, names); |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | msg); |
| | | } catch (DefinitionDecodingException e) { |
| | | ufn = path.getManagedObjectDefinition().getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(ufn, ufn, ufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectDecodingException e) { |
| | | ufn = path.getManagedObjectDefinition().getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(ufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg, e); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn); |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | ufn = path.getManagedObjectDefinition().getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MONFE.get(ufn); |
| | |
| | | app.printVerboseMessage(msg); |
| | | return MenuResult.cancel(); |
| | | } else { |
| | | throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg); |
| | | throw new ClientException(ReturnCode.NO_SUCH_OBJECT, msg); |
| | | } |
| | | } |
| | | |
| | |
| | | // FIXME: just output this as a warnings (incl. the name) but |
| | | // continue. |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_DDE.get(ufn, ufn, ufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectDecodingException e) { |
| | | // FIXME: just output this as a warnings (incl. the name) but |
| | | // continue. |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_MODE.get(ufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg, e); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn); |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msg); |
| | | } |
| | | } else if (relation instanceof SetRelationDefinition) { |
| | |
| | | // FIXME: just output this as a warnings (incl. the name) but |
| | | // continue. |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_DDE.get(ufn, ufn, ufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectDecodingException e) { |
| | | // FIXME: just output this as a warnings (incl. the name) but |
| | | // continue. |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_MODE.get(ufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg, e); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn); |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msg); |
| | | } |
| | | } else if (relation instanceof OptionalRelationDefinition) { |
| | |
| | | app.printVerboseMessage(msg); |
| | | return MenuResult.cancel(); |
| | | } else { |
| | | throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg); |
| | | throw new ClientException(ReturnCode.NO_SUCH_OBJECT, msg); |
| | | } |
| | | } |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | msg); |
| | | } catch (DefinitionDecodingException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_DDE.get(ufn, ufn, ufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectDecodingException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_MODE.get(ufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg, e); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CME.get(ufn); |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msg); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_LIST_MONFE.get(ufn); |
| | | throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg); |
| | | throw new ClientException(ReturnCode.NO_SUCH_OBJECT, msg); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.tools.ClientException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | | import org.opends.server.util.cli.CommandBuilder; |
| | |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.forgerock.util.Reject; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | import org.opends.server.util.cli.HelpCallback; |
| | | import org.opends.server.util.cli.Menu; |
| | | import org.opends.server.util.cli.MenuBuilder; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public MenuResult<String> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | try { |
| | | // First get the parent managed object. |
| | | InstantiableRelationDefinition<?, ?> rd = pd.getRelationDefinition(); |
| | |
| | | parent = context.getManagedObject(path); |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | msg); |
| | | } catch (DefinitionDecodingException e) { |
| | | LocalizableMessage pufn = path.getManagedObjectDefinition() |
| | | .getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_DDE.get(pufn, pufn, pufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectDecodingException e) { |
| | | LocalizableMessage pufn = path.getManagedObjectDefinition() |
| | | .getUserFriendlyName(); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_PARENT_MODE.get(pufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg, e); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_CREATE_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_SERVER_DOWN, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_SERVER_DOWN, |
| | | msg); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | LocalizableMessage pufn = path.getManagedObjectDefinition() |
| | |
| | | app.printVerboseMessage(msg); |
| | | return MenuResult.cancel(); |
| | | } else { |
| | | throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg); |
| | | throw new ClientException(ReturnCode.NO_SUCH_OBJECT, msg); |
| | | } |
| | | } |
| | | |
| | |
| | | MenuCallback<Void> { |
| | | |
| | | // Any exception that was caught during processing. |
| | | private CLIException e = null; |
| | | private ClientException e = null; |
| | | |
| | | // The managed object being edited. |
| | | private final ManagedObject<?> mo; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public MenuResult<Void> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | displayPropertyHeader(app, pd); |
| | | |
| | | MenuResult<Void> result = pd.accept(this, null); |
| | |
| | | try { |
| | | values.addAll(Arrays.asList(context.listManagedObjects(path, rd))); |
| | | } catch (AuthorizationException e) { |
| | | this.e = new CLIException(e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | return MenuResult.quit(); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | this.e = new CLIException(e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | return MenuResult.cancel(); |
| | | } catch (CommunicationException e) { |
| | | this.e = new CLIException(e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | return MenuResult.quit(); |
| | | } |
| | | |
| | |
| | | oldValues); |
| | | return MenuResult.success(); |
| | | } |
| | | } catch (CLIException e) { |
| | | } catch (ClientException e) { |
| | | this.e = e; |
| | | return MenuResult.cancel(); |
| | | } |
| | |
| | | oldValues); |
| | | return MenuResult.success(); |
| | | } |
| | | } catch (CLIException e) { |
| | | } catch (ClientException e) { |
| | | this.e = e; |
| | | return MenuResult.cancel(); |
| | | } |
| | |
| | | registerModification(d, new TreeSet<E>(newValues), oldValues); |
| | | return MenuResult.success(); |
| | | } |
| | | } catch (CLIException e) { |
| | | } catch (ClientException e) { |
| | | this.e = e; |
| | | return MenuResult.cancel(); |
| | | } |
| | |
| | | isLastChoiceReset = false; |
| | | registerModification(d, values, oldValues); |
| | | return MenuResult.success(); |
| | | } catch (CLIException e) { |
| | | } catch (ClientException e) { |
| | | this.e = e; |
| | | return MenuResult.cancel(); |
| | | } |
| | |
| | | implements MenuCallback<Boolean> { |
| | | |
| | | // Any exception that was caught during processing. |
| | | private CLIException e = null; |
| | | private ClientException e = null; |
| | | |
| | | // The managed object being edited. |
| | | private final ManagedObject<?> mo; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | displayPropertyHeader(app, pd); |
| | | |
| | | MenuResult<Boolean> result = pd.accept(this, null); |
| | |
| | | try { |
| | | values.addAll(Arrays.asList(context.listManagedObjects(path, rd))); |
| | | } catch (AuthorizationException e) { |
| | | this.e = new CLIException(e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | return MenuResult.quit(); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | this.e = new CLIException(e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | return MenuResult.cancel(); |
| | | } catch (CommunicationException e) { |
| | | this.e = new CLIException(e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | return MenuResult.quit(); |
| | | } |
| | | |
| | |
| | | addCallback = new MenuCallback<Boolean>() { |
| | | |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | MenuBuilder<String> builder = new MenuBuilder<String>(app); |
| | | |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_SELECT_COMPONENTS_ADD |
| | |
| | | MenuCallback<Boolean> removeCallback = new MenuCallback<Boolean>() { |
| | | |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | MenuBuilder<String> builder = new MenuBuilder<String>(app); |
| | | |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_SELECT_COMPONENTS_REMOVE |
| | |
| | | addCallback = new MenuCallback<Boolean>() { |
| | | |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | MenuBuilder<T> builder = new MenuBuilder<T>(app); |
| | | |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_SELECT_VALUES_ADD.get()); |
| | |
| | | MenuCallback<Boolean> removeCallback = new MenuCallback<Boolean>() { |
| | | |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | MenuBuilder<T> builder = new MenuBuilder<T>(app); |
| | | |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_SELECT_VALUES_REMOVE.get()); |
| | |
| | | MenuCallback<Boolean> addCallback = new MenuCallback<Boolean>() { |
| | | |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | app.println(); |
| | | SortedSet<T> previousValues = new TreeSet<T>(currentValues); |
| | | readPropertyValues(app, mo.getManagedObjectDefinition(), d, |
| | |
| | | MenuCallback<Boolean> removeCallback = new MenuCallback<Boolean>() { |
| | | |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | MenuBuilder<T> builder = new MenuBuilder<T>(app); |
| | | |
| | | builder.setPrompt(INFO_EDITOR_PROMPT_SELECT_VALUES_REMOVE.get()); |
| | |
| | | MenuCallback<Boolean> callback = new MenuCallback<Boolean>() { |
| | | |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | isLastChoiceReset = false; |
| | | currentValues.clear(); |
| | | app.println(); |
| | |
| | | MenuCallback<Boolean> callback = new MenuCallback<Boolean>() { |
| | | |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | currentValues.clear(); |
| | | currentValues.addAll(defaultValues); |
| | | isLastChoiceReset = true; |
| | |
| | | MenuCallback<Boolean> callback = new MenuCallback<Boolean>() { |
| | | |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | currentValues.clear(); |
| | | currentValues.addAll(oldValues); |
| | | isLastChoiceReset = false; |
| | |
| | | try { |
| | | app.println(); |
| | | result = menu.run(); |
| | | } catch (CLIException e) { |
| | | } catch (ClientException e) { |
| | | this.e = e; |
| | | return null; |
| | | } |
| | |
| | | MenuCallback<Boolean> { |
| | | |
| | | // Any exception that was caught during processing. |
| | | private CLIException e = null; |
| | | private ClientException e = null; |
| | | |
| | | // The managed object being edited. |
| | | private final ManagedObject<?> mo; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | MenuResult<Boolean> result = pd.accept(this, null); |
| | | if (e != null) { |
| | | throw e; |
| | |
| | | boolean result; |
| | | try { |
| | | result = app.confirmAction(INFO_EDITOR_PROMPT_READ_ONLY.get(), false); |
| | | } catch (CLIException e) { |
| | | } catch (ClientException e) { |
| | | this.e = e; |
| | | return null; |
| | | } |
| | |
| | | implements MenuCallback<Boolean> { |
| | | |
| | | // Any exception that was caught during processing. |
| | | private CLIException e = null; |
| | | private ClientException e = null; |
| | | |
| | | // The managed object being edited. |
| | | private final ManagedObject<?> mo; |
| | |
| | | * {@inheritDoc} |
| | | */ |
| | | public MenuResult<Boolean> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | displayPropertyHeader(app, pd); |
| | | |
| | | MenuResult<Boolean> result = pd.accept(this, null); |
| | |
| | | try { |
| | | values.addAll(Arrays.asList(context.listManagedObjects(path, rd))); |
| | | } catch (AuthorizationException e) { |
| | | this.e = new CLIException(e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | return MenuResult.quit(); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | this.e = new CLIException(e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | return MenuResult.cancel(); |
| | | } catch (CommunicationException e) { |
| | | this.e = new CLIException(e.getMessageObject()); |
| | | this.e = new ClientException(ReturnCode.TODO, e.getMessageObject()); |
| | | return MenuResult.quit(); |
| | | } |
| | | |
| | |
| | | new MenuCallback<T>() { |
| | | |
| | | public MenuResult<T> invoke(ConsoleApplication app) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | app.println(); |
| | | Set<T> values = readPropertyValues(app, mo |
| | | .getManagedObjectDefinition(), d); |
| | |
| | | try { |
| | | app.println(); |
| | | result = menu.run(); |
| | | } catch (CLIException e) { |
| | | } catch (ClientException e) { |
| | | this.e = e; |
| | | return null; |
| | | } |
| | |
| | | // Read new values for a property. |
| | | private static <T> SortedSet<T> readPropertyValues(ConsoleApplication app, |
| | | ManagedObjectDefinition<?, ?> d, PropertyDefinition<T> pd) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | SortedSet<T> values = new TreeSet<T>(pd); |
| | | readPropertyValues(app, d, pd, values); |
| | | return values; |
| | |
| | | // Add values to a property. |
| | | private static <T> void readPropertyValues(ConsoleApplication app, |
| | | ManagedObjectDefinition<?, ?> d, PropertyDefinition<T> pd, |
| | | SortedSet<T> values) throws CLIException { |
| | | SortedSet<T> values) throws ClientException { |
| | | // Make sure there is at least one value if mandatory and empty. |
| | | if (values.isEmpty()) { |
| | | while (true) { |
| | |
| | | * {@code MenuResult.cancel()} if the user to chose to |
| | | * cancel any changes, or {@code MenuResult.quit()} if the |
| | | * user chose to quit the application. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If the user input could not be retrieved for some |
| | | * reason. |
| | | */ |
| | | public MenuResult<Void> edit(ManagedObject<?> mo, |
| | | Collection<PropertyDefinition<?>> c, boolean isCreate) |
| | | throws CLIException { |
| | | throws ClientException { |
| | | |
| | | // Get values for this missing mandatory property. |
| | | for (PropertyDefinition<?> pd : c) { |
| | |
| | | import org.opends.server.admin.client.OperationRejectedException; |
| | | import org.opends.server.admin.condition.Condition; |
| | | import org.opends.server.admin.condition.ContainsCondition; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.ClientException; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.SubCommand; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | import org.opends.server.util.cli.CommandBuilder; |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.MenuResult; |
| | |
| | | * @throws ClientException |
| | | * If an unrecoverable client exception occurred whilst |
| | | * interacting with the server. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If an error occurred whilst interacting with the |
| | | * console. |
| | | */ |
| | | public static MenuResult<Void> modifyManagedObject(ConsoleApplication app, |
| | | ManagementContext context, ManagedObject<?> mo, |
| | | SubCommandHandler handler) throws ClientException, |
| | | CLIException { |
| | | ManagementContext context, ManagedObject<?> mo, SubCommandHandler handler) |
| | | throws ClientException |
| | | { |
| | | ManagedObjectDefinition<?, ?> d = mo.getManagedObjectDefinition(); |
| | | LocalizableMessage ufn = d.getUserFriendlyName(); |
| | | |
| | |
| | | return MenuResult.cancel(); |
| | | } |
| | | } else { |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, e |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, e |
| | | .getMessageObject(), e); |
| | | } |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, |
| | | msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_CME.get(ufn); |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (OperationRejectedException e) { |
| | | if (app.isInteractive()) { |
| | | // If interactive, give the user the chance to fix the |
| | |
| | | return MenuResult.cancel(); |
| | | } |
| | | } else { |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, e |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, e |
| | | .getMessageObject(), e); |
| | | } |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectAlreadyExistsException e) { |
| | | // Should never happen. |
| | | throw new IllegalStateException(e); |
| | |
| | | */ |
| | | private static MenuResult<Void> checkReferences(ConsoleApplication app, |
| | | ManagementContext context, ManagedObject<?> mo, |
| | | SubCommandHandler handler) throws ClientException, |
| | | CLIException { |
| | | SubCommandHandler handler) throws ClientException |
| | | { |
| | | ManagedObjectDefinition<?, ?> d = mo.getManagedObjectDefinition(); |
| | | LocalizableMessage ufn = d.getUserFriendlyName(); |
| | | |
| | |
| | | ref = context.getManagedObject(path); |
| | | } catch (DefinitionDecodingException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_DDE.get(rufn, rufn, rufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectDecodingException e) { |
| | | // FIXME: should not abort here. Instead, display the |
| | | // errors (if verbose) and apply the changes to the |
| | | // partial managed object. |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_MODE.get(rufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg, e); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_MONFE.get(rufn); |
| | | throw new ClientException(LDAPResultCode.NO_SUCH_OBJECT, msg); |
| | | throw new ClientException(ReturnCode.NO_SUCH_OBJECT, msg); |
| | | } |
| | | |
| | | Condition condition = apd.getTargetIsEnabledCondition(); |
| | |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_CME.get(ufn); |
| | | throw new ClientException( |
| | | LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (OperationRejectedException e) { |
| | | // Give the user the chance to fix the problems. |
| | | app.println(); |
| | |
| | | } |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } |
| | | |
| | | return MenuResult.success(); |
| | |
| | | @Override |
| | | public MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | ClientException, CLIException { |
| | | ClientException { |
| | | // Get the naming argument values. |
| | | List<String> names = getNamingArgValues(app, namingArgs); |
| | | |
| | |
| | | result = getManagedObject(app, context, path, names); |
| | | } catch (AuthorizationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_AUTHZ.get(ufn); |
| | | throw new ClientException(LDAPResultCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | throw new ClientException(ReturnCode.INSUFFICIENT_ACCESS_RIGHTS, msg); |
| | | } catch (DefinitionDecodingException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_DDE.get(ufn, ufn, ufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ManagedObjectDecodingException e) { |
| | | // FIXME: should not abort here. Instead, display the errors (if |
| | | // verbose) and apply the changes to the partial managed object. |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_GET_CHILD_MODE.get(ufn); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg, e); |
| | | throw new ClientException(ReturnCode.OTHER, msg, e); |
| | | } catch (CommunicationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_CE.get(ufn, e.getMessage()); |
| | | throw new ClientException(LDAPResultCode.OTHER, msg); |
| | | throw new ClientException(ReturnCode.OTHER, msg); |
| | | } catch (ConcurrentModificationException e) { |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_MODIFY_CME.get(ufn); |
| | | throw new ClientException(LDAPResultCode.CONSTRAINT_VIOLATION, msg); |
| | | throw new ClientException(ReturnCode.CONSTRAINT_VIOLATION, msg); |
| | | } catch (ManagedObjectNotFoundException e) { |
| | | String objName = names.get(names.size() - 1); |
| | | ArgumentException except = null; |
| | |
| | | import java.util.Set; |
| | | import java.util.SortedMap; |
| | | import java.util.TreeMap; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.admin.AbstractManagedObjectDefinition; |
| | | import org.opends.server.admin.Configuration; |
| | |
| | | import org.opends.server.admin.client.ManagedObject; |
| | | import org.opends.server.admin.client.ManagedObjectDecodingException; |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import com.forgerock.opendj.cli.Argument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.SubCommand; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | import org.opends.server.util.cli.CommandBuilder; |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.Menu; |
| | |
| | | |
| | | // Any CLI exception that was caught when attempting to find |
| | | // the managed object. |
| | | private CLIException clie; |
| | | private ClientException clie; |
| | | |
| | | private ConcurrentModificationException cme; |
| | | |
| | |
| | | } else { |
| | | childName = sresult.getValue(); |
| | | } |
| | | } catch (CLIException e) { |
| | | } catch (ClientException e) { |
| | | clie = e; |
| | | result = MenuResult.quit(); |
| | | return; |
| | |
| | | } else { |
| | | childName = sresult.getValue(); |
| | | } |
| | | } catch (CLIException e) { |
| | | } catch (ClientException e) { |
| | | clie = e; |
| | | result = MenuResult.quit(); |
| | | return; |
| | |
| | | String typeUsage = getSubTypesUsage(d); |
| | | LocalizableMessage msg = ERR_DSCFG_ERROR_SUB_TYPE_UNRECOGNIZED.get( |
| | | name, r.getUserFriendlyName(), typeUsage); |
| | | clie = new CLIException(msg); |
| | | clie = new ClientException(ReturnCode.TODO, msg); |
| | | result = MenuResult.quit(); |
| | | return; |
| | | } else { |
| | |
| | | * object path, or {@link MenuResult#quit()}, or |
| | | * {@link MenuResult#cancel()}, if the sub-command was |
| | | * run interactively and the user chose to quit or cancel. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If one of the naming arguments referenced a managed |
| | | * object of the wrong type. |
| | | * @throws DefinitionDecodingException |
| | |
| | | */ |
| | | public MenuResult<ManagedObject<?>> find(ConsoleApplication app, |
| | | ManagementContext context, ManagedObjectPath<?, ?> path, |
| | | List<String> args) throws CLIException, CommunicationException, |
| | | List<String> args) throws ClientException, CommunicationException, |
| | | AuthorizationException, ConcurrentModificationException, |
| | | DefinitionDecodingException, ManagedObjectDecodingException, |
| | | ManagedObjectNotFoundException { |
| | |
| | | * parsed successfully. |
| | | * @throws ClientException |
| | | * If the management context could not be created. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If a CLI exception occurred. |
| | | */ |
| | | public abstract MenuResult<Integer> run(ConsoleApplication app, |
| | | ManagementContextFactory factory) throws ArgumentException, |
| | | ClientException, CLIException; |
| | | ClientException; |
| | | |
| | | |
| | | |
| | |
| | | * @throws CommunicationException |
| | | * If the client cannot contact the server due to an |
| | | * underlying communication problem. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If one of the naming arguments referenced a managed |
| | | * object of the wrong type. |
| | | * @throws ClientException |
| | |
| | | */ |
| | | protected final MenuResult<ManagedObject<?>> getManagedObject( |
| | | ConsoleApplication app, ManagementContext context, |
| | | ManagedObjectPath<?, ?> path, List<String> args) throws CLIException, |
| | | ManagedObjectPath<?, ?> path, List<String> args) throws ClientException, |
| | | AuthorizationException, DefinitionDecodingException, |
| | | ManagedObjectDecodingException, CommunicationException, |
| | | ConcurrentModificationException, ManagedObjectNotFoundException, |
| | | ClientException { |
| | | ConcurrentModificationException, ManagedObjectNotFoundException |
| | | { |
| | | ManagedObjectFinder finder = new ManagedObjectFinder(); |
| | | return finder.find(app, context, path, args); |
| | | } |
| | |
| | | * @throws AuthorizationException |
| | | * If the children cannot be listed due to an authorization |
| | | * failure. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If the user input can be read from the console or if |
| | | * there are no children. |
| | | */ |
| | |
| | | RelationDefinition<C, S> r, |
| | | AbstractManagedObjectDefinition<? extends C, ? extends S> d) |
| | | throws AuthorizationException, ConcurrentModificationException, |
| | | CommunicationException, CLIException { |
| | | CommunicationException, ClientException { |
| | | if (d == null) { |
| | | d = r.getChildDefinition(); |
| | | } |
| | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.ArgumentGroup; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.FileBasedArgument; |
| | | import com.forgerock.opendj.cli.IntegerArgument; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | |
| | | taskArgs.validateArgs(); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | addMessage(buf, ce.getMessageObject()); |
| | | } |
| | |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.tasks.PurgeConflictsHistoricalTask; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.tools.ToolConstants; |
| | | import org.opends.server.tools.tasks.TaskEntry; |
| | | import org.opends.server.tools.tasks.TaskScheduleInteraction; |
| | |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.FileBasedArgument; |
| | | import com.forgerock.opendj.cli.IntegerArgument; |
| | | |
| | |
| | | suffixes.add(dn); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | confirmationLimitReached = true; |
| | |
| | | INFO_REPLICATION_PURGE_HISTORICAL_LOCAL_PROMPT.get(), |
| | | true, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | { |
| | | interaction.run(); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | cancelled = true; |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | INFO_REPLICATION_ENABLE_REPLICATION_SERVER1_PROMPT.get(), |
| | | true, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | askConfirmation(INFO_REPLICATION_ENABLE_SECURE1_PROMPT.get(replicationPort1), |
| | | false, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | INFO_REPLICATION_ENABLE_REPLICATION_DOMAIN1_PROMPT.get(), |
| | | true, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | cancelled = true; |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | INFO_REPLICATION_ENABLE_REPLICATION_SERVER2_PROMPT.get(), |
| | | true, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | secureReplication2 = |
| | | askConfirmation(INFO_REPLICATION_ENABLE_SECURE2_PROMPT.get(replicationPort2), false, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | INFO_REPLICATION_ENABLE_REPLICATION_DOMAIN2_PROMPT.get(), |
| | | true, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | disableAll = askConfirmation(INFO_REPLICATION_PROMPT_DISABLE_ALL.get(), |
| | | disableAll, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | disableReplicationServer, |
| | | logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | false, |
| | | logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | INFO_REPLICATION_DISABLE_ALL_SUFFIXES_DISABLE_REPLICATION_SERVER.get( |
| | | ConnectionUtils.getHostPort(ctx), repPort), true, logger)); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | cancelled = !askConfirmation(INFO_REPLICATION_CONFIRM_DISABLE_ADS.get( |
| | | ADSContext.getAdministrationSuffixDN()), true, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | cancelled = !askConfirmation( |
| | | INFO_REPLICATION_CONFIRM_DISABLE_SCHEMA.get(), true, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | logger); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | ADSContext.getAdministrationSuffixDN(), hostPortSource), true, |
| | | logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | INFO_REPLICATION_CONFIRM_INITIALIZE_ALL_GENERIC.get( |
| | | hostPortSource), true, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | ADSContext.getAdministrationSuffixDN(), hostPortDestination, |
| | | hostPortSource), true, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | INFO_REPLICATION_CONFIRM_INITIALIZE_GENERIC.get( |
| | | hostPortDestination, hostPortSource), true, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | get(Utils.getMessageFromCollection(exceptionMsgs, |
| | | Constants.LINE_SEPARATOR)), true, logger); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | cancelled = true; |
| | |
| | | suffixes.add(dn); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | confirmationLimitReached = true; |
| | |
| | | suffixes.add(dn); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | confirmationLimitReached = true; |
| | |
| | | true, logger); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | confirmationLimitReached = true; |
| | |
| | | suffixes.add(dn); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | confirmationLimitReached = true; |
| | |
| | | ReplicationCliReturnCode.USER_CANCELLED, null); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | throw new ReplicationCliException( |
| | |
| | | ReplicationCliReturnCode.USER_CANCELLED, null); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | throw new ReplicationCliException( |
| | |
| | | returnValue = SubcommandChoice.CANCEL; |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | returnValue = SubcommandChoice.CANCEL; |
| | | logger.warn(LocalizableMessage.raw("Error reading input: "+ce, ce)); |
| | |
| | | ReplicationCliReturnCode.USER_CANCELLED, null); |
| | | } |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | println(ce.getMessageObject()); |
| | | throw new ReplicationCliException( |
| | |
| | | import org.opends.server.admin.client.ManagementContext; |
| | | import org.opends.server.admin.client.cli.SecureConnectionCliArgs; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.tools.ClientException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import org.opends.server.tools.ToolConstants; |
| | | import org.opends.server.tools.dsconfig.LDAPManagementContextFactory; |
| | | import org.opends.server.types.DN; |
| | |
| | | import org.opends.server.backends.task.RecurringTask; |
| | | import org.opends.server.types.DirectoryException; |
| | | import org.opends.server.util.StaticUtils; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | import org.opends.server.util.cli.MenuBuilder; |
| | | import org.opends.server.util.cli.MenuResult; |
| | |
| | | |
| | | /** |
| | | * Executes the interaction with the user. |
| | | * @throws CLIException if there is an error prompting the user. |
| | | * @throws ClientException if there is an error prompting the user. |
| | | */ |
| | | public void run() throws CLIException |
| | | public void run() throws ClientException |
| | | { |
| | | headerDisplayed = false; |
| | | |
| | |
| | | this.formatter = formatter; |
| | | } |
| | | |
| | | private void runFailedDependencyAction() throws CLIException |
| | | private void runFailedDependencyAction() throws ClientException |
| | | { |
| | | if (args.dependencyArg.isPresent()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void askForFailedDependencyAction() throws CLIException |
| | | private void askForFailedDependencyAction() throws ClientException |
| | | { |
| | | checkHeaderDisplay(); |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new CLIException(LocalizableMessage.EMPTY); |
| | | throw new ClientException(ReturnCode.TODO, LocalizableMessage.EMPTY); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void runDependency() throws CLIException |
| | | private void runDependency() throws ClientException |
| | | { |
| | | if (args.dependencyArg.isPresent()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void askForDependency() throws CLIException |
| | | private void askForDependency() throws ClientException |
| | | { |
| | | checkHeaderDisplay(); |
| | | |
| | |
| | | return taskIDDefined; |
| | | } |
| | | |
| | | private void runErrorNotification() throws CLIException |
| | | private void runErrorNotification() throws ClientException |
| | | { |
| | | if (args.errorNotificationArg.isPresent()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void askForErrorNotification() throws CLIException |
| | | private void askForErrorNotification() throws ClientException |
| | | { |
| | | List<String> addresses = |
| | | askForEmailNotification(INFO_HAS_ERROR_NOTIFICATION_PROMPT.get(), |
| | |
| | | } |
| | | |
| | | private List<String> askForEmailNotification(LocalizableMessage hasNotificationPrompt, |
| | | LocalizableMessage emailAddressPrompt) throws CLIException |
| | | LocalizableMessage emailAddressPrompt) throws ClientException |
| | | { |
| | | checkHeaderDisplay(); |
| | | |
| | |
| | | return addresses; |
| | | } |
| | | |
| | | private void runCompletionNotification() throws CLIException |
| | | private void runCompletionNotification() throws ClientException |
| | | { |
| | | if (args.completionNotificationArg.isPresent()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void askForCompletionNotification() throws CLIException |
| | | private void askForCompletionNotification() throws ClientException |
| | | { |
| | | List<String> addresses = |
| | | askForEmailNotification(INFO_HAS_COMPLETION_NOTIFICATION_PROMPT.get(), |
| | |
| | | uData.setNotifyUponCompletionEmailAddresses(addresses); |
| | | } |
| | | |
| | | private void runStartNowOrSchedule() throws CLIException |
| | | private void runStartNowOrSchedule() throws ClientException |
| | | { |
| | | if (args.startArg.isPresent()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void askToStartNowOrSchedule() throws CLIException |
| | | private void askToStartNowOrSchedule() throws ClientException |
| | | { |
| | | checkHeaderDisplay(); |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | throw new CLIException(LocalizableMessage.EMPTY); |
| | | throw new ClientException(ReturnCode.TODO, LocalizableMessage.EMPTY); |
| | | } |
| | | } |
| | | |
| | | private void askForStartDate() throws CLIException |
| | | private void askForStartDate() throws ClientException |
| | | { |
| | | checkHeaderDisplay(); |
| | | |
| | |
| | | uData.setStartDate(startDate); |
| | | } |
| | | |
| | | private void askForTaskSchedule() throws CLIException |
| | | private void askForTaskSchedule() throws ClientException |
| | | { |
| | | checkHeaderDisplay(); |
| | | |
| | |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | import static org.opends.server.util.StaticUtils.wrapText; |
| | | import static org.opends.server.util.StaticUtils.getExceptionMessage; |
| | |
| | | * been called. |
| | | * |
| | | * @throws ArgumentException if there is a problem with the arguments. |
| | | * @throws CLIException if there is a problem with one of the values provided |
| | | * @throws ClientException if there is a problem with one of the values provided |
| | | * by the user. |
| | | */ |
| | | protected void validateTaskArgs() throws ArgumentException, CLIException |
| | | protected void validateTaskArgs() throws ArgumentException, ClientException |
| | | { |
| | | if (processAsTask()) |
| | | { |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS |
| | | * Copyright 2013-2014 ForgeRock AS |
| | | */ |
| | | package org.opends.server.tools.upgrade; |
| | | |
| | | import org.opends.server.tools.ClientException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | /** |
| | | * Abstract upgrade task implementation. |
| | |
| | | import javax.security.auth.callback.ConfirmationCallback; |
| | | |
| | | import org.opends.server.core.LockFileManager; |
| | | import org.opends.server.tools.ClientException; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.StaticUtils; |
| | | |
| | |
| | | { |
| | | final LocalizableMessage message = INFO_UPGRADE_ABORTED_BY_USER.get(); |
| | | context.notify(message, WARNING); |
| | | throw new ClientException(EXIT_CODE_ERROR, message); |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, message); |
| | | } |
| | | |
| | | try |
| | |
| | | { |
| | | final LocalizableMessage message = ERR_UPGRADE_TASKS_FAIL.get(e.getMessage()); |
| | | context.notify(message, ERROR_CALLBACK); |
| | | throw new ClientException(EXIT_CODE_ERROR, message); |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, message); |
| | | } |
| | | finally |
| | | { |
| | |
| | | { |
| | | final LocalizableMessage message = ERR_UPGRADE_REQUIRES_SERVER_OFFLINE.get(); |
| | | context.notify(message, NOTICE_CALLBACK); |
| | | throw new ClientException(EXIT_CODE_ERROR, message); |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, message); |
| | | } |
| | | } |
| | | finally |
| | |
| | | final LocalizableMessage message = |
| | | ERR_UPGRADE_VERSION_UP_TO_DATE.get(context.getToVersion()); |
| | | context.notify(message, NOTICE_CALLBACK); |
| | | throw new ClientException(EXIT_CODE_SUCCESS, message); |
| | | throw new ClientException(ReturnCode.SUCCESS, message); |
| | | } |
| | | |
| | | // The upgrade only supports version >= 2.4.5. |
| | |
| | | final LocalizableMessage message = INFO_UPGRADE_VERSION_IS_NOT_SUPPORTED.get( |
| | | UPGRADESUPPORTSVERSIONFROM, UPGRADESUPPORTSVERSIONFROM); |
| | | context.notify(message, NOTICE_CALLBACK); |
| | | throw new ClientException(EXIT_CODE_ERROR, message); |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, message); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | final LocalizableMessage message = LocalizableMessage.raw(e.getMessage()); |
| | | context.notify(message, ERROR_CALLBACK); |
| | | throw new ClientException(EXIT_CODE_ERROR, message); |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, message); |
| | | } |
| | | finally |
| | | { |
| | |
| | | import javax.security.auth.callback.UnsupportedCallbackException; |
| | | |
| | | import org.opends.server.extensions.ConfigFileHandler; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.opends.server.util.StaticUtils; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.BooleanArgument; |
| | | import com.forgerock.opendj.cli.StringArgument; |
| | | import com.forgerock.opendj.cli.SubCommandArgumentParser; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import org.opends.server.util.cli.ConsoleApplication; |
| | | |
| | | /** |
| | |
| | | } |
| | | catch (ClientException ex) |
| | | { |
| | | return ex.getExitCode(); |
| | | return ex.getReturnCode(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | readInput(LocalizableMessage.raw(prompt), defaultOption, |
| | | Style.SUBTITLE); |
| | | } |
| | | catch (CLIException e) |
| | | catch (ClientException e) |
| | | { |
| | | logger.error(LocalizableMessage.raw(e.getMessage())); |
| | | break; |
| | |
| | | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.tools.upgrade.Upgrade.EXIT_CODE_ERROR; |
| | | |
| | | import javax.security.auth.callback.Callback; |
| | | import javax.security.auth.callback.CallbackHandler; |
| | |
| | | import javax.security.auth.callback.TextOutputCallback; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.opends.server.tools.ClientException; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.util.BuildVersion; |
| | | |
| | |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | throw new ClientException(EXIT_CODE_ERROR, |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, |
| | | ERR_UPGRADE_DISPLAY_NOTIFICATION_ERROR.get(e.getMessage())); |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | throw new ClientException(EXIT_CODE_ERROR, |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, |
| | | ERR_UPGRADE_DISPLAY_NOTIFICATION_ERROR.get(e.getMessage())); |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | throw new ClientException(EXIT_CODE_ERROR, |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, |
| | | ERR_UPGRADE_DISPLAY_NOTIFICATION_ERROR.get(e.getMessage())); |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (final Exception e) |
| | | { |
| | | throw new ClientException(EXIT_CODE_ERROR, |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, |
| | | ERR_UPGRADE_DISPLAY_CONFIRM_ERROR.get(e.getMessage())); |
| | | } |
| | | return confirmYNCallback.getSelectedIndex(); |
| | |
| | | import java.util.logging.Logger; |
| | | |
| | | import org.opends.messages.RuntimeMessages; |
| | | import org.opends.server.tools.ClientException; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | import static org.opends.messages.ToolMessages.ERR_UPGRADE_INVALID_LOG_FILE; |
| | | |
| | |
| | | } |
| | | catch (FileNotFoundException e) |
| | | { |
| | | throw new ClientException(1, ERR_UPGRADE_INVALID_LOG_FILE.get(e |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, ERR_UPGRADE_INVALID_LOG_FILE.get(e |
| | | .getMessage())); |
| | | } |
| | | } |
| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Copyright 2013 ForgeRock AS |
| | | * Copyright 2013-2014 ForgeRock AS |
| | | */ |
| | | |
| | | package org.opends.server.tools.upgrade; |
| | | |
| | | import org.opends.server.tools.ClientException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | /** |
| | | * An upgrade task. |
| | |
| | | import javax.security.auth.callback.TextOutputCallback; |
| | | |
| | | import org.forgerock.opendj.ldap.Filter; |
| | | import org.opends.server.tools.ClientException; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | import org.opends.server.tools.RebuildIndex; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.ChangeOperationType; |
| | |
| | | { |
| | | final LocalizableMessage msg = ERR_UPGRADE_PERFORMING_POST_TASKS_FAIL.get(); |
| | | context.notifyProgress(pnc.setProgress(-100)); |
| | | throw new ClientException(EXIT_CODE_ERROR, msg); |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, msg); |
| | | } |
| | | } |
| | | else |
| | |
| | | logger.error(message); |
| | | if (!context.isIgnoreErrorsMode()) |
| | | { |
| | | throw new ClientException(EXIT_CODE_ERROR, message); |
| | | throw new ClientException(ReturnCode.ERROR_UNEXPECTED, message); |
| | | } |
| | | } |
| | | |
| | |
| | | import org.opends.admin.ads.util.ConnectionUtils; |
| | | import org.opends.admin.ads.util.OpendsCertificateException; |
| | | import org.opends.quicksetup.util.Utils; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.util.PasswordReader; |
| | | import org.opends.server.util.SetupUtils; |
| | | import org.opends.server.util.StaticUtils; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import com.forgerock.opendj.cli.ReturnCode; |
| | | |
| | | |
| | | /** |
| | |
| | | * @return Returns <code>true</code> if the user wishes the action to be |
| | | * performed, or <code>false</code> if they refused, or if an |
| | | * exception occurred. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If the user's response could not be read from the console for |
| | | * some reason. |
| | | */ |
| | | public final boolean confirmAction(LocalizableMessage prompt, final boolean defaultValue) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | if (!isInteractive()) |
| | | { |
| | |
| | | { |
| | | readLineOfInput(msg); |
| | | } |
| | | catch (CLIException e) |
| | | catch (ClientException e) |
| | | { |
| | | // Ignore the exception - applications don't care. |
| | | } |
| | |
| | | * The prompt. |
| | | * @return Returns the line of input, or <code>null</code> if the end of input |
| | | * has been reached. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If the line of input could not be retrieved for some reason. |
| | | */ |
| | | public final String readLineOfInput(LocalizableMessage prompt) throws CLIException |
| | | public final String readLineOfInput(LocalizableMessage prompt) throws ClientException |
| | | { |
| | | if (prompt != null) |
| | | { |
| | |
| | | String s = in.readLine(); |
| | | if (s == null) |
| | | { |
| | | throw CLIException |
| | | throw ClientException |
| | | .adaptInputException(new EOFException("End of input")); |
| | | } |
| | | else |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | throw CLIException.adaptInputException(e); |
| | | throw ClientException.adaptInputException(e); |
| | | } |
| | | } |
| | | |
| | |
| | | * @param msgStyle |
| | | * The formatted style chosen. |
| | | * @return The user's input as a string. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If an Exception occurs during the process. |
| | | */ |
| | | public final String readInput(final LocalizableMessage prompt, |
| | | final String defaultValue, final Style msgStyle) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | String answer = null; |
| | | if (msgStyle == Style.TITLE) |
| | |
| | | } |
| | | catch (IOException e) |
| | | { |
| | | throw CLIException.adaptInputException(e); |
| | | throw ClientException.adaptInputException(e); |
| | | } |
| | | |
| | | if (msgStyle == Style.TITLE |
| | |
| | | * The default value to assume if the user presses ENTER without |
| | | * typing anything, or <CODE>null</CODE> if there should not be a |
| | | * default and the user must explicitly provide a value. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If the line of input could not be retrieved for some reason. |
| | | * @return The string value read from the user. |
| | | */ |
| | | public String readInput(LocalizableMessage prompt, String defaultValue) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | while (true) |
| | | { |
| | |
| | | { |
| | | s = readInput(prompt, defaultValue); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce)); |
| | | } |
| | |
| | | * @param prompt |
| | | * The password prompt. |
| | | * @return Returns the password. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If the password could not be retrieved for some reason. |
| | | */ |
| | | public final String readPassword(LocalizableMessage prompt) throws CLIException |
| | | public final String readPassword(LocalizableMessage prompt) throws ClientException |
| | | { |
| | | err.print(wrapText(prompt + " ", MAX_LINE_WIDTH)); |
| | | char[] pwChars; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw CLIException.adaptInputException(e); |
| | | throw ClientException.adaptInputException(e); |
| | | } |
| | | return new String(pwChars); |
| | | } |
| | |
| | | { |
| | | pwd = readPassword(prompt); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce)); |
| | | } |
| | |
| | | * @param defaultValue |
| | | * The port default value. |
| | | * @return Returns the port. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If the port could not be retrieved for some reason. |
| | | */ |
| | | public final int readPort(LocalizableMessage prompt, final int defaultValue) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | ValidationCallback<Integer> callback = new ValidationCallback<Integer>() |
| | | { |
| | | @Override |
| | | public Integer validate(ConsoleApplication app, String input) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | String ninput = input.trim(); |
| | | if (ninput.length() == 0) |
| | |
| | | { |
| | | port = readPort(prompt, defaultValue); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | port = -1; |
| | | logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce)); |
| | |
| | | * An input validator responsible for validating and decoding the |
| | | * user's response. |
| | | * @return Returns the decoded user's response. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If an unexpected error occurred which prevented validation. |
| | | */ |
| | | public final <T> T readValidatedInput(LocalizableMessage prompt, |
| | | ValidationCallback<T> validator) throws CLIException |
| | | ValidationCallback<T> validator) throws ClientException |
| | | { |
| | | while (true) |
| | | { |
| | |
| | | * @param maxTries |
| | | * The maximum number of tries that we can make. |
| | | * @return Returns the decoded user's response. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If an unexpected error occurred which prevented validation or if |
| | | * the maximum number of tries was reached. |
| | | */ |
| | | public final <T> T readValidatedInput(LocalizableMessage prompt, |
| | | ValidationCallback<T> validator, int maxTries) throws CLIException |
| | | ValidationCallback<T> validator, int maxTries) throws ClientException |
| | | { |
| | | int nTries = 0; |
| | | while (nTries < maxTries) |
| | |
| | | } |
| | | nTries++; |
| | | } |
| | | throw new CLIException(ERR_TRIES_LIMIT_REACHED.get(maxTries)); |
| | | throw new ClientException(ReturnCode.TODO, ERR_TRIES_LIMIT_REACHED.get(maxTries)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * the Logger to be used to log the error message. |
| | | * @return Returns <code>true</code> if the user wishes the action to be |
| | | * performed, or <code>false</code> if they refused. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * if the user did not provide valid answer after a certain number |
| | | * of tries (ConsoleApplication.CONFIRMATION_MAX_TRIES) |
| | | */ |
| | | protected final boolean askConfirmation(LocalizableMessage prompt, boolean defaultValue, |
| | | LocalizedLogger logger) throws CLIException |
| | | LocalizedLogger logger) throws ClientException |
| | | { |
| | | boolean v = defaultValue; |
| | | |
| | |
| | | v = confirmAction(prompt, defaultValue); |
| | | done = true; |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | if (StaticUtils.hasDescriptor(ce.getMessageObject(), |
| | | ERR_CONFIRMATION_TRIES_LIMIT_REACHED) |
| | |
| | | if (!done) |
| | | { |
| | | // This means we reached the maximum number of tries |
| | | throw new CLIException(ERR_CONFIRMATION_TRIES_LIMIT_REACHED |
| | | throw new ClientException(ReturnCode.TODO, ERR_CONFIRMATION_TRIES_LIMIT_REACHED |
| | | .get(CONFIRMATION_MAX_TRIES)); |
| | | } |
| | | return v; |
| | |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED.get(hostName, portNumber); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | if (e.getCause() instanceof SSLException) |
| | |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get(hostName, portNumber); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | String hostPort = |
| | | ServerDescriptor.getServerRepresentation(hostName, portNumber); |
| | | LocalizableMessage message = Utils.getMessageForException(e, hostPort); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber); |
| | | throw new ClientException( |
| | | LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message); |
| | | } |
| | | } |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | LocalizableMessage message = |
| | | ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber); |
| | | throw new ClientException(LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR, |
| | | message); |
| | | } |
| | | } |
| | |
| | | { |
| | | s = readInput(INFO_ADMINISTRATOR_UID_PROMPT.get(), defaultValue); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce)); |
| | | } |
| | |
| | | { |
| | | newInt = readInteger(prompt, defaultValue); |
| | | } |
| | | catch (CLIException ce) |
| | | catch (ClientException ce) |
| | | { |
| | | newInt = -1; |
| | | logger.warn(LocalizableMessage.raw("Error reading input: " + ce, ce)); |
| | |
| | | * @param defaultValue |
| | | * The default value. |
| | | * @return Returns the value. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If the value could not be retrieved for some reason. |
| | | */ |
| | | public final int readInteger(LocalizableMessage prompt, final int defaultValue) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | ValidationCallback<Integer> callback = new ValidationCallback<Integer>() |
| | | { |
| | | @Override |
| | | public Integer validate(ConsoleApplication app, String input) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | String ninput = input.trim(); |
| | | if (ninput.length() == 0) |
| | |
| | | import org.opends.server.tools.SSLConnectionException; |
| | | import org.opends.server.admin.client.cli.SecureConnectionCliArgs; |
| | | import com.forgerock.opendj.cli.ArgumentException; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | import org.opends.server.util.SelectableCertificateKeyManager; |
| | | import org.opends.admin.ads.ADSContext; |
| | | import org.opends.admin.ads.util.ApplicationTrustManager; |
| | |
| | | { |
| | | |
| | | public String validate(ConsoleApplication app, String input) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | String ninput = input.trim(); |
| | | if (ninput.length() == 0) |
| | |
| | | hostName = app.readValidatedInput(INFO_LDAP_CONN_PROMPT_HOST_NAME |
| | | .get(hostName), callback); |
| | | } |
| | | catch (CLIException e) |
| | | catch (ClientException e) |
| | | { |
| | | throw ArgumentExceptionFactory.unableToReadConnectionParameters(e); |
| | | } |
| | |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | catch (CLIException e) |
| | | catch (ClientException e) |
| | | { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | { |
| | | |
| | | public Integer validate(ConsoleApplication app, String input) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | String ninput = input.trim(); |
| | | if (ninput.length() == 0) |
| | |
| | | } |
| | | portNumber = app.readValidatedInput(askPortNumber, callback); |
| | | } |
| | | catch (CLIException e) |
| | | catch (ClientException e) |
| | | { |
| | | throw ArgumentExceptionFactory.unableToReadConnectionParameters(e); |
| | | } |
| | |
| | | { |
| | | |
| | | public String validate(ConsoleApplication app, String input) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | String ninput = input.trim(); |
| | | if (ninput.length() == 0) |
| | |
| | | providedBindDN = bindDN; |
| | | } |
| | | } |
| | | catch (CLIException e) |
| | | catch (ClientException e) |
| | | { |
| | | throw ArgumentExceptionFactory |
| | | .unableToReadConnectionParameters(e); |
| | |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | catch (CLIException e) |
| | | catch (ClientException e) |
| | | { |
| | | throw new RuntimeException(e); |
| | | |
| | |
| | | ValidationCallback<String> callback = new ValidationCallback<String>() |
| | | { |
| | | public String validate(ConsoleApplication app, String input) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | String ninput = input.trim(); |
| | | if (ninput.length() == 0) |
| | |
| | | truststorePath = app.readValidatedInput( |
| | | INFO_LDAP_CONN_PROMPT_SECURITY_TRUSTSTORE_PATH.get(), callback); |
| | | } |
| | | catch (CLIException e) |
| | | catch (ClientException e) |
| | | { |
| | | throw ArgumentExceptionFactory.unableToReadConnectionParameters(e); |
| | | } |
| | |
| | | ValidationCallback<String> callback = new ValidationCallback<String>() |
| | | { |
| | | public String validate(ConsoleApplication app, String input) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | String ninput = input.trim(); |
| | | if (ninput.length() == 0) |
| | |
| | | keystorePath = app.readValidatedInput( |
| | | INFO_LDAP_CONN_PROMPT_SECURITY_KEYSTORE_PATH.get(), callback); |
| | | } |
| | | catch (CLIException e) |
| | | catch (ClientException e) |
| | | { |
| | | throw ArgumentExceptionFactory.unableToReadConnectionParameters(e); |
| | | } |
| | |
| | | { |
| | | throw ArgumentExceptionFactory.unableToReadConnectionParameters(e); |
| | | } |
| | | catch (CLIException e) |
| | | catch (ClientException e) |
| | | { |
| | | throw ArgumentExceptionFactory.unableToReadConnectionParameters(e); |
| | | } |
| | |
| | | new ValidationCallback<String>() |
| | | { |
| | | public String validate(ConsoleApplication app, String input) |
| | | throws CLIException |
| | | throws ClientException |
| | | { |
| | | String ninput = input.trim(); |
| | | if (ninput.length() == 0) |
| | |
| | | INFO_LDAP_CONN_PROMPT_SECURITY_TRUSTSTORE_PATH.get(), |
| | | callback); |
| | | } |
| | | catch (CLIException e) |
| | | catch (ClientException e) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | catch (CLIException cliE) |
| | | catch (ClientException cliE) |
| | | { |
| | | throw new RuntimeException(cliE); |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.util.cli; |
| | | |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | |
| | | |
| | |
| | | * with the option will be invoked and its result returned. |
| | | * |
| | | * @return Returns the result of invoking the chosen menu call-back. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If an I/O exception occurred or if one of the menu |
| | | * option call-backs failed for some reason. |
| | | */ |
| | | MenuResult<T> run() throws CLIException; |
| | | MenuResult<T> run() throws ClientException; |
| | | } |
| | |
| | | import org.opends.server.util.table.TableBuilder; |
| | | import org.opends.server.util.table.TablePrinter; |
| | | import org.opends.server.util.table.TextTablePrinter; |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public MenuResult<T> invoke(ConsoleApplication app) throws CLIException { |
| | | public MenuResult<T> invoke(ConsoleApplication app) throws ClientException { |
| | | List<T> values = new ArrayList<T>(); |
| | | for (MenuCallback<T> callback : callbacks) { |
| | | MenuResult<T> result = callback.invoke(app); |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public MenuResult<T> run() throws CLIException { |
| | | public MenuResult<T> run() throws ClientException { |
| | | // The validation call-back which will be used to determine the |
| | | // action call-back. |
| | | ValidationCallback<MenuCallback<T>> validator = |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | public MenuResult<T> invoke(ConsoleApplication app) throws CLIException { |
| | | public MenuResult<T> invoke(ConsoleApplication app) throws ClientException { |
| | | return result; |
| | | } |
| | | |
| | |
| | | public void addHelpOption(final HelpCallback callback) { |
| | | MenuCallback<T> wrapper = new MenuCallback<T>() { |
| | | |
| | | public MenuResult<T> invoke(ConsoleApplication app) throws CLIException { |
| | | public MenuResult<T> invoke(ConsoleApplication app) throws ClientException { |
| | | app.println(); |
| | | callback.display(app); |
| | | return MenuResult.again(); |
| | |
| | | /** |
| | | * Sets the maximum number of tries that the user can provide an invalid |
| | | * value in the menu. -1 for unlimited tries (the default). If this limit is |
| | | * reached a CLIException will be thrown. |
| | | * reached a ClientException will be thrown. |
| | | * @param nTries the maximum number of tries. |
| | | */ |
| | | public void setMaxTries(int nTries) |
| | |
| | | */ |
| | | package org.opends.server.util.cli; |
| | | |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | |
| | | /** |
| | |
| | | * @param app |
| | | * The application console. |
| | | * @return Returns the result of invoking the menu call-back. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If the menu call-back fails for some reason. |
| | | */ |
| | | MenuResult<T> invoke(ConsoleApplication app) throws CLIException; |
| | | MenuResult<T> invoke(ConsoleApplication app) throws ClientException; |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.util.cli; |
| | | |
| | | import com.forgerock.opendj.cli.CLIException; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | |
| | | /** |
| | |
| | | * The user input to be validated. |
| | | * @return Returns the decoded input if the input is valid, or |
| | | * <code>null</code> if it is not. |
| | | * @throws CLIException |
| | | * @throws ClientException |
| | | * If an unexpected error occurred which prevented |
| | | * validation. |
| | | */ |
| | | T validate(ConsoleApplication app, String input) throws CLIException; |
| | | T validate(ConsoleApplication app, String input) throws ClientException; |
| | | } |
| | |
| | | import org.opends.server.tools.*; |
| | | import static org.testng.Assert.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | |
| | | |
| | |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.testng.Assert.*; |
| | | import com.forgerock.opendj.cli.ClientException; |
| | | |
| | | |
| | | |