java.lang.Object
net.i2p.util.PasswordManager
net.i2p.router.util.RouterPasswordManager
Direct Known Subclasses:
ConsolePasswordManager

public class RouterPasswordManagerextends 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 Details

    • _context

      protected final RouterContext _context
      The router context.
  • Constructor Details

    • RouterPasswordManager

      public RouterPasswordManager(RouterContext ctx)
      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

      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:
      true if the hashed entry was written to router.config
    • 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:
      true if the plain entry was written to router.config
    • 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:
      true if the base64 entry was written to router.config
    • 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:
      true if the hashed entry was written to router.config
    • 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:
      true if every stored password form for the prefix was deleted