PageRenderTime 15ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/james-2.2.0/src/java/org/apache/james/fetchmail/ParsedConfiguration.java

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