001package ca.uhn.fhir.rest.server.mail;
002
003/*-
004 * #%L
005 * HAPI FHIR - Server Framework
006 * %%
007 * Copyright (C) 2014 - 2022 Smile CDR, Inc.
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023import org.apache.commons.lang3.StringUtils;
024import org.apache.commons.lang3.builder.EqualsBuilder;
025import org.apache.commons.lang3.builder.HashCodeBuilder;
026import org.apache.commons.lang3.builder.ToStringBuilder;
027
028public class MailConfig {
029        private String mySmtpHostname;
030        private Integer mySmtpPort;
031        private String mySmtpUsername;
032        private String mySmtpPassword;
033        private boolean mySmtpUseStartTLS;
034
035        public MailConfig() {
036        }
037
038        public String getSmtpHostname() {
039                return mySmtpHostname;
040        }
041
042        public MailConfig setSmtpHostname(String theSmtpHostname) {
043                mySmtpHostname = theSmtpHostname;
044                return this;
045        }
046
047        public Integer getSmtpPort() {
048                return mySmtpPort;
049        }
050
051        public MailConfig setSmtpPort(Integer theSmtpPort) {
052                mySmtpPort = theSmtpPort;
053                return this;
054        }
055
056        public String getSmtpUsername() {
057                return mySmtpUsername;
058        }
059
060        public MailConfig setSmtpUsername(String theSmtpUsername) {
061                // SimpleJavaMail treats empty smtp username as valid username and requires auth
062                mySmtpUsername = StringUtils.isBlank(theSmtpUsername) ? null : theSmtpUsername;
063                return this;
064        }
065
066        public String getSmtpPassword() {
067                return mySmtpPassword;
068        }
069
070        public MailConfig setSmtpPassword(String theSmtpPassword) {
071                // SimpleJavaMail treats empty smtp password as valid password and requires auth
072                mySmtpPassword = StringUtils.isBlank(theSmtpPassword) ? null : theSmtpPassword;
073                return this;
074        }
075
076        public boolean isSmtpUseStartTLS() {
077                return mySmtpUseStartTLS;
078        }
079
080        public MailConfig setSmtpUseStartTLS(boolean theSmtpUseStartTLS) {
081                mySmtpUseStartTLS = theSmtpUseStartTLS;
082                return this;
083        }
084
085        @Override
086        public boolean equals(Object object) {
087                if (this == object) {
088                        return true;
089                }
090                if (object == null || getClass() != object.getClass()) {
091                        return false;
092                }
093                return EqualsBuilder.reflectionEquals(this, object);
094        }
095
096        @Override
097        public int hashCode() {
098                return HashCodeBuilder.reflectionHashCode(this);
099        }
100
101        @Override
102        public String toString() {
103                return ToStringBuilder.reflectionToString(this);
104        }
105}