Package java.io

Examples of java.io.Console.readPassword()


        PasswordCallback passwordCallback = (PasswordCallback) callbacks[i];

        if (password == null) {
          // It is used instead of cons.readPassword(prompt), because the prompt
          // may contain '%' characters
          passwordCallback.setPassword(cons.readPassword("%s", new Object[] {((PasswordCallback) callbacks[i]).getPrompt()}));
        }
        else {
          passwordCallback.setPassword(password);
        }
      }
View Full Code Here


                password = pass.toCharArray();
            } else {
                try {
                    Console console = System.console();
                    if (console != null) {
                        password = console.readPassword("Password: ");
                    } else {
                        log.info("No console detected for password input.");
                    }
                } catch (Throwable t) {
                    log.error("Unexpected error while reading password", t);
View Full Code Here

            password = pass.toCharArray();
        } else {
            try {
                Console console = System.console();
                if (console != null) {
                    password = console.readPassword("Password: ");
                } else {
                    log.info("No console detected for password input.");
                }
            } catch (Throwable t) {
                log.error("Unexpected error while reading password", t);
View Full Code Here

                try {
                    // verify password
                    char[] verify = null;
                    Console console = System.console();
                    if (console != null) {
                        verify = console.readPassword("Re-type Password: ");
                    } else {
                        log.info("No console detected for password verification.");
                    }
                    if (verify == null || verify.length != password.length) {
                        System.err.println("Passwords do not match.");
View Full Code Here

      System.exit(1);
    }
 
    boolean noMatch;
    do {
        char [] newPassword1 = c.readPassword("Enter master secret: ");
        char [] newPassword2 = c.readPassword("Enter master secret again: ");
        noMatch = ! Arrays.equals(newPassword1, newPassword2);
        if (noMatch) {
            c.format("Passwords don't match. Try again.%n");
        } else {
View Full Code Here

    }
 
    boolean noMatch;
    do {
        char [] newPassword1 = c.readPassword("Enter master secret: ");
        char [] newPassword2 = c.readPassword("Enter master secret again: ");
        noMatch = ! Arrays.equals(newPassword1, newPassword2);
        if (noMatch) {
            c.format("Passwords don't match. Try again.%n");
        } else {
            this.master = Arrays.copyOf(newPassword1, newPassword1.length);
View Full Code Here

          if (callbacks[i] instanceof PasswordCallback)
          {
            if (password==null)
            {
              //It is used instead of cons.readPassword(prompt), because the prompt may contain '%' characters
              ((PasswordCallback)callbacks[i]).setPassword(cons.readPassword("%s", new Object[]{((PasswordCallback)callbacks[i]).getPrompt()}));
            } else {
              ((PasswordCallback)callbacks[i]).setPassword(password);
            }
          } else {
            throw new UnsupportedCallbackException(callbacks[i]);
View Full Code Here

            String passwd = cliRequest.commandLine.getOptionValue( CLIManager.ENCRYPT_MASTER_PASSWORD );
           
            if ( passwd == null )
            {
                Console cons = System.console();
                char[] password = ( cons == null ) ? null : cons.readPassword( "Master password: " );
                if ( password != null )
                {
                    // Cipher uses Strings
                    passwd = String.copyValueOf( password );
                   
View Full Code Here

            String passwd = cliRequest.commandLine.getOptionValue( CLIManager.ENCRYPT_PASSWORD );
           
            if ( passwd == null )
            {
                Console cons = System.console();
                char[] password = ( cons == null ) ? null : cons.readPassword( "Password: " );
                if ( password != null )
                {
                    // Cipher uses Strings
                    passwd = String.copyValueOf( password );
View Full Code Here

            if (console == null) {
                throw new IOException(
                        "Cannot obtain the console with which to read the password from.");
            }

            pwd = console.readPassword();
        } else {
            BufferedReader pwdReader =
                    new BufferedReader(new InputStreamReader(in));
            String buffer = pwdReader.readLine();
            if (buffer == null) return null;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.