java.lang.Object
i2p.susi.dns.BaseBean
Direct Known Subclasses:
AddressbookBean, BlacklistBean, ConfigBean, LogBean, SubscriptionsBean

public class BaseBeanextends Object
Holds methods common to several Beans.
  • Field Details

    • _context

      protected final I2PAppContext _context
      The I2P application context.
    • properties

      protected final Properties properties
      The configuration properties.
    • action

      protected String action
      The current action.
    • lastSerial

      protected String lastSerial
      The last serial number for CSRF.
    • serial

      protected String serial
      The serial number.
    • method

      protected String method
      The HTTP method.
    • configLastLoaded

      private long configLastLoaded
      When the config file was last loaded.
    • PRIVATE_BOOK

      private static final String PRIVATE_BOOK
      Config key of the private address book.
      See Also:
    • DEFAULT_PRIVATE_BOOK

      private static final String DEFAULT_PRIVATE_BOOK
      Default path of the private address book.
      See Also:
    • RC_PROP_THEME_NAME

      private static final String RC_PROP_THEME_NAME
      Router console key of the theme name.
      See Also:
    • PROP_THEME_NAME

      private static final String PROP_THEME_NAME
      Addressbook key of the theme name.
      See Also:
    • DEFAULT_THEME

      private static final String DEFAULT_THEME
      The theme used by default.
      See Also:
    • BASE_THEME_PATH

      private static final String BASE_THEME_PATH
      Base path of the theme files.
      See Also:
    • PROP_PW_ENABLE

      public static final String PROP_PW_ENABLE
      Property for password enable.
      See Also:
    • RC_PROP_ENABLE_SORA_FONT

      private static final String RC_PROP_ENABLE_SORA_FONT
      Config key enabling the Sora font.
      See Also:
    • ADDRESSBOOK_DIR

      private static final String ADDRESSBOOK_DIR
      Directory holding the addressbook files.
      See Also:
    • CONFIG_FILE

      private static final String CONFIG_FILE
      Name of the addressbook config file.
      See Also:
  • Constructor Details

    • BaseBean

      public BaseBean()
      Default constructor. Initializes the I2P context and properties.
  • Method Details

    • addressbookDir

      protected File addressbookDir()
      Returns the addressbook directory.
      Returns:
      the addressbook directory
    • configFile

      protected File configFile()
      The addressbook configuration file.
      Returns:
      the file, which may not exist
    • loadConfig

      protected void loadConfig()
      Loads the configuration if needed.
    • reload

      protected void reload()
      Reloads the configuration from file.
    • getTheme

      public String getTheme()
      Returns the theme path.
      Returns:
      the theme path
    • getThemeName

      public String getThemeName()
      The configured console theme name.
      Returns:
      the theme name, never null, falling back to the default theme
    • getThemes

      public String[] getThemes()
      Get all themes.
      Returns:
      String[] -- Array of all the themes found.
    • useSoraFont

      public boolean useSoraFont()
      Checks if Sora font should be used.
      Returns:
      true if Sora font is enabled
    • isOverrideCssActive

      public boolean isOverrideCssActive()
      Determine if a user-provided override.css file is active.
      Returns:
      true if override.css is active
    • getAction

      public String getAction()
      Get the action.
      Returns:
      the action requested by the current request
    • setAction

      public void setAction(String action)
      Sets the action. HTML is stripped from the value.
      Parameters:
      action - the action string
    • getSerial

      public String getSerial()
      Generate a new random serial for CSRF protection and clear the pending action.
      Returns:
      a new serial number
    • setSerial

      public void setSerial(String serial)
      Sets the serial. HTML is stripped from the value.
      Parameters:
      serial - the serial number
    • storeMethod

      public void storeMethod(String method)
      Store the HTTP method.
      Parameters:
      method - the HTTP method
    • _t

      protected static String _t(String s)
      Translate a string.
      Parameters:
      s - the string to translate
      Returns:
      the translated string
    • _t

      protected static String _t(String s, Object o)
      Translate a string with one parameter.
      Parameters:
      s - the string to translate
      o - the value substituted for the placeholder in s
      Returns:
      the translated string
    • _t

      protected static String _t(String s, Object o, Object o2)
      Translate a string with two parameters.
      Parameters:
      s - the string to translate
      o - the first parameter
      o2 - the second parameter
      Returns:
      the translated string
    • ngettext

      protected static String ngettext(String s, String p, int n)
      Translate a string with plural form (ngettext).
      Parameters:
      s - the singular form
      p - the plural form
      n - the number of items, which selects the singular or plural form
      Returns:
      the translated string
    • debug

      protected void debug(String msg)
      Log a debug message.
      Parameters:
      msg - the message to log
    • warn

      protected void warn(Throwable t)
      Log a warning message.
      Parameters:
      t - the throwable to log