Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6875 s2s exclude fields when sharing #6937

Merged
merged 9 commits into from
Oct 13, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto;
import de.symeda.sormas.api.person.PersonDto;
import de.symeda.sormas.api.person.PersonReferenceDto;
import de.symeda.sormas.api.sormastosormas.S2SIgnoreProperty;
import de.symeda.sormas.api.sormastosormas.SormasToSormasConfig;
import de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto;
import de.symeda.sormas.api.symptoms.SymptomsDto;
import de.symeda.sormas.api.therapy.TherapyDto;
Expand Down Expand Up @@ -389,16 +391,20 @@ public class CaseDataDto extends PseudonymizableDto implements SormasToSormasEnt
@SensitiveData
@Size(max = COLUMN_LENGTH_DEFAULT, message = Validations.textTooLong)
private String pointOfEntryDetails;
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_ADDITIONAL_DETAILS)
@SensitiveData
@Size(max = COLUMN_LENGTH_DEFAULT, message = Validations.textTooLong)
private String additionalDetails;
@HideForCountriesExcept(countries = {
COUNTRY_CODE_GERMANY,
COUNTRY_CODE_SWITZERLAND })
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_EXTERNAL_ID)
@Size(max = COLUMN_LENGTH_DEFAULT, message = Validations.textTooLong)
private String externalID;
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_EXTERNAL_TOKEN)
@Size(max = COLUMN_LENGTH_DEFAULT, message = Validations.textTooLong)
private String externalToken;
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_INTERNAL_TOKEN)
@Size(max = COLUMN_LENGTH_TEXT, message = Validations.textTooLong)
private String internalToken;
private boolean sharedToCountry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import de.symeda.sormas.api.infrastructure.district.DistrictReferenceDto;
import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto;
import de.symeda.sormas.api.person.PersonReferenceDto;
import de.symeda.sormas.api.sormastosormas.S2SIgnoreProperty;
import de.symeda.sormas.api.sormastosormas.SormasToSormasConfig;
import de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto;
import de.symeda.sormas.api.user.UserReferenceDto;
import de.symeda.sormas.api.utils.DataHelper;
Expand Down Expand Up @@ -209,10 +211,13 @@ public class ContactDto extends PseudonymizableDto implements SormasToSormasEnti
@HideForCountriesExcept(countries = {
COUNTRY_CODE_GERMANY,
COUNTRY_CODE_SWITZERLAND })
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_EXTERNAL_ID)
@Size(max = COLUMN_LENGTH_DEFAULT, message = Validations.textTooLong)
private String externalID;
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_EXTERNAL_TOKEN)
@Size(max = COLUMN_LENGTH_DEFAULT, message = Validations.textTooLong)
private String externalToken;
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_INTERNAL_TOKEN)
@Size(max = COLUMN_LENGTH_TEXT, message = Validations.textTooLong)
private String internalToken;

Expand Down Expand Up @@ -283,6 +288,7 @@ public class ContactDto extends PseudonymizableDto implements SormasToSormasEnti
COUNTRY_CODE_SWITZERLAND })
private Date quarantineOfficialOrderSentDate;
@SensitiveData
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_ADDITIONAL_DETAILS)
@Size(max = COLUMN_LENGTH_BIG, message = Validations.textTooLong)
private String additionalDetails;
private EpiDataDto epiData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import de.symeda.sormas.api.importexport.format.ImportExportFormat;
import de.symeda.sormas.api.importexport.format.ImportFormat;
import de.symeda.sormas.api.location.LocationDto;
import de.symeda.sormas.api.sormastosormas.S2SIgnoreProperty;
import de.symeda.sormas.api.sormastosormas.SormasToSormasConfig;
import de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto;
import de.symeda.sormas.api.user.UserReferenceDto;
import de.symeda.sormas.api.utils.DataHelper;
Expand Down Expand Up @@ -120,8 +122,10 @@ public class EventDto extends PseudonymizableDto implements SormasToSormasEntity
private Date eventInvestigationStartDate;
private Date eventInvestigationEndDate;
private EventManagementStatus eventManagementStatus;
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_EXTERNAL_ID)
@Size(max = COLUMN_LENGTH_DEFAULT, message = Validations.textTooLong)
private String externalId;
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_EXTERNAL_TOKEN)
@Size(max = COLUMN_LENGTH_DEFAULT, message = Validations.textTooLong)
private String externalToken;
@Size(max = COLUMN_LENGTH_DEFAULT, message = Validations.textTooLong)
Expand Down Expand Up @@ -211,6 +215,7 @@ public class EventDto extends PseudonymizableDto implements SormasToSormasEntity
private boolean ownershipHandedOver;

@HideForCountriesExcept
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_INTERNAL_TOKEN)
@Size(max = COLUMN_LENGTH_TEXT, message = Validations.textTooLong)
private String internalToken;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import de.symeda.sormas.api.infrastructure.facility.FacilityType;
import de.symeda.sormas.api.infrastructure.region.RegionReferenceDto;
import de.symeda.sormas.api.location.LocationDto;
import de.symeda.sormas.api.sormastosormas.S2SIgnoreProperty;
import de.symeda.sormas.api.sormastosormas.SormasToSormasConfig;
import de.symeda.sormas.api.utils.DataHelper;
import de.symeda.sormas.api.utils.Diseases;
import de.symeda.sormas.api.utils.EmbeddedPersonalData;
Expand Down Expand Up @@ -320,11 +322,14 @@ public class PersonDto extends PseudonymizableDto {
private SymptomJournalStatus symptomJournalStatus;
@SensitiveData
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_GERMANY)
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_EXTERNAL_ID)
@Size(max = COLUMN_LENGTH_DEFAULT, message = Validations.textTooLong)
private String externalId;
@HideForCountriesExcept(countries = CountryHelper.COUNTRY_CODE_GERMANY)
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_EXTERNAL_TOKEN)
@Size(max = COLUMN_LENGTH_DEFAULT, message = Validations.textTooLong)
private String externalToken;
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_INTERNAL_TOKEN)
@Size(max = COLUMN_LENGTH_TEXT, message = Validations.textTooLong)
private String internalToken;

Expand All @@ -335,6 +340,7 @@ public class PersonDto extends PseudonymizableDto {
@SensitiveData
private CountryReferenceDto citizenship;
@SensitiveData
@S2SIgnoreProperty(configProperty = SormasToSormasConfig.SORMAS2SORMAS_IGNORE_ADDITIONAL_DETAILS)
@Size(max = COLUMN_LENGTH_TEXT, message = Validations.textTooLong)
private String additionalDetails;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* SORMAS® - Surveillance Outbreak Response Management & Analysis System
* Copyright © 2016-2021 Helmholtz-Zentrum für Infektionsforschung GmbH (HZI)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package de.symeda.sormas.api.sormastosormas;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* @author Alex Vidrean
* @since 07-Oct-21
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface S2SIgnoreProperty {

/**
* Property from sormas.properties file populated trough {@link de.symeda.sormas.api.ConfigFacade}
*/
String configProperty();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.symeda.sormas.api.sormastosormas;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class SormasToSormasConfig implements Serializable {
Expand All @@ -12,14 +14,25 @@ public class SormasToSormasConfig implements Serializable {
// resort in the REST client, as it needs to be shared between REST client and sormas-rest.
public static final String SENDER_SERVER_ID = "senderServerId";

public static final String SORMAS2SORMAS_IGNORE_ADDITIONAL_DETAILS = "sormas2sormas.ignoreProperty.additionalDetails";
public static final String SORMAS2SORMAS_IGNORE_EXTERNAL_ID = "sormas2sormas.ignoreProperty.externalId";
public static final String SORMAS2SORMAS_IGNORE_EXTERNAL_TOKEN = "sormas2sormas.ignoreProperty.externalToken";
public static final String SORMAS2SORMAS_IGNORE_INTERNAL_TOKEN = "sormas2sormas.ignoreProperty.internalToken";

private String id;
private String path;
private String keystoreName;
private String keystorePass;
private String rootCaAlias;
private String truststoreName;
private String truststorePass;
private boolean retainCaseExternalToken;
private Map<String, Boolean> ignoreProperties = new HashMap<>();
{
this.ignoreProperties.put(SORMAS2SORMAS_IGNORE_ADDITIONAL_DETAILS, true);
this.ignoreProperties.put(SORMAS2SORMAS_IGNORE_EXTERNAL_ID, true);
this.ignoreProperties.put(SORMAS2SORMAS_IGNORE_EXTERNAL_TOKEN, true);
this.ignoreProperties.put(SORMAS2SORMAS_IGNORE_INTERNAL_TOKEN, true);
}

private String oidcServer;
private String oidcRealm;
Expand Down Expand Up @@ -76,12 +89,12 @@ public void setTruststorePass(String truststorePass) {
this.truststorePass = truststorePass;
}

public boolean getRetainCaseExternalToken() {
return retainCaseExternalToken;
public Map<String, Boolean> getIgnoreProperties() {
return ignoreProperties;
}

public void setRetainCaseExternalToken(boolean retainCaseExternalToken) {
this.retainCaseExternalToken = retainCaseExternalToken;
public void setIgnoreProperties(Map<String, Boolean> ignoreProperties) {
this.ignoreProperties = ignoreProperties;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import javax.annotation.Resource;
import javax.ejb.LocalBean;
Expand Down Expand Up @@ -138,14 +140,14 @@ public class ConfigFacadeEjb implements ConfigFacade {
public static final String SORMAS2SORMAS_TRUSTSTORE_NAME = "sormas2sormas.truststoreName";
public static final String SORMAS2SORMAS_TRUSTSTORE_PASS = "sormas2sormas.truststorePass";

private static final String SORMAS2SORMAS_IGNORE_PROPERTY_PREFIX = "sormas2sormas.ignoreProperty.";

private static final String SORMAS2SORMAS_OIDC_REALM = "sormas2sormas.oidc.realm";
private static final String SORMAS2SORMAS_OIDC_CLIENT_ID = "sormas2sormas.oidc.clientId";
private static final String SORMAS2SORMAS_OIDC_CLIENT_SECRET = "sormas2sormas.oidc.clientSecret";

private static final String SORMAS2SORMAS_ETCD_KEY_PREFIX = "sormas2sormas.etcd.keyPrefix";

private static final String SORMAS2SORMAS_RETAIN_CASE_EXTERNAL_TOKEN = "sormas2sormas.retainCaseExternalToken";

private static final String EXTERNAL_SURVEILLANCE_TOOL_GATEWAY_URL = "survnet.url";

private static final String DASHBOARD_MAP_MARKER_LIMIT = "dashboardMapMarkerLimit";
Expand Down Expand Up @@ -516,16 +518,23 @@ public SormasToSormasConfig getS2SConfig() {
config.setTruststoreName(getProperty(SORMAS2SORMAS_TRUSTSTORE_NAME, null));
config.setTruststorePass(getProperty(SORMAS2SORMAS_TRUSTSTORE_PASS, null));
config.setRootCaAlias(getProperty(SORMAS2SORMAS_ROOT_CA_ALIAS, null));
config.setRetainCaseExternalToken(getBoolean(SORMAS2SORMAS_RETAIN_CASE_EXTERNAL_TOKEN, true));
config.setId(getProperty(SORMAS2SORMAS_ID, null));
config.setOidcServer(getProperty(CENTRAL_OIDC_URL, null));
config.setOidcRealm(getProperty(SORMAS2SORMAS_OIDC_REALM, null));
config.setOidcClientId(getProperty(SORMAS2SORMAS_OIDC_CLIENT_ID, null));
config.setOidcClientSecret(getProperty(SORMAS2SORMAS_OIDC_CLIENT_SECRET, null));
config.setKeyPrefix(getProperty(SORMAS2SORMAS_ETCD_KEY_PREFIX, null));
config.getIgnoreProperties().putAll(getS2SIgnoreProperties());
return config;
}

private Map<String, Boolean> getS2SIgnoreProperties() {
return props.stringPropertyNames().stream()
.filter(property -> property.startsWith(SORMAS2SORMAS_IGNORE_PROPERTY_PREFIX))
.collect(Collectors.toMap(property -> property, property -> getBoolean(property, true)));

}

@Override
public String getExternalSurveillanceToolGatewayUrl() {
return getProperty(EXTERNAL_SURVEILLANCE_TOOL_GATEWAY_URL, null);
Expand Down
Loading