View Javadoc

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