From db531e4359788d3e6b97df7f69d7c131f8ec33b6 Mon Sep 17 00:00:00 2001 From: Cheolsoo Park Date: Mon, 17 Dec 2012 13:10:11 -0800 Subject: [PATCH] SQOOP-776: show connection command shows password in plain text (Jarek Jarcec Cecho via Cheolsoo Park) --- .../sqoop/client/utils/FormDisplayer.java | 72 ++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java b/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java index 97eea795..4d0442fb 100644 --- a/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java +++ b/client/src/main/java/org/apache/sqoop/client/utils/FormDisplayer.java @@ -22,13 +22,16 @@ import org.apache.sqoop.model.MFramework; import org.apache.sqoop.model.MInput; import org.apache.sqoop.model.MInputType; +import org.apache.sqoop.model.MIntegerInput; import org.apache.sqoop.model.MJobForms; +import org.apache.sqoop.model.MMapInput; import org.apache.sqoop.model.MStringInput; import org.apache.sqoop.utils.StringUtils; import org.codehaus.groovy.tools.shell.IO; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.ResourceBundle; /** @@ -128,12 +131,79 @@ private static void displayForm(IO io, MForm form, ResourceBundle bundle) { io.out.print(bundle.getString(input.getLabelKey())); io.out.print(": "); if(!input.isEmpty()) { - io.out.print(input.getUrlSafeValueString()); + // Based on the input type, let's perform specific load + switch (input.getType()) { + case STRING: + displayInputString(io, (MStringInput) input); + break; + case INTEGER: + displayInputInteger(io, (MIntegerInput) input); + break; + case MAP: + displayInputMap(io, (MMapInput) input); + break; + case ENUM: + displayInputEnum(io, (MEnumInput) input); + break; + default: + io.out.println("Unsupported data type " + input.getType()); + return; + } } io.out.println(""); } } + /** + * Display content of String input. + * + * @param io Shell's IO object + * @param input String input + */ + private static void displayInputString(IO io, MStringInput input) { + if (input.isMasked()) { + io.out.print("(This input is sensitive)"); + } else { + io.out.print(input.getValue()); + } + } + + /** + * Display content of Integer input. + * + * @param io Shell's IO object + * @param input Integer input + */ + private static void displayInputInteger(IO io, MIntegerInput input) { + io.out.print(input.getValue()); + } + + /** + * Display content of Map input + * + * @param io Shell's IO object + * @param input Map input + */ + private static void displayInputMap(IO io, MMapInput input) { + for(Map.Entry entry : input.getValue().entrySet()) { + io.out.println(); + io.out.print(" "); + io.out.print(entry.getKey()); + io.out.print(" = "); + io.out.print(entry.getValue()); + } + } + + /** + * Display content of Enum input + * + * @param io Shell's IO object + * @param input Enum input + */ + private static void displayInputEnum(IO io, MEnumInput input) { + io.out.print(input.getValue()); + } + private FormDisplayer() { // Do not instantiate }