Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 7cb282a7 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

[URGENT] fix mail alerting for new users

parent bae7f86a
No related branches found
No related tags found
No related merge requests found
Pipeline #197515 failed
...@@ -473,7 +473,7 @@ ...@@ -473,7 +473,7 @@
"login.button.login": "Login", "login.button.login": "Login",
"login.button.password.reset": "Request reset password", "login.button.password.reset": "Request reset password",
"login.button.sso.login": "Request reset password", "login.button.sso.login": "SSO login",
"login.dialog.password.expiration.dialog.description": "Your password is about to expire on {{expirationDate}}! Please change the password before the expiration date!", "login.dialog.password.expiration.dialog.description": "Your password is about to expire on {{expirationDate}}! Please change the password before the expiration date!",
"login.dialog.password.expiration.dialog.title": "Warning! Your password is about to expire", "login.dialog.password.expiration.dialog.title": "Warning! Your password is about to expire",
"login.error.generic.error": "Default error ({{errorStatus}}) occurred during login.", "login.error.generic.error": "Default error ({{errorStatus}}) occurred during login.",
......
...@@ -473,7 +473,7 @@ ...@@ -473,7 +473,7 @@
"login.button.login": "Autentifica", "login.button.login": "Autentifica",
"login.button.password.reset": "Solicitati resetarea parolei", "login.button.password.reset": "Solicitati resetarea parolei",
"login.button.sso.login": "Solicitati resetarea parolei", "login.button.sso.login": "SSO Autentifica",
"login.dialog.password.expiration.dialog.description": "Parola dvs. este pe cale sa expire la {{expirationDate}}! Va rugam sa va schimbati parola inainte de data expirarii!", "login.dialog.password.expiration.dialog.description": "Parola dvs. este pe cale sa expire la {{expirationDate}}! Va rugam sa va schimbati parola inainte de data expirarii!",
"login.dialog.password.expiration.dialog.title": "Avertizare! Parola dvs. este pe cale sa expire", "login.dialog.password.expiration.dialog.title": "Avertizare! Parola dvs. este pe cale sa expire",
"login.error.generic.error": "A aparut o eroare generica ({{errorStatus}}) in timpul conectarii.", "login.error.generic.error": "A aparut o eroare generica ({{errorStatus}}) in timpul conectarii.",
......
...@@ -18,13 +18,15 @@ ...@@ -18,13 +18,15 @@
*/ */
package eu.europa.ec.edelivery.smp.utils; package eu.europa.ec.edelivery.smp.utils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.io.*; import java.io.*;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.lowerCase;
import static org.apache.commons.lang3.StringUtils.trim;
/** /**
* This class is used to substitute named variables in the string with key value pairs from the map. * This class is used to substitute named variables in the string with key value pairs from the map.
...@@ -56,12 +58,13 @@ public class StringNamedSubstitutor { ...@@ -56,12 +58,13 @@ public class StringNamedSubstitutor {
LOG.debug("Using default charset: [{}]", charset); LOG.debug("Using default charset: [{}]", charset);
return resolve(string, config, charset); return resolve(string, config, charset);
} }
/** /**
* Substitute named variables in the string with key value pairs from the map. * Substitute named variables in the string with key value pairs from the map.
* The variables are in the form of ${name} and are case-insensitive and can contain only letters, digits, _ and . * The variables are in the form of ${name} and are case-insensitive and can contain only letters, digits, _ and .
* *
* @param string the string to resolve * @param string the string to resolve
* @param config the config to use * @param config the config to use
* @param charset the character of the input stream * @param charset the character of the input stream
* @return the resolved string * @return the resolved string
*/ */
...@@ -79,7 +82,7 @@ public class StringNamedSubstitutor { ...@@ -79,7 +82,7 @@ public class StringNamedSubstitutor {
* The input stream is ready with default charset. * The input stream is ready with default charset.
* *
* @param templateIS the InputStream to resolve * @param templateIS the InputStream to resolve
* @param config the map of property names and its values * @param config the map of property names and its values
* @return the resolved string * @return the resolved string
* @throws IOException if an I/O error occurs * @throws IOException if an I/O error occurs
*/ */
...@@ -99,10 +102,9 @@ public class StringNamedSubstitutor { ...@@ -99,10 +102,9 @@ public class StringNamedSubstitutor {
* @return the resolved string * @return the resolved string
*/ */
public static String resolve(InputStream templateIS, Map<String, Object> config, String charset) throws IOException { public static String resolve(InputStream templateIS, Map<String, Object> config, String charset) throws IOException {
Map<String, Object> lowerCaseMap = config.entrySet().stream()
.collect(Collectors.toMap(e -> StringUtils.lowerCase(e.getKey()), Map.Entry::getValue));
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) { try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
resolve(templateIS, lowerCaseMap, byteArrayOutputStream, charset); resolve(templateIS, config, byteArrayOutputStream, charset);
return byteArrayOutputStream.toString(); return byteArrayOutputStream.toString();
} }
} }
...@@ -119,9 +121,7 @@ public class StringNamedSubstitutor { ...@@ -119,9 +121,7 @@ public class StringNamedSubstitutor {
*/ */
public static void resolve(InputStream templateIS, Map<String, Object> config, public static void resolve(InputStream templateIS, Map<String, Object> config,
OutputStream outputStream, String charset) throws IOException { OutputStream outputStream, String charset) throws IOException {
Map<String, Object> lowerCaseMap = config.entrySet().stream() Map<String, Object> lowerCaseMap = normalizeData(config);
.collect(Collectors.toMap(e -> StringUtils.lowerCase(e.getKey()), Map.Entry::getValue));
try (BufferedReader template = new BufferedReader(new InputStreamReader(templateIS, charset)); try (BufferedReader template = new BufferedReader(new InputStreamReader(templateIS, charset));
Writer writer = new OutputStreamWriter(outputStream, charset)) { Writer writer = new OutputStreamWriter(outputStream, charset)) {
int read; int read;
...@@ -136,7 +136,7 @@ public class StringNamedSubstitutor { ...@@ -136,7 +136,7 @@ public class StringNamedSubstitutor {
if (name == null) { if (name == null) {
writer.write(START_NAME); writer.write(START_NAME);
} else { } else {
String key = StringUtils.lowerCase(name); String key = lowerCase(name);
Object objValue = lowerCaseMap.get(key); Object objValue = lowerCaseMap.get(key);
String value = objValue != null ? String.valueOf(lowerCaseMap.get(key)) : null; String value = objValue != null ? String.valueOf(lowerCaseMap.get(key)) : null;
...@@ -152,6 +152,20 @@ public class StringNamedSubstitutor { ...@@ -152,6 +152,20 @@ public class StringNamedSubstitutor {
} }
} }
/**
* Normalize the data model to trim and lower case the keys.
*
* @param dataModel the data model
* @return the normalized data model
*/
private static Map<String, Object> normalizeData(Map<String, Object> dataModel) {
Map<String, Object> lowerCaseMap = new HashMap<>();
// Note: do not use stream with Collectors.toMap because it throws NPE if value is null
dataModel.forEach((key, value) ->
lowerCaseMap.put(lowerCase(trim(key)), value));
return lowerCaseMap;
}
private static boolean isStartSequence(BufferedReader reader) throws IOException { private static boolean isStartSequence(BufferedReader reader) throws IOException {
reader.mark(START_NAME.length()); reader.mark(START_NAME.length());
int read = reader.read(); int read = reader.read();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment