net.i2p.router.util

## Class RouterPasswordManager

- java.lang.Object
- - net.i2p.util.PasswordManager
  - - net.i2p.router.util.RouterPasswordManager

- Direct Known Subclasses:
    ConsolePasswordManager

      public class RouterPasswordManager
      extends PasswordManager

  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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected RouterContext` | `_context`

    - ### Fields inherited from class net.i2p.util.PasswordManager

      `PROP_B64, PROP_CRYPT, PROP_MD5, PROP_PW, PROP_SHASH, SALT_LENGTH, SHASH_LENGTH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RouterPasswordManager(RouterContext ctx)` // migrate these to b64 private static final String[] MIGRATE_FROM = { // This has a separate router.reseedProxy.username prop, // so let's not mess with it "router.reseedProxy.password", // Don't migrate these until we have a console form for them, // which we aren't likely to ever bother with "routerconsole.keyPassword", "routerconsole.keystorePassword", "i2cp.keyPassword", "i2cp.keystorePassword" }; private static final String[] MIGRATE_TO = { "router.reseedProxy.auth", "routerconsole.ssl.key.auth", "routerconsole.ssl.keystore.auth", "i2cp.ssl.key.auth", "i2cp.ssl.keystore.auth" };

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `migrate()` Migrate from plaintext to salt/hash
    `boolean` | `remove(String realm, String user)` Remove password, any kind.
    `boolean` | `save(String realm, String user, String pw)` Same as saveHash()
    `boolean` | `saveB64(String realm, String user, String pw)` This will fail if if user contains '#' or '=' or starts with '!'
    `boolean` | `saveHash(String realm, String user, String pw)` This will fail if user contains '#' or '=' or starts with '!'
    `boolean` | `savePlain(String realm, String user, String pw)` This will fail if pw contains a '#' or if user contains '#' or '=' or starts with '!'

    - ### Methods inherited from class net.i2p.util.PasswordManager

      `check, checkB64, checkHash, checkHash, checkPlain, createHash, get, getB64, getPlain, md5Hex, md5Hex, md5Sum, sha256Hex, sha256Hex`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _context

          protected final RouterContext _context

  - ### Constructor Detail

    - #### RouterPasswordManager

          public RouterPasswordManager(RouterContext ctx)

      // migrate these to b64 private static final String[] MIGRATE_FROM = { // This has a separate router.reseedProxy.username prop, // so let's not mess with it "router.reseedProxy.password", // Don't migrate these until we have a console form for them, // which we aren't likely to ever bother with "routerconsole.keyPassword", "routerconsole.keystorePassword", "i2cp.keyPassword", "i2cp.keystorePassword" }; private static final String[] MIGRATE_TO = { "router.reseedProxy.auth", "routerconsole.ssl.key.auth", "routerconsole.ssl.keystore.auth", "i2cp.ssl.key.auth", "i2cp.ssl.keystore.auth" };

  - ### Method Detail

    - #### migrate

          protected boolean migrate()

      Migrate from plaintext to salt/hash
      Returns:
        success or nothing to migrate

    - #### remove

          public boolean remove(String realm,
                                String user)

      Remove password, any kind.
      Parameters:
        `realm` - e.g. i2cp, routerconsole, etc.
        `user` - null or "" for no user, already trimmed
      Returns:
        success

    - #### save

          public boolean save(String realm,
                              String user,
                              String pw)

      Same as saveHash()
      Parameters:
        `realm` - e.g. i2cp, routerconsole, etc.
        `user` - null or "" for no user, already trimmed
        `pw` - plain text, already trimmed
      Returns:
        success

    - #### saveB64

          public boolean saveB64(String realm,
                                 String user,
                                 String pw)

      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 trimmed
        `pw` - plain text, already trimmed
      Returns:
        success

    - #### saveHash

          public boolean saveHash(String realm,
                                  String user,
                                  String pw)

      This will fail if user contains '#' or '=' or starts with '!'
      Parameters:
        `realm` - e.g. i2cp, routerconsole, etc.
        `user` - null or "" for no user, already trimmed
        `pw` - plain text, already trimmed
      Returns:
        success

    - #### savePlain

          public boolean savePlain(String realm,
                                   String user,
                                   String pw)

      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 trimmed
        `pw` - plain text, already trimmed
      Returns:
        success