1 17 package org.apache.geronimo.mail; 18 19 import java.util.Properties ; 20 21 import org.apache.commons.logging.Log; 22 import org.apache.commons.logging.LogFactory; 23 24 import org.apache.geronimo.gbean.GBeanInfo; 25 import org.apache.geronimo.gbean.GBeanInfoBuilder; 26 27 39 public class SMTPSTransportGBean extends ProtocolGBean { 40 41 static public final String SMTPS_PORT = "mail.smtp.port"; 43 static public final String SMTPS_CONNECTION_TIMEOUT = "mail.smtp.connectiontimeout"; 44 static public final String SMTPS_TIMEOUT = "mail.smtp.timeout"; 45 static public final String SMTPS_FROM = "mail.smtp.from"; 46 static public final String SMTPS_AUTH = "mail.smtp.auth"; 47 static public final String SMTPS_REALM = "mail.smtp.sasl.realm"; 48 static public final String SMTPS_QUITWAIT = "mail.smtp.quitwait"; 49 static public final String SMTPS_FACTORY_CLASS = "mail.smtp.socketFactory.class"; 50 static public final String SMTPS_FACTORY_FALLBACK = "mail.smtp.socketFactory.fallback"; 51 static public final String SMTPS_FACTORY_PORT = "mail.smtp.socketFactory.port"; 52 static public final String SMTPS_LOCALHOST = "mail.smtp.localhost"; 53 static public final String SMTPS_LOCALADDRESS = "mail.smtp.localaddress"; 54 static public final String SMTPS_LOCALPORT = "mail.smtp.localport"; 55 static public final String SMTPS_EHLO = "mail.smtp.ehlo"; 56 static public final String SMTPS_SUBMITTER = "mail.smtp.submitter"; 57 static public final String SMTPS_DSN_NOTIFY = "mail.smtp.dsn.notify"; 58 static public final String SMTPS_DSN_RET = "mail.smtp.dsn.ret"; 59 static public final String SMTPS_8BITMIME = "mail.smtp.allow8bitmime"; 60 static public final String SMTPS_SEND_PARTIAL = "mail.smtp.sendpartial"; 61 static public final String SMTPS_REPORT_SUCCESS = "mail.smtp.reportsuccess"; 62 static public final String SMTPS_MAIL_EXTENSION = "mail.smtp.mailextension"; 63 static public final String SMTPS_STARTTLS_ENABLE = "mail.smtp.starttls.enable"; 64 65 static public final String GBEAN_EHLO = "ehlo"; 66 static public final String GBEAN_SUBMITTER = "submitter"; 67 static public final String GBEAN_DSN_NOTIFY = "dsnNotify"; 68 static public final String GBEAN_DSN_RET = "dsnRet"; 69 static public final String GBEAN_8BITMIME = "allow8bitmime"; 70 static public final String GBEAN_SEND_PARTIAL = "sendPartical"; 71 static public final String GBEAN_REPORT_SUCCESS = "reportSuccess"; 72 static public final String GBEAN_MAIL_EXTENSION = "mailExtension"; 73 static public final String GBEAN_STARTTLS_ENABLE = "startTLSEnable"; 74 75 private final Log log = LogFactory.getLog(SMTPSTransportGBean.class); 76 77 private Integer port; 78 private Integer connectionTimeout; 79 private Integer timeout; 80 private String from; 81 private String localhost; 82 private String localaddress; 83 private Integer localport; 84 private Boolean ehlo; 85 private Boolean auth; 86 private String submitter; 87 private String dsnNotify; 88 private String dsnRet; 89 private Boolean allow8bitmime; 90 private Boolean sendPartial; 91 private String saslRealm; 92 private Boolean quitWait; 93 private Boolean reportSuccess; 94 private String socketFactoryClass; 95 private Boolean socketFactoryFallback; 96 private Integer socketFactoryPort; 97 private String mailExtension; 98 private Boolean startTLSEnable; 99 100 101 139 public SMTPSTransportGBean(String objectName, Properties properties, String host, String user, 140 Integer port, 141 Integer connectionTimeout, 142 Integer timeout, 143 String from, 144 String localhost, 145 String localaddress, 146 Integer localport, 147 Boolean ehlo, 148 Boolean auth, 149 Boolean startTLSEnable, 150 String submitter, 151 String dsnNotify, 152 String dsnRet, 153 Boolean allow8bitmime, 154 Boolean sendPartial, 155 String saslRealm, 156 Boolean quitWait, 157 Boolean reportSuccess, 158 String socketFactoryClass, 159 Boolean socketFactoryFallback, 160 Integer socketFactoryPort, 161 String mailExtension) { 162 super(objectName, "smtps", properties, host, user); 163 164 setPort(port); 165 setConnectionTimeout(connectionTimeout); 166 setTimeout(timeout); 167 setFrom(from); 168 setLocalhost(localhost); 169 setLocaladdress(localaddress); 170 setLocalport(localport); 171 setEhlo(ehlo); 172 setAuth(auth); 173 setStartTLSEnable(startTLSEnable); 174 setSubmitter(submitter); 175 setDsnNotify(dsnNotify); 176 setDsnRet(dsnRet); 177 setAllow8bitmime(allow8bitmime); 178 setSendPartial(sendPartial); 179 setSaslRealm(saslRealm); 180 setQuitWait(quitWait); 181 setReportSuccess(reportSuccess); 182 setSocketFactoryClass(socketFactoryClass); 183 setSocketFactoryFallback(socketFactoryFallback); 184 setSocketFactoryPort(socketFactoryPort); 185 setMailExtension(mailExtension); 186 } 187 188 192 public Integer getPort() { 193 return port; 194 } 195 196 207 public void setPort(Integer port) { 208 this.port = port; 209 } 210 211 214 public Integer getConnectionTimeout() { 215 return connectionTimeout; 216 } 217 218 228 public void setConnectionTimeout(Integer connectionTimeout) { 229 this.connectionTimeout = connectionTimeout; 230 } 231 232 235 public Integer getTimeout() { 236 return timeout; 237 } 238 239 249 public void setTimeout(Integer timeout) { 250 this.timeout = timeout; 251 } 252 253 256 public String getFrom() { 257 return from; 258 } 259 260 272 public void setFrom(String from) { 273 this.from = from; 274 } 275 276 279 public String getLocalhost() { 280 return localhost; 281 } 282 283 295 public void setLocalhost(String localhost) { 296 this.localhost = localhost; 297 } 298 299 302 public String getLocaladdress() { 303 return localaddress; 304 } 305 306 319 public void setLocaladdress(String localaddress) { 320 this.localaddress = localaddress; 321 } 322 323 326 public Integer getLocalport() { 327 return localport; 328 } 329 330 341 public void setLocalport(Integer localport) { 342 this.localport = localport; 343 } 344 345 353 public Boolean getEhlo() { 354 return ehlo; 355 } 356 357 370 public void setEhlo(Boolean ehlo) { 371 this.ehlo = ehlo; 372 } 373 374 380 public Boolean getAuth() { 381 return auth; 382 } 383 384 396 public void setAuth(Boolean auth) { 397 this.auth = auth; 398 } 399 400 411 public Boolean getStartTLSEnable() { 412 return startTLSEnable; 413 } 414 415 433 public void setStartTLSEnable(Boolean startTLSEnable) { 434 this.startTLSEnable = startTLSEnable; 435 } 436 437 444 public String getSubmitter() { 445 return submitter; 446 } 447 448 460 public void setSubmitter(String submitter) { 461 this.submitter = submitter; 462 } 463 464 470 public String getDsnNotify() { 471 return dsnNotify; 472 } 473 474 485 public void setDsnNotify(String dsnNotify) { 486 this.dsnNotify = dsnNotify; 487 } 488 489 494 public String getDsnRet() { 495 return dsnRet; 496 } 497 498 508 public void setDsnRet(String dsnRet) { 509 this.dsnRet = dsnRet; 510 } 511 512 521 public Boolean getAllow8bitmime() { 522 return allow8bitmime; 523 } 524 525 540 public void setAllow8bitmime(Boolean allow8bitmime) { 541 this.allow8bitmime = allow8bitmime; 542 } 543 544 552 public Boolean getSendPartial() { 553 return sendPartial; 554 } 555 556 569 public void setSendPartial(Boolean sendPartial) { 570 this.sendPartial = sendPartial; 571 } 572 573 576 public String getSaslRealm() { 577 return saslRealm; 578 } 579 580 588 public void setSaslRealm(String saslRealm) { 589 this.saslRealm = saslRealm; 590 } 591 592 599 public Boolean getQuitWait() { 600 return quitWait; 601 } 602 603 615 public void setQuitWait(Boolean quitWait) { 616 this.quitWait = quitWait; 617 } 618 619 627 public Boolean getReportSuccess() { 628 return reportSuccess; 629 } 630 631 645 public void setReportSuccess(Boolean reportSuccess) { 646 this.reportSuccess = reportSuccess; 647 } 648 649 656 public String getSocketFactoryClass() { 657 return socketFactoryClass; 658 } 659 660 672 public void setSocketFactoryClass(String socketFactoryClass) { 673 this.socketFactoryClass = socketFactoryClass; 674 } 675 676 684 public Boolean getSocketFactoryFallback() { 685 return socketFactoryFallback; 686 } 687 688 702 public void setSocketFactoryFallback(Boolean socketFactoryFallback) { 703 this.socketFactoryFallback = socketFactoryFallback; 704 } 705 706 712 public Integer getSocketFactoryPort() { 713 return socketFactoryPort; 714 } 715 716 727 public void setSocketFactoryPort(Integer socketFactoryPort) { 728 this.socketFactoryPort = socketFactoryPort; 729 } 730 731 741 public String getMailExtension() { 742 return mailExtension; 743 } 744 745 760 public void setMailExtension(String mailExtension) { 761 this.mailExtension = mailExtension; 762 } 763 764 767 public void addOverrides(Properties props) { 768 super.addOverrides(props); 769 770 if (port != null) props.setProperty(SMTPS_PORT, port.toString()); 771 if (connectionTimeout != null) props.setProperty(SMTPS_CONNECTION_TIMEOUT, connectionTimeout.toString()); 772 if (timeout != null) props.setProperty(SMTPS_TIMEOUT, timeout.toString()); 773 if (from != null) props.setProperty(SMTPS_FROM, from); 774 if (localhost != null) props.setProperty(SMTPS_LOCALHOST, localhost); 775 if (localaddress != null) props.setProperty(SMTPS_LOCALADDRESS, localaddress); 776 if (localport != null) props.setProperty(SMTPS_LOCALPORT, localport.toString()); 777 if (ehlo != null) props.setProperty(SMTPS_EHLO, ehlo.toString()); 778 if (auth != null) props.setProperty(SMTPS_AUTH, auth.toString()); 779 if (startTLSEnable != null) props.setProperty(SMTPS_STARTTLS_ENABLE, startTLSEnable.toString()); 780 if (submitter != null) props.setProperty(SMTPS_SUBMITTER, submitter); 781 if (dsnNotify != null) props.setProperty(SMTPS_DSN_NOTIFY, dsnNotify.toString()); 782 if (dsnRet != null) props.setProperty(SMTPS_DSN_RET, dsnRet.toString()); 783 if (allow8bitmime != null) props.setProperty(SMTPS_8BITMIME, allow8bitmime.toString()); 784 if (sendPartial != null) props.setProperty(SMTPS_SEND_PARTIAL, sendPartial.toString()); 785 if (saslRealm != null) props.setProperty(SMTPS_REALM, saslRealm); 786 if (quitWait != null) props.setProperty(SMTPS_QUITWAIT, quitWait.toString()); 787 if (reportSuccess != null) props.setProperty(SMTPS_REPORT_SUCCESS, reportSuccess.toString()); 788 if (socketFactoryClass != null) props.setProperty(SMTPS_FACTORY_CLASS, socketFactoryClass); 789 if (socketFactoryFallback != null) props.setProperty(SMTPS_FACTORY_FALLBACK, socketFactoryFallback.toString()); 790 if (socketFactoryPort != null) props.setProperty(SMTPS_FACTORY_PORT, socketFactoryPort.toString()); 791 if (mailExtension != null) props.setProperty(SMTPS_MAIL_EXTENSION, mailExtension); 792 } 793 794 public void doStart() throws Exception { 795 log.debug("Started " + getObjectName()); 796 } 797 798 public void doStop() throws Exception { 799 log.debug("Stopped " + getObjectName()); 800 } 801 802 public void doFail() { 803 log.warn("Failed " + getObjectName()); 804 } 805 806 public static final GBeanInfo GBEAN_INFO; 807 808 static { 809 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(SMTPSTransportGBean.class); 810 811 infoFactory.addAttribute(GBEAN_PORT, Integer .class, true); 812 infoFactory.addAttribute(GBEAN_CONNECTION_TIMEOUT, Integer .class, true); 813 infoFactory.addAttribute(GBEAN_TIMEOUT, Integer .class, true); 814 infoFactory.addAttribute(GBEAN_AUTH, Boolean .class, true); 815 infoFactory.addAttribute(GBEAN_STARTTLS_ENABLE, Boolean .class, true); 816 infoFactory.addAttribute(GBEAN_EHLO, Boolean .class, true); 817 infoFactory.addAttribute(GBEAN_FROM, String .class, true); 818 infoFactory.addAttribute(GBEAN_LOCALHOST, String .class, true); 819 infoFactory.addAttribute(GBEAN_LOCALADDRESS, String .class, true); 820 infoFactory.addAttribute(GBEAN_LOCALPORT, Integer .class, true); 821 infoFactory.addAttribute(GBEAN_REALM, String .class, true); 822 infoFactory.addAttribute(GBEAN_QUITWAIT, Boolean .class, true); 823 infoFactory.addAttribute(GBEAN_FACTORY_CLASS, String .class, true); 824 infoFactory.addAttribute(GBEAN_FACTORY_FALLBACK, Boolean .class, true); 825 infoFactory.addAttribute(GBEAN_FACTORY_PORT, Integer .class, true); 826 827 infoFactory.addAttribute(GBEAN_SUBMITTER, String .class, true); 828 infoFactory.addAttribute(GBEAN_DSN_NOTIFY, String .class, true); 829 infoFactory.addAttribute(GBEAN_DSN_RET, String .class, true); 830 infoFactory.addAttribute(GBEAN_8BITMIME, Boolean .class, true); 831 infoFactory.addAttribute(GBEAN_SEND_PARTIAL, Boolean .class, true); 832 infoFactory.addAttribute(GBEAN_REPORT_SUCCESS, Boolean .class, true); 833 infoFactory.addAttribute(GBEAN_MAIL_EXTENSION, String .class, true); 834 835 infoFactory.addAttribute(GBEAN_OBJECTNAME, String .class, false); 836 infoFactory.addAttribute(GBEAN_PROTOCOL, String .class, true); 837 infoFactory.addAttribute(GBEAN_PROPERTIES, Properties .class, true); 838 infoFactory.addAttribute(GBEAN_HOST, String .class, true); 839 infoFactory.addAttribute(GBEAN_USER, String .class, true); 840 infoFactory.addOperation(GBEAN_ADD_OVERRIDES, new Class []{Properties .class}); 841 842 infoFactory.setConstructor(new String []{GBEAN_OBJECTNAME, GBEAN_PROPERTIES, GBEAN_HOST, GBEAN_USER, 843 GBEAN_PORT, 844 GBEAN_CONNECTION_TIMEOUT, 845 GBEAN_TIMEOUT, 846 GBEAN_FROM, 847 GBEAN_LOCALHOST, 848 GBEAN_LOCALADDRESS, 849 GBEAN_LOCALPORT, 850 GBEAN_EHLO, 851 GBEAN_AUTH, 852 GBEAN_STARTTLS_ENABLE, 853 GBEAN_SUBMITTER, 854 GBEAN_DSN_NOTIFY, 855 GBEAN_DSN_RET, 856 GBEAN_8BITMIME, 857 GBEAN_SEND_PARTIAL, 858 GBEAN_REALM, 859 GBEAN_QUITWAIT, 860 GBEAN_REPORT_SUCCESS, 861 GBEAN_FACTORY_CLASS, 862 GBEAN_FACTORY_FALLBACK, 863 GBEAN_FACTORY_PORT, 864 GBEAN_MAIL_EXTENSION}); 865 866 GBEAN_INFO = infoFactory.getBeanInfo(); 867 } 868 869 public static GBeanInfo getGBeanInfo() { 870 return GBEAN_INFO; 871 } 872 } 873 874 | Popular Tags |