From 39c9622eccdbefc13469303bb8a0735edbeaeac9 Mon Sep 17 00:00:00 2001 From: Bernardus Jansen Date: Wed, 18 May 2016 09:52:14 +0200 Subject: [PATCH 1/5] mail password via SMTP Signed-off-by: Bernardus Jansen --- libresonic-main/pom.xml | 6 ++ .../command/AdvancedSettingsCommand.java | 46 ++++++++++ .../AdvancedSettingsController.java | 14 ++++ .../player/controller/MultiController.java | 84 ++++++++++++------- .../player/service/SettingsService.java | 64 +++++++++++++- 5 files changed, 185 insertions(+), 29 deletions(-) diff --git a/libresonic-main/pom.xml b/libresonic-main/pom.xml index 22bbaa82..e0fe90bb 100644 --- a/libresonic-main/pom.xml +++ b/libresonic-main/pom.xml @@ -253,6 +253,12 @@ runtime + + javax.mail + javax.mail-api + 1.5.5 + + taglibs standard diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java index bd3d7b08..5fe712af 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java @@ -40,6 +40,12 @@ public class AdvancedSettingsCommand { private boolean isReloadNeeded; private boolean toast; + private String smtpServer; + private String smtpEncryption; + private int smtpPort; + private String smtpUser; + private String smtpPassword; + public String getDownloadLimit() { return downloadLimit; } @@ -127,4 +133,44 @@ public class AdvancedSettingsCommand { public void setToast(boolean toast) { this.toast = toast; } + + public String getSMTPServer() { + return smtpServer; + } + + public void setSMTPServer(String smtpServer) { + this.smtpServer = smtpServer; + } + + public String getSMTPEncryption() { + return smtpEncryption; + } + + public void setSMTPEncryption(String smtpEncryption) { + this.smtpEncryption = smtpEncryption; + } + + public int getSMTPPort() { + return smtpPort; + } + + public void setSMTPPort(int smtpPort) { + this.smtpPort = smtpPort; + } + + public String getSMTPUser() { + return smtpUser; + } + + public void setSMTPUser(String smtpUser) { + this.smtpUser = smtpUser; + } + + public String getSMTPPassword() { + return smtpPassword; + } + + public void setSMTPPassword(String smtpPassword) { + this.smtpPassword = smtpPassword; + } } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java index 996a35fa..d5abaf24 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java @@ -47,6 +47,11 @@ public class AdvancedSettingsController extends SimpleFormController { command.setLdapAutoShadowing(settingsService.isLdapAutoShadowing()); command.setBrand(settingsService.getBrand()); + command.setSMTPServer(settingsService.getSMTPServer()); + command.setSMTPEncryption(settingsService.getSMTPEncryption()); + command.setSMTPPort(settingsService.getSMTPPort()); + command.setSMTPUser(settingsService.getSMTPUser()); + return command; } @@ -74,6 +79,15 @@ public class AdvancedSettingsController extends SimpleFormController { settingsService.setLdapManagerPassword(command.getLdapManagerPassword()); } + settingsService.setSMTPServer(command.getSMTPServer()); + settingsService.setSMTPEncryption(command.getSMTPEncryption()); + settingsService.setSMTPPort(command.getSMTPPort()); + settingsService.setSMTPUser(command.getSMTPUser()); + + if (StringUtils.isNotEmpty(command.getSMTPPassword())) { + settingsService.setSMTPPassword(command.getSMTPPassword()); + } + settingsService.save(); } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java index ba446ba4..a5dac659 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java @@ -23,20 +23,21 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Properties; +import java.util.Date; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.mail.Message; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; + import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.StringUtils; -import org.apache.http.NameValuePair; -import org.apache.http.client.HttpClient; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.message.BasicNameValuePair; -import org.apache.http.params.HttpConnectionParams; import org.springframework.web.bind.ServletRequestUtils; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.multiaction.MultiActionController; @@ -137,32 +138,59 @@ public class MultiController extends MultiActionController { } private boolean emailPassword(String password, String username, String email) { - HttpClient client = new DefaultHttpClient(); + String prot = "smtp"; + + if (settingsService.getSMTPServer() == null || settingsService.getSMTPServer().isEmpty()) { + LOG.warn("Can not send email; no SMTP server configured."); + return false; + } + + Properties props = new Properties(); + if (settingsService.getSMTPEncryption().equals("SSL/TLS")) { + prot = "smtps"; + props.put("mail." + prot + ".ssl.enable", "true"); + } else if (settingsService.getSMTPEncryption().equals("STARTTLS")) { + prot = "smtp"; + props.put("mail." + prot + ".starttls.enable", "true"); + } + props.put("mail." + prot + ".host", settingsService.getSMTPServer()); + props.put("mail." + prot + ".port", settingsService.getSMTPPort()); + if (settingsService.getSMTPUser() != null && !settingsService.getSMTPUser().isEmpty()) { + props.put("mail." + prot + ".auth", "true"); + } + + Session session = Session.getInstance(props, null); + try { - HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); - HttpConnectionParams.setSoTimeout(client.getParams(), 10000); - HttpPost method = new HttpPost("http://libresonic.org/backend/sendMail.view"); - - List params = new ArrayList(); - params.add(new BasicNameValuePair("from", "noreply@libresonic.org")); - params.add(new BasicNameValuePair("to", email)); - params.add(new BasicNameValuePair("subject", "Libresonic Password")); - params.add(new BasicNameValuePair("text", - "Hi there!\n\n" + - "You have requested to reset your Libresonic password. Please find your new login details below.\n\n" + - "Username: " + username + "\n" + - "Password: " + password + "\n\n" + - "--\n" + - "The Libresonic Team\n" + - "libresonic.org")); - method.setEntity(new UrlEncodedFormEntity(params, StringUtil.ENCODING_UTF8)); - client.execute(method); + Message message = new MimeMessage(session); + message.setFrom(new InternetAddress("libresonic@libresonic.org")); + message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(email)); + message.setSubject("Libresonic Password"); + message.setText("Hi there!\n\n" + + "You have requested to reset your Libresonic password. Please find your new login details below.\n\n" + + "Username: " + username + "\n" + + "Password: " + password + "\n\n" + + "--\n" + + "Your Libresonic server\n" + + "libresonic.org"); + message.setSentDate(new Date()); + + Transport trans = session.getTransport(prot); + try { + if (settingsService.getSMTPUser() != null && !settingsService.getSMTPUser().isEmpty()) { + trans.connect(); + } else { + trans.connect(settingsService.getSMTPServer(), settingsService.getSMTPUser(), settingsService.getSMTPPassword()); + } + trans.sendMessage(message, message.getAllRecipients()); + } finally { + trans.close(); + } return true; + } catch (Exception x) { LOG.warn("Failed to send email.", x); return false; - } finally { - client.getConnectionManager().shutdown(); } } diff --git a/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java b/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java index 894dadf2..53081b75 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java +++ b/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java @@ -144,6 +144,12 @@ public class SettingsService { private static final String KEY_SONOS_SERVICE_NAME = "SonosServiceName"; private static final String KEY_SONOS_SERVICE_ID = "SonosServiceId"; + private static final String KEY_SMTP_SERVER = "SMTPServer"; + private static final String KEY_SMTP_ENCRYPTION = "SMTPEncryption"; + private static final String KEY_SMTP_PORT = "SMTPPort"; + private static final String KEY_SMTP_USER = "SMTPUser"; + private static final String KEY_SMTP_PASSWORD = "SMTPPassword"; + // Default values. private static final String DEFAULT_INDEX_STRING = "A B C D E F G H I J K L M N O P Q R S T U V W X-Z(XYZ)"; private static final String DEFAULT_IGNORED_ARTICLES = "The El La Los Las Le Les"; @@ -212,6 +218,12 @@ public class SettingsService { private static final String DEFAULT_SONOS_SERVICE_NAME = "Libresonic"; private static final int DEFAULT_SONOS_SERVICE_ID = 242; + private static final String DEFAULT_SMTP_SERVER = null; + private static final String DEFAULT_SMTP_ENCRYPTION = "None"; + private static final String DEFAULT_SMTP_PORT = "25"; + private static final String DEFAULT_SMTP_USER = null; + private static final String DEFAULT_SMTP_PASSWORD = null; + // Array of obsolete keys. Used to clean property file. private static final List OBSOLETE_KEYS = Arrays.asList("PortForwardingPublicPort", "PortForwardingLocalPort", "DownsamplingCommand", "DownsamplingCommand2", "DownsamplingCommand3", "AutoCoverBatch", "MusicMask", @@ -1052,7 +1064,7 @@ public class SettingsService { if (cachedMusicFolders == null) { cachedMusicFolders = musicFolderDao.getAllMusicFolders(); } - + List result = new ArrayList(cachedMusicFolders.size()); for (MusicFolder folder : cachedMusicFolders) { if ((includeDisabled || folder.isEnabled()) && (includeNonExisting || FileUtil.exists(folder.getPath()))) { @@ -1446,4 +1458,54 @@ public class SettingsService { public void setVersionService(VersionService versionService) { this.versionService = versionService; } + + public String getSMTPServer() { + return properties.getProperty(KEY_SMTP_SERVER, DEFAULT_SMTP_SERVER); + } + + public void setSMTPServer(String smtpServer) { + setString(KEY_SMTP_SERVER, smtpServer); + } + + public String getSMTPPort() { + return getString(KEY_SMTP_PORT, DEFAULT_SMTP_PORT); + } + + public void setSMTPPort(String smtpPort) { + setString(KEY_SMTP_PORT, smtpPort); + } + + public String getSMTPEncryption() { + return properties.getProperty(KEY_SMTP_ENCRYPTION, DEFAULT_SMTP_ENCRYPTION); + } + + public void setSMTPEncryption(String encryptionMethod) { + setString(KEY_SMTP_ENCRYPTION, encryptionMethod); + } + + public String getSMTPUser() { + return properties.getProperty(KEY_SMTP_USER, DEFAULT_SMTP_USER); + } + + public void setSMTPUser(String smtpUser) { + setString(KEY_SMTP_USER, smtpUser); + } + + public String getSMTPPassword() { + String s = properties.getProperty(KEY_SMTP_PASSWORD, DEFAULT_SMTP_PASSWORD); + try { + return StringUtil.utf8HexDecode(s); + } catch (Exception x) { + LOG.warn("Failed to decode SMTP password.", x); + return s; + } + } + public void setSMTPPassword(String smtpPassword) { + try { + smtpPassword = StringUtil.utf8HexEncode(smtpPassword); + } catch (Exception x) { + LOG.warn("Failed to encode SMTP password.", x); + } + properties.setProperty(KEY_SMTP_PASSWORD, smtpPassword); + } } From 72cbac1a5655e8331cccf35c7a3eee2af99241c8 Mon Sep 17 00:00:00 2001 From: Bernardus Jansen Date: Thu, 19 May 2016 21:51:14 +0200 Subject: [PATCH 2/5] Small changes/fixes Signed-off-by: Bernardus Jansen --- .../player/command/AdvancedSettingsCommand.java | 6 +++--- .../player/controller/MultiController.java | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java index 5fe712af..f2669608 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java @@ -42,7 +42,7 @@ public class AdvancedSettingsCommand { private String smtpServer; private String smtpEncryption; - private int smtpPort; + private String smtpPort; private String smtpUser; private String smtpPassword; @@ -150,11 +150,11 @@ public class AdvancedSettingsCommand { this.smtpEncryption = smtpEncryption; } - public int getSMTPPort() { + public String getSMTPPort() { return smtpPort; } - public void setSMTPPort(int smtpPort) { + public void setSMTPPort(String smtpPort) { this.smtpPort = smtpPort; } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java index a5dac659..0828afa6 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java @@ -137,7 +137,11 @@ public class MultiController extends MultiActionController { return new ModelAndView("recover", "model", map); } + /* + * e-mail user new password via configured SMTP server + */ private boolean emailPassword(String password, String username, String email) { + /* Default to protocol smtp when SMTPEncryption is set to "None" */ String prot = "smtp"; if (settingsService.getSMTPServer() == null || settingsService.getSMTPServer().isEmpty()) { @@ -155,6 +159,7 @@ public class MultiController extends MultiActionController { } props.put("mail." + prot + ".host", settingsService.getSMTPServer()); props.put("mail." + prot + ".port", settingsService.getSMTPPort()); + /* use authentication when SMTPUser is configured */ if (settingsService.getSMTPUser() != null && !settingsService.getSMTPUser().isEmpty()) { props.put("mail." + prot + ".auth", "true"); } @@ -174,13 +179,13 @@ public class MultiController extends MultiActionController { "Your Libresonic server\n" + "libresonic.org"); message.setSentDate(new Date()); - + Transport trans = session.getTransport(prot); try { - if (settingsService.getSMTPUser() != null && !settingsService.getSMTPUser().isEmpty()) { - trans.connect(); - } else { + if (props.get("mail." + prot + ".auth").equals("true")) { trans.connect(settingsService.getSMTPServer(), settingsService.getSMTPUser(), settingsService.getSMTPPassword()); + } else { + trans.connect(); } trans.sendMessage(message, message.getAllRecipients()); } finally { From 69121a894ae9b8b46c2195d86f842194b1021263 Mon Sep 17 00:00:00 2001 From: Bernardus Jansen Date: Thu, 19 May 2016 22:46:58 +0200 Subject: [PATCH 3/5] SMTP frontend Signed-off-by: Bernardus Jansen --- libresonic-main/pom.xml | 6 +++ .../command/AdvancedSettingsCommand.java | 20 ++++---- .../AdvancedSettingsController.java | 20 ++++---- .../player/controller/MultiController.java | 22 ++++---- .../player/service/SettingsService.java | 34 ++++++------- .../webapp/WEB-INF/jsp/advancedSettings.jsp | 50 +++++++++++++++++++ 6 files changed, 104 insertions(+), 48 deletions(-) diff --git a/libresonic-main/pom.xml b/libresonic-main/pom.xml index e0fe90bb..f068e92d 100644 --- a/libresonic-main/pom.xml +++ b/libresonic-main/pom.xml @@ -259,6 +259,12 @@ 1.5.5 + + com.sun.mail + javax.mail + 1.5.5 + + taglibs standard diff --git a/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java b/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java index f2669608..093c34b3 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java +++ b/libresonic-main/src/main/java/org/libresonic/player/command/AdvancedSettingsCommand.java @@ -134,43 +134,43 @@ public class AdvancedSettingsCommand { this.toast = toast; } - public String getSMTPServer() { + public String getSmtpServer() { return smtpServer; } - public void setSMTPServer(String smtpServer) { + public void setSmtpServer(String smtpServer) { this.smtpServer = smtpServer; } - public String getSMTPEncryption() { + public String getSmtpEncryption() { return smtpEncryption; } - public void setSMTPEncryption(String smtpEncryption) { + public void setSmtpEncryption(String smtpEncryption) { this.smtpEncryption = smtpEncryption; } - public String getSMTPPort() { + public String getSmtpPort() { return smtpPort; } - public void setSMTPPort(String smtpPort) { + public void setSmtpPort(String smtpPort) { this.smtpPort = smtpPort; } - public String getSMTPUser() { + public String getSmtpUser() { return smtpUser; } - public void setSMTPUser(String smtpUser) { + public void setSmtpUser(String smtpUser) { this.smtpUser = smtpUser; } - public String getSMTPPassword() { + public String getSmtpPassword() { return smtpPassword; } - public void setSMTPPassword(String smtpPassword) { + public void setSmtpPassword(String smtpPassword) { this.smtpPassword = smtpPassword; } } diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java index d5abaf24..c822717a 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/AdvancedSettingsController.java @@ -47,10 +47,10 @@ public class AdvancedSettingsController extends SimpleFormController { command.setLdapAutoShadowing(settingsService.isLdapAutoShadowing()); command.setBrand(settingsService.getBrand()); - command.setSMTPServer(settingsService.getSMTPServer()); - command.setSMTPEncryption(settingsService.getSMTPEncryption()); - command.setSMTPPort(settingsService.getSMTPPort()); - command.setSMTPUser(settingsService.getSMTPUser()); + command.setSmtpServer(settingsService.getSmtpServer()); + command.setSmtpEncryption(settingsService.getSmtpEncryption()); + command.setSmtpPort(settingsService.getSmtpPort()); + command.setSmtpUser(settingsService.getSmtpUser()); return command; } @@ -79,13 +79,13 @@ public class AdvancedSettingsController extends SimpleFormController { settingsService.setLdapManagerPassword(command.getLdapManagerPassword()); } - settingsService.setSMTPServer(command.getSMTPServer()); - settingsService.setSMTPEncryption(command.getSMTPEncryption()); - settingsService.setSMTPPort(command.getSMTPPort()); - settingsService.setSMTPUser(command.getSMTPUser()); + settingsService.setSmtpServer(command.getSmtpServer()); + settingsService.setSmtpEncryption(command.getSmtpEncryption()); + settingsService.setSmtpPort(command.getSmtpPort()); + settingsService.setSmtpUser(command.getSmtpUser()); - if (StringUtils.isNotEmpty(command.getSMTPPassword())) { - settingsService.setSMTPPassword(command.getSMTPPassword()); + if (StringUtils.isNotEmpty(command.getSmtpPassword())) { + settingsService.setSmtpPassword(command.getSmtpPassword()); } settingsService.save(); diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java index 0828afa6..d03137e2 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java @@ -138,29 +138,29 @@ public class MultiController extends MultiActionController { } /* - * e-mail user new password via configured SMTP server + * e-mail user new password via configured Smtp server */ private boolean emailPassword(String password, String username, String email) { - /* Default to protocol smtp when SMTPEncryption is set to "None" */ + /* Default to protocol smtp when SmtpEncryption is set to "None" */ String prot = "smtp"; - if (settingsService.getSMTPServer() == null || settingsService.getSMTPServer().isEmpty()) { - LOG.warn("Can not send email; no SMTP server configured."); + if (settingsService.getSmtpServer() == null || settingsService.getSmtpServer().isEmpty()) { + LOG.warn("Can not send email; no Smtp server configured."); return false; } Properties props = new Properties(); - if (settingsService.getSMTPEncryption().equals("SSL/TLS")) { + if (settingsService.getSmtpEncryption().equals("SSL/TLS")) { prot = "smtps"; props.put("mail." + prot + ".ssl.enable", "true"); - } else if (settingsService.getSMTPEncryption().equals("STARTTLS")) { + } else if (settingsService.getSmtpEncryption().equals("STARTTLS")) { prot = "smtp"; props.put("mail." + prot + ".starttls.enable", "true"); } - props.put("mail." + prot + ".host", settingsService.getSMTPServer()); - props.put("mail." + prot + ".port", settingsService.getSMTPPort()); - /* use authentication when SMTPUser is configured */ - if (settingsService.getSMTPUser() != null && !settingsService.getSMTPUser().isEmpty()) { + props.put("mail." + prot + ".host", settingsService.getSmtpServer()); + props.put("mail." + prot + ".port", settingsService.getSmtpPort()); + /* use authentication when SmtpUser is configured */ + if (settingsService.getSmtpUser() != null && !settingsService.getSmtpUser().isEmpty()) { props.put("mail." + prot + ".auth", "true"); } @@ -183,7 +183,7 @@ public class MultiController extends MultiActionController { Transport trans = session.getTransport(prot); try { if (props.get("mail." + prot + ".auth").equals("true")) { - trans.connect(settingsService.getSMTPServer(), settingsService.getSMTPUser(), settingsService.getSMTPPassword()); + trans.connect(settingsService.getSmtpServer(), settingsService.getSmtpUser(), settingsService.getSmtpPassword()); } else { trans.connect(); } diff --git a/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java b/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java index 53081b75..79ffe859 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java +++ b/libresonic-main/src/main/java/org/libresonic/player/service/SettingsService.java @@ -144,11 +144,11 @@ public class SettingsService { private static final String KEY_SONOS_SERVICE_NAME = "SonosServiceName"; private static final String KEY_SONOS_SERVICE_ID = "SonosServiceId"; - private static final String KEY_SMTP_SERVER = "SMTPServer"; - private static final String KEY_SMTP_ENCRYPTION = "SMTPEncryption"; - private static final String KEY_SMTP_PORT = "SMTPPort"; - private static final String KEY_SMTP_USER = "SMTPUser"; - private static final String KEY_SMTP_PASSWORD = "SMTPPassword"; + private static final String KEY_SMTP_SERVER = "SmtpServer"; + private static final String KEY_SMTP_ENCRYPTION = "SmtpEncryption"; + private static final String KEY_SMTP_PORT = "SmtpPort"; + private static final String KEY_SMTP_USER = "SmtpUser"; + private static final String KEY_SMTP_PASSWORD = "SmtpPassword"; // Default values. private static final String DEFAULT_INDEX_STRING = "A B C D E F G H I J K L M N O P Q R S T U V W X-Z(XYZ)"; @@ -1459,52 +1459,52 @@ public class SettingsService { this.versionService = versionService; } - public String getSMTPServer() { + public String getSmtpServer() { return properties.getProperty(KEY_SMTP_SERVER, DEFAULT_SMTP_SERVER); } - public void setSMTPServer(String smtpServer) { + public void setSmtpServer(String smtpServer) { setString(KEY_SMTP_SERVER, smtpServer); } - public String getSMTPPort() { + public String getSmtpPort() { return getString(KEY_SMTP_PORT, DEFAULT_SMTP_PORT); } - public void setSMTPPort(String smtpPort) { + public void setSmtpPort(String smtpPort) { setString(KEY_SMTP_PORT, smtpPort); } - public String getSMTPEncryption() { + public String getSmtpEncryption() { return properties.getProperty(KEY_SMTP_ENCRYPTION, DEFAULT_SMTP_ENCRYPTION); } - public void setSMTPEncryption(String encryptionMethod) { + public void setSmtpEncryption(String encryptionMethod) { setString(KEY_SMTP_ENCRYPTION, encryptionMethod); } - public String getSMTPUser() { + public String getSmtpUser() { return properties.getProperty(KEY_SMTP_USER, DEFAULT_SMTP_USER); } - public void setSMTPUser(String smtpUser) { + public void setSmtpUser(String smtpUser) { setString(KEY_SMTP_USER, smtpUser); } - public String getSMTPPassword() { + public String getSmtpPassword() { String s = properties.getProperty(KEY_SMTP_PASSWORD, DEFAULT_SMTP_PASSWORD); try { return StringUtil.utf8HexDecode(s); } catch (Exception x) { - LOG.warn("Failed to decode SMTP password.", x); + LOG.warn("Failed to decode Smtp password.", x); return s; } } - public void setSMTPPassword(String smtpPassword) { + public void setSmtpPassword(String smtpPassword) { try { smtpPassword = StringUtil.utf8HexEncode(smtpPassword); } catch (Exception x) { - LOG.warn("Failed to encode SMTP password.", x); + LOG.warn("Failed to encode Smtp password.", x); } properties.setProperty(KEY_SMTP_PASSWORD, smtpPassword); } diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp index 57106568..344b8414 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp @@ -41,6 +41,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+ + + + + + + + + +
+ + +
+ + +
+ @@ -85,7 +86,6 @@ From 0cfd6e8318cd5fd5fdbab16603fed4cc8fe9f1d7 Mon Sep 17 00:00:00 2001 From: Bernardus Jansen Date: Sat, 21 May 2016 18:57:47 +0200 Subject: [PATCH 5/5] Fix nullptr exception Signed-off-by: Bernardus Jansen --- .../java/org/libresonic/player/controller/MultiController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java index d03137e2..52baad91 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/MultiController.java @@ -182,7 +182,7 @@ public class MultiController extends MultiActionController { Transport trans = session.getTransport(prot); try { - if (props.get("mail." + prot + ".auth").equals("true")) { + if (props.get("mail." + prot + ".auth") != null && props.get("mail." + prot + ".auth").equals("true")) { trans.connect(settingsService.getSmtpServer(), settingsService.getSmtpUser(), settingsService.getSmtpPassword()); } else { trans.connect();
From 8f1f1a133b459dd6c087aadc97471f1c3267ec95 Mon Sep 17 00:00:00 2001 From: Bernardus Jansen Date: Thu, 19 May 2016 23:08:06 +0200 Subject: [PATCH 4/5] Added frontend strings Signed-off-by: Bernardus Jansen --- .../player/i18n/ResourceBundle_en.properties | 17 +++++++++++++++++ .../player/i18n/ResourceBundle_nl.properties | 6 ++++++ .../webapp/WEB-INF/jsp/advancedSettings.jsp | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties b/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties index 0deade45..6fc2cae7 100644 --- a/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties +++ b/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_en.properties @@ -341,6 +341,14 @@ advancedsettings.ldapsearchfilter = LDAP search filter advancedsettings.ldapmanagerdn = LDAP manager DN
(Optional)
advancedsettings.ldapmanagerpassword = Password advancedsettings.ldapautoshadowing = Automatically create users in {0} +advancedsettings.smtpPort = SMTP port +advancedsettings.smtpServer = SMTP server +advancedsettings.smtpEncryption = SMTP encryption method +advancedsettings.smtpUser = SMTP username +advancedsettings.smtpPassword = SMTP password +advancedsettings.smtpEncryption.none = None +advancedsettings.smtpEncryption.starttls = STARTTLS +advancedsettings.smtpEncryption.ssl = SSL/TLS # personalSettings.jsp personalsettings.title = Personal settings for {0} @@ -808,6 +816,15 @@ helppopup.autocontrol.text =

With this option selected, {0} will automaticall in the playlist. Otherwise, you must start and connect the player yourself.

helppopup.dynamicip.title = Dynamic IP address helppopup.dynamicip.text =

Turn off this option if the player uses a static IP address.

+helppopup.smtpServer.title = SMTP Server +helppopup.smtpServer.text =

The hostname of the SMTP server. This server will be used to send e-mails to users \ + who have requested a password reset.

+helppopup.smtpPort.title = SMTP Port +helppopup.smtpPort.text =

The server's port that should be connected to for SMTP traffic.

+helppopup.smtpUser.title = SMTP User +helppopup.smtpUser.text =

The username to be used to authenticate with the server. Leave empty to connect without authentication.

+helppopup.smtpEncryption.title = SMTP Encryption +helppopup.smtpEncryption.text =

The encryption method to be used to connect to the SMTP server. Choose "None" for no encryption.

# wap/index.jsp wap.index.missing = No music found diff --git a/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_nl.properties b/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_nl.properties index d98cc8e3..2dae8742 100644 --- a/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_nl.properties +++ b/libresonic-main/src/main/resources/org/libresonic/player/i18n/ResourceBundle_nl.properties @@ -339,6 +339,12 @@ advancedsettings.ldapsearchfilter = LDAP zoekfilter advancedsettings.ldapmanagerdn = LDAP manager DN
(Optioneel)
advancedsettings.ldapmanagerpassword = Wachtwoord advancedsettings.ldapautoshadowing = Maak automatisch gebruikers aan in {0} +advancedsettings.smtpPort = SMTP poort +advancedsettings.smtpServer = SMTP server +advancedsettings.smtpEncryption = SMTP versleutelingsmethode +advancedsettings.smtpUser = SMTP gebruikersnaam +advancedsettings.smtpPassword = SMTP wachtwoord +advancedsettings.smtpEncryption.none = Geen # personalsettings.jsp personalsettings.title = Persoonlijke instellingen voor {0} diff --git a/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp b/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp index 344b8414..d12c1975 100644 --- a/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp +++ b/libresonic-main/src/main/webapp/WEB-INF/jsp/advancedSettings.jsp @@ -70,6 +70,7 @@ +
-