All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opencms.mail.CmsMailHost Maven / Gradle / Ivy

Go to download

OpenCms is an enterprise-ready, easy to use website content management system based on Java and XML technology. Offering a complete set of features, OpenCms helps content managers worldwide to create and maintain beautiful websites fast and efficiently.

There is a newer version: 17.0
Show newest version
/*
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software GmbH & Co. KG, please see the
 * company website: http://www.alkacon.com
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package org.opencms.mail;

/**
 * Contains the configuration of an individual mail host.

* * @since 6.0.0 */ public class CmsMailHost implements Comparable { /** The name of the mail host. */ private String m_hostname; /** The order of this mail host. */ private Integer m_order; /** The password to use for authentication. */ private String m_password; /** The port to use. */ private int m_port; /** The protocol to use. */ private String m_protocol; /** The user name to use for authentication. */ private String m_username; /** The security setting. */ private String m_security; /** * Creates a new mail host.

* * @param hostname the name of the mail host * @param order the order in which the host is tried * @param protocol the protocol to use (default "smtp") * @param security the security setting * @param username the user name to use for authentication * @param password the password to use for authentication * @param port the port, if < 0 then 25 is used */ public CmsMailHost( String hostname, Integer port, Integer order, String protocol, String security, String username, String password) { m_hostname = hostname; int portInt = port.intValue(); m_port = (portInt < 0) ? 25 : portInt; m_protocol = (protocol != null) ? protocol : CmsMailSettings.MAIL_DEFAULT_PROTOCOL; m_username = username; m_password = password; m_security = security; m_order = order; } /** * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(CmsMailHost obj) { if (obj == this) { return 0; } return m_order.compareTo(obj.m_order); } /** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof CmsMailHost) { CmsMailHost other = (CmsMailHost)obj; return m_hostname.equals(other.m_hostname) && m_protocol.equals(other.m_protocol) && m_username.equals(other.m_username); } return false; } /** * Returns the host name.

* * @return the host name */ public String getHostname() { return m_hostname; } /** * Returns the order of this mail host.

* * @return the order of this mail host */ public Integer getOrder() { return m_order; } /** * Returns the password used for authentication.

* * @return the password used for authentication */ public String getPassword() { return m_password; } /** * Returns the port.

* * @return the port */ public int getPort() { return m_port; } /** * Returns the protocol used for mail sending, default is "smtp".

* * @return the protocol used for mail sending */ public String getProtocol() { return m_protocol; } /** * Gets the value of the security setting.

* * @return the value of the security setting */ public String getSecurity() { return m_security; } /** * Returns the user name used for authentication.

* * @return the user name used for authentication */ public String getUsername() { return m_username; } /** * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return (m_hostname.hashCode() * 1117) + (m_protocol.hashCode() * 2003) + m_username.hashCode(); } /** * Returns true only if authentication is enabled, * the default is false.

* * Authentication is enabled only if both "username" and "password" * are not null.

* * @return true only if authentication is enabled */ public boolean isAuthenticating() { return (m_username != null) && (m_password != null); } /** * @see java.lang.Object#toString() */ @Override public String toString() { StringBuffer buf = new StringBuffer(64); buf.append(this.getClass().getName()); buf.append(" hostname="); buf.append(getHostname()); buf.append(" port="); buf.append(getPort()); buf.append(" order="); buf.append(m_order); buf.append(" protocol="); buf.append(getProtocol()); buf.append(" security=" + getSecurity()); if (isAuthenticating()) { buf.append(" user="); buf.append(getUsername()); buf.append(" password="); buf.append(getPassword()); } return buf.toString(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy