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 java.net.InetAddress;
23  import java.net.UnknownHostException;
24  import java.util.HashSet;
25  import java.util.Set;
26  import java.util.StringTokenizer;
27  
28  import javax.mail.internet.ParseException;
29  
30  import org.apache.avalon.framework.configuration.Configuration;
31  import org.apache.avalon.framework.configuration.ConfigurationException;
32  import org.apache.avalon.framework.logger.Logger;
33  import org.apache.james.services.MailServer;
34  import org.apache.mailet.MailAddress;
35  import org.apache.james.services.UsersRepository;
36  
37  /***
38   * <p>Parses and validates an 
39   * <code>org.apache.avalon.framework.configuration.Configuration</code>.</p>
40   * 
41   * <p>Creation Date: 27-May-03</p>
42   * 
43   */
44  class ParsedConfiguration
45  {
46      /***
47       * The logger.
48       */
49      private Logger fieldLogger;
50      
51      /***
52       * The name of the folder to fetch from the javamail provider
53       *
54       */
55      private String fieldJavaMailFolderName = "INBOX";    
56      
57  
58      /***
59       * The name of the javamail provider we want to user (pop3,imap,nntp,etc...)
60       *
61       */
62      private String fieldJavaMailProviderName = "pop3";
63  
64  
65      /***
66       * Returns the javaMailFolderName.
67       * @return String
68       */
69      public String getJavaMailFolderName()
70      {
71          return fieldJavaMailFolderName;
72      }
73  
74  
75      /***
76       * Returns the javaMailProviderName.
77       * @return String
78       */
79      public String getJavaMailProviderName()
80      {
81          return fieldJavaMailProviderName;
82      }
83  
84  
85      /***
86       * Sets the javaMailFolderName.
87       * @param javaMailFolderName The javaMailFolderName to set
88       */
89      protected void setJavaMailFolderName(String javaMailFolderName)
90      {
91          fieldJavaMailFolderName = javaMailFolderName;
92      }
93  
94  
95      /***
96       * Sets the javaMailProviderName.
97       * @param javaMailProviderName The javaMailProviderName to set
98       */
99      protected void setJavaMailProviderName(String javaMailProviderName)
100     {
101         fieldJavaMailProviderName = javaMailProviderName;
102     }
103 
104 
105     
106     
107     /***
108      * Fetch both old (seen) and new messages from the mailserver.  The default
109      * is to fetch only messages the server are not marked as seen.
110      */
111     private boolean fieldFetchAll = false;
112 
113 
114     /***
115      * The unique, identifying name for this task
116      */
117     private String fieldFetchTaskName;
118     
119 
120     /***
121      * The server host name for this fetch task
122      */
123     private String fieldHost;
124 
125     /***
126      * Keep retrieved messages on the remote mailserver.  Normally, messages
127      * are deleted from the folder on the mailserver after they have been retrieved
128      */
129     private boolean fieldLeave = false;
130     
131     /***
132      * Keep blacklisted messages on the remote mailserver.  Normally, messages
133      * are kept in the folder on the mailserver if they have been rejected
134      */
135     private boolean fieldLeaveBlacklisted = true;
136     
137     /***
138      * Keep messages for remote recipients on the remote mailserver.  Normally,
139      * messages are kept in the folder on the mailserver if they have been 
140      * rejected.
141      */
142     private boolean fieldLeaveRemoteRecipient = true;    
143     
144     /***
145      * Keep messages for undefined users on the remote mailserver.  Normally, 
146      * messages are kept in the folder on the mailserver if they have been 
147      * rejected.
148      */
149     private boolean fieldLeaveUserUndefined = true;
150     
151     /***
152      * Keep undeliverable messages on the remote mailserver.  Normally, 
153      * messages are kept in the folder on the mailserver if they cannot 
154      * be delivered.
155      */
156     private boolean fieldLeaveUndeliverable = true;            
157     
158 
159     /***
160      * Mark retrieved messages on the remote mailserver as seen.  Normally, 
161      * messages are marked as seen after they have been retrieved
162      */
163     private boolean fieldMarkSeen = true;
164     
165     /***
166      * Mark blacklisted messages on the remote mailserver as seen.  Normally, 
167      * messages are not marked as seen if they have been rejected
168      */
169     private boolean fieldMarkBlacklistedSeen = false;
170     
171     /***
172      * Mark remote recipient messages on the remote mailserver as seen. Normally, 
173      * messages are not marked as seen if they have been rejected
174      */
175     private boolean fieldMarkRemoteRecipientSeen = false;    
176     
177     /***
178      * Mark messages for undefined users on the remote mail server as seen.
179      * Normally, messages are not marked as seen if they have been rejected.
180      */
181     private boolean fieldMarkUserUndefinedSeen = false;
182     
183     /***
184      * Mark undeliverable messages on the remote mail server as seen.
185      * Normally, messages are not marked as seen if they are undeliverable.
186      */
187     private boolean fieldMarkUndeliverableSeen = false; 
188     
189     /***
190      * Defer processing of messages for which the intended recipient cannot
191      * be determined to the next pass.
192      */
193     private boolean fieldDeferRecipientNotFound = false;                 
194 
195 
196     /***
197      * Recurse folders if available?
198      */
199     private boolean fieldRecurse = false;
200     
201 
202     /***
203      * The MailServer service
204      */
205     private MailServer fieldServer;    
206     
207 
208     /***
209      * The domain part to use to complete partial addresses
210      */
211     private String fieldDefaultDomainName; 
212     
213     /***
214      * Only accept mail for defined recipients.
215      * All other mail is rejected.
216      */
217     private boolean fieldRejectUserUndefined;
218     
219     /***
220      * The index of the received header to use to compute the remote address
221      * and remote host name for a message. This is 0 based and defaults to -1.
222      */
223     private int fieldRemoteReceivedHeaderIndex = -1;
224     
225     /***
226      * Keep messages with an invalid received header on the remote mailserver.
227      * Normally, messages are kept in the folder on the mailserver if they have been
228      * rejected
229      */
230     private boolean fieldLeaveRemoteReceivedHeaderInvalid = true;
231     
232     /***
233      * Mark messages with an invalid received header on the remote mailserver as 
234      * seen.  Normally, messages are not marked as seen if they have been rejected.
235      */
236     private boolean fieldMarkRemoteReceivedHeaderInvalidSeen = false;
237     
238     /***
239      * Reject messages with an invalid received header.
240      */
241     private boolean fieldRejectRemoteReceivedHeaderInvalid;                
242     
243     /***
244      * Reject messages for which a recipient could not be determined.
245      */
246     private boolean fieldRejectRecipientNotFound;
247     
248     /***
249      * Leave messages on the server for which a recipient could not be
250      * determined.
251      */
252     private boolean fieldLeaveRecipientNotFound; 
253     
254     /***
255      * Mark as seen messages on the server for which a recipient could not be
256      * determined.
257      */
258     private boolean fieldMarkRecipientNotFoundSeen;       
259     
260     /***
261      * Reject mail for blacklisted users
262      */
263     private boolean fieldRejectBlacklisted;
264 
265     /***
266      * Only accept mail for local recipients.
267      * All other mail is rejected.
268      */
269     private boolean fieldRejectRemoteRecipient;    
270 
271     /***
272      * The Set of MailAddresses for whom mail should be rejected
273      */    
274     private Set fieldBlacklist; 
275 
276     /***
277      * The maximum message size limit
278      * 0 means no limit.
279      */
280     private int fieldMaxMessageSizeLimit = 0;
281     
282     /***
283      * Reject mail exceeding the maximum message size limit
284      */
285     private boolean fieldRejectMaxMessageSizeExceeded;
286     
287     /***
288      * Leave messages on the server that exceed the maximum message size limit.
289      */
290     private boolean fieldLeaveMaxMessageSizeExceeded; 
291     
292     /***
293      * Mark as seen messages on the server that exceed the maximum message size
294      * limit.
295      */
296     private boolean fieldMarkMaxMessageSizeExceededSeen;        
297     
298    /***
299      * The Local Users repository
300      */
301     private UsersRepository fieldLocalUsers;    
302 
303 
304 
305     /***
306      * Constructor for ParsedConfiguration.
307      */
308     private ParsedConfiguration()
309     {
310         super();
311     }
312     
313     /***
314      * Constructor for ParsedConfiguration.
315      * @param configuration
316      * @param logger
317      * @param server
318      * @param localUsers
319      * @throws ConfigurationException
320      */
321     public ParsedConfiguration(Configuration configuration, Logger logger, MailServer server, UsersRepository localUsers) throws ConfigurationException
322     {
323         this();
324         setLogger(logger);
325         setServer(server);
326         setLocalUsers(localUsers);      
327         configure(configuration);
328     }
329     
330     /***
331      * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
332      */
333     protected void configure(Configuration conf) throws ConfigurationException
334     {
335         setHost(conf.getChild("host").getValue());
336 
337         setFetchTaskName(conf.getAttribute("name"));
338         setJavaMailProviderName(
339             conf.getChild("javaMailProviderName").getValue());
340         setJavaMailFolderName(conf.getChild("javaMailFolderName").getValue());
341         setRecurse(conf.getChild("recursesubfolders").getValueAsBoolean());
342 
343         Configuration recipientNotFound = conf.getChild("recipientnotfound");
344         setDeferRecipientNotFound(
345             recipientNotFound.getAttributeAsBoolean("defer"));
346         setRejectRecipientNotFound(
347             recipientNotFound.getAttributeAsBoolean("reject"));
348         setLeaveRecipientNotFound(
349             recipientNotFound.getAttributeAsBoolean("leaveonserver"));
350         setMarkRecipientNotFoundSeen(
351             recipientNotFound.getAttributeAsBoolean("markseen"));
352 
353         Configuration defaultDomainName = conf.getChild("defaultdomain", false);
354         if (null != defaultDomainName)
355             setDefaultDomainName(defaultDomainName.getValue());
356 
357         setFetchAll(conf.getChild("fetchall").getValueAsBoolean());
358 
359         Configuration fetched = conf.getChild("fetched");
360         setLeave(fetched.getAttributeAsBoolean("leaveonserver"));
361         setMarkSeen(fetched.getAttributeAsBoolean("markseen"));
362 
363         Configuration remoterecipient = conf.getChild("remoterecipient");
364         setRejectRemoteRecipient(
365             remoterecipient.getAttributeAsBoolean("reject"));
366         setLeaveRemoteRecipient(
367             remoterecipient.getAttributeAsBoolean("leaveonserver"));
368         setMarkRemoteRecipientSeen(
369             remoterecipient.getAttributeAsBoolean("markseen"));
370 
371         Configuration blacklist = conf.getChild("blacklist");
372         setBlacklist(blacklist.getValue(""));
373         setRejectBlacklisted(blacklist.getAttributeAsBoolean("reject"));
374         setLeaveBlacklisted(blacklist.getAttributeAsBoolean("leaveonserver"));
375         setMarkBlacklistedSeen(blacklist.getAttributeAsBoolean("markseen"));
376 
377         Configuration userundefined = conf.getChild("userundefined");
378         setRejectUserUndefined(userundefined.getAttributeAsBoolean("reject"));
379         setLeaveUserUndefined(
380             userundefined.getAttributeAsBoolean("leaveonserver"));
381         setMarkUserUndefinedSeen(
382             userundefined.getAttributeAsBoolean("markseen"));
383 
384         Configuration undeliverable = conf.getChild("undeliverable");
385         setLeaveUndeliverable(
386             undeliverable.getAttributeAsBoolean("leaveonserver"));
387         setMarkUndeliverableSeen(
388             undeliverable.getAttributeAsBoolean("markseen"));
389 
390         Configuration remotereceivedheader = conf.getChild("remotereceivedheader", false);
391         if (null != remotereceivedheader)
392         {
393             setRemoteReceivedHeaderIndex(
394                 remotereceivedheader.getAttributeAsInteger("index"));
395             setRejectRemoteReceivedHeaderInvalid(
396                 remotereceivedheader.getAttributeAsBoolean("reject"));
397             setLeaveRemoteReceivedHeaderInvalid(
398                 remotereceivedheader.getAttributeAsBoolean("leaveonserver"));
399             setMarkRemoteReceivedHeaderInvalidSeen(
400                 remotereceivedheader.getAttributeAsBoolean("markseen"));
401         }            
402 
403         Configuration maxmessagesize = conf.getChild("maxmessagesize", false);
404         if (null != maxmessagesize)
405         {
406             setMaxMessageSizeLimit(
407                 maxmessagesize.getAttributeAsInteger("limit") * 1024);
408             setRejectMaxMessageSizeExceeded(
409                 maxmessagesize.getAttributeAsBoolean("reject"));
410             setLeaveMaxMessageSizeExceeded(
411                 maxmessagesize.getAttributeAsBoolean("leaveonserver"));
412             setMarkMaxMessageSizeExceededSeen(
413                 maxmessagesize.getAttributeAsBoolean("markseen"));
414         }
415 
416         if (getLogger().isDebugEnabled())
417         {
418             getLogger().info(
419                 "Configured FetchMail fetch task " + getFetchTaskName());
420         }
421     }
422 
423 
424         
425     
426     /***
427      * Returns the fetchAll.
428      * @return boolean
429      */
430     public boolean isFetchAll()
431     {
432         return fieldFetchAll;
433     }
434 
435     /***
436      * Returns the fetchTaskName.
437      * @return String
438      */
439     public String getFetchTaskName()
440     {
441         return fieldFetchTaskName;
442     }
443 
444     /***
445      * Returns the host.
446      * @return String
447      */
448     public String getHost()
449     {
450         return fieldHost;
451     }
452 
453     /***
454      * Returns the keep.
455      * @return boolean
456      */
457     public boolean isLeave()
458     {
459         return fieldLeave;
460     }
461 
462     /***
463      * Returns the markSeen.
464      * @return boolean
465      */
466     public boolean isMarkSeen()
467     {
468         return fieldMarkSeen;
469     }
470     
471     /***
472      * Answers true if the folder should be opened read only.
473      * For this to be true the configuration options must not require
474      * folder updates.
475      * 
476      * @return boolean
477      */
478     protected boolean isOpenReadOnly()
479     {
480         return isLeave()
481             && !isMarkSeen()
482             && isLeaveBlacklisted()
483             && !isMarkBlacklistedSeen()
484             && isLeaveRemoteRecipient()
485             && !isMarkRemoteRecipientSeen()
486             && isLeaveUserUndefined()
487             && !isMarkUserUndefinedSeen()
488             && isLeaveUndeliverable()
489             && !isMarkUndeliverableSeen()
490             && isLeaveMaxMessageSizeExceeded()
491             && !isMarkMaxMessageSizeExceededSeen()              
492             && isLeaveRemoteReceivedHeaderInvalid()
493             && !isMarkRemoteReceivedHeaderInvalidSeen()             
494             ;
495     }   
496 
497     /***
498      * Returns the recurse.
499      * @return boolean
500      */
501     public boolean isRecurse()
502     {
503         return fieldRecurse;
504     }
505 
506     /***
507      * Returns the server.
508      * @return MailServer
509      */
510     public MailServer getServer()
511     {
512         return fieldServer;
513     }
514 
515     /***
516      * Sets the fetchAll.
517      * @param fetchAll The fetchAll to set
518      */
519     protected void setFetchAll(boolean fetchAll)
520     {
521         fieldFetchAll = fetchAll;
522     }
523 
524     /***
525      * Sets the fetchTaskName.
526      * @param fetchTaskName The fetchTaskName to set
527      */
528     protected void setFetchTaskName(String fetchTaskName)
529     {
530         fieldFetchTaskName = fetchTaskName;
531     }
532 
533     /***
534      * Sets the host.
535      * @param host The host to set
536      */
537     protected void setHost(String host)
538     {
539         fieldHost = host;
540     }
541 
542     /***
543      * Sets the keep.
544      * @param keep The keep to set
545      */
546     protected void setLeave(boolean keep)
547     {
548         fieldLeave = keep;
549     }
550 
551     /***
552      * Sets the markSeen.
553      * @param markSeen The markSeen to set
554      */
555     protected void setMarkSeen(boolean markSeen)
556     {
557         fieldMarkSeen = markSeen;
558     }
559 
560     /***
561      * Sets the recurse.
562      * @param recurse The recurse to set
563      */
564     protected void setRecurse(boolean recurse)
565     {
566         fieldRecurse = recurse;
567     }
568 
569     /***
570      * Sets the server.
571      * @param server The server to set
572      */
573     protected void setServer(MailServer server)
574     {
575         fieldServer = server;
576     }
577 
578     /***
579      * Returns the logger.
580      * @return Logger
581      */
582     public Logger getLogger()
583     {
584         return fieldLogger;
585     }
586 
587     /***
588      * Sets the logger.
589      * @param logger The logger to set
590      */
591     protected void setLogger(Logger logger)
592     {
593         fieldLogger = logger;
594     }
595 
596 /***
597  * Returns the localUsers.
598  * @return UsersRepository
599  */
600 public UsersRepository getLocalUsers()
601 {
602     return fieldLocalUsers;
603 }
604 
605 /***
606  * Sets the localUsers.
607  * @param localUsers The localUsers to set
608  */
609 protected void setLocalUsers(UsersRepository localUsers)
610 {
611     fieldLocalUsers = localUsers;
612 }
613 
614     /***
615      * Returns the keepRejected.
616      * @return boolean
617      */
618     public boolean isLeaveBlacklisted()
619     {
620         return fieldLeaveBlacklisted;
621     }
622 
623     /***
624      * Returns the markRejectedSeen.
625      * @return boolean
626      */
627     public boolean isMarkBlacklistedSeen()
628     {
629         return fieldMarkBlacklistedSeen;
630     }
631 
632     /***
633      * Sets the keepRejected.
634      * @param keepRejected The keepRejected to set
635      */
636     protected void setLeaveBlacklisted(boolean keepRejected)
637     {
638         fieldLeaveBlacklisted = keepRejected;
639     }
640 
641     /***
642      * Sets the markRejectedSeen.
643      * @param markRejectedSeen The markRejectedSeen to set
644      */
645     protected void setMarkBlacklistedSeen(boolean markRejectedSeen)
646     {
647         fieldMarkBlacklistedSeen = markRejectedSeen;
648     }
649 
650     /***
651      * Returns the blacklist.
652      * @return Set
653      */
654     public Set getBlacklist()
655     {
656         return fieldBlacklist;
657     }
658 
659     /***
660      * Sets the blacklist.
661      * @param blacklist The blacklist to set
662      */
663     protected void setBlacklist(Set blacklist)
664     {
665         fieldBlacklist = blacklist;
666     }
667     
668     /***
669      * Sets the blacklist.
670      * @param blacklist The blacklist to set
671      */
672     protected void setBlacklist(String blacklistValue)
673         throws ConfigurationException
674     {
675         StringTokenizer st = new StringTokenizer(blacklistValue, ", \t", false);
676         Set blacklist = new HashSet();
677         String token = null;
678         while (st.hasMoreTokens())
679         {
680             try
681             {
682                 token = st.nextToken();
683                 blacklist.add(new MailAddress(token));
684             }
685             catch (ParseException pe)
686             {
687                 throw new ConfigurationException(
688                     "Invalid blacklist mail address specified: " + token);
689             }
690         }
691         setBlacklist(blacklist);
692     }   
693 
694     /***
695      * Returns the localRecipientsOnly.
696      * @return boolean
697      */
698     public boolean isRejectUserUndefined()
699     {
700         return fieldRejectUserUndefined;
701     }
702 
703     /***
704      * Sets the localRecipientsOnly.
705      * @param localRecipientsOnly The localRecipientsOnly to set
706      */
707     protected void setRejectUserUndefined(boolean localRecipientsOnly)
708     {
709         fieldRejectUserUndefined = localRecipientsOnly;
710     }
711 
712     /***
713      * Returns the markExternalSeen.
714      * @return boolean
715      */
716     public boolean isMarkUserUndefinedSeen()
717     {
718         return fieldMarkUserUndefinedSeen;
719     }
720 
721     /***
722      * Sets the markExternalSeen.
723      * @param markExternalSeen The markExternalSeen to set
724      */
725     protected void setMarkUserUndefinedSeen(boolean markExternalSeen)
726     {
727         fieldMarkUserUndefinedSeen = markExternalSeen;
728     }
729 
730     /***
731      * Returns the leaveExternal.
732      * @return boolean
733      */
734     public boolean isLeaveUserUndefined()
735     {
736         return fieldLeaveUserUndefined;
737     }
738 
739     /***
740      * Sets the leaveExternal.
741      * @param leaveExternal The leaveExternal to set
742      */
743     protected void setLeaveUserUndefined(boolean leaveExternal)
744     {
745         fieldLeaveUserUndefined = leaveExternal;
746     }
747 
748     /***
749      * Returns the leaveRemoteRecipient.
750      * @return boolean
751      */
752     public boolean isLeaveRemoteRecipient()
753     {
754         return fieldLeaveRemoteRecipient;
755     }
756 
757     /***
758      * Returns the markRemoteRecipientSeen.
759      * @return boolean
760      */
761     public boolean isMarkRemoteRecipientSeen()
762     {
763         return fieldMarkRemoteRecipientSeen;
764     }
765 
766     /***
767      * Sets the leaveRemoteRecipient.
768      * @param leaveRemoteRecipient The leaveRemoteRecipient to set
769      */
770     protected void setLeaveRemoteRecipient(boolean leaveRemoteRecipient)
771     {
772         fieldLeaveRemoteRecipient = leaveRemoteRecipient;
773     }
774 
775     /***
776      * Sets the markRemoteRecipientSeen.
777      * @param markRemoteRecipientSeen The markRemoteRecipientSeen to set
778      */
779     protected void setMarkRemoteRecipientSeen(boolean markRemoteRecipientSeen)
780     {
781         fieldMarkRemoteRecipientSeen = markRemoteRecipientSeen;
782     }
783 
784     /***
785      * Returns the rejectRemoteRecipient.
786      * @return boolean
787      */
788     public boolean isRejectRemoteRecipient()
789     {
790         return fieldRejectRemoteRecipient;
791     }
792 
793     /***
794      * Sets the rejectRemoteRecipient.
795      * @param rejectRemoteRecipient The rejectRemoteRecipient to set
796      */
797     protected void setRejectRemoteRecipient(boolean rejectRemoteRecipient)
798     {
799         fieldRejectRemoteRecipient = rejectRemoteRecipient;
800     }
801 
802     /***
803      * Returns the defaultDomainName. Lazy initializes if required.
804      * @return String
805      */
806     public String getDefaultDomainName()
807     {
808         String defaultDomainName = null;
809         if (null == (defaultDomainName = getDefaultDomainNameBasic()))
810         {
811             updateDefaultDomainName();
812             return getDefaultDomainName();
813         }   
814         return defaultDomainName;
815     }
816     
817     /***
818      * Returns the defaultDomainName.
819      * @return String
820      */
821     private String getDefaultDomainNameBasic()
822     {
823         return fieldDefaultDomainName;
824     }   
825 
826     /***
827      * Validates and sets the defaultDomainName.
828      * @param defaultDomainName The defaultDomainName to set
829      */
830     protected void setDefaultDomainName(String defaultDomainName) throws ConfigurationException
831     {
832         validateDefaultDomainName(defaultDomainName);
833         setDefaultDomainNameBasic(defaultDomainName);
834     }
835 
836     /***
837      * Sets the defaultDomainName.
838      * @param defaultDomainName The defaultDomainName to set
839      */
840     private void setDefaultDomainNameBasic(String defaultDomainName)
841     {
842         fieldDefaultDomainName = defaultDomainName;
843     }
844 
845     /***
846      * Validates the defaultDomainName.
847      * @param defaultDomainName The defaultDomainName to validate
848      */
849     protected void validateDefaultDomainName(String defaultDomainName) throws ConfigurationException
850     {
851         if (!getServer().isLocalServer(defaultDomainName))
852         {
853             throw new ConfigurationException(
854                 "Default domain name is not a local server: "
855                     + defaultDomainName);
856         }
857     }
858     
859     /***
860      * Computes the defaultDomainName.
861      */
862     protected String computeDefaultDomainName()
863     {
864         String hostName = null;
865         try
866         {
867             // These shenanigans are required to get the fully qualified
868             // hostname prior to JDK 1.4 in which get getCanonicalHostName()
869             // does the job for us
870             InetAddress addr1 = java.net.InetAddress.getLocalHost();
871             InetAddress addr2 = addr1.getByName(addr1.getHostAddress());
872             hostName = addr2.getHostName();
873         }
874         catch (UnknownHostException ue)
875         {
876             hostName = "localhost";
877         }
878         return hostName;
879     }   
880     
881     /***
882      * Updates the defaultDomainName.
883      */
884     protected void updateDefaultDomainName()
885     {
886         setDefaultDomainNameBasic(computeDefaultDomainName());
887     }   
888 
889     /***
890      * Returns the leaveUndeliverable.
891      * @return boolean
892      */
893     public boolean isLeaveUndeliverable()
894     {
895         return fieldLeaveUndeliverable;
896     }
897 
898     /***
899      * Returns the markUndeliverableSeen.
900      * @return boolean
901      */
902     public boolean isMarkUndeliverableSeen()
903     {
904         return fieldMarkUndeliverableSeen;
905     }
906 
907     /***
908      * Sets the leaveUndeliverable.
909      * @param leaveUndeliverable The leaveUndeliverable to set
910      */
911     protected void setLeaveUndeliverable(boolean leaveUndeliverable)
912     {
913         fieldLeaveUndeliverable = leaveUndeliverable;
914     }
915 
916     /***
917      * Sets the markUndeliverableSeen.
918      * @param markUndeliverableSeen The markUndeliverableSeen to set
919      */
920     protected void setMarkUndeliverableSeen(boolean markUndeliverableSeen)
921     {
922         fieldMarkUndeliverableSeen = markUndeliverableSeen;
923     }
924 
925     /***
926      * Returns the rejectBlacklisted.
927      * @return boolean
928      */
929     public boolean isRejectBlacklisted()
930     {
931         return fieldRejectBlacklisted;
932     }
933 
934     /***
935      * Sets the rejectBlacklisted.
936      * @param rejectBlacklisted The rejectBlacklisted to set
937      */
938     protected void setRejectBlacklisted(boolean rejectBlacklisted)
939     {
940         fieldRejectBlacklisted = rejectBlacklisted;
941     }
942 
943     /***
944      * Returns the leaveRecipientNotFound.
945      * @return boolean
946      */
947     public boolean isLeaveRecipientNotFound()
948     {
949         return fieldLeaveRecipientNotFound;
950     }
951 
952     /***
953      * Returns the markRecipientNotFoundSeen.
954      * @return boolean
955      */
956     public boolean isMarkRecipientNotFoundSeen()
957     {
958         return fieldMarkRecipientNotFoundSeen;
959     }
960 
961     /***
962      * Returns the rejectRecipientNotFound.
963      * @return boolean
964      */
965     public boolean isRejectRecipientNotFound()
966     {
967         return fieldRejectRecipientNotFound;
968     }
969 
970     /***
971      * Sets the leaveRecipientNotFound.
972      * @param leaveRecipientNotFound The leaveRecipientNotFound to set
973      */
974     protected void setLeaveRecipientNotFound(boolean leaveRecipientNotFound)
975     {
976         fieldLeaveRecipientNotFound = leaveRecipientNotFound;
977     }
978 
979     /***
980      * Sets the markRecipientNotFoundSeen.
981      * @param markRecipientNotFoundSeen The markRecipientNotFoundSeen to set
982      */
983     protected void setMarkRecipientNotFoundSeen(boolean markRecipientNotFoundSeen)
984     {
985         fieldMarkRecipientNotFoundSeen = markRecipientNotFoundSeen;
986     }
987 
988     /***
989      * Sets the rejectRecipientNotFound.
990      * @param rejectRecipientNotFound The rejectRecipientNotFound to set
991      */
992     protected void setRejectRecipientNotFound(boolean rejectRecipientNotFound)
993     {
994         fieldRejectRecipientNotFound = rejectRecipientNotFound;
995     }
996 
997     /***
998      * Returns the deferRecipientNotFound.
999      * @return boolean
1000      */
1001     public boolean isDeferRecipientNotFound()
1002     {
1003         return fieldDeferRecipientNotFound;
1004     }
1005 
1006     /***
1007      * Sets the deferRecipientNotFound.
1008      * @param deferRecipientNotFound The deferRecepientNotFound to set
1009      */
1010     protected void setDeferRecipientNotFound(boolean deferRecipientNotFound)
1011     {
1012         fieldDeferRecipientNotFound = deferRecipientNotFound;
1013     }
1014 
1015     /***
1016      * Returns the remoteReceivedHeaderIndex.
1017      * @return int
1018      */
1019     public int getRemoteReceivedHeaderIndex()
1020     {
1021         return fieldRemoteReceivedHeaderIndex;
1022     }
1023 
1024     /***
1025      * Sets the remoteReceivedHeaderIndex.
1026      * @param remoteReceivedHeaderIndex The remoteReceivedHeaderIndex to set
1027      */
1028     protected void setRemoteReceivedHeaderIndex(int remoteReceivedHeaderIndex)
1029     {
1030         fieldRemoteReceivedHeaderIndex = remoteReceivedHeaderIndex;
1031     }
1032 
1033     /***
1034      * Returns the leaveMaxMessageSize.
1035      * @return boolean
1036      */
1037     public boolean isLeaveMaxMessageSizeExceeded()
1038     {
1039         return fieldLeaveMaxMessageSizeExceeded;
1040     }
1041 
1042     /***
1043      * Returns the markMaxMessageSizeSeen.
1044      * @return boolean
1045      */
1046     public boolean isMarkMaxMessageSizeExceededSeen()
1047     {
1048         return fieldMarkMaxMessageSizeExceededSeen;
1049     }
1050 
1051     /***
1052      * Returns the maxMessageSizeLimit.
1053      * @return int
1054      */
1055     public int getMaxMessageSizeLimit()
1056     {
1057         return fieldMaxMessageSizeLimit;
1058     }
1059 
1060     /***
1061      * Returns the rejectMaxMessageSize.
1062      * @return boolean
1063      */
1064     public boolean isRejectMaxMessageSizeExceeded()
1065     {
1066         return fieldRejectMaxMessageSizeExceeded;
1067     }
1068 
1069     /***
1070      * Sets the leaveMaxMessageSize.
1071      * @param leaveMaxMessageSize The leaveMaxMessageSize to set
1072      */
1073     protected void setLeaveMaxMessageSizeExceeded(boolean leaveMaxMessageSize)
1074     {
1075         fieldLeaveMaxMessageSizeExceeded = leaveMaxMessageSize;
1076     }
1077 
1078     /***
1079      * Sets the markMaxMessageSizeSeen.
1080      * @param markMaxMessageSizeSeen The markMaxMessageSizeSeen to set
1081      */
1082     protected void setMarkMaxMessageSizeExceededSeen(boolean markMaxMessageSizeSeen)
1083     {
1084         fieldMarkMaxMessageSizeExceededSeen = markMaxMessageSizeSeen;
1085     }
1086 
1087     /***
1088      * Sets the maxMessageSizeLimit.
1089      * @param maxMessageSizeLimit The maxMessageSizeLimit to set
1090      */
1091     protected void setMaxMessageSizeLimit(int maxMessageSizeLimit)
1092     {
1093         fieldMaxMessageSizeLimit = maxMessageSizeLimit;
1094     }
1095 
1096     /***
1097      * Sets the rejectMaxMessageSize.
1098      * @param rejectMaxMessageSize The rejectMaxMessageSize to set
1099      */
1100     protected void setRejectMaxMessageSizeExceeded(boolean rejectMaxMessageSize)
1101     {
1102         fieldRejectMaxMessageSizeExceeded = rejectMaxMessageSize;
1103     }
1104 
1105     /***
1106      * Returns the leaveRemoteReceivedHeaderInvalid.
1107      * @return boolean
1108      */
1109     public boolean isLeaveRemoteReceivedHeaderInvalid()
1110     {
1111         return fieldLeaveRemoteReceivedHeaderInvalid;
1112     }
1113 
1114     /***
1115      * Returns the markRemoteReceivedHeaderInvalidSeen.
1116      * @return boolean
1117      */
1118     public boolean isMarkRemoteReceivedHeaderInvalidSeen()
1119     {
1120         return fieldMarkRemoteReceivedHeaderInvalidSeen;
1121     }
1122 
1123     /***
1124      * Returns the rejectRemoteReceivedHeaderInvalid.
1125      * @return boolean
1126      */
1127     public boolean isRejectRemoteReceivedHeaderInvalid()
1128     {
1129         return fieldRejectRemoteReceivedHeaderInvalid;
1130     }
1131 
1132     /***
1133      * Sets the leaveRemoteReceivedHeaderInvalid.
1134      * @param leaveRemoteReceivedHeaderInvalid The leaveRemoteReceivedHeaderInvalid to set
1135      */
1136     protected void setLeaveRemoteReceivedHeaderInvalid(boolean leaveRemoteReceivedHeaderInvalid)
1137     {
1138         fieldLeaveRemoteReceivedHeaderInvalid =
1139             leaveRemoteReceivedHeaderInvalid;
1140     }
1141 
1142     /***
1143      * Sets the markRemoteReceivedHeaderInvalidSeen.
1144      * @param markRemoteReceivedHeaderInvalidSeen The markRemoteReceivedHeaderInvalidSeen to set
1145      */
1146     protected void setMarkRemoteReceivedHeaderInvalidSeen(boolean markRemoteReceivedHeaderInvalidSeen)
1147     {
1148         fieldMarkRemoteReceivedHeaderInvalidSeen =
1149             markRemoteReceivedHeaderInvalidSeen;
1150     }
1151 
1152     /***
1153      * Sets the rejectRemoteReceivedHeaderInvalid.
1154      * @param rejectRemoteReceivedHeaderInvalid The rejectRemoteReceivedHeaderInvalid to set
1155      */
1156     protected void setRejectRemoteReceivedHeaderInvalid(boolean rejectRemoteReceivedHeaderInvalid)
1157     {
1158         fieldRejectRemoteReceivedHeaderInvalid =
1159             rejectRemoteReceivedHeaderInvalid;
1160     }
1161 
1162 }