2 * Sonar, open source software quality management tool.
3 * Copyright (C) 2008-2012 SonarSource
4 * mailto:contact AT sonarsource DOT com
6 * Sonar 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 * Sonar 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
17 * License along with Sonar; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
20 package org.sonar.plugins.emailnotifications;
22 import org.apache.commons.configuration.Configuration;
23 import org.sonar.api.CoreProperties;
24 import org.sonar.api.ServerExtension;
27 * Ruby uses constants from this class.
31 public class EmailConfiguration implements ServerExtension {
33 public static final String SMTP_HOST = "email.smtp_host.secured";
34 public static final String SMTP_HOST_DEFAULT = "";
35 public static final String SMTP_PORT = "email.smtp_port.secured";
36 public static final String SMTP_PORT_DEFAULT = "25";
37 public static final String SMTP_SECURE_CONNECTION = "email.smtp_secure_connection.secured";
38 public static final String SMTP_SECURE_CONNECTION_DEFAULT = "";
39 public static final String SMTP_USERNAME = "email.smtp_username.secured";
40 public static final String SMTP_USERNAME_DEFAULT = "";
41 public static final String SMTP_PASSWORD = "email.smtp_password.secured";
42 public static final String SMTP_PASSWORD_DEFAULT = "";
43 public static final String FROM = "email.from";
44 public static final String FROM_DEFAULT = "noreply@nowhere";
45 public static final String PREFIX = "email.prefix";
46 public static final String PREFIX_DEFAULT = "[SONAR]";
48 private Configuration configuration;
50 public EmailConfiguration(Configuration configuration) {
51 this.configuration = configuration;
54 public String getSmtpHost() {
55 return configuration.getString(SMTP_HOST, SMTP_HOST_DEFAULT);
58 public String getSmtpPort() {
59 return configuration.getString(SMTP_PORT, SMTP_PORT_DEFAULT);
62 public String getSecureConnection() {
63 return configuration.getString(SMTP_SECURE_CONNECTION, SMTP_SECURE_CONNECTION_DEFAULT);
66 public String getSmtpUsername() {
67 return configuration.getString(SMTP_USERNAME, SMTP_USERNAME_DEFAULT);
70 public String getSmtpPassword() {
71 return configuration.getString(SMTP_PASSWORD, SMTP_PASSWORD_DEFAULT);
74 public String getFrom() {
75 return configuration.getString(FROM, FROM_DEFAULT);
78 public String getPrefix() {
79 return configuration.getString(PREFIX, PREFIX_DEFAULT);
82 public String getServerBaseURL() {
83 return configuration.getString(CoreProperties.SERVER_BASE_URL, CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE);