Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Bug 1194690 - CLI doesn't work when agent-server communication uses
Browse files Browse the repository at this point in the history
sslsocket

Update LoginCommand so transport can be specified as one of [http, https,
socket, sslsocket].

(cherry picked from commit 37310ac)
  • Loading branch information
Libor Zoubek authored and Michael Burman committed Apr 2, 2015
1 parent f4a606b commit 2d0895d
Showing 1 changed file with 13 additions and 4 deletions.
Expand Up @@ -21,6 +21,8 @@

import java.io.PrintWriter;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand All @@ -36,6 +38,7 @@
*/
public class LoginCommand implements ClientCommand {
private static final Log LOG = LogFactory.getLog(LoginCommand.class);
private static final List<String> SUPPORTED_TRANSPORTS = Arrays.asList("http", "https", "socket", "sslsocket");

//Added to switch between jbossRemoting and WS subsystems
private String subsystem = null;
Expand Down Expand Up @@ -82,8 +85,9 @@ public boolean execute(ClientMain client, String[] args) {
argIndex++;
if (args.length > argIndex) {
transport = args[argIndex];
if (!"http".equals(transport) || !"https".equals(transport)) {
printWriter.println("Invalid transport [" + transport + "], should be either http or https");
if (!SUPPORTED_TRANSPORTS.contains(transport)) {
printWriter.println("Invalid transport [" + transport + "], must be one of "
+ Arrays.toString(SUPPORTED_TRANSPORTS.toArray()));
return true;
}
}
Expand Down Expand Up @@ -164,7 +168,12 @@ private String usage() {

@Override
public String getSyntax() {
return getPromptCommandString() + " username password [host]|[host port]|[host port <http>|<https>]";
StringBuilder transports = new StringBuilder();
for (String t : SUPPORTED_TRANSPORTS) {
transports.append("<" + t + ">|");
}
transports.deleteCharAt(transports.length() - 1);
return getPromptCommandString() + " username password [host]|[host port]|[host port " + transports + "]";
}

@Override
Expand All @@ -178,6 +187,6 @@ public String getDetailedHelp() {
+ "name and port may optionally be specified. The host name defaults to "
+ "localhost and the port to 7080. You may also specify the transport "
+ "to use when communicating with the server; it must be one " //
+ "of 'servlet' or 'sslservlet'.";
+ "of " + SUPPORTED_TRANSPORTS + ".";
}
}

0 comments on commit 2d0895d

Please sign in to comment.