Skip to content

Commit

Permalink
Merge pull request #90 from DP-3T/develop
Browse files Browse the repository at this point in the history
Release 1.0.12
  • Loading branch information
UBaggeler authored Oct 20, 2020
2 parents 46d9e3d + 766f03d commit bf1ef68
Show file tree
Hide file tree
Showing 20 changed files with 5,022 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

package org.dpppt.switzerland.backend.sdk.config.ws.config;

import io.jsonwebtoken.SignatureAlgorithm;
import java.io.ByteArrayInputStream;
import java.io.Reader;
import java.io.StringReader;
Expand All @@ -20,28 +21,34 @@
import java.security.Security;
import java.security.cert.CertificateFactory;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.util.io.pem.PemObject;
import org.bouncycastle.util.io.pem.PemReader;
import org.dpppt.switzerland.backend.sdk.config.ws.controller.DPPPTConfigController;
import org.dpppt.switzerland.backend.sdk.config.ws.filter.ResponseWrapperFilter;
import org.dpppt.switzerland.backend.sdk.config.ws.interceptor.HeaderInjector;
import org.dpppt.switzerland.backend.sdk.config.ws.model.ConfigResponse;
import org.dpppt.switzerland.backend.sdk.config.ws.model.FaqEntry;
import org.dpppt.switzerland.backend.sdk.config.ws.model.WhatToDoPositiveTestTexts;
import org.dpppt.switzerland.backend.sdk.config.ws.model.WhatToDoPositiveTestTextsCollection;
import org.dpppt.switzerland.backend.sdk.config.ws.poeditor.Messages;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import io.jsonwebtoken.SignatureAlgorithm;

@Configuration
@EnableScheduling
public abstract class WSBaseConfig implements SchedulingConfigurer, WebMvcConfigurer {
Expand Down Expand Up @@ -120,4 +127,106 @@ private PublicKey loadPublicKeyFromString() {
throw new RuntimeException();
}
}

@Bean
public Messages messages(MessageSource messageSource) {
Messages messages = new Messages(messageSource);
loadTexts(messages);
return messages;
}

@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource =
new ReloadableResourceBundleMessageSource();

messageSource.setBasename("classpath:i18n/messages");
messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}

public void loadTexts(Messages messages) {
ConfigResponse.setWhatToDoPositiveTestTexts(
new WhatToDoPositiveTestTextsCollection() {
{
setDe(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("de")));
setFr(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("fr")));
setIt(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("it")));
setEn(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("en")));
setPt(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("pt")));
setEs(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("es")));
setSq(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("sq")));
setBs(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("bs")));
setHr(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("hr")));
setSr(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("sr")));
setRm(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("rm")));
setTr(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("tr")));
setTi(getWhatToDoPositiveTestText(messages, Locale.forLanguageTag("ti")));
}
});
}

private WhatToDoPositiveTestTexts getWhatToDoPositiveTestText(
Messages messages, Locale locale) {
return new WhatToDoPositiveTestTexts() {
{
setEnterCovidcodeBoxSupertitle(
messages.getMessage("inform_detail_box_subtitle", locale));
setEnterCovidcodeBoxTitle(messages.getMessage("inform_detail_box_title", locale));
setEnterCovidcodeBoxText(messages.getMessage("inform_detail_box_text", locale));
setEnterCovidcodeBoxButtonTitle(
messages.getMessage("inform_detail_box_button", locale));

setInfoBox(null); // no infobox needed at the moment

setFaqEntries(
Arrays.asList(
new FaqEntry() {
{
setTitle(
messages.getMessage(
"inform_detail_faq1_title", locale));
setText(
messages.getMessage(
"inform_detail_faq1_text", locale));
setLinkTitle(
messages.getMessage(
"infoline_coronavirus_number", locale));
setLinkUrl(
"tel://"
+ messages.getMessage(
"infoline_coronavirus_number",
locale)
.replace(" ", ""));
setIconAndroid("ic_verified_user");
setIconIos("ic-verified-user");
}
},
new FaqEntry() {
{
setTitle(
messages.getMessage(
"inform_detail_faq2_title", locale));
setText(
messages.getMessage(
"inform_detail_faq2_text", locale));
setIconAndroid("ic_key");
setIconIos("ic-key");
}
},
new FaqEntry() {
{
setTitle(
messages.getMessage(
"inform_detail_faq3_title", locale));
setText(
messages.getMessage(
"inform_detail_faq3_text", locale));
setIconAndroid("ic_person");
setIconIos("ic-user");
}
}));
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@

package org.dpppt.switzerland.backend.sdk.config.ws.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class ConfigResponse {

private boolean forceUpdate = false;
private boolean forceTraceShutdown = false;

private InfoBoxCollection infoBox = null;
private static WhatToDoPositiveTestTextsCollection whatToDoPositiveTestTexts;

private SDKConfig sdkConfig = new SDKConfig();
private GAENSDKConfig iOSGaenSdkConfig = new GAENSDKConfig();
Expand Down Expand Up @@ -45,7 +49,15 @@ public void setInfoBox(InfoBoxCollection infoBox) {
this.infoBox = infoBox;
}

public boolean isForceTraceShutdown() {
public WhatToDoPositiveTestTextsCollection getWhatToDoPositiveTestTexts() {
return whatToDoPositiveTestTexts;
}

public static void setWhatToDoPositiveTestTexts(WhatToDoPositiveTestTextsCollection whatToDoPositiveTestTexts) {
ConfigResponse.whatToDoPositiveTestTexts = whatToDoPositiveTestTexts;
}

public boolean isForceTraceShutdown() {
return forceTraceShutdown;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2020 Ubique Innovation AG <https://www.ubique.ch>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*/

package org.dpppt.switzerland.backend.sdk.config.ws.model;

public class FaqEntry {

private String title;
private String text;
private String iconAndroid;
private String iconIos;

/* optional */
private String linkTitle;
private String linkUrl;

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getText() {
return text;
}

public void setText(String text) {
this.text = text;
}

public String getIconAndroid() {
return iconAndroid;
}

public void setIconAndroid(String iconAndroid) {
this.iconAndroid = iconAndroid;
}

public String getIconIos() {
return iconIos;
}

public void setIconIos(String iconIos) {
this.iconIos = iconIos;
}

public String getLinkTitle() {
return linkTitle;
}

public void setLinkTitle(String linkTitle) {
this.linkTitle = linkTitle;
}

public String getLinkUrl() {
return linkUrl;
}

public void setLinkUrl(String linkUrl) {
this.linkUrl = linkUrl;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (c) 2020 Ubique Innovation AG <https://www.ubique.ch>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* SPDX-License-Identifier: MPL-2.0
*/

package org.dpppt.switzerland.backend.sdk.config.ws.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class WhatToDoPositiveTestTexts {

private String enterCovidcodeBoxSupertitle;
private String enterCovidcodeBoxTitle;
private String enterCovidcodeBoxText;
private String enterCovidcodeBoxButtonTitle;

//dismissible will be ignored by clients
private InfoBox infoBox;

private List<FaqEntry> faqEntries;

public String getEnterCovidcodeBoxSupertitle() {
return enterCovidcodeBoxSupertitle;
}

public void setEnterCovidcodeBoxSupertitle(String enterCovidcodeBoxSupertitle) {
this.enterCovidcodeBoxSupertitle = enterCovidcodeBoxSupertitle;
}

public String getEnterCovidcodeBoxTitle() {
return enterCovidcodeBoxTitle;
}

public void setEnterCovidcodeBoxTitle(String enterCovidcodeBoxTitle) {
this.enterCovidcodeBoxTitle = enterCovidcodeBoxTitle;
}

public String getEnterCovidcodeBoxText() {
return enterCovidcodeBoxText;
}

public void setEnterCovidcodeBoxText(String enterCovidcodeBoxText) {
this.enterCovidcodeBoxText = enterCovidcodeBoxText;
}

public String getEnterCovidcodeBoxButtonTitle() {
return enterCovidcodeBoxButtonTitle;
}

public void setEnterCovidcodeBoxButtonTitle(String enterCovidcodeBoxButtonTitle) {
this.enterCovidcodeBoxButtonTitle = enterCovidcodeBoxButtonTitle;
}

public InfoBox getInfoBox() {
return infoBox;
}

public void setInfoBox(InfoBox infoBox) {
this.infoBox = infoBox;
}

public List<FaqEntry> getFaqEntries() {
return faqEntries;
}

public void setFaqEntries(List<FaqEntry> faqEntries) {
this.faqEntries = faqEntries;
}
}
Loading

0 comments on commit bf1ef68

Please sign in to comment.