public final class PasswordUtil extends Object
This class is thread-safe.
Modifier and Type | Method and Description |
---|---|
static String |
escapePassword(String unescaped)
|
static void |
escapePassword(String unescaped,
StringBuilder escaped)
Converts a password to UTF-8 and then encodes each byte in hexadecimal.
|
static String |
getAnonymousFTPPassword()
Convenience function which returns the customary password used for
anonymous FTP connections.
|
static String |
getLocalHostName()
Convenience function which returns the name of local host if known;
null otherwise. |
static String |
getUserIdentifier()
Convenience function which returns user_name@host_name.
|
static String |
getUserName()
Convenience function which returns the value of system property
user.name.
|
static String |
unescapePassword(String escaped)
Converts specified hexadecimal string to UTF-8 bytes, then returns the
string built using these UTF-8 bytes.
|
public static String getAnonymousFTPPassword()
Unlike for getUserIdentifier()
, the returned password is
guaranteed to contain character '@'.
Note that the returned password is unescaped.
public static String getUserIdentifier()
Note that the returned identifier is unescaped.
getAnonymousFTPPassword()
public static String getUserName()
public static String getLocalHostName()
null
otherwise.public static void escapePassword(String unescaped, StringBuilder escaped)
unescaped
- password to be ``escaped''escaped
- escaped password is appended to this buffer.public static String unescapePassword(String escaped)
escapePassword(String)
.escaped
- a password in ``escaped'' formnull
if specified string
cannot be decoded.