Package java.io

Examples of java.io.Console$LineReader


    }
  }
 
  @Override
  public boolean promptForIdentity(String message) {
    final Console console = System.console();
    showHeader(console);
   
    final String line = console.readLine("# %s [~/.ssh/id_pub]: ", message);
    final File home = new File(System.getProperty("java.home"));
   
    if (line == null || line.length() == 0) {
      identity = new File(home, ".ssh/id_pub").getAbsolutePath();
      return true;
View Full Code Here


    return true;
  }

  @Override
  public void showMessage(String message) {
    final Console console = System.console();
    showHeader(console);
    console.printf("# %s\n#\n", message);
  }
View Full Code Here

  public static String[] create(String title, String description, String username, String password) {
    if (!GraphicsEnvironment.isHeadless()) {
      return swingCredentialsDialog(title, description, username, password);
    }

    final Console console = System.console();
    console.printf("#\n# %s\n# %s\n#\n", title, description);
    final String user = console.readLine("# %s: ", username);
    final char[] pass = console.readPassword("# %s: ", password);
    console.printf("#\n");

    return new String[] { user, new String(pass) };
  }
View Full Code Here

    public static char[] getSensitiveValue(String passwordPrompt) {
        while (true) {
            if (passwordPrompt == null)
                passwordPrompt = "Enter your password";

            Console console = System.console();

            char[] passwd = console.readPassword(passwordPrompt + ": ");
            char[] passwd1 = console.readPassword(passwordPrompt + " again: ");
            boolean noMatch = !Arrays.equals(passwd, passwd1);
            if (noMatch)
                System.out.println("Values entered don't match");
            else {
                System.out.println("Values match");
View Full Code Here

    public VaultInteractiveSession() {
    }

    public void start() {
        Console console = System.console();

        if (console == null) {
            System.err.println("No console.");
            System.exit(1);
        }

        while (encDir == null || encDir.length() == 0 || !(encDir.endsWith("/") || encDir.endsWith("\\"))) {
            encDir = console
                    .readLine("Enter directory to store encrypted files (end with either / or \\ based on Unix or Windows:");
        }

        while (keystoreURL == null || keystoreURL.length() == 0) {
            keystoreURL = console.readLine("Enter Keystore URL:");
        }

        char[] keystorePasswd = getSensitiveValue("Enter Keystore password");

        try {
            maskedPassword = getMaskedPassword(console, new String(keystorePasswd));
            System.out.println("                ");
            System.out.println("Please make note of the following:");
            System.out.println("********************************************");
            System.out.println("Masked Password:" + maskedPassword);
            System.out.println("salt:" + salt);
            System.out.println("Iteration Count:" + iterationCount);
            System.out.println("********************************************");
            System.out.println("                ");
        } catch (Exception e) {
            System.out.println("Exception encountered:" + e.getLocalizedMessage());
        }

        while (keystoreAlias == null || keystoreAlias.length() == 0) {
            keystoreAlias = console.readLine("Enter Keystore Alias:");
        }

        try {
            vault = SecurityVaultFactory.get();
            System.out.println("Obtained Vault");
View Full Code Here

     * Asks for the password.
     */
    private static class InteractivelyAskForPassword implements Callable<String,IOException> {
        @IgnoreJRERequirement
        public String call() throws IOException {
            Console console = System.console();
            if (console == null)    return null;    // no terminal

            char[] w = console.readPassword("Password:");
            if (w==null)    return null;
            return new String(w);
        }
View Full Code Here

    @Override
    public void login(Credentials credentials) throws IOException, CryptoException {
        System.out.println("Input login:");
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        credentials.setUsername(bufferedReader.readLine());
        Console cons = System.console();
        char[] passwd = null;
        if (cons != null) {
            passwd = cons.readPassword("[%s]", "Password:");
        } else {
            System.out.println("Input password(it is not hidden!):");
            passwd = bufferedReader.readLine().toCharArray();
        }
        credentials.setHashedPassword(CryptoUtil.cryptPassword(passwd));
View Full Code Here

      Logger.getLogger("com.almworks.sqlite4java").setLevel(Level.OFF);
      Logger.getLogger("com.k42b3.kadabra").setLevel(Level.OFF);


      // start kadabra
      Console console = System.console();
      Kadabra instance = new Kadabra();

      if(args.length == 2 && args[0].equals("status"))
      {
        int id = Integer.parseInt(args[1]);

        instance.status(id);
      }
      else if(args.length == 2 && args[0].equals("release"))
      {
        int id = Integer.parseInt(args[1]);

        instance.release(id);
      }
      else if(args.length == 1 && args[0].equals("list"))
      {
        instance.listProject();
      }
      else if(args.length == 2 && args[0].equals("list") && args[1].equals("resource"))
      {
        instance.listResource();
      }
      else if(args.length == 1 && args[0].equals("add"))
      {
        String name = console.readLine("Name: ");

        String leftPath = console.readLine("Left path: ");
        int legtResourceId = Integer.parseInt(console.readLine("Left resource id: "));

        String rightPath = console.readLine("Right path: ");
        int rightResourceId = Integer.parseInt(console.readLine("Right resource id: "));

        instance.addProject(name, leftPath, legtResourceId, rightPath, rightResourceId);
      }
      else if(args.length == 2 && args[0].equals("add") && args[1].equals("resource"))
      {
        String type = console.readLine("Type [System|Ftp|Ssh]: ").toUpperCase();
        HashMap<String, String> config = new HashMap<String, String>();
        ArrayList<String> configFields = HandlerFactory.factoryConfig(type);

        String name = console.readLine("Name: ");

        for(int i = 0; i < configFields.size(); i++)
        {
          String key = configFields.get(i);
          String value = console.readLine(key + ": ");

          config.put(key, value);
        }

        instance.addResource(type, name, config);
      }
      else if(args.length == 2 && args[0].equals("add") && args[1].equals("exclude"))
      {
        int projectId = Integer.parseInt(console.readLine("Project ID: "));
        String pattern = console.readLine("Pattern: ");

        instance.addExclude(projectId, pattern);
      }
      else if(args.length == 1 && args[0].equals("del"))
      {
        int projectId = Integer.parseInt(console.readLine("Project ID: "));

        instance.deleteProject(projectId);
      }
      else if(args.length == 2 && args[0].equals("del") && args[1].equals("resource"))
      {
        int resourceId = Integer.parseInt(console.readLine("Resource ID: "));

        instance.deleteResource(resourceId);
      }
      else if(args.length == 2 && args[0].equals("del") && args[1].equals("exclude"))
      {
        int excludeId = Integer.parseInt(console.readLine("Exclude ID: "));

        instance.deleteExclude(excludeId);
      }
      else if(args.length == 1 && args[0].equals("build"))
      {
View Full Code Here

            case 'e': {
                // Prompt for the property and value to be encoded.
                // Don't use a command line option because the plain text password
                // could get captured in command history.
                Console console = System.console();
                if (null != console) {
                    associatedProperty = "rhq.autoinstall.server.admin.password";
                    if (!confirm(console, "Property " + associatedProperty)) {
                        associatedProperty = "rhq.server.database.password";
                        if (!confirm(console, "Property " + associatedProperty)) {
                            associatedProperty = ask(console, "Property: ");
                        }
                    }

                    String prompt = "Value: ";
                    if (associatedProperty != null && associatedProperty.toLowerCase().contains("password")) {
                        prompt = "Password: ";
                    }

                    valueToEncode = String.valueOf(console.readLine("%s", prompt));
                } else {
                    LOG.error("NO CONSOLE!");
                }

                break;
View Full Code Here

        String propertyValue = props.getProperty(propertyName);
        if (StringUtil.isBlank(propertyValue)) {

            // prompt for the property value
            Console console = System.console();
            console.format("\nThe [%s] property is required but not set in [%s].\n", propertyName, propertiesFileName);
            console.format("Do you want to set [%s] value now?\n", propertyName);
            String response = "";
            while (!(response.startsWith("n") || response.startsWith("y"))) {
                response = String.valueOf(console.readLine("%s", "yes|no: ")).toLowerCase();
            }
            if (response.startsWith("n")) {
                throw new RHQControlException("Please update the [" + propertiesFileName + "] file as required.");
            }

            do {
                propertyValue = "";
                while (StringUtil.isBlank(propertyValue)) {
                    if (!hideInput) {
                        propertyValue = String.valueOf(console.readLine("%s", propertyName
                            + (((obfuscate || encode) ? " (enter as plain text): " : ": "))));
                    } else {
                        propertyValue = String.valueOf(console.readPassword("%s", propertyName
                            + (((obfuscate || encode) ? " (enter as plain text): " : ": "))));
                    }
                }

                if (!hideInput) {
                    console.format("Is [" + propertyValue + "] correct?\n");
                    response = "";
                    while (!(response.startsWith("n") || response.startsWith("y"))) {
                        response = String.valueOf(console.readLine("%s", "yes|no: ")).toLowerCase();
                    }
                } else {
                    console.format("Confirm:\n");
                    String confirmValue = String.valueOf(console.readPassword("%s", propertyName
                        + (((obfuscate || encode) ? " (enter as plain text): " : ": "))));
                    if (propertyValue.equals(confirmValue)) {
                        response = "yes";
                    } else {
                        response = "no";
                        console.printf("Did not match. Please try again.\n");
                    }
                }
            } while (response.startsWith("n"));

            propertyValue = obfuscate ? Obfuscator.encode(propertyValue) : propertyValue;
View Full Code Here

TOP

Related Classes of java.io.Console$LineReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.