View Javadoc

1   /************************************************************************
2    * Copyright (c) 2003-2006 The Apache Software Foundation.             *
3    * All rights reserved.                                                *
4    * ------------------------------------------------------------------- *
5    * Licensed under the Apache License, Version 2.0 (the "License"); you *
6    * may not use this file except in compliance with the License. You    *
7    * may obtain a copy of the License at:                                *
8    *                                                                     *
9    *     http://www.apache.org/licenses/LICENSE-2.0                      *
10   *                                                                     *
11   * Unless required by applicable law or agreed to in writing, software *
12   * distributed under the License is distributed on an "AS IS" BASIS,   *
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or     *
14   * implied.  See the License for the specific language governing       *
15   * permissions and limitations under the License.                      *
16   ***********************************************************************/
17  
18  package org.apache.james.fetchmail;
19  
20  import javax.mail.Session;
21  
22  import org.apache.avalon.framework.configuration.ConfigurationException;
23  
24  public class DynamicAccount extends Account
25  {
26  
27      /***
28       * Constructor for DynamicAccount.
29       * @param sequenceNumber
30       * @param parsedConfiguration
31       * @param user
32       * @param password
33       * @param recipient
34       * @param ignoreRecipientHeader
35       * @param session
36       * @throws ConfigurationException
37       */
38      private DynamicAccount(
39          int sequenceNumber,
40          ParsedConfiguration parsedConfiguration,
41          String user,
42          String password,
43          String recipient,
44          boolean ignoreRecipientHeader,
45          String customRecipientHeader,
46          Session session)
47          throws ConfigurationException
48      {
49          super(
50              sequenceNumber,
51              parsedConfiguration,
52              user,
53              password,
54              recipient,
55              ignoreRecipientHeader,
56              customRecipientHeader,
57              session);
58      }
59  
60      /***
61       * Constructor for DynamicAccount.
62       * @param sequenceNumber
63       * @param parsedConfiguration
64       * @param userName
65       * @param userPrefix 
66       * @param userSuffix
67       * @param password
68       * @param recipientPrefix 
69       * @param recipientSuffix  
70       * @param ignoreRecipientHeader
71       * @param session
72       * @throws ConfigurationException
73       */
74      public DynamicAccount(
75          int sequenceNumber,
76          ParsedConfiguration parsedConfiguration,
77          String userName,
78          String userPrefix,
79          String userSuffix,
80          String password,
81          String recipientPrefix,
82          String recipientSuffix,
83          boolean ignoreRecipientHeader,
84          String customRecipientHeader,
85          Session session)
86          throws ConfigurationException
87      {
88          this(
89              sequenceNumber,
90              parsedConfiguration,
91              null,
92              password,
93              null,
94              ignoreRecipientHeader,
95              customRecipientHeader,
96              session);
97  
98          StringBuffer userBuffer = new StringBuffer(userPrefix);
99          userBuffer.append(userName);
100         userBuffer.append(userSuffix);
101         setUser(userBuffer.toString());
102 
103         StringBuffer recipientBuffer = new StringBuffer(recipientPrefix);
104         recipientBuffer.append(userName);
105         recipientBuffer.append(recipientSuffix);
106         setRecipient(recipientBuffer.toString());
107     }
108 }