|
|
@ -60,7 +60,7 @@ public class Web extends TemplateServlet { |
|
|
|
data.put(USER, user); |
|
|
|
data.put(USER, user); |
|
|
|
|
|
|
|
|
|
|
|
if (!user.hashPermission(User.PERMISSION_CREATE_LISTS)){ |
|
|
|
if (!user.hashPermission(User.PERMISSION_CREATE_LISTS)){ |
|
|
|
data.put(ERROR,t("You are not allowed to create new mailing lists!")); |
|
|
|
data.put(ERROR,t("Ihnen ist es nicht gestattet, neue Mailinglisten anzulegen!")); |
|
|
|
return loadTemplate(ADMIN,data,resp); |
|
|
|
return loadTemplate(ADMIN,data,resp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -88,17 +88,17 @@ public class Web extends TemplateServlet { |
|
|
|
data.put(SMTP_PORT, smtpPort); |
|
|
|
data.put(SMTP_PORT, smtpPort); |
|
|
|
|
|
|
|
|
|
|
|
if (name == null || name.isBlank() || email == null || email.isBlank()) { |
|
|
|
if (name == null || name.isBlank() || email == null || email.isBlank()) { |
|
|
|
data.put(ERROR, "List name and address are required!"); |
|
|
|
data.put(ERROR, "Name und Adresse der Liste sind notwendige Felder!"); |
|
|
|
return loadTemplate(ADD_LIST, data, resp); |
|
|
|
return loadTemplate(ADD_LIST, data, resp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!Util.isEmail(email)) { |
|
|
|
if (!Util.isEmail(email)) { |
|
|
|
data.put(ERROR, t("List email ({}) is not a valid email address!", email)); |
|
|
|
data.put(ERROR, t("Listen-E-Mail-Adresse ({}) ist keine gültige E-Mail-Adresse!", email)); |
|
|
|
return loadTemplate(ADD_LIST, data, resp); |
|
|
|
return loadTemplate(ADD_LIST, data, resp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (imapHost == null || imapHost.isBlank() || imapUser == null || imapUser.isBlank() || imapPass == null || imapPass.isBlank()) { |
|
|
|
if (imapHost == null || imapHost.isBlank() || imapUser == null || imapUser.isBlank() || imapPass == null || imapPass.isBlank()) { |
|
|
|
data.put(ERROR, "IMAP credentials are required!"); |
|
|
|
data.put(ERROR, "IMAP-Zugangsdaten sind erforderlich!"); |
|
|
|
return loadTemplate(ADD_LIST, data, resp); |
|
|
|
return loadTemplate(ADD_LIST, data, resp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -107,12 +107,12 @@ public class Web extends TemplateServlet { |
|
|
|
imapPort = Integer.parseInt(req.getParameter(IMAP_PORT)); |
|
|
|
imapPort = Integer.parseInt(req.getParameter(IMAP_PORT)); |
|
|
|
data.put(IMAP_PORT, imapPort); |
|
|
|
data.put(IMAP_PORT, imapPort); |
|
|
|
} catch (NumberFormatException nfe) { |
|
|
|
} catch (NumberFormatException nfe) { |
|
|
|
data.put(ERROR, t("'{}' is not a proper port number!", req.getParameter(IMAP_PORT))); |
|
|
|
data.put(ERROR, t("'{}' ist keine gültige Port-Nummer!", req.getParameter(IMAP_PORT))); |
|
|
|
return loadTemplate(ADD_LIST, data, resp); |
|
|
|
return loadTemplate(ADD_LIST, data, resp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (smtpHost == null || smtpHost.isBlank() || smtpUser == null || smtpUser.isBlank() || smtpPass == null || smtpPass.isBlank()) { |
|
|
|
if (smtpHost == null || smtpHost.isBlank() || smtpUser == null || smtpUser.isBlank() || smtpPass == null || smtpPass.isBlank()) { |
|
|
|
data.put(ERROR, "SMTP credentials are required!"); |
|
|
|
data.put(ERROR, "SMTP-Zugangsdaten sind erforderlich!"); |
|
|
|
return loadTemplate(ADD_LIST, data, resp); |
|
|
|
return loadTemplate(ADD_LIST, data, resp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -120,7 +120,7 @@ public class Web extends TemplateServlet { |
|
|
|
smtpPort = Integer.parseInt(req.getParameter(SMTP_PORT)); |
|
|
|
smtpPort = Integer.parseInt(req.getParameter(SMTP_PORT)); |
|
|
|
data.put(SMTP_PORT, smtpPort); |
|
|
|
data.put(SMTP_PORT, smtpPort); |
|
|
|
} catch (NumberFormatException nfe) { |
|
|
|
} catch (NumberFormatException nfe) { |
|
|
|
data.put(ERROR, t("'{}' is not a proper port number!", req.getParameter(SMTP_PORT))); |
|
|
|
data.put(ERROR, t("'{}' ist keine gültige Port-Nummer!", req.getParameter(SMTP_PORT))); |
|
|
|
return loadTemplate(ADD_LIST, data, resp); |
|
|
|
return loadTemplate(ADD_LIST, data, resp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -129,20 +129,20 @@ public class Web extends TemplateServlet { |
|
|
|
ListMember.create(list, user, ListMember.STATE_OWNER); |
|
|
|
ListMember.create(list, user, ListMember.STATE_OWNER); |
|
|
|
return redirectTo(INDEX, resp); |
|
|
|
return redirectTo(INDEX, resp); |
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
return t("Failed to create list '{}': {}", name, e.getMessage()); |
|
|
|
return t("Erzeugen der Liste '{}' fehlgeschlagen: {}", name, e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String confirm(HttpServletRequest req, HttpServletResponse resp) { |
|
|
|
private String confirm(HttpServletRequest req, HttpServletResponse resp) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
var token = req.getParameter(TOKEN); |
|
|
|
var token = req.getParameter(TOKEN); |
|
|
|
if (token== null || token.isBlank()) return t("Invalid or missing token!"); |
|
|
|
if (token== null || token.isBlank()) return t("Ungültiger oder fehlender Token!"); |
|
|
|
var user = ListMember.confirm(token); |
|
|
|
var user = ListMember.confirm(token); |
|
|
|
if (user != null) return loadTemplate(INDEX,Map.of(USER,user.safeMap(),NOTES,"Confirmed list subscription!"),resp); |
|
|
|
if (user != null) return loadTemplate(INDEX,Map.of(USER,user.safeMap(),NOTES,"Listen-Mitgliedschaft bestätigt!"),resp); |
|
|
|
return t("Unknown user or token"); |
|
|
|
return t("Nutzer oder Token unbekannt"); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
LOG.debug("Failed to confirm list membership:",e); |
|
|
|
LOG.debug("Bestätigung des Listen-Abonnements fehlgeschlagen:",e); |
|
|
|
return t("Confirmation of list membership failed!"); |
|
|
|
return t("Bestätigung des Listen-Abonnements fehlgeschlagen!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -188,7 +188,7 @@ public class Web extends TemplateServlet { |
|
|
|
return confirm(req,resp); |
|
|
|
return confirm(req,resp); |
|
|
|
case RELOAD: |
|
|
|
case RELOAD: |
|
|
|
loadTemplates(); |
|
|
|
loadTemplates(); |
|
|
|
data.put(NOTES,t("Templates have been reloaded")); |
|
|
|
data.put(NOTES,t("Vorlagen wurden neu geladen")); |
|
|
|
path = INDEX; |
|
|
|
path = INDEX; |
|
|
|
case "css": |
|
|
|
case "css": |
|
|
|
case INDEX: |
|
|
|
case INDEX: |
|
|
@ -199,16 +199,16 @@ public class Web extends TemplateServlet { |
|
|
|
data.put(LIST,listEmail); |
|
|
|
data.put(LIST,listEmail); |
|
|
|
return loadTemplate(path, data, resp); |
|
|
|
return loadTemplate(path, data, resp); |
|
|
|
} |
|
|
|
} |
|
|
|
return t("You are not allowed to subscribe to '{}'!",list.email()); |
|
|
|
return t("Es ist ihnen nicht gestattet, '{}' zu abonnieren!",list.email()); |
|
|
|
case "js": |
|
|
|
case "js": |
|
|
|
resp.setContentType("text/javascript"); |
|
|
|
resp.setContentType("text/javascript"); |
|
|
|
return loadTemplate(path,data,resp); |
|
|
|
return loadTemplate(path,data,resp); |
|
|
|
case LOGIN: |
|
|
|
case LOGIN: |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (User.noUsers()) return loadTemplate(REGISTER, Map.of(NOTES,t("User database is empty. Create admin user first:")), resp); |
|
|
|
if (User.noUsers()) return loadTemplate(REGISTER, Map.of(NOTES,t("Nutzer-Datenbank ist leer. Admin-Nutzer wird hiermit angelegt:")), resp); |
|
|
|
return loadTemplate(path,null,resp); |
|
|
|
return loadTemplate(path,null,resp); |
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
return "Error reading user database!"; |
|
|
|
return "Fehler beim Lesen der Datenbank!"; |
|
|
|
} |
|
|
|
} |
|
|
|
case LOGOUT: |
|
|
|
case LOGOUT: |
|
|
|
req.getSession().invalidate(); |
|
|
|
req.getSession().invalidate(); |
|
|
@ -231,8 +231,8 @@ public class Web extends TemplateServlet { |
|
|
|
private String handleLogin(HttpServletRequest req, HttpServletResponse resp) { |
|
|
|
private String handleLogin(HttpServletRequest req, HttpServletResponse resp) { |
|
|
|
var email = req.getParameter("email"); |
|
|
|
var email = req.getParameter("email"); |
|
|
|
var pass = req.getParameter("pass"); |
|
|
|
var pass = req.getParameter("pass"); |
|
|
|
if (email == null || pass == null) return loadTemplate("login", Map.of("error",t("Missing username or password!")), resp); |
|
|
|
if (email == null || pass == null) return loadTemplate("login", Map.of("error",t("Nutzername oder Passwort fehlen!")), resp); |
|
|
|
if (!Util.isEmail(email)) return loadTemplate("login", Map.of("error",t("'{}' is not a valid email address!",email)), resp); |
|
|
|
if (!Util.isEmail(email)) return loadTemplate("login", Map.of("error",t("'{}' ist keine gültige Mailadresse!",email)), resp); |
|
|
|
try { |
|
|
|
try { |
|
|
|
var user = User.loadUser(email,pass); |
|
|
|
var user = User.loadUser(email,pass); |
|
|
|
req.getSession().setAttribute("user",user); |
|
|
|
req.getSession().setAttribute("user",user); |
|
|
@ -240,10 +240,10 @@ public class Web extends TemplateServlet { |
|
|
|
resp.sendRedirect(String.join("/",WEB_ROOT,"admin")); |
|
|
|
resp.sendRedirect(String.join("/",WEB_ROOT,"admin")); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
LOG.warn("Static.handleLogin failed:",e); |
|
|
|
LOG.warn("Static.handleLogin fehlgeschlagen:",e); |
|
|
|
Thread.sleep(10000); |
|
|
|
Thread.sleep(10000); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
return loadTemplate("login", Map.of(ERROR,t("Invalid username/password"),EMAIL,email), resp); |
|
|
|
return loadTemplate("login", Map.of(ERROR,t("Ungültiger Nutzername oder ungültiges Passwort!"),EMAIL,email), resp); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
@ -265,7 +265,7 @@ public class Web extends TemplateServlet { |
|
|
|
return unsubscribe(req,resp); |
|
|
|
return unsubscribe(req,resp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return t("No handler for path {}!",path); |
|
|
|
return t("Kein Handler für den Pfad '{}'!",path); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -277,7 +277,7 @@ public class Web extends TemplateServlet { |
|
|
|
resp.sendRedirect(String.join("/",WEB_ROOT,page)); |
|
|
|
resp.sendRedirect(String.join("/",WEB_ROOT,page)); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
return t("Was not able to redirect to {} page: {}", page, e.getMessage()); |
|
|
|
return t("Weiterleitung nach {} fehlgeschlagen: {}", page, e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -293,15 +293,15 @@ public class Web extends TemplateServlet { |
|
|
|
if (email == null || email.isBlank() || |
|
|
|
if (email == null || email.isBlank() || |
|
|
|
name == null || name.isBlank() || |
|
|
|
name == null || name.isBlank() || |
|
|
|
pass == null || pass.isBlank() || |
|
|
|
pass == null || pass.isBlank() || |
|
|
|
pass_repeat == null || pass_repeat.isBlank()) return loadTemplate(REGISTER,Map.of(ERROR,"Fill all fields, please!",NAME,name,EMAIL,email),resp); |
|
|
|
pass_repeat == null || pass_repeat.isBlank()) return loadTemplate(REGISTER,Map.of(ERROR,"Bitte alle Felder ausfüllen!",NAME,name,EMAIL,email),resp); |
|
|
|
if (!pass.equals(pass_repeat)) return loadTemplate(REGISTER,Map.of(ERROR,"Passwords do not match!",NAME,name,EMAIL,email),resp); |
|
|
|
if (!pass.equals(pass_repeat)) return loadTemplate(REGISTER,Map.of(ERROR,"Passworte stimmen nicht überein!",NAME,name,EMAIL,email),resp); |
|
|
|
if (Util.simplePassword(pass)) return loadTemplate(REGISTER,Map.of(ERROR,"Password to short or to simple!",NAME,name,EMAIL,email),resp); |
|
|
|
if (Util.simplePassword(pass)) return loadTemplate(REGISTER,Map.of(ERROR,"Passwort zu kurz oder zu einfach!",NAME,name,EMAIL,email),resp); |
|
|
|
|
|
|
|
|
|
|
|
var firstUser = false; |
|
|
|
var firstUser = false; |
|
|
|
try { |
|
|
|
try { |
|
|
|
firstUser = User.noUsers(); |
|
|
|
firstUser = User.noUsers(); |
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
return t("Failed to access user database: {}",e.getMessage()); |
|
|
|
return t("Fehler beim Zugriff auf die Nutzer-Datenbank: {}",e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -311,8 +311,8 @@ public class Web extends TemplateServlet { |
|
|
|
req.getSession().setAttribute("user",user); |
|
|
|
req.getSession().setAttribute("user",user); |
|
|
|
return redirectTo(INDEX,resp); |
|
|
|
return redirectTo(INDEX,resp); |
|
|
|
} catch (SQLException e) { |
|
|
|
} catch (SQLException e) { |
|
|
|
LOG.warn("Failed to create new user:",e); |
|
|
|
LOG.warn("Erzeugen des neuen Nutzers fehlgeschlagen:",e); |
|
|
|
return t("Failed to create new user: {}",e.getMessage()); |
|
|
|
return t("Erzeugen des neuen Nutzers fehlgeschlagen: {}",e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -330,12 +330,12 @@ public class Web extends TemplateServlet { |
|
|
|
var list = MailingList.load(listEmail); |
|
|
|
var list = MailingList.load(listEmail); |
|
|
|
|
|
|
|
|
|
|
|
if (list == null){ |
|
|
|
if (list == null){ |
|
|
|
data.put(ERROR,"No list provided by form data!"); |
|
|
|
data.put(ERROR,"Formular-Daten enthalten keine Liste!"); |
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (name == null || name.isBlank() || email == null || email.isBlank()){ |
|
|
|
if (name == null || name.isBlank() || email == null || email.isBlank()){ |
|
|
|
data.put(ERROR,"Name and email are required fields for list subscription!"); |
|
|
|
data.put(ERROR,"Name und E-Mail-Adresse sind für das Abonnieren der Mailingliste erforderlich!"); |
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
} |
|
|
|
} |
|
|
|
if (pass != null && pass.isBlank()) pass = null; |
|
|
|
if (pass != null && pass.isBlank()) pass = null; |
|
|
@ -352,36 +352,36 @@ public class Web extends TemplateServlet { |
|
|
|
// success → subscribe
|
|
|
|
// success → subscribe
|
|
|
|
} catch (InvalidKeyException | SQLException e) { |
|
|
|
} catch (InvalidKeyException | SQLException e) { |
|
|
|
// invalid credentials
|
|
|
|
// invalid credentials
|
|
|
|
data.put(ERROR,t("'{}' already in database, but with different password!",email)); |
|
|
|
data.put(ERROR,t("'{}' gibt es schon in der Datenbank, hat dort aber ein anderes Passwort!",email)); |
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
data.put(USER,user.safeMap()); |
|
|
|
data.put(USER,user.safeMap()); |
|
|
|
|
|
|
|
|
|
|
|
if (!list.isOpenFor(user)){ |
|
|
|
if (!list.isOpenFor(user)){ |
|
|
|
data.put(ERROR,t("You are not allowed to join {}!",list.email())); |
|
|
|
data.put(ERROR,t("Ihnen ist es nicht gestattet, '{}' zu abonnieren!",list.email())); |
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
list.requestSubscription(user,skipConfirmation); |
|
|
|
list.requestSubscription(user,skipConfirmation); |
|
|
|
if (skipConfirmation) { |
|
|
|
if (skipConfirmation) { |
|
|
|
data.put(NOTES, t("Successfully subscribed '{}' to '{}'.", user.email(), list.email())); |
|
|
|
data.put(NOTES, t("'{}' hat die Mailingliste '{}' erfolgreich abonniert.", user.email(), list.email())); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
data.put(NOTES, t("Sent confirmation mail to '{}.", user.email())); |
|
|
|
data.put(NOTES, t("Bestätigungs-Email wurde an '{} versendet.", user.email())); |
|
|
|
} |
|
|
|
} |
|
|
|
return loadTemplate(INDEX,data,resp); |
|
|
|
return loadTemplate(INDEX,data,resp); |
|
|
|
} catch (SQLException sqle) { |
|
|
|
} catch (SQLException sqle) { |
|
|
|
LOG.debug("List subscription failed: ",sqle); |
|
|
|
LOG.debug("Abonnieren der Liste fehlgeschlagen: ",sqle); |
|
|
|
var cause = getCausingException(sqle); |
|
|
|
var cause = getCausingException(sqle); |
|
|
|
int code = cause.getErrorCode(); |
|
|
|
int code = cause.getErrorCode(); |
|
|
|
if (code == PRIMARY_KEY_CONSTRAINT) {// user already exists
|
|
|
|
if (code == PRIMARY_KEY_CONSTRAINT) {// user already exists
|
|
|
|
data.put(ERROR,t("You already are member of this list!",sqle.getMessage())); |
|
|
|
data.put(ERROR,t("Sie haben diese Liste bereits abonniert!",sqle.getMessage())); |
|
|
|
} else data.put(ERROR,t("Subscription failed: {}",sqle.getMessage())); |
|
|
|
} else data.put(ERROR,t("Abonnieren der Liste fehlgeschlagen: {}",sqle.getMessage())); |
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
} catch (MessagingException e) { |
|
|
|
} catch (MessagingException e) { |
|
|
|
LOG.warn("Failed to send request confirmation email:",e); |
|
|
|
LOG.warn("Senden der Bestätigungs-Email fehlgeschlagen:",e); |
|
|
|
data.put(ERROR,t("Failed to send request confirmation email: {}",e.getMessage())); |
|
|
|
data.put(ERROR,t("Senden der Bestätigungs-Email fehlgeschlagen: {}",e.getMessage())); |
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
return loadTemplate(SUBSCRIBE,data,resp); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|