001 /****************************************************************
002 * Licensed to the Apache Software Foundation (ASF) under one *
003 * or more contributor license agreements. See the NOTICE file *
004 * distributed with this work for additional information *
005 * regarding copyright ownership. The ASF licenses this file *
006 * to you under the Apache License, Version 2.0 (the *
007 * "License"); you may not use this file except in compliance *
008 * with the License. You may obtain a copy of the License at *
009 * *
010 * http://www.apache.org/licenses/LICENSE-2.0 *
011 * *
012 * Unless required by applicable law or agreed to in writing, *
013 * software distributed under the License is distributed on an *
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015 * KIND, either express or implied. See the License for the *
016 * specific language governing permissions and limitations *
017 * under the License. *
018 ****************************************************************/
019
020 package org.apache.james.fetchmail;
021
022 import javax.mail.Session;
023
024 import org.apache.commons.configuration.ConfigurationException;
025
026 public class DynamicAccount extends Account {
027
028 /**
029 * Constructor for DynamicAccount.
030 *
031 * @param sequenceNumber
032 * @param parsedConfiguration
033 * @param user
034 * @param password
035 * @param recipient
036 * @param ignoreRecipientHeader
037 * @param session
038 * @throws ConfigurationException
039 */
040 private DynamicAccount(int sequenceNumber, ParsedConfiguration parsedConfiguration, String user, String password, String recipient, boolean ignoreRecipientHeader, String customRecipientHeader, Session session) throws ConfigurationException {
041 super(sequenceNumber, parsedConfiguration, user, password, recipient, ignoreRecipientHeader, customRecipientHeader, session);
042 }
043
044 /**
045 * Constructor for DynamicAccount.
046 *
047 * @param sequenceNumber
048 * @param parsedConfiguration
049 * @param userName
050 * @param userPrefix
051 * @param userSuffix
052 * @param password
053 * @param recipientPrefix
054 * @param recipientSuffix
055 * @param ignoreRecipientHeader
056 * @param session
057 * @throws ConfigurationException
058 */
059 public DynamicAccount(int sequenceNumber, ParsedConfiguration parsedConfiguration, String userName, String userPrefix, String userSuffix, String password, String recipientPrefix, String recipientSuffix, boolean ignoreRecipientHeader, String customRecipientHeader, Session session)
060 throws ConfigurationException {
061 this(sequenceNumber, parsedConfiguration, null, password, null, ignoreRecipientHeader, customRecipientHeader, session);
062
063 StringBuffer userBuffer = new StringBuffer(userPrefix);
064 userBuffer.append(userName);
065 userBuffer.append(userSuffix);
066 setUser(userBuffer.toString());
067
068 StringBuffer recipientBuffer = new StringBuffer(recipientPrefix);
069 recipientBuffer.append(userName);
070 recipientBuffer.append(recipientSuffix);
071 setRecipient(recipientBuffer.toString());
072 }
073 }