public String getInputNomask(String prompt, boolean isNotInputMask) throws IOException, UserInterruption { String userInput = ""; String breakConnectPrompt = EXIT_PROD_STR; if (isNotInputMask) breakConnectPrompt = "Command Interrupted - Please hit <Enter> ... "; crObj.setPrompt(breakConnectPrompt, false, false); try { System.out.print(" \r" + prompt); userInput = crObj.getLine(); } catch (Throwable t) { UserInterruption uie = null; if (t instanceof UserInterruption) { uie = (UserInterruption) t; retryCnt = 0; } else uie = new UserInterruption(); throw uie; } finally { cwObj.print(SessionDefaults.lineSeperator); } // return characters entered by the user return userInput; }
public String getInputMask(String prompt, boolean isInputMask) throws IOException, UserInterruption { String password = ""; WCIUtils wcs = null; boolean isWindows = System.getProperty("os.name").toUpperCase().startsWith("WINDOW"); MaskingThread et = new MaskingThread(prompt); Thread mask = new Thread(et); mask.start(); // if it is windows envrionment use the dll to disable echo if (isWindows) { try { wcs = new WCIUtils(); wcs.disableEcho(); } catch (Throwable e) { } } crObj.setMaskingThread(et, wcs); String breakConnectPrompt = EXIT_PROD_STR; if (!this.isLaunchConnect || isInputMask) breakConnectPrompt = "Command Interrupted - Please hit <Enter> ... " + SessionDefaults.lineSeperator; crObj.setPrompt(breakConnectPrompt, false, false); try { password = crObj.getLine(); } catch (Throwable t) { UserInterruption uie = null; if (t instanceof UserInterruption) { uie = (UserInterruption) t; retryCnt = 0; } else uie = new UserInterruption(); throw uie; } finally { // stop masking et.stopMasking(); if (isWindows) { try { wcs.enableEcho(); } catch (Exception e) { } wcs = null; } cwObj.print(SessionDefaults.lineSeperator); } // return the password entered by the user return password; }
private String getRequiredArg(String prompt) throws IOException, UserInterruption { String value = null; String breakConnectPrompt = EXIT_PROD_STR; if (!this.isLaunchConnect) breakConnectPrompt = "Command Interrupted - Please hit <Enter> ... " + SessionDefaults.lineSeperator; crObj.setPrompt(breakConnectPrompt, false, false); cwObj.print(prompt); // set retry count to 0 if user hits a Ctrl+C while entering login parameters try { value = crObj.getLine(); } catch (UserInterruption ui) { retryCnt = 0; throw ui; } return value; }