001 /* 002 * Sonar, open source software quality management tool. 003 * Copyright (C) 2008-2011 SonarSource 004 * mailto:contact AT sonarsource DOT com 005 * 006 * Sonar is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * Sonar is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with Sonar; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 019 */ 020 package org.sonar.plugins.emailnotifications; 021 022 import org.apache.commons.configuration.Configuration; 023 import org.sonar.api.CoreProperties; 024 import org.sonar.api.ServerExtension; 025 026 /** 027 * Ruby uses constants from this class. 028 * 029 * @since 2.10 030 */ 031 public class EmailConfiguration implements ServerExtension { 032 033 public static final String SMTP_HOST = "email.smtp_host.secured"; 034 public static final String SMTP_HOST_DEFAULT = ""; 035 public static final String SMTP_PORT = "email.smtp_port.secured"; 036 public static final String SMTP_PORT_DEFAULT = "25"; 037 public static final String SMTP_SECURE_CONNECTION = "email.smtp_secure_connection.secured"; 038 public static final String SMTP_SECURE_CONNECTION_DEFAULT = ""; 039 public static final String SMTP_USERNAME = "email.smtp_username.secured"; 040 public static final String SMTP_USERNAME_DEFAULT = ""; 041 public static final String SMTP_PASSWORD = "email.smtp_password.secured"; 042 public static final String SMTP_PASSWORD_DEFAULT = ""; 043 public static final String FROM = "email.from"; 044 public static final String FROM_DEFAULT = "noreply@nowhere"; 045 public static final String PREFIX = "email.prefix"; 046 public static final String PREFIX_DEFAULT = "[SONAR]"; 047 048 private Configuration configuration; 049 050 public EmailConfiguration(Configuration configuration) { 051 this.configuration = configuration; 052 } 053 054 public String getSmtpHost() { 055 return configuration.getString(SMTP_HOST, SMTP_HOST_DEFAULT); 056 } 057 058 public String getSmtpPort() { 059 return configuration.getString(SMTP_PORT, SMTP_PORT_DEFAULT); 060 } 061 062 public String getSecureConnection() { 063 return configuration.getString(SMTP_SECURE_CONNECTION, SMTP_SECURE_CONNECTION_DEFAULT); 064 } 065 066 public String getSmtpUsername() { 067 return configuration.getString(SMTP_USERNAME, SMTP_USERNAME_DEFAULT); 068 } 069 070 public String getSmtpPassword() { 071 return configuration.getString(SMTP_PASSWORD, SMTP_PASSWORD_DEFAULT); 072 } 073 074 public String getFrom() { 075 return configuration.getString(FROM, FROM_DEFAULT); 076 } 077 078 public String getPrefix() { 079 return configuration.getString(PREFIX, PREFIX_DEFAULT); 080 } 081 082 public String getServerBaseURL() { 083 return configuration.getString(CoreProperties.SERVER_BASE_URL, CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE); 084 } 085 086 }