de.fhg.igd.util
Class Password

java.lang.Object
  extended by de.fhg.igd.util.Password

public class Password
extends Object

Reads in passwords from the command line. This class attempts to disable character echoing for the input. Windows NT DOS shells do not support ANSI terminal codes. Conceiling password input is not supported on this OS. UNIX'es should have no problems with that.

Passwords are read by means of the System.in standard input stream.

Version:
"$Id: Password.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Volker Roth

Field Summary
static int MAX_LEN
          The maximum length supported for passwords.
 
Constructor Summary
Password()
           
 
Method Summary
static boolean canConceal()
          Returns false if password input cannot be conceiled.
static void clear(char[] c)
          Clears the given character array by filling it with zeroes.
static char[] read(String message)
          Reads in a password and returns it as a character array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_LEN

public static final int MAX_LEN
The maximum length supported for passwords. Longer inputs are truncated.

See Also:
Constant Field Values
Constructor Detail

Password

public Password()
Method Detail

canConceal

public static boolean canConceal()
Returns false if password input cannot be conceiled. This method checks the system property "os.name". If the value of this property is "Windows NT" then false is returned and true otherwise.

Returns:
false if password input cannot be conceiled and true if conceiling is probably possible.

read

public static char[] read(String message)
Reads in a password and returns it as a character array. If possible, the password input is conceiled by switching on ANSI character input conceiling. This works only on terminals which support ANSI control codes (Windows NT DOS shells don't).

Parameters:
message - The message printed before the password prompt.
Returns:
The password.

clear

public static void clear(char[] c)
Clears the given character array by filling it with zeroes.

Parameters:
c - The character array holding a password.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.