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