java.lang.Object
net.i2p.util.PasswordManager
net.i2p.router.util.RouterPasswordManager
- Direct Known Subclasses:
ConsolePasswordManager
Comprehensive password management for router configuration with migration support.
Manages both plaintext and salted/hashed password storage in router configuration. Provides migration utilities for transitioning from legacy plaintext passwords to modern hashed authentication.
Supports multiple authentication realms including i2cp, routerconsole, and keystore-based authentication. Includes validation, migration, and obfuscation utilities for secure password handling.
Handles password migration between different storage formats while maintaining backward compatibility and security best practices. Includes comprehensive logging and error handling for authentication operations.
Field Summary
FieldsFields inherited from class PasswordManager
PROP_B64, PROP_MD5, PROP_PW, PROP_SHASH, SALT_LENGTH, SHASH_LENGTHModifier and TypeFieldDescriptionprotected static final StringStored obfuscated as b64 of the UTF-8 bytes.protected static final StringStored as the hex of the MD5 hash of the UTF-8 bytes.protected static final StringStored as plain text.protected static final StringStored as the b64 of the 16 byte salt + the 32 byte hash of the UTF-8 bytes.protected static final intLength of the random salt prefixed to each stored hash, in bytes.protected static final intStored hash length in bytes (salt + session key, 48).Constructor Summary
ConstructorsConstructorDescriptionPassword manager for the given router context.Method Summary
All MethodsModifier and TypeMethodDescriptionprotected booleanmigrate()Migrate from plaintext to salt/hash.booleanRemove password, any kind.booleanSame as saveHash().booleanThis will fail if if user contains '#' or '=' or starts with '!'.booleanThis will fail if user contains '#' or '=' or starts with '!'.booleanThis will fail if pw contains a '#' or if user contains '#' or '=' or starts with '!'.Methods inherited from class PasswordManager
check, checkB64, checkHash, checkHash, checkPlain, createHash, get, getB64, getPlain, md5Hex, md5Hex, md5Sum, sha256Hex, sha256Hex, sha256SumModifier and TypeMethodDescriptionbooleanChecks both plaintext and hash.booleanChecks a password stored base64-encoded.booleanCheck pw against b64 salt+hash, as generated by createHash().booleanWith random salt.booleancheckPlain(String realm, String user, String pw) Checks a password stored in plaintext.createHash(String pw) Create a salt+hash, to be saved and verified later by verifyHash().Either plain or b64.Retrieve the base64-stored password.Retrieve the plaintext-stored password.static StringStraight MD5, no salt Will return the MD5 sum of the data, compatible with Jetty and RFC 2617.static StringStraight 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 StringReturn the SHA256 sum of the data, compatible with RFC 7616.static StringStraight 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.
Field Details
_context
The router context.
Constructor Details
RouterPasswordManager
Password manager for the given router context.- Parameters:
ctx- the router context
Method Details
migrate
protected boolean migrate()Migrate from plaintext to salt/hash.- Returns:
- success or nothing to migrate
save
savePlain
This will fail if pw contains a '#' or if user contains '#' or '=' or starts with '!'.- Parameters:
realm- e.g. i2cp, routerconsole, etc.user- null or "" for no user, already trimmedpw- plain text, already trimmed- Returns:
- true if the plain entry was written to
router.config
saveB64
This will fail if if user contains '#' or '=' or starts with '!'.- Parameters:
realm- e.g. i2cp, routerconsole, etc.user- null or "" for no user, already trimmedpw- plain text, already trimmed- Returns:
- true if the base64 entry was written to
router.config
saveHash
This will fail if user contains '#' or '=' or starts with '!'.- Parameters:
realm- e.g. i2cp, routerconsole, etc.user- null or "" for no user, already trimmedpw- plain text, already trimmed- Returns:
- true if the hashed entry was written to
router.config
remove