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  package org.apache.james.fetchmail;
21  
22  import javax.mail.Session;
23  
24  import org.apache.avalon.framework.configuration.ConfigurationException;
25  
26  public class DynamicAccount extends Account
27  {
28  
29      /***
30       * Constructor for DynamicAccount.
31       * @param sequenceNumber
32       * @param parsedConfiguration
33       * @param user
34       * @param password
35       * @param recipient
36       * @param ignoreRecipientHeader
37       * @param session
38       * @throws ConfigurationException
39       */
40      private DynamicAccount(
41          int sequenceNumber,
42          ParsedConfiguration parsedConfiguration,
43          String user,
44          String password,
45          String recipient,
46          boolean ignoreRecipientHeader,
47          String customRecipientHeader,
48          Session session)
49          throws ConfigurationException
50      {
51          super(
52              sequenceNumber,
53              parsedConfiguration,
54              user,
55              password,
56              recipient,
57              ignoreRecipientHeader,
58              customRecipientHeader,
59              session);
60      }
61  
62      /***
63       * Constructor for DynamicAccount.
64       * @param sequenceNumber
65       * @param parsedConfiguration
66       * @param userName
67       * @param userPrefix 
68       * @param userSuffix
69       * @param password
70       * @param recipientPrefix 
71       * @param recipientSuffix  
72       * @param ignoreRecipientHeader
73       * @param session
74       * @throws ConfigurationException
75       */
76      public DynamicAccount(
77          int sequenceNumber,
78          ParsedConfiguration parsedConfiguration,
79          String userName,
80          String userPrefix,
81          String userSuffix,
82          String password,
83          String recipientPrefix,
84          String recipientSuffix,
85          boolean ignoreRecipientHeader,
86          String customRecipientHeader,
87          Session session)
88          throws ConfigurationException
89      {
90          this(
91              sequenceNumber,
92              parsedConfiguration,
93              null,
94              password,
95              null,
96              ignoreRecipientHeader,
97              customRecipientHeader,
98              session);
99  
100         StringBuffer userBuffer = new StringBuffer(userPrefix);
101         userBuffer.append(userName);
102         userBuffer.append(userSuffix);
103         setUser(userBuffer.toString());
104 
105         StringBuffer recipientBuffer = new StringBuffer(recipientPrefix);
106         recipientBuffer.append(userName);
107         recipientBuffer.append(recipientSuffix);
108         setRecipient(recipientBuffer.toString());
109     }
110 }