public class PasswordManager extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static String | PROP_B64stored obfuscated as b64 of the UTF-8 bytes |
protected static String | PROP_MD5stored as the hex of the MD5 hash of the UTF-8 bytes. |
protected static String | PROP_PWstored as plain text |
protected static String | PROP_SHASHStored as the b64 of the 16 byte salt + the 32 byte hash of the UTF-8 bytes |
protected static int | SALT_LENGTHSALT_LENGTH. |
protected static int | SHASH_LENGTHStored hash length in bytes (salt + session key, 48). |
| Constructor and Description |
|---|
PasswordManager(I2PAppContext ctx)PasswordManager. |
| 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 |
static String | sha256Hex(String fullpw)Return the SHA256 sum of the data, compatible with RFC 7616. |
static String | sha256Hex(String subrealm,
String user,
String pw)Straight SHA256, no salt
Will return the SHA256 sum of "user:subrealm:pw", compatible with RFC 7616. |
static byte[] | sha256Sum(byte[] data)Standard SHA-256 checksum |
protected static final String PROP_B64
protected static final String PROP_MD5
protected static final String PROP_PW
protected static final String PROP_SHASH
protected static final int SALT_LENGTH
protected static final int SHASH_LENGTH
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 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 shash, String pw)
shash - b64 stringpw - plain text non-null, 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 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 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 getB64(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 static String md5Hex(String fullpw)
fullpw - non-null, plain text, 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 byte[] md5Sum(byte[] data)
data - non-nullpublic static String sha256Hex(String fullpw)
fullpw - non-null, plain text, already trimmedpublic static String sha256Hex(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 byte[] sha256Sum(byte[] data)
data - non-null