org.nervousync.mail.config.MailConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of utils-jdk11 Show documentation
Show all versions of utils-jdk11 Show documentation
Java utility collections, development by Nervousync Studio (NSYC)
/*
* Licensed to the Nervousync Studio (NSYC) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nervousync.mail.config;
import jakarta.xml.bind.annotation.*;
import org.nervousync.beans.core.BeanObject;
import org.nervousync.commons.Globals;
import org.nervousync.proxy.ProxyConfig;
import org.nervousync.enumerations.mail.MailProtocol;
import org.nervousync.security.factory.SecureConfig;
/**
* Mail configure information define
* 邮件配置信息定义
*
* @author Steven Wee [email protected]
* @version $Revision: 1.0.0 $ $Date: Jul 31, 2021 19:06:18 $
*/
@XmlType(name = "mail_config", namespace = "https://nervousync.org/schemas/mail")
@XmlRootElement(name = "mail_config", namespace = "https://nervousync.org/schemas/mail")
@XmlAccessorType(XmlAccessType.NONE)
public final class MailConfig extends BeanObject {
/**
* Serial version UID
* 序列化UID
*/
private static final long serialVersionUID = -506685998495058905L;
/**
* Secure config name
* 安全配置名称
*/
@XmlElement(name = "secure_name")
private String secureName;
/**
* Secure config information
* 安全配置定义
*/
@XmlElement(name = "secure_config", namespace = "https://nervousync.org/schemas/secure")
private SecureConfig secureConfig;
/**
* Mail account username
* 邮件账户用户名
*/
@XmlElement(name = "username")
private String userName;
/**
* Mail account password
* 邮件账户密码
*/
@XmlElement(name = "password")
private String password;
/**
* Proxy configure information
* 代理服务器配置信息
*/
@XmlElement(name = "proxy_config", namespace = "https://nervousync.org/schemas/proxy")
private ProxyConfig proxyConfig = ProxyConfig.redirect();
/**
* Mail send server config
* 邮件发送服务器配置信息
*/
@XmlElement(name = "send_config")
private ServerConfig sendConfig;
/**
* Mail receive server config
* 邮件接收服务器配置信息
*/
@XmlElement(name = "receive_config")
private ServerConfig receiveConfig;
/**
* Attaches the file storage path
* 附件文件的保存地址
*/
@XmlElement(name = "storage_path")
private String storagePath;
/**
* Base64 encoded binary data bytes of x509 certificate
* Using for email signature verify
* Base64编码的x509证书二进制数组
* 用于电子邮件签名验证
*/
@XmlElement
private String certificate;
/**
* Base64 encoded binary data bytes of private key
* Using for email signature
* Base64编码的私有密钥二进制数组
* 用于电子邮件签名
*/
@XmlElement(name = "private_key")
private String privateKey;
/**
* Constructor method for MailConfig
* MailConfig构造方法
*/
public MailConfig() {
this.secureName = Globals.DEFAULT_VALUE_STRING;
this.certificate = Globals.DEFAULT_VALUE_STRING;
this.privateKey = Globals.DEFAULT_VALUE_STRING;
}
/**
* Getter method for secure config name
* 安全配置名称的Getter方法
*
* @return Secure config name
* 安全配置名称
*/
public String getSecureName() {
return secureName;
}
/**
* Setter method for secure config name
* 安全配置名称的Setter方法
*
* @param secureName Secure config name
* 安全配置名称
*/
public void setSecureName(String secureName) {
this.secureName = secureName;
}
/**
* Getter method for secure config information
* 安全配置名称的Getter方法
*
* @return Secure config information
* 安全配置定义
*/
public SecureConfig getSecureConfig() {
return secureConfig;
}
/**
* Setter method for secure config information
* 安全配置定义的Setter方法
*
* @param secureConfig Secure config information
* 安全配置定义
*/
public void setSecureConfig(SecureConfig secureConfig) {
this.secureConfig = secureConfig;
}
/**
* Getter method for mail account username
* 邮件账户用户名的Getter方法
*
* @return Mail account username
* 邮件账户用户名
*/
public String getUserName() {
return userName;
}
/**
* Setter method for mail account username
* 邮件账户用户名的Setter方法
*
* @param userName Mail account username
* 邮件账户用户名
*/
public void setUserName(String userName) {
this.userName = userName;
}
/**
* Getter method for mail account password
* 邮件账户密码的Getter方法
*
* @return Mail account password
* 邮件账户密码
*/
public String getPassword() {
return password;
}
/**
* Setter method for mail account password
* 邮件账户密码的Setter方法
*
* @param password Mail account password
* 邮件账户密码
*/
public void setPassword(String password) {
this.password = password;
}
/**
* Getter method for proxy configure information
* 代理服务器配置信息的Getter方法
*
* @return Proxy configure information
* 代理服务器配置信息
*/
public ProxyConfig getProxyConfig() {
return proxyConfig;
}
/**
* Setter method for proxy configure information
* 代理服务器配置信息的Setter方法
*
* @param proxyConfig Proxy configure information
* 代理服务器配置信息
*/
public void setProxyConfig(ProxyConfig proxyConfig) {
this.proxyConfig = proxyConfig;
}
/**
* Getter method for mail send server config
* 邮件发送服务器配置信息的Getter方法
*
* Mail send server config
* 邮件发送服务器配置信息
*/
public ServerConfig getSendConfig() {
return sendConfig;
}
/**
* Setter method for mail send server config
* 邮件发送服务器配置信息的Setter方法
*
* @param sendConfig Mail send server config
* 邮件发送服务器配置信息
*/
public void setSendConfig(ServerConfig sendConfig) {
this.sendConfig = sendConfig;
}
/**
* Getter method for mail receive server config
* 邮件接收服务器配置信息的Getter方法
*
* @return Mail receive server config
* 邮件接收服务器配置信息
*/
public ServerConfig getReceiveConfig() {
return receiveConfig;
}
/**
* Setter method for mail receive server config
* 邮件接收服务器配置信息的Setter方法
*
* @param receiveConfig Mail receive server config
* 邮件接收服务器配置信息
*/
public void setReceiveConfig(ServerConfig receiveConfig) {
this.receiveConfig = receiveConfig;
}
/**
* Getter method for attaches the file storage path
* 附件文件的保存地址的Getter方法
*
* @return Attaches the file storage path
* 附件文件的保存地址
*/
public String getStoragePath() {
return storagePath;
}
/**
* Setter method for attaches the file storage path
* 附件文件的保存地址的Setter方法
*
* @param storagePath Attaches the file storage path
* 附件文件的保存地址
*/
public void setStoragePath(String storagePath) {
this.storagePath = storagePath;
}
/**
* Getter method for base64 encoded binary data bytes of x509 certificate
* Base64编码的x509证书二进制数组的Getter方法
*
* @return Base64 encoded binary data bytes of x509 certificate
* Base64编码的x509证书二进制数组
*/
public String getCertificate() {
return certificate;
}
/**
* Setter method for base64 encoded binary data bytes of x509 certificate
* Base64编码的x509证书二进制数组的Setter方法
*
* @param certificate Base64 encoded binary data bytes of x509 certificate
* Base64编码的x509证书二进制数组
*/
public void setCertificate(String certificate) {
this.certificate = certificate;
}
/**
* Getter method for base64 encoded binary data bytes of private key
* Base64编码的私有密钥二进制数组的Getter方法
*
* @return Base64 encoded binary data bytes of private key
* Base64编码的私有密钥二进制数组
*/
public String getPrivateKey() {
return privateKey;
}
/**
* Setter method for base64 encoded binary data bytes of private key
* Base64编码的私有密钥二进制数组的Setter方法
*
* @param privateKey Base64 encoded binary data bytes of private key
* Base64编码的私有密钥二进制数组
*/
public void setPrivateKey(String privateKey) {
this.privateKey = privateKey;
}
/**
* Copy configure information from given MailConfig instance
* 从给定的MailConfig实例对象复制配置信息
*
* @param mailConfig MailConfig instance
* 邮件配置信息实例对象
*/
public void copyProperties(final MailConfig mailConfig) {
if (mailConfig == null) {
return;
}
this.secureName = mailConfig.getSecureName();
this.userName = mailConfig.getUserName();
this.password = mailConfig.getPassword();
this.proxyConfig = mailConfig.getProxyConfig();
this.sendConfig = mailConfig.getSendConfig();
this.receiveConfig = mailConfig.getReceiveConfig();
this.storagePath = mailConfig.getStoragePath();
this.certificate = mailConfig.getCertificate();
this.privateKey = getPrivateKey();
}
/**
* Mail server configure information define
* 邮件服务器配置信息定义
*
* @author Steven Wee [email protected]
* @version $Revision: 1.0.0 $ $Date: Jul 31, 2021 19:09:18 $
*/
@XmlType(name = "server_config", namespace = "https://nervousync.org/schemas/mail")
@XmlRootElement(name = "server_config", namespace = "https://nervousync.org/schemas/mail")
@XmlAccessorType(XmlAccessType.NONE)
public static final class ServerConfig extends BeanObject {
/**
* Serial version UID
* 序列化UID
*/
private static final long serialVersionUID = -1768113760096890529L;
/**
* Mail server domain name
* 邮件服务器域名
*/
@XmlElement(name = "host_name")
private String hostName;
/**
* Mail server port
* 邮件服务器端口号
*/
@XmlElement(name = "host_port")
private int hostPort;
/**
* Using secure connection to host server
* 使用安全连接到邮件服务器
*/
@XmlElement(name = "ssl")
private boolean ssl;
/**
* Host server authenticate login
* 邮件服务器需要身份验证
*/
@XmlElement(name = "auth_login")
private boolean authLogin;
/**
* Mail server protocol
* 邮件服务器协议
*/
@XmlElement(name = "protocol")
private MailProtocol protocolOption;
/**
* Connection timeout(Unit: seconds)
* 连接超时时间(单位:秒)
*/
@XmlElement(name = "connection_timeout")
private int connectionTimeout = 5;
/**
* Process timeout(Unit: seconds)
* 操作超时时间(单位:秒)
*/
@XmlElement(name = "process_timeout")
private int processTimeout = 5;
/**
* Constructor method for ServerConfig
* ServerConfig构造方法
*/
public ServerConfig() {
this.hostName = Globals.DEFAULT_VALUE_STRING;
}
/**
* Getter method for mail server domain name
* 邮件服务器域名的Getter方法
*
* @return Mail server domain name
* 邮件服务器域名
*/
public String getHostName() {
return hostName;
}
/**
* Setter method for mail server domain name
* 邮件服务器域名的Setter方法
*
* @param hostName Mail server domain name
* 邮件服务器域名
*/
public void setHostName(String hostName) {
this.hostName = hostName;
}
/**
* Getter method for mail server port
* 邮件服务器端口号的Getter方法
*
* @return Mail server port
* 邮件服务器端口号
*/
public int getHostPort() {
return hostPort;
}
/**
* Setter method for mail server port
* 邮件服务器端口号的Setter方法
*
* @param hostPort Mail server port
* 邮件服务器端口号
*/
public void setHostPort(int hostPort) {
this.hostPort = hostPort;
}
/**
* Getter method for using secure connection to host server
* 使用安全连接到邮件服务器的Getter方法
*
* @return Using secure connection to host server
* 使用安全连接到邮件服务器
*/
public boolean isSsl() {
return ssl;
}
/**
* Setter method for using secure connection to host server
* 使用安全连接到邮件服务器的Setter方法
*
* @param ssl Using secure connection to host server
* 使用安全连接到邮件服务器
*/
public void setSsl(boolean ssl) {
this.ssl = ssl;
}
/**
* Getter method for host server authenticate login
* 邮件服务器需要身份验证的Getter方法
*
* @return Host server authenticate login
* 邮件服务器需要身份验证
*/
public boolean isAuthLogin() {
return authLogin;
}
/**
* Setter method for host server authenticate login
* 邮件服务器需要身份验证的Setter方法
*
* @param authLogin Host server authenticate login
* 邮件服务器需要身份验证
*/
public void setAuthLogin(boolean authLogin) {
this.authLogin = authLogin;
}
/**
* Getter method for mail server protocol
* 邮件服务器协议的Getter方法
*
* @return Mail server protocol
* 邮件服务器协议
*/
public MailProtocol getProtocolOption() {
return protocolOption;
}
/**
* Setter method for mail server protocol
* 邮件服务器协议的Setter方法
*
* @param protocolOption Mail server protocol
* 邮件服务器协议
*/
public void setProtocolOption(MailProtocol protocolOption) {
this.protocolOption = protocolOption;
}
/**
* Getter method for connection timeout
* 连接超时时间的Getter方法
*
* @return Connection timeout(Unit: seconds)
* 连接超时时间(单位:秒)
*/
public int getConnectionTimeout() {
return connectionTimeout;
}
/**
* Setter method for connection timeout
* 连接超时时间的Setter方法
*
* @param connectionTimeout Connection timeout(Unit: seconds)
* 连接超时时间(单位:秒)
*/
public void setConnectionTimeout(int connectionTimeout) {
this.connectionTimeout = connectionTimeout;
}
/**
* Getter method for process timeout
* 操作超时时间的Getter方法
*
* @return Process timeout(Unit: seconds)
* 操作超时时间(单位:秒)
*/
public int getProcessTimeout() {
return processTimeout;
}
/**
* Setter method for process timeout
* 操作超时时间的Setter方法
*
* @param processTimeout Process timeout(Unit: seconds)
* 操作超时时间(单位:秒)
*/
public void setProcessTimeout(int processTimeout) {
this.processTimeout = processTimeout;
}
}
}