APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.security.util

public Class Password

extends Object
Class Inheritance
Imports
java.io.*, java.nio.*, java.nio.charset.*, java.util.Arrays, .Locale, jdk.internal.access.SharedSecrets, jdk.internal.io.JdkConsoleImpl, jdk.internal.misc.VM

A utility class for reading passwords

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static char[]
readPassword(InputStream in)

Reads user password from given input stream.

public static char[]
readPassword(InputStream in, boolean
true if the password should be echoed on the screen
isEchoOn
)

Reads user password from given input stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALLOW_STDINback to summary
private static final boolean ALLOW_STDIN

Constructor Detail

Passwordback to summary
public Password()

Method Detail

readPasswordback to summary
public static char[] readPassword(InputStream in) throws IOException

Reads user password from given input stream.

readPasswordback to summary
public static char[] readPassword(InputStream in, boolean isEchoOn) throws IOException

Reads user password from given input stream.

Parameters
isEchoOn:boolean

true if the password should be echoed on the screen

Annotations
@SuppressWarnings:fallthrough
sun.security.util back to summary

private Class Password.ConsoleHolder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final Console
private static final JdkConsoleImpl
private static final CharsetEncoder

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean
public static byte[]

Returns:

its byte[] format, equivalent to new String(pass).getBytes() but String is immutable and cannot be cleaned up.
convertToBytes
(char[]
a char[]
pass
)

Convert a password read from console into its original bytes.

public static char[]
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

c1back to summary
private static final Console c1
c2back to summary
private static final JdkConsoleImpl c2
encback to summary
private static final CharsetEncoder enc

Constructor Detail

ConsoleHolderback to summary
private ConsoleHolder()

Method Detail

consoleIsAvailableback to summary
public static boolean consoleIsAvailable()
convertToBytesback to summary
public static byte[] convertToBytes(char[] pass)

Convert a password read from console into its original bytes.

Parameters
pass:char[]

a char[]

Returns:byte[]

its byte[] format, equivalent to new String(pass).getBytes() but String is immutable and cannot be cleaned up.

readPasswordback to summary
public static char[] readPassword()