From 75cedbd27c8023d5c9cba3804f242f6846aee72d Mon Sep 17 00:00:00 2001 From: saravahdatipour Date: Tue, 10 Dec 2024 17:11:50 +0100 Subject: [PATCH] changes to have the email form in the docker image --- Dockerfile | 4 +- .../email/common/BaseConfiguration.java | 72 +------------ src/main/resources/assets/css/style.css | 97 ++++++++++++++++++ .../resources/assets/img/button-primary.svg | 12 +++ src/main/resources/assets/img/yivi-banner.png | Bin 0 -> 4434 bytes src/main/resources/email-en.html | 95 ++++++++++++++--- src/main/resources/email-nl.html | 93 ++++++++++++++--- 7 files changed, 274 insertions(+), 99 deletions(-) create mode 100644 src/main/resources/assets/css/style.css create mode 100644 src/main/resources/assets/img/button-primary.svg create mode 100644 src/main/resources/assets/img/yivi-banner.png diff --git a/Dockerfile b/Dockerfile index 05e6f48..6e42007 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,13 +27,11 @@ COPY --from=webappbuild /www/ /usr/local/tomee/webapps/ROOT/ # Copy the war file to the webapps directory COPY --from=javabuild /app/build/libs/irma_email_issuer.war /usr/local/tomee/webapps/ -COPY ./src/main/resources/email-en.html /email-templates/email-en.html -COPY ./src/main/resources/email-nl.html /email-templates/email-nl.html + RUN mkdir /usr/local/keys ENV IRMA_CONF="/config/" -ENV EMAIL_TEMPLATE_DIR="/email-templates/" EXPOSE 8080 # Copy the config file to the webapp. This is done at runtime so that the config file can be mounted as a volume. diff --git a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java index fa38fb2..c91c1e6 100644 --- a/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java +++ b/src/main/java/foundation/privacybydesign/email/common/BaseConfiguration.java @@ -20,31 +20,26 @@ import java.security.spec.X509EncodedKeySpec; import java.util.ArrayList; import java.util.HashMap; -import java.nio.file.Path; public class BaseConfiguration { // Override these in a static {} block public static Class> clazz; public static Logger logger = LoggerFactory.getLogger(BaseConfiguration.class); - public static String configFileName = "config.json"; + public static String filename = "config.json"; public static String environmentVarPrefix = "IRMA_CONF_"; public static String confDirEnvironmentVarName = "IRMA_CONF"; - public static String emailTemplateDirVarName = "EMAIL_TEMPLATE_DIR"; - public static String emailTemplateDir; public static String confDirName; - public static String templatefDirName; public static boolean printOnLoad = false; public static boolean testing = false; // Return this from a static getInstance() public static BaseConfiguration instance; private static URI confPath; - private static URI templatePath; public static void load() { try { - String json = new String(getResource(configFileName)); + String json = new String(getResource(filename)); instance = GsonUtil.getGson().fromJson(json, clazz); logger.info("Using configuration directory: " + BaseConfiguration.getConfigurationDirectory().toString()); } catch (IOException|JsonSyntaxException e) { @@ -73,32 +68,6 @@ public static byte[] getResource(String filename) throws IOException { return convertStreamToByteArray(getResourceStream(filename), 2048); } - public static FileInputStream getEmailTemplateStream(String filename) throws IOException { - validateFilename(filename); - Path resolvedPath = resolvePath(getTemplateDirectory(), filename); - logger.info("trying to load: " + resolvedPath.toString()); - return new FileInputStream(resolvedPath.toFile()); - } - - private static void validateFilename(String filename) { - if (filename == null || filename.isEmpty() || filename.contains("..")) { - throw new IllegalArgumentException("Invalid filename: " + filename); - } - // Optional: Add further filename validation, such as allowed extensions - } - - private static Path resolvePath(URI baseDirectory, String filename) { - Path resolvedPath = new File(baseDirectory).toPath().resolve(filename).normalize(); - if (!resolvedPath.startsWith(new File(baseDirectory).toPath())) { - throw new SecurityException("Path traversal attempt detected for file: " + filename); - } - return resolvedPath; - } - - public static byte[] getEmailTemplate(String filename) throws IOException { - return convertStreamToByteArray(getEmailTemplateStream(filename), 2048); - } - public static byte[] convertStreamToByteArray(InputStream stream, int size) throws IOException { byte[] buffer = new byte[size]; ByteArrayOutputStream os = new ByteArrayOutputStream(); @@ -242,45 +211,12 @@ public static URI getEnvironmentVariableConfDir() throws URISyntaxException { return pathToURI(envDir, true); } - public static URI getEnvironmentVariableTemplateDir() throws URISyntaxException { - String envDir = System.getenv(emailTemplateDirVarName); - if (envDir == null || envDir.length() == 0) - return null; - return pathToURI(envDir, true); - } - - public static URI getTemplateDirectory() throws IllegalStateException, IllegalArgumentException { - if (templatePath != null) - return templatePath; - try { - URI envCandidate = getEnvironmentVariableTemplateDir(); - if (envCandidate != null) { - if (isEmailTemplateDirectory(envCandidate)) { - logger.info("Taking template directory specified by environment variable " + emailTemplateDirVarName); - templatePath = envCandidate; - return templatePath; - } else { - // If the user specified an incorrect path (s)he will want to know, so bail out here - throw new IllegalArgumentException("Specified path in " + emailTemplateDirVarName - + " is not a valid configuration directory"); - } - } - throw new IllegalStateException("No valid template directory found"); - } catch (URISyntaxException e) { - throw new IllegalArgumentException(e); - } - } - /** * Returns true if the specified path is a valid configuration directory. A directory * is considered a valid configuration directory if it contains a file called $filename. */ public static boolean isConfDirectory(URI candidate) { - return candidate != null && new File(candidate.resolve(configFileName)).isFile(); - } - - public static boolean isEmailTemplateDirectory(URI candidate) { - return candidate != null && new File(candidate.resolve("email-en.html")).isFile(); + return candidate != null && new File(candidate.resolve(filename)).isFile(); } /** @@ -292,7 +228,7 @@ public static URI GetJavaResourcesDirectory() throws URISyntaxException { // seems to be to ask for an existing file or directory within the resources. That is, // BaseConfiguration.class.getClassLoader().getResource("/") or variants thereof // give an incorrect path. - String testfile = BaseConfiguration.testing ? "config.test.json" : configFileName; + String testfile = BaseConfiguration.testing ? "config.test.json" : filename; URL url = BaseConfiguration.class.getClassLoader().getResource(testfile); if (url != null) // Construct an URI of the parent path return pathToURI(new File(url.getPath()).getParent(), true); diff --git a/src/main/resources/assets/css/style.css b/src/main/resources/assets/css/style.css new file mode 100644 index 0000000..07a81df --- /dev/null +++ b/src/main/resources/assets/css/style.css @@ -0,0 +1,97 @@ +body { + margin: 0; + padding: 0; + min-height: 100%; + width: 100%; +} +.email-body { + background-color: #ffffff; + color: #b9113d; + font-family: Optima, Candara, "Noto Sans", source-sans-pro, sans-serif; + font-size: 16px; + font-weight: 400; + letter-spacing: 0.15008px; + line-height: 1.5; + padding: 32px 0; +} +.email-table { + margin: 0 auto; + max-width: 600px; + background-color: #ffffff; + border-radius: 0; +} +.email-header { + padding: 16px 24px; +} +.email-banner { + outline: none; + border: none; + text-decoration: none; + vertical-align: top; + display: inline-block; + max-width: 100%; +} +.email-title { + font-weight: bold; + margin: 0; + font-size: 24px; + padding: 16px 24px; +} +.email-text { + color: #a3244a; + font-size: 18px; + font-family: Optima, Candara, "Noto Sans", source-sans-pro, sans-serif; + font-weight: normal; + text-align: left; + padding: 16px 24px; +} +.email-button-container { + background-color: #ffffff; + text-align: center; + padding: 16px 24px; +} +.email-button { + color: #ffffff; + font-size: 16px; + font-family: Optima, Candara, "Noto Sans", source-sans-pro, sans-serif; + font-weight: bold; + background-color: #f4f1f1; + border-radius: 4px; + display: block; + padding: 16px 32px; + text-decoration: none; + background: #a3244a url('../img/button-primary.svg') no-repeat right; +} +.email-footer-text { + color: #a3244a; + font-size: 18px; + font-family: Optima, Candara, "Noto Sans", source-sans-pro, sans-serif; + font-weight: normal; + padding: 16px 24px; +} +.email-divider hr { + width: 100%; + border: none; + border-top: 3px solid #8b173a; + margin: 0; +} +.email-footer { + color: #a3244a; + font-size: 16px; + font-family: Optima, Candara, "Noto Sans", source-sans-pro, sans-serif; + font-weight: normal; + padding: 16px 24px; + display: flex; + flex-direction: column; + gap: 8px; +} +.email-footer p { + display: flex; + align-items: center; + gap: 8px; + margin: 0; +} +.email-footer .icon { + display: flex; + align-items: center; +} \ No newline at end of file diff --git a/src/main/resources/assets/img/button-primary.svg b/src/main/resources/assets/img/button-primary.svg new file mode 100644 index 0000000..b1a8d57 --- /dev/null +++ b/src/main/resources/assets/img/button-primary.svg @@ -0,0 +1,12 @@ + + + + + + diff --git a/src/main/resources/assets/img/yivi-banner.png b/src/main/resources/assets/img/yivi-banner.png new file mode 100644 index 0000000000000000000000000000000000000000..bccc3e12cc21d060e21aa0b7e554d63f977363db GIT binary patch literal 4434 zcmXX~c{J2-)E|wlku6_qvZonTW6!>1)G#!LQ7Ajfu8<6cOqlHZ5@wjln(b#N+ccJ` z>}v?U60&9~(h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{$zDo^ru6p!g;&^NVzL2>jihs0t@0q(u zy@?jp=XT)HUof;>w8es|l7Rs*RO*=dRo{aIZ#b;Ihm8$>;C7(is_nekW|{H1CeeE_wiqSY1;pJ!sCuL3rrliWIPjuUL?HstG%JvBJX=ZMR zcsGq16Mx76+-87qZx^S&9RYQala(VKd5LZZuANfGeE4F$FmFzVr_TL%asuzjf`qP+l9Tl(c9177$RBcO48=q(!x()KYT7TI|m{>Idc@0*m? z9Pe|njNj4Mh>4QVxL^^?$yn}n#Z2fZFZZb+<3-UbnI;Vmz^HHaCV{ab`$-wH)058`MKJZ|`}WO-cSkqak}2-+D&XF8 zKtxM#IbM}yxyT>@v(ke0^XU#1UKaAQFT1YN7QgK3qJ4WCtKtPHU#kl8-rfz&o zkoh?f?x<``iuS?O9T*f!nGn=nIokq)==OY+H=lG6bSE|3zk(p+bq9{@Igr2ycWajE z|L6yM;`f!E$K}EbRBtO8`PUNjke!v?k~PSl&n=3`=tB4;ob*StshSl;b~A~ddTCG2Qx6O)f-Q_#tix-&gp6Y0Vk^=h4dYAKyrSXO0 z&AOA}j`!AD0?Ux32YxqR_r_gv!@#E`>7t?(2X2ZT!;#cc7D64p)}-%$z7L#sx73D* zvb%?3$H}@20mg^?cA2|dnLkC!DeR6Y$cIIdrqE2cSgk<8QL_|%w@Nbx`3gfl0n^wd zRXxt?F~)uTLZtbL^58ccu_9Wl-vkD)ofe - - - Add e-mail address to Yivi app - - - - -

Click the link to add the e-mail address to your Yivi app.

-

- Add e-mail address to your Yivi app -

- - - + + + + + + + \ No newline at end of file diff --git a/src/main/resources/email-nl.html b/src/main/resources/email-nl.html index 7ac157f..b757704 100644 --- a/src/main/resources/email-nl.html +++ b/src/main/resources/email-nl.html @@ -1,16 +1,81 @@ - - - Voeg e-mailadres toe aan Yivi-app - - - - -

Klik op de link om het e-mailadres toe te voegen aan je Yivi-app.

-

- Voeg e-mailadres toe aan je Yivi-app -

- - - + + + + + + + \ No newline at end of file