3 * Copyright (C) 2009-2024 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.server.common.email.config;
22 public final class EmailConfigurationBuilder {
26 private EmailConfigurationSecurityProtocol securityProtocol;
27 private String fromAddress;
28 private String fromName;
29 private String subjectPrefix;
30 private EmailConfigurationAuthMethod authMethod;
31 private String username;
32 private String basicPassword;
33 private String oauthAuthenticationHost;
34 private String oauthClientId;
35 private String oauthClientSecret;
36 private String oauthTenant;
38 private EmailConfigurationBuilder() {
41 public static EmailConfigurationBuilder builder() {
42 return new EmailConfigurationBuilder();
45 public EmailConfigurationBuilder id(String id) {
50 public EmailConfigurationBuilder host(String host) {
55 public EmailConfigurationBuilder port(String port) {
60 public EmailConfigurationBuilder securityProtocol(EmailConfigurationSecurityProtocol securityProtocol) {
61 this.securityProtocol = securityProtocol;
65 public EmailConfigurationBuilder fromAddress(String fromAddress) {
66 this.fromAddress = fromAddress;
70 public EmailConfigurationBuilder fromName(String fromName) {
71 this.fromName = fromName;
75 public EmailConfigurationBuilder subjectPrefix(String subjectPrefix) {
76 this.subjectPrefix = subjectPrefix;
80 public EmailConfigurationBuilder authMethod(EmailConfigurationAuthMethod authMethod) {
81 this.authMethod = authMethod;
85 public EmailConfigurationBuilder username(String username) {
86 this.username = username;
90 public EmailConfigurationBuilder basicPassword(String basicPassword) {
91 this.basicPassword = basicPassword;
95 public EmailConfigurationBuilder oauthAuthenticationHost(String oauthAuthenticationHost) {
96 this.oauthAuthenticationHost = oauthAuthenticationHost;
100 public EmailConfigurationBuilder oauthClientId(String oauthClientId) {
101 this.oauthClientId = oauthClientId;
105 public EmailConfigurationBuilder oauthClientSecret(String oauthClientSecret) {
106 this.oauthClientSecret = oauthClientSecret;
110 public EmailConfigurationBuilder oauthTenant(String oauthTenant) {
111 this.oauthTenant = oauthTenant;
115 public EmailConfiguration build() {
116 return new EmailConfiguration(id, host, port, securityProtocol, fromAddress, fromName, subjectPrefix, authMethod, username, basicPassword, oauthAuthenticationHost,
117 oauthClientId, oauthClientSecret, oauthTenant);