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: [email protected]
For additional commands, e-mail: [email protected]