0001: /****************************************************************
0002: * Licensed to the Apache Software Foundation (ASF) under one *
0003: * or more contributor license agreements. See the NOTICE file *
0004: * distributed with this work for additional information *
0005: * regarding copyright ownership. The ASF licenses this file *
0006: * to you under the Apache License, Version 2.0 (the *
0007: * "License"); you may not use this file except in compliance *
0008: * with the License. You may obtain a copy of the License at *
0009: * *
0010: * http://www.apache.org/licenses/LICENSE-2.0 *
0011: * *
0012: * Unless required by applicable law or agreed to in writing, *
0013: * software distributed under the License is distributed on an *
0014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
0015: * KIND, either express or implied. See the License for the *
0016: * specific language governing permissions and limitations *
0017: * under the License. *
0018: ****************************************************************/package org.apache.james.fetchmail;
0019:
0020: import java.net.InetAddress;
0021: import java.net.UnknownHostException;
0022: import java.util.HashSet;
0023: import java.util.Set;
0024: import java.util.StringTokenizer;
0025:
0026: import javax.mail.internet.ParseException;
0027:
0028: import org.apache.avalon.framework.configuration.Configuration;
0029: import org.apache.avalon.framework.configuration.ConfigurationException;
0030: import org.apache.avalon.framework.logger.Logger;
0031: import org.apache.james.services.MailServer;
0032: import org.apache.mailet.MailAddress;
0033: import org.apache.james.services.UsersRepository;
0034:
0035: /**
0036: * <p>Parses and validates an
0037: * <code>org.apache.avalon.framework.configuration.Configuration</code>.</p>
0038: *
0039: * <p>Creation Date: 27-May-03</p>
0040: *
0041: */
0042: class ParsedConfiguration {
0043: /**
0044: * The logger.
0045: */
0046: private Logger fieldLogger;
0047:
0048: /**
0049: * The name of the folder to fetch from the javamail provider
0050: *
0051: */
0052: private String fieldJavaMailFolderName = "INBOX";
0053:
0054: /**
0055: * The name of the javamail provider we want to user (pop3,imap,nntp,etc...)
0056: *
0057: */
0058: private String fieldJavaMailProviderName = "pop3";
0059:
0060: /**
0061: * Returns the javaMailFolderName.
0062: * @return String
0063: */
0064: public String getJavaMailFolderName() {
0065: return fieldJavaMailFolderName;
0066: }
0067:
0068: /**
0069: * Returns the javaMailProviderName.
0070: * @return String
0071: */
0072: public String getJavaMailProviderName() {
0073: return fieldJavaMailProviderName;
0074: }
0075:
0076: /**
0077: * Sets the javaMailFolderName.
0078: * @param javaMailFolderName The javaMailFolderName to set
0079: */
0080: protected void setJavaMailFolderName(String javaMailFolderName) {
0081: fieldJavaMailFolderName = javaMailFolderName;
0082: }
0083:
0084: /**
0085: * Sets the javaMailProviderName.
0086: * @param javaMailProviderName The javaMailProviderName to set
0087: */
0088: protected void setJavaMailProviderName(String javaMailProviderName) {
0089: fieldJavaMailProviderName = javaMailProviderName;
0090: }
0091:
0092: /**
0093: * Fetch both old (seen) and new messages from the mailserver. The default
0094: * is to fetch only messages the server are not marked as seen.
0095: */
0096: private boolean fieldFetchAll = false;
0097:
0098: /**
0099: * The unique, identifying name for this task
0100: */
0101: private String fieldFetchTaskName;
0102:
0103: /**
0104: * The server host name for this fetch task
0105: */
0106: private String fieldHost;
0107:
0108: /**
0109: * Keep retrieved messages on the remote mailserver. Normally, messages
0110: * are deleted from the folder on the mailserver after they have been retrieved
0111: */
0112: private boolean fieldLeave = false;
0113:
0114: /**
0115: * Keep blacklisted messages on the remote mailserver. Normally, messages
0116: * are kept in the folder on the mailserver if they have been rejected
0117: */
0118: private boolean fieldLeaveBlacklisted = true;
0119:
0120: /**
0121: * Keep messages for remote recipients on the remote mailserver. Normally,
0122: * messages are kept in the folder on the mailserver if they have been
0123: * rejected.
0124: */
0125: private boolean fieldLeaveRemoteRecipient = true;
0126:
0127: /**
0128: * Keep messages for undefined users on the remote mailserver. Normally,
0129: * messages are kept in the folder on the mailserver if they have been
0130: * rejected.
0131: */
0132: private boolean fieldLeaveUserUndefined = true;
0133:
0134: /**
0135: * Keep undeliverable messages on the remote mailserver. Normally,
0136: * messages are kept in the folder on the mailserver if they cannot
0137: * be delivered.
0138: */
0139: private boolean fieldLeaveUndeliverable = true;
0140:
0141: /**
0142: * Mark retrieved messages on the remote mailserver as seen. Normally,
0143: * messages are marked as seen after they have been retrieved
0144: */
0145: private boolean fieldMarkSeen = true;
0146:
0147: /**
0148: * Mark blacklisted messages on the remote mailserver as seen. Normally,
0149: * messages are not marked as seen if they have been rejected
0150: */
0151: private boolean fieldMarkBlacklistedSeen = false;
0152:
0153: /**
0154: * Mark remote recipient messages on the remote mailserver as seen. Normally,
0155: * messages are not marked as seen if they have been rejected
0156: */
0157: private boolean fieldMarkRemoteRecipientSeen = false;
0158:
0159: /**
0160: * Mark messages for undefined users on the remote mail server as seen.
0161: * Normally, messages are not marked as seen if they have been rejected.
0162: */
0163: private boolean fieldMarkUserUndefinedSeen = false;
0164:
0165: /**
0166: * Mark undeliverable messages on the remote mail server as seen.
0167: * Normally, messages are not marked as seen if they are undeliverable.
0168: */
0169: private boolean fieldMarkUndeliverableSeen = false;
0170:
0171: /**
0172: * Defer processing of messages for which the intended recipient cannot
0173: * be determined to the next pass.
0174: */
0175: private boolean fieldDeferRecipientNotFound = false;
0176:
0177: /**
0178: * Recurse folders if available?
0179: */
0180: private boolean fieldRecurse = false;
0181:
0182: /**
0183: * The MailServer service
0184: */
0185: private MailServer fieldServer;
0186:
0187: /**
0188: * The domain part to use to complete partial addresses
0189: */
0190: private String fieldDefaultDomainName;
0191:
0192: /**
0193: * Only accept mail for defined recipients.
0194: * All other mail is rejected.
0195: */
0196: private boolean fieldRejectUserUndefined;
0197:
0198: /**
0199: * The index of the received header to use to compute the remote address
0200: * and remote host name for a message. This is 0 based and defaults to -1.
0201: */
0202: private int fieldRemoteReceivedHeaderIndex = -1;
0203:
0204: /**
0205: * Keep messages with an invalid received header on the remote mailserver.
0206: * Normally, messages are kept in the folder on the mailserver if they have been
0207: * rejected
0208: */
0209: private boolean fieldLeaveRemoteReceivedHeaderInvalid = true;
0210:
0211: /**
0212: * Mark messages with an invalid received header on the remote mailserver as
0213: * seen. Normally, messages are not marked as seen if they have been rejected.
0214: */
0215: private boolean fieldMarkRemoteReceivedHeaderInvalidSeen = false;
0216:
0217: /**
0218: * Reject messages with an invalid received header.
0219: */
0220: private boolean fieldRejectRemoteReceivedHeaderInvalid;
0221:
0222: /**
0223: * Reject messages for which a recipient could not be determined.
0224: */
0225: private boolean fieldRejectRecipientNotFound;
0226:
0227: /**
0228: * Leave messages on the server for which a recipient could not be
0229: * determined.
0230: */
0231: private boolean fieldLeaveRecipientNotFound;
0232:
0233: /**
0234: * Mark as seen messages on the server for which a recipient could not be
0235: * determined.
0236: */
0237: private boolean fieldMarkRecipientNotFoundSeen;
0238:
0239: /**
0240: * Reject mail for blacklisted users
0241: */
0242: private boolean fieldRejectBlacklisted;
0243:
0244: /**
0245: * Only accept mail for local recipients.
0246: * All other mail is rejected.
0247: */
0248: private boolean fieldRejectRemoteRecipient;
0249:
0250: /**
0251: * The Set of MailAddresses for whom mail should be rejected
0252: */
0253: private Set fieldBlacklist;
0254:
0255: /**
0256: * The maximum message size limit
0257: * 0 means no limit.
0258: */
0259: private int fieldMaxMessageSizeLimit = 0;
0260:
0261: /**
0262: * Reject mail exceeding the maximum message size limit
0263: */
0264: private boolean fieldRejectMaxMessageSizeExceeded;
0265:
0266: /**
0267: * Leave messages on the server that exceed the maximum message size limit.
0268: */
0269: private boolean fieldLeaveMaxMessageSizeExceeded;
0270:
0271: /**
0272: * Mark as seen messages on the server that exceed the maximum message size
0273: * limit.
0274: */
0275: private boolean fieldMarkMaxMessageSizeExceededSeen;
0276:
0277: /**
0278: * The Local Users repository
0279: */
0280: private UsersRepository fieldLocalUsers;
0281:
0282: /**
0283: * Constructor for ParsedConfiguration.
0284: */
0285: private ParsedConfiguration() {
0286: super ();
0287: }
0288:
0289: /**
0290: * Constructor for ParsedConfiguration.
0291: * @param configuration
0292: * @param logger
0293: * @param server
0294: * @param localUsers
0295: * @throws ConfigurationException
0296: */
0297: public ParsedConfiguration(Configuration configuration,
0298: Logger logger, MailServer server, UsersRepository localUsers)
0299: throws ConfigurationException {
0300: this ();
0301: setLogger(logger);
0302: setServer(server);
0303: setLocalUsers(localUsers);
0304: configure(configuration);
0305: }
0306:
0307: /**
0308: * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
0309: */
0310: protected void configure(Configuration conf)
0311: throws ConfigurationException {
0312: setHost(conf.getChild("host").getValue());
0313:
0314: setFetchTaskName(conf.getAttribute("name"));
0315: setJavaMailProviderName(conf.getChild("javaMailProviderName")
0316: .getValue());
0317: setJavaMailFolderName(conf.getChild("javaMailFolderName")
0318: .getValue());
0319: setRecurse(conf.getChild("recursesubfolders")
0320: .getValueAsBoolean());
0321:
0322: Configuration recipientNotFound = conf
0323: .getChild("recipientnotfound");
0324: setDeferRecipientNotFound(recipientNotFound
0325: .getAttributeAsBoolean("defer"));
0326: setRejectRecipientNotFound(recipientNotFound
0327: .getAttributeAsBoolean("reject"));
0328: setLeaveRecipientNotFound(recipientNotFound
0329: .getAttributeAsBoolean("leaveonserver"));
0330: setMarkRecipientNotFoundSeen(recipientNotFound
0331: .getAttributeAsBoolean("markseen"));
0332:
0333: Configuration defaultDomainName = conf.getChild(
0334: "defaultdomain", false);
0335: if (null != defaultDomainName)
0336: setDefaultDomainName(defaultDomainName.getValue());
0337:
0338: setFetchAll(conf.getChild("fetchall").getValueAsBoolean());
0339:
0340: Configuration fetched = conf.getChild("fetched");
0341: setLeave(fetched.getAttributeAsBoolean("leaveonserver"));
0342: setMarkSeen(fetched.getAttributeAsBoolean("markseen"));
0343:
0344: Configuration remoterecipient = conf
0345: .getChild("remoterecipient");
0346: setRejectRemoteRecipient(remoterecipient
0347: .getAttributeAsBoolean("reject"));
0348: setLeaveRemoteRecipient(remoterecipient
0349: .getAttributeAsBoolean("leaveonserver"));
0350: setMarkRemoteRecipientSeen(remoterecipient
0351: .getAttributeAsBoolean("markseen"));
0352:
0353: Configuration blacklist = conf.getChild("blacklist");
0354: setBlacklist(blacklist.getValue(""));
0355: setRejectBlacklisted(blacklist.getAttributeAsBoolean("reject"));
0356: setLeaveBlacklisted(blacklist
0357: .getAttributeAsBoolean("leaveonserver"));
0358: setMarkBlacklistedSeen(blacklist
0359: .getAttributeAsBoolean("markseen"));
0360:
0361: Configuration userundefined = conf.getChild("userundefined");
0362: setRejectUserUndefined(userundefined
0363: .getAttributeAsBoolean("reject"));
0364: setLeaveUserUndefined(userundefined
0365: .getAttributeAsBoolean("leaveonserver"));
0366: setMarkUserUndefinedSeen(userundefined
0367: .getAttributeAsBoolean("markseen"));
0368:
0369: Configuration undeliverable = conf.getChild("undeliverable");
0370: setLeaveUndeliverable(undeliverable
0371: .getAttributeAsBoolean("leaveonserver"));
0372: setMarkUndeliverableSeen(undeliverable
0373: .getAttributeAsBoolean("markseen"));
0374:
0375: Configuration remotereceivedheader = conf.getChild(
0376: "remotereceivedheader", false);
0377: if (null != remotereceivedheader) {
0378: setRemoteReceivedHeaderIndex(remotereceivedheader
0379: .getAttributeAsInteger("index"));
0380: setRejectRemoteReceivedHeaderInvalid(remotereceivedheader
0381: .getAttributeAsBoolean("reject"));
0382: setLeaveRemoteReceivedHeaderInvalid(remotereceivedheader
0383: .getAttributeAsBoolean("leaveonserver"));
0384: setMarkRemoteReceivedHeaderInvalidSeen(remotereceivedheader
0385: .getAttributeAsBoolean("markseen"));
0386: }
0387:
0388: Configuration maxmessagesize = conf.getChild("maxmessagesize",
0389: false);
0390: if (null != maxmessagesize) {
0391: setMaxMessageSizeLimit(maxmessagesize
0392: .getAttributeAsInteger("limit") * 1024);
0393: setRejectMaxMessageSizeExceeded(maxmessagesize
0394: .getAttributeAsBoolean("reject"));
0395: setLeaveMaxMessageSizeExceeded(maxmessagesize
0396: .getAttributeAsBoolean("leaveonserver"));
0397: setMarkMaxMessageSizeExceededSeen(maxmessagesize
0398: .getAttributeAsBoolean("markseen"));
0399: }
0400:
0401: if (getLogger().isDebugEnabled()) {
0402: getLogger().info(
0403: "Configured FetchMail fetch task "
0404: + getFetchTaskName());
0405: }
0406: }
0407:
0408: /**
0409: * Returns the fetchAll.
0410: * @return boolean
0411: */
0412: public boolean isFetchAll() {
0413: return fieldFetchAll;
0414: }
0415:
0416: /**
0417: * Returns the fetchTaskName.
0418: * @return String
0419: */
0420: public String getFetchTaskName() {
0421: return fieldFetchTaskName;
0422: }
0423:
0424: /**
0425: * Returns the host.
0426: * @return String
0427: */
0428: public String getHost() {
0429: return fieldHost;
0430: }
0431:
0432: /**
0433: * Returns the keep.
0434: * @return boolean
0435: */
0436: public boolean isLeave() {
0437: return fieldLeave;
0438: }
0439:
0440: /**
0441: * Returns the markSeen.
0442: * @return boolean
0443: */
0444: public boolean isMarkSeen() {
0445: return fieldMarkSeen;
0446: }
0447:
0448: /**
0449: * Answers true if the folder should be opened read only.
0450: * For this to be true the configuration options must not require
0451: * folder updates.
0452: *
0453: * @return boolean
0454: */
0455: protected boolean isOpenReadOnly() {
0456: return isLeave() && !isMarkSeen() && isLeaveBlacklisted()
0457: && !isMarkBlacklistedSeen() && isLeaveRemoteRecipient()
0458: && !isMarkRemoteRecipientSeen()
0459: && isLeaveUserUndefined() && !isMarkUserUndefinedSeen()
0460: && isLeaveUndeliverable() && !isMarkUndeliverableSeen()
0461: && isLeaveMaxMessageSizeExceeded()
0462: && !isMarkMaxMessageSizeExceededSeen()
0463: && isLeaveRemoteReceivedHeaderInvalid()
0464: && !isMarkRemoteReceivedHeaderInvalidSeen();
0465: }
0466:
0467: /**
0468: * Returns the recurse.
0469: * @return boolean
0470: */
0471: public boolean isRecurse() {
0472: return fieldRecurse;
0473: }
0474:
0475: /**
0476: * Returns the server.
0477: * @return MailServer
0478: */
0479: public MailServer getServer() {
0480: return fieldServer;
0481: }
0482:
0483: /**
0484: * Sets the fetchAll.
0485: * @param fetchAll The fetchAll to set
0486: */
0487: protected void setFetchAll(boolean fetchAll) {
0488: fieldFetchAll = fetchAll;
0489: }
0490:
0491: /**
0492: * Sets the fetchTaskName.
0493: * @param fetchTaskName The fetchTaskName to set
0494: */
0495: protected void setFetchTaskName(String fetchTaskName) {
0496: fieldFetchTaskName = fetchTaskName;
0497: }
0498:
0499: /**
0500: * Sets the host.
0501: * @param host The host to set
0502: */
0503: protected void setHost(String host) {
0504: fieldHost = host;
0505: }
0506:
0507: /**
0508: * Sets the keep.
0509: * @param keep The keep to set
0510: */
0511: protected void setLeave(boolean keep) {
0512: fieldLeave = keep;
0513: }
0514:
0515: /**
0516: * Sets the markSeen.
0517: * @param markSeen The markSeen to set
0518: */
0519: protected void setMarkSeen(boolean markSeen) {
0520: fieldMarkSeen = markSeen;
0521: }
0522:
0523: /**
0524: * Sets the recurse.
0525: * @param recurse The recurse to set
0526: */
0527: protected void setRecurse(boolean recurse) {
0528: fieldRecurse = recurse;
0529: }
0530:
0531: /**
0532: * Sets the server.
0533: * @param server The server to set
0534: */
0535: protected void setServer(MailServer server) {
0536: fieldServer = server;
0537: }
0538:
0539: /**
0540: * Returns the logger.
0541: * @return Logger
0542: */
0543: public Logger getLogger() {
0544: return fieldLogger;
0545: }
0546:
0547: /**
0548: * Sets the logger.
0549: * @param logger The logger to set
0550: */
0551: protected void setLogger(Logger logger) {
0552: fieldLogger = logger;
0553: }
0554:
0555: /**
0556: * Returns the localUsers.
0557: * @return UsersRepository
0558: */
0559: public UsersRepository getLocalUsers() {
0560: return fieldLocalUsers;
0561: }
0562:
0563: /**
0564: * Sets the localUsers.
0565: * @param localUsers The localUsers to set
0566: */
0567: protected void setLocalUsers(UsersRepository localUsers) {
0568: fieldLocalUsers = localUsers;
0569: }
0570:
0571: /**
0572: * Returns the keepRejected.
0573: * @return boolean
0574: */
0575: public boolean isLeaveBlacklisted() {
0576: return fieldLeaveBlacklisted;
0577: }
0578:
0579: /**
0580: * Returns the markRejectedSeen.
0581: * @return boolean
0582: */
0583: public boolean isMarkBlacklistedSeen() {
0584: return fieldMarkBlacklistedSeen;
0585: }
0586:
0587: /**
0588: * Sets the keepRejected.
0589: * @param keepRejected The keepRejected to set
0590: */
0591: protected void setLeaveBlacklisted(boolean keepRejected) {
0592: fieldLeaveBlacklisted = keepRejected;
0593: }
0594:
0595: /**
0596: * Sets the markRejectedSeen.
0597: * @param markRejectedSeen The markRejectedSeen to set
0598: */
0599: protected void setMarkBlacklistedSeen(boolean markRejectedSeen) {
0600: fieldMarkBlacklistedSeen = markRejectedSeen;
0601: }
0602:
0603: /**
0604: * Returns the blacklist.
0605: * @return Set
0606: */
0607: public Set getBlacklist() {
0608: return fieldBlacklist;
0609: }
0610:
0611: /**
0612: * Sets the blacklist.
0613: * @param blacklist The blacklist to set
0614: */
0615: protected void setBlacklist(Set blacklist) {
0616: fieldBlacklist = blacklist;
0617: }
0618:
0619: /**
0620: * Sets the blacklist.
0621: * @param blacklist The blacklist to set
0622: */
0623: protected void setBlacklist(String blacklistValue)
0624: throws ConfigurationException {
0625: StringTokenizer st = new StringTokenizer(blacklistValue,
0626: ", \t", false);
0627: Set blacklist = new HashSet();
0628: String token = null;
0629: while (st.hasMoreTokens()) {
0630: try {
0631: token = st.nextToken();
0632: blacklist.add(new MailAddress(token));
0633: } catch (ParseException pe) {
0634: throw new ConfigurationException(
0635: "Invalid blacklist mail address specified: "
0636: + token);
0637: }
0638: }
0639: setBlacklist(blacklist);
0640: }
0641:
0642: /**
0643: * Returns the localRecipientsOnly.
0644: * @return boolean
0645: */
0646: public boolean isRejectUserUndefined() {
0647: return fieldRejectUserUndefined;
0648: }
0649:
0650: /**
0651: * Sets the localRecipientsOnly.
0652: * @param localRecipientsOnly The localRecipientsOnly to set
0653: */
0654: protected void setRejectUserUndefined(boolean localRecipientsOnly) {
0655: fieldRejectUserUndefined = localRecipientsOnly;
0656: }
0657:
0658: /**
0659: * Returns the markExternalSeen.
0660: * @return boolean
0661: */
0662: public boolean isMarkUserUndefinedSeen() {
0663: return fieldMarkUserUndefinedSeen;
0664: }
0665:
0666: /**
0667: * Sets the markExternalSeen.
0668: * @param markExternalSeen The markExternalSeen to set
0669: */
0670: protected void setMarkUserUndefinedSeen(boolean markExternalSeen) {
0671: fieldMarkUserUndefinedSeen = markExternalSeen;
0672: }
0673:
0674: /**
0675: * Returns the leaveExternal.
0676: * @return boolean
0677: */
0678: public boolean isLeaveUserUndefined() {
0679: return fieldLeaveUserUndefined;
0680: }
0681:
0682: /**
0683: * Sets the leaveExternal.
0684: * @param leaveExternal The leaveExternal to set
0685: */
0686: protected void setLeaveUserUndefined(boolean leaveExternal) {
0687: fieldLeaveUserUndefined = leaveExternal;
0688: }
0689:
0690: /**
0691: * Returns the leaveRemoteRecipient.
0692: * @return boolean
0693: */
0694: public boolean isLeaveRemoteRecipient() {
0695: return fieldLeaveRemoteRecipient;
0696: }
0697:
0698: /**
0699: * Returns the markRemoteRecipientSeen.
0700: * @return boolean
0701: */
0702: public boolean isMarkRemoteRecipientSeen() {
0703: return fieldMarkRemoteRecipientSeen;
0704: }
0705:
0706: /**
0707: * Sets the leaveRemoteRecipient.
0708: * @param leaveRemoteRecipient The leaveRemoteRecipient to set
0709: */
0710: protected void setLeaveRemoteRecipient(boolean leaveRemoteRecipient) {
0711: fieldLeaveRemoteRecipient = leaveRemoteRecipient;
0712: }
0713:
0714: /**
0715: * Sets the markRemoteRecipientSeen.
0716: * @param markRemoteRecipientSeen The markRemoteRecipientSeen to set
0717: */
0718: protected void setMarkRemoteRecipientSeen(
0719: boolean markRemoteRecipientSeen) {
0720: fieldMarkRemoteRecipientSeen = markRemoteRecipientSeen;
0721: }
0722:
0723: /**
0724: * Returns the rejectRemoteRecipient.
0725: * @return boolean
0726: */
0727: public boolean isRejectRemoteRecipient() {
0728: return fieldRejectRemoteRecipient;
0729: }
0730:
0731: /**
0732: * Sets the rejectRemoteRecipient.
0733: * @param rejectRemoteRecipient The rejectRemoteRecipient to set
0734: */
0735: protected void setRejectRemoteRecipient(
0736: boolean rejectRemoteRecipient) {
0737: fieldRejectRemoteRecipient = rejectRemoteRecipient;
0738: }
0739:
0740: /**
0741: * Returns the defaultDomainName. Lazy initializes if required.
0742: * @return String
0743: */
0744: public String getDefaultDomainName() {
0745: String defaultDomainName = null;
0746: if (null == (defaultDomainName = getDefaultDomainNameBasic())) {
0747: updateDefaultDomainName();
0748: return getDefaultDomainName();
0749: }
0750: return defaultDomainName;
0751: }
0752:
0753: /**
0754: * Returns the defaultDomainName.
0755: * @return String
0756: */
0757: private String getDefaultDomainNameBasic() {
0758: return fieldDefaultDomainName;
0759: }
0760:
0761: /**
0762: * Validates and sets the defaultDomainName.
0763: * @param defaultDomainName The defaultDomainName to set
0764: */
0765: protected void setDefaultDomainName(String defaultDomainName)
0766: throws ConfigurationException {
0767: validateDefaultDomainName(defaultDomainName);
0768: setDefaultDomainNameBasic(defaultDomainName);
0769: }
0770:
0771: /**
0772: * Sets the defaultDomainName.
0773: * @param defaultDomainName The defaultDomainName to set
0774: */
0775: private void setDefaultDomainNameBasic(String defaultDomainName) {
0776: fieldDefaultDomainName = defaultDomainName;
0777: }
0778:
0779: /**
0780: * Validates the defaultDomainName.
0781: * @param defaultDomainName The defaultDomainName to validate
0782: */
0783: protected void validateDefaultDomainName(String defaultDomainName)
0784: throws ConfigurationException {
0785: if (!getServer().isLocalServer(defaultDomainName)) {
0786: throw new ConfigurationException(
0787: "Default domain name is not a local server: "
0788: + defaultDomainName);
0789: }
0790: }
0791:
0792: /**
0793: * Computes the defaultDomainName.
0794: */
0795: protected String computeDefaultDomainName() {
0796: String hostName = null;
0797: try {
0798: // These shenanigans are required to get the fully qualified
0799: // hostname prior to JDK 1.4 in which get getCanonicalHostName()
0800: // does the job for us
0801: InetAddress addr1 = java.net.InetAddress.getLocalHost();
0802: InetAddress addr2 = addr1.getByName(addr1.getHostAddress());
0803: hostName = addr2.getHostName();
0804: } catch (UnknownHostException ue) {
0805: hostName = "localhost";
0806: }
0807: return hostName;
0808: }
0809:
0810: /**
0811: * Updates the defaultDomainName.
0812: */
0813: protected void updateDefaultDomainName() {
0814: setDefaultDomainNameBasic(computeDefaultDomainName());
0815: }
0816:
0817: /**
0818: * Returns the leaveUndeliverable.
0819: * @return boolean
0820: */
0821: public boolean isLeaveUndeliverable() {
0822: return fieldLeaveUndeliverable;
0823: }
0824:
0825: /**
0826: * Returns the markUndeliverableSeen.
0827: * @return boolean
0828: */
0829: public boolean isMarkUndeliverableSeen() {
0830: return fieldMarkUndeliverableSeen;
0831: }
0832:
0833: /**
0834: * Sets the leaveUndeliverable.
0835: * @param leaveUndeliverable The leaveUndeliverable to set
0836: */
0837: protected void setLeaveUndeliverable(boolean leaveUndeliverable) {
0838: fieldLeaveUndeliverable = leaveUndeliverable;
0839: }
0840:
0841: /**
0842: * Sets the markUndeliverableSeen.
0843: * @param markUndeliverableSeen The markUndeliverableSeen to set
0844: */
0845: protected void setMarkUndeliverableSeen(
0846: boolean markUndeliverableSeen) {
0847: fieldMarkUndeliverableSeen = markUndeliverableSeen;
0848: }
0849:
0850: /**
0851: * Returns the rejectBlacklisted.
0852: * @return boolean
0853: */
0854: public boolean isRejectBlacklisted() {
0855: return fieldRejectBlacklisted;
0856: }
0857:
0858: /**
0859: * Sets the rejectBlacklisted.
0860: * @param rejectBlacklisted The rejectBlacklisted to set
0861: */
0862: protected void setRejectBlacklisted(boolean rejectBlacklisted) {
0863: fieldRejectBlacklisted = rejectBlacklisted;
0864: }
0865:
0866: /**
0867: * Returns the leaveRecipientNotFound.
0868: * @return boolean
0869: */
0870: public boolean isLeaveRecipientNotFound() {
0871: return fieldLeaveRecipientNotFound;
0872: }
0873:
0874: /**
0875: * Returns the markRecipientNotFoundSeen.
0876: * @return boolean
0877: */
0878: public boolean isMarkRecipientNotFoundSeen() {
0879: return fieldMarkRecipientNotFoundSeen;
0880: }
0881:
0882: /**
0883: * Returns the rejectRecipientNotFound.
0884: * @return boolean
0885: */
0886: public boolean isRejectRecipientNotFound() {
0887: return fieldRejectRecipientNotFound;
0888: }
0889:
0890: /**
0891: * Sets the leaveRecipientNotFound.
0892: * @param leaveRecipientNotFound The leaveRecipientNotFound to set
0893: */
0894: protected void setLeaveRecipientNotFound(
0895: boolean leaveRecipientNotFound) {
0896: fieldLeaveRecipientNotFound = leaveRecipientNotFound;
0897: }
0898:
0899: /**
0900: * Sets the markRecipientNotFoundSeen.
0901: * @param markRecipientNotFoundSeen The markRecipientNotFoundSeen to set
0902: */
0903: protected void setMarkRecipientNotFoundSeen(
0904: boolean markRecipientNotFoundSeen) {
0905: fieldMarkRecipientNotFoundSeen = markRecipientNotFoundSeen;
0906: }
0907:
0908: /**
0909: * Sets the rejectRecipientNotFound.
0910: * @param rejectRecipientNotFound The rejectRecipientNotFound to set
0911: */
0912: protected void setRejectRecipientNotFound(
0913: boolean rejectRecipientNotFound) {
0914: fieldRejectRecipientNotFound = rejectRecipientNotFound;
0915: }
0916:
0917: /**
0918: * Returns the deferRecipientNotFound.
0919: * @return boolean
0920: */
0921: public boolean isDeferRecipientNotFound() {
0922: return fieldDeferRecipientNotFound;
0923: }
0924:
0925: /**
0926: * Sets the deferRecipientNotFound.
0927: * @param deferRecipientNotFound The deferRecepientNotFound to set
0928: */
0929: protected void setDeferRecipientNotFound(
0930: boolean deferRecipientNotFound) {
0931: fieldDeferRecipientNotFound = deferRecipientNotFound;
0932: }
0933:
0934: /**
0935: * Returns the remoteReceivedHeaderIndex.
0936: * @return int
0937: */
0938: public int getRemoteReceivedHeaderIndex() {
0939: return fieldRemoteReceivedHeaderIndex;
0940: }
0941:
0942: /**
0943: * Sets the remoteReceivedHeaderIndex.
0944: * @param remoteReceivedHeaderIndex The remoteReceivedHeaderIndex to set
0945: */
0946: protected void setRemoteReceivedHeaderIndex(
0947: int remoteReceivedHeaderIndex) {
0948: fieldRemoteReceivedHeaderIndex = remoteReceivedHeaderIndex;
0949: }
0950:
0951: /**
0952: * Returns the leaveMaxMessageSize.
0953: * @return boolean
0954: */
0955: public boolean isLeaveMaxMessageSizeExceeded() {
0956: return fieldLeaveMaxMessageSizeExceeded;
0957: }
0958:
0959: /**
0960: * Returns the markMaxMessageSizeSeen.
0961: * @return boolean
0962: */
0963: public boolean isMarkMaxMessageSizeExceededSeen() {
0964: return fieldMarkMaxMessageSizeExceededSeen;
0965: }
0966:
0967: /**
0968: * Returns the maxMessageSizeLimit.
0969: * @return int
0970: */
0971: public int getMaxMessageSizeLimit() {
0972: return fieldMaxMessageSizeLimit;
0973: }
0974:
0975: /**
0976: * Returns the rejectMaxMessageSize.
0977: * @return boolean
0978: */
0979: public boolean isRejectMaxMessageSizeExceeded() {
0980: return fieldRejectMaxMessageSizeExceeded;
0981: }
0982:
0983: /**
0984: * Sets the leaveMaxMessageSize.
0985: * @param leaveMaxMessageSize The leaveMaxMessageSize to set
0986: */
0987: protected void setLeaveMaxMessageSizeExceeded(
0988: boolean leaveMaxMessageSize) {
0989: fieldLeaveMaxMessageSizeExceeded = leaveMaxMessageSize;
0990: }
0991:
0992: /**
0993: * Sets the markMaxMessageSizeSeen.
0994: * @param markMaxMessageSizeSeen The markMaxMessageSizeSeen to set
0995: */
0996: protected void setMarkMaxMessageSizeExceededSeen(
0997: boolean markMaxMessageSizeSeen) {
0998: fieldMarkMaxMessageSizeExceededSeen = markMaxMessageSizeSeen;
0999: }
1000:
1001: /**
1002: * Sets the maxMessageSizeLimit.
1003: * @param maxMessageSizeLimit The maxMessageSizeLimit to set
1004: */
1005: protected void setMaxMessageSizeLimit(int maxMessageSizeLimit) {
1006: fieldMaxMessageSizeLimit = maxMessageSizeLimit;
1007: }
1008:
1009: /**
1010: * Sets the rejectMaxMessageSize.
1011: * @param rejectMaxMessageSize The rejectMaxMessageSize to set
1012: */
1013: protected void setRejectMaxMessageSizeExceeded(
1014: boolean rejectMaxMessageSize) {
1015: fieldRejectMaxMessageSizeExceeded = rejectMaxMessageSize;
1016: }
1017:
1018: /**
1019: * Returns the leaveRemoteReceivedHeaderInvalid.
1020: * @return boolean
1021: */
1022: public boolean isLeaveRemoteReceivedHeaderInvalid() {
1023: return fieldLeaveRemoteReceivedHeaderInvalid;
1024: }
1025:
1026: /**
1027: * Returns the markRemoteReceivedHeaderInvalidSeen.
1028: * @return boolean
1029: */
1030: public boolean isMarkRemoteReceivedHeaderInvalidSeen() {
1031: return fieldMarkRemoteReceivedHeaderInvalidSeen;
1032: }
1033:
1034: /**
1035: * Returns the rejectRemoteReceivedHeaderInvalid.
1036: * @return boolean
1037: */
1038: public boolean isRejectRemoteReceivedHeaderInvalid() {
1039: return fieldRejectRemoteReceivedHeaderInvalid;
1040: }
1041:
1042: /**
1043: * Sets the leaveRemoteReceivedHeaderInvalid.
1044: * @param leaveRemoteReceivedHeaderInvalid The leaveRemoteReceivedHeaderInvalid to set
1045: */
1046: protected void setLeaveRemoteReceivedHeaderInvalid(
1047: boolean leaveRemoteReceivedHeaderInvalid) {
1048: fieldLeaveRemoteReceivedHeaderInvalid = leaveRemoteReceivedHeaderInvalid;
1049: }
1050:
1051: /**
1052: * Sets the markRemoteReceivedHeaderInvalidSeen.
1053: * @param markRemoteReceivedHeaderInvalidSeen The markRemoteReceivedHeaderInvalidSeen to set
1054: */
1055: protected void setMarkRemoteReceivedHeaderInvalidSeen(
1056: boolean markRemoteReceivedHeaderInvalidSeen) {
1057: fieldMarkRemoteReceivedHeaderInvalidSeen = markRemoteReceivedHeaderInvalidSeen;
1058: }
1059:
1060: /**
1061: * Sets the rejectRemoteReceivedHeaderInvalid.
1062: * @param rejectRemoteReceivedHeaderInvalid The rejectRemoteReceivedHeaderInvalid to set
1063: */
1064: protected void setRejectRemoteReceivedHeaderInvalid(
1065: boolean rejectRemoteReceivedHeaderInvalid) {
1066: fieldRejectRemoteReceivedHeaderInvalid = rejectRemoteReceivedHeaderInvalid;
1067: }
1068:
1069: }
|