Uploaded image for project: 'James Server'
  1. James Server
  2. JAMES-1134

fetchmail configure function does not handle multiple accounts properly

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0-M1, 3.0-M2
    • Fix Version/s: 3.0-beta3
    • Component/s: FetchMail
    • Labels:
      None

      Description

      From ML:

      fetchmail configure function does not handle multiple accounts properly

      (as described in
      http://james.apache.org/server/3/configuration_fetchmail.html, under
      "One Account, One User")

      Here is an updated code allowing the parsing of the configuration with
      multiple accounts:

      /**

      • Method configure parses and validates the Configuration data and creates
      • a new<code>ParsedConfiguration</code>, an<code>Account</code> for each
      • configured static account and a<code>ParsedDynamicAccountParameters</code>
      • for each dynamic account.
        *
      • @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
        */
        @SuppressWarnings("unchecked")
        public void configure(HierarchicalConfiguration configuration) throws ConfigurationException {

      // Set any Session parameters passed in the Configuration
      setSessionParameters(configuration);

      // Create the ParsedConfiguration used in the delegation chain
      ParsedConfiguration parsedConfiguration =
      new ParsedConfiguration(
      configuration,
      logger,
      getServer(),
      getLocalUsers(),
      getDNSService());
      setParsedConfiguration(parsedConfiguration);

      // Setup the Accounts
      List<HierarchicalConfiguration> allAccounts = configuration.configurationsAt("accounts");
      if (allAccounts.size()< 1)
      throw new ConfigurationException("Missing<accounts> section.");

      if (allAccounts.size()> 1)
      throw new ConfigurationException("Too many<accounts> sections, there must be exactly one");

      HierarchicalConfiguration accounts = allAccounts.get(0);

      if (accounts.getKeys().hasNext() == false)
      throw new ConfigurationException("Missing<account> section.");

      List<Node> accountsChildren = accounts.getRoot().getChildren();
      int i = 0;

      // Create an Account for every configured account
      for (Node accountsChild: accountsChildren) {

      String accountsChildName = accountsChild.getName();

      if ("alllocal".equals(accountsChildName))

      { HierarchicalConfiguration accountsChildConfig = accounts.configurationAt(accountsChildName); //<allLocal> is dynamic, save the parameters for accounts to // be created when the task is triggered getParsedDynamicAccountParameters().add(new ParsedDynamicAccountParameters(i, accountsChildConfig)); continue; }

      if ("account".equals(accountsChildName))

      { // Create an Account for the named user and // add it to the list of static accounts List<HierarchicalConfiguration> accountsChildsConfig = accounts.configurationsAt(accountsChildName); Account account = new Account( i, parsedConfiguration, accountsChildsConfig.get(i).getString("[@user]"), accountsChildsConfig.get(i).getString("[@password]"), accountsChildsConfig.get(i).getString("[@recipient]"), accountsChildsConfig.get(i).getBoolean("[@ignorercpt-header]"), accountsChildsConfig.get(i).getString("[@customrcpt-header]",""), getSession()); getStaticAccounts().add(account); i++; continue; }

      throw new ConfigurationException(
      "Illegal token:<"
      + accountsChildName
      + "> in<accounts>");
      }
      }

        Attachments

        1. vcs-diff2703435384745471813.patch
          5 kB
          Toël Hartmann

          Activity

            People

            • Assignee:
              norman Norman Maurer
              Reporter:
              norman Norman Maurer
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: