You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by "Norman Maurer (JIRA)" <se...@james.apache.org> on 2010/11/15 22:12:55 UTC

[jira] Created: (JAMES-1134) fetchmail configure function does not handle multiple accounts properly

fetchmail configure function does not handle multiple accounts properly
-----------------------------------------------------------------------

                 Key: JAMES-1134
                 URL: https://issues.apache.org/jira/browse/JAMES-1134
             Project: JAMES Server
          Issue Type: Bug
            Reporter: Norman Maurer
             Fix For: 3.0-M2, 3.0-M1


>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>");
       }
   }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Re: [jira] Created: (JAMES-1134) fetchmail configure function does not handle multiple accounts properly

Posted by Toël Hartmann <to...@toel.se>.
Thank you for reporting those for me, I will attach patches to those 
shortly.

/Toël

On 2010-11-15 22:12, Norman Maurer (JIRA) wrote:
> fetchmail configure function does not handle multiple accounts properly
> -----------------------------------------------------------------------
>
>                   Key: JAMES-1134
>                   URL: https://issues.apache.org/jira/browse/JAMES-1134
>               Project: JAMES Server
>            Issue Type: Bug
>              Reporter: Norman Maurer
>               Fix For: 3.0-M2, 3.0-M1
>
>
> > 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>");
>         }
>     }
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[jira] Updated: (JAMES-1134) fetchmail configure function does not handle multiple accounts properly

Posted by "Norman Maurer (JIRA)" <se...@james.apache.org>.
     [ https://issues.apache.org/jira/browse/JAMES-1134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Norman Maurer updated JAMES-1134:
---------------------------------

          Component/s: FetchMail
    Affects Version/s: 3.0-M1
                       3.0-M2
        Fix Version/s:     (was: 3.0-M2)
                           (was: 3.0-M1)
                       3.0-M3

> fetchmail configure function does not handle multiple accounts properly
> -----------------------------------------------------------------------
>
>                 Key: JAMES-1134
>                 URL: https://issues.apache.org/jira/browse/JAMES-1134
>             Project: JAMES Server
>          Issue Type: Bug
>          Components: FetchMail
>    Affects Versions: 3.0-M1, 3.0-M2
>            Reporter: Norman Maurer
>             Fix For: 3.0-M3
>
>
> 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>");
>        }
>    }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[jira] Resolved: (JAMES-1134) fetchmail configure function does not handle multiple accounts properly

Posted by "Norman Maurer (JIRA)" <se...@james.apache.org>.
     [ https://issues.apache.org/jira/browse/JAMES-1134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Norman Maurer resolved JAMES-1134.
----------------------------------

    Resolution: Fixed
      Assignee: Norman Maurer

Committed a fix. Please review:

http://svn.apache.org/viewvc/james/server/trunk/fetchmail/src/main/java/org/apache/james/fetchmail/FetchMail.java?r1=1030632&r2=1035599&pathrev=1035599

Thx again..

> fetchmail configure function does not handle multiple accounts properly
> -----------------------------------------------------------------------
>
>                 Key: JAMES-1134
>                 URL: https://issues.apache.org/jira/browse/JAMES-1134
>             Project: JAMES Server
>          Issue Type: Bug
>          Components: FetchMail
>    Affects Versions: 3.0-M1, 3.0-M2
>            Reporter: Norman Maurer
>            Assignee: Norman Maurer
>             Fix For: 3.0-M3
>
>         Attachments: vcs-diff2703435384745471813.patch
>
>
> 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>");
>        }
>    }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


[jira] Updated: (JAMES-1134) fetchmail configure function does not handle multiple accounts properly

Posted by "Toël Hartmann (JIRA)" <se...@james.apache.org>.
     [ https://issues.apache.org/jira/browse/JAMES-1134?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Toël Hartmann updated JAMES-1134:
---------------------------------

    Attachment: vcs-diff2703435384745471813.patch

Allow support for parsing of multiple accounts configuration

> fetchmail configure function does not handle multiple accounts properly
> -----------------------------------------------------------------------
>
>                 Key: JAMES-1134
>                 URL: https://issues.apache.org/jira/browse/JAMES-1134
>             Project: JAMES Server
>          Issue Type: Bug
>          Components: FetchMail
>    Affects Versions: 3.0-M1, 3.0-M2
>            Reporter: Norman Maurer
>             Fix For: 3.0-M3
>
>         Attachments: vcs-diff2703435384745471813.patch
>
>
> 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>");
>        }
>    }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org