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.
    • PROP_MIGRATED

      private static final String PROP_MIGRATED
      Property marking the old passwords as already moved.
      See Also:
    • PROP_I2CP_OLD_PW

      private static final String PROP_I2CP_OLD_PW
      Old I2CP password property, migrated to per-destination properties.
      See Also:
    • PROP_I2CP_OLD_USER

      private static final String PROP_I2CP_OLD_USER
      Old I2CP username property, migrated to the new store.
      See Also:
    • PROP_I2CP_NEW

      private static final String PROP_I2CP_NEW
      Property the migrated I2CP credentials live under.
      See Also:
  • 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)
      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