public class PasswordManager extends Object
Modifier and Type | Field and Description |
---|---|
protected static String |
PROP_B64
stored obfuscated as b64 of the UTF-8 bytes
|
protected static String |
PROP_CRYPT
stored as a Unix crypt string
|
protected static String |
PROP_MD5
stored as the hex of the MD5 hash of the UTF-8 bytes.
|
protected static String |
PROP_PW
stored as plain text
|
protected static String |
PROP_SHASH
stored as the b64 of the 16 byte salt + the 32 byte hash of the UTF-8 bytes
|
protected static int |
SALT_LENGTH |
protected static int |
SHASH_LENGTH
48
|
Constructor and Description |
---|
PasswordManager(I2PAppContext ctx) |
Modifier and Type | Method and Description |
---|---|
boolean |
check(String realm,
String user,
String pw)
Checks both plaintext and hash
|
boolean |
checkB64(String realm,
String user,
String pw) |
boolean |
checkHash(String shash,
String pw)
Check pw against b64 salt+hash, as generated by createHash()
|
boolean |
checkHash(String realm,
String user,
String pw)
With random salt
|
boolean |
checkPlain(String realm,
String user,
String pw) |
String |
createHash(String pw)
Create a salt+hash, to be saved and verified later by verifyHash().
|
String |
get(String realm,
String user)
Either plain or b64
|
String |
getB64(String realm,
String user) |
String |
getPlain(String realm,
String user) |
static String |
md5Hex(String fullpw)
Straight MD5, no salt
Will return the MD5 sum of the data, compatible with Jetty
and RFC 2617.
|
static String |
md5Hex(String subrealm,
String user,
String pw)
Straight MD5, no salt
Will return the MD5 sum of "user:subrealm:pw", compatible with Jetty
and RFC 2617.
|
static byte[] |
md5Sum(byte[] data)
Standard MD5 checksum
|
protected static final int SALT_LENGTH
protected static final int SHASH_LENGTH
protected static final String PROP_PW
protected static final String PROP_B64
protected static final String PROP_MD5
protected static final String PROP_CRYPT
protected static final String PROP_SHASH
public PasswordManager(I2PAppContext ctx)
public boolean check(String realm, String user, String pw)
realm
- e.g. i2cp, routerconsole, etc.user
- null or "" for no user, already trimmedpw
- plain text, already trimmedpublic boolean checkPlain(String realm, String user, String pw)
realm
- e.g. i2cp, routerconsole, etc.user
- null or "" for no user, already trimmedpw
- plain text, already trimmedpublic boolean checkB64(String realm, String user, String pw)
realm
- e.g. i2cp, routerconsole, etc.user
- null or "" for no user, already trimmedpw
- plain text, already trimmedpublic boolean checkHash(String realm, String user, String pw)
realm
- e.g. i2cp, routerconsole, etc.user
- null or "" for no user, already trimmedpw
- plain text, already trimmedpublic boolean checkHash(String shash, String pw)
shash
- b64 stringpw
- plain text non-null, already trimmedpublic String createHash(String pw)
pw
- plain text non-null, already trimmedpublic String get(String realm, String user)
realm
- e.g. i2cp, routerconsole, etc.user
- null or "" for no user, already trimmedpublic String getPlain(String realm, String user)
realm
- e.g. i2cp, routerconsole, etc.user
- null or "" for no user, already trimmedpublic String getB64(String realm, String user)
realm
- e.g. i2cp, routerconsole, etc.user
- null or "" for no user, already trimmedpublic static String md5Hex(String subrealm, String user, String pw)
subrealm
- to be used in creating the checksumuser
- non-null, non-empty, already trimmedpw
- non-null, plain text, already trimmedpublic static String md5Hex(String fullpw)
fullpw
- non-null, plain text, already trimmedpublic static byte[] md5Sum(byte[] data)
data
- non-null