Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit f6a0980

Browse files
Merge pull request SORMAS-Foundation#2721 from hzi-braunschweig/2624_sormas-to-sormas-rest-endpoints
[SORMAS2SORMAS] SORMAS-Foundation#2624 SORMAS-Foundation#2625 SORMAS-Foundation#2627 SORMAS-Foundation#2844
2 parents 8e77121 + e500ba3 commit f6a0980

268 files changed

Lines changed: 5275 additions & 1520 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

GUIDE_SORMAS2SORMAS_CERTIFICATE.md

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This guide explains how to:
55
* set up the server address list file
66
* add certificates of other SORMAS instances to the local truststore
77
* add other servers to the local server list
8+
* handling self-signed ssl certificates on test systems
89

910
### Prerequisites
1011

@@ -14,31 +15,40 @@ See [Installing Java](SERVER_SETUP.md#java-11)
1415
### Using the certificate generation script
1516

1617
1. Run ``bash ./generate-cert.sh``
17-
2. If the ``sormas2sormas`` directory is not found, you will be prompted to provide its path.
18-
3. If the ``SORMAS_PROPERTIES`` environment variable is not available, the script will search for the ``sormas.properties``
19-
file in ``/opt/domains/sormas/sormas.properties`` by default. If it is not found there, you will be prompted to provide
20-
the path to the ``sormas.properties`` file.
21-
4. For the generation of the certificate, the following data is needed: a password, a *Common Name* (CN)
22-
and an *Organization* (O). These may be set in environment variables (recommended), or provided
23-
manually as the script executes.
24-
* The password environment variable should be named ``SORMAS_S2S_CERT_PASS``. Please note that the password has to be
25-
at least 6 characters, or you will be prompted for a new one.
26-
* the *Common Name* environment variable should be named ``SORMAS_S2S_CERT_CN``.<br/>
27-
**Important**: for Germany, this value should be the SurvNet Code Site. <br/>
28-
E.g. *2.03.1.01.*
29-
* the *Organization* (O) environment variable should be named ``SORMAS_S2S_CERT_ORG``.<br/>
18+
2. If the ``SORMAS2SORMAS_DIR`` environment variable is not available, the script will search for ``/opt/sormas2sormas`` by default.
19+
If it is not found there, you will be prompted to provide the pat to the *sormas2sormas* directory.
20+
3. If the ``SORMAS_DOMAIN_DIR`` environment variable is not available, the script will search for ``/opt/domains/sormas`` by default.<br>
21+
If it is not found there, you will be prompted to provide the path to the *sormas domain directory*.
22+
>If you don't have a local sormas installation, for example you are using the docker environment,
23+
>you can specify any existing directory and after the script finishes you will find a ``sormas.properties`` file there
24+
>that contains the necessary configuration that must be added to the ``sormas.properties`` file of your installation
25+
4. For the generation of the certificate, the following data is needed:
26+
an identifier of the *Organization*, the name of the *Organization*, the host name of the SORMAS server, the **https** port of the server,
27+
a password for the certificate keystore and a password for the REST user to be used when sharing data through the REST api.
28+
These may be set in environment variables (recommended), or provided manually as the script executes.
29+
30+
* the identifier of the *Organization* environment variable should be named ``SORMAS_ORG_ID``.
31+
This variable is also used as *Common Name* (CN) of the certificate<br/>
32+
**Important**: for Germany, this value should be the SORMAS SurvNet Code Site (e.g. 2.99.1.01 if the regular Code Site was 1.99.1.01). <br/>
33+
* the name of the organization *Organization* (O) environment variable should be named ``SORMAS_ORG_NAME``.<br/>
3034
**Important**: for Germany, this value should be the name of the Health Department (Gesundheitsamt)
3135
to which the SORMAS instance will be assigned. <br/>
32-
E.g. *GA Braunschweig*
36+
E.g. *GA Musterhausen*
37+
* the host name variable should be named ``SORMAS_HOST_NAME``. <br/>
38+
E.g. *sormas.gesundheitsamt-musterhausen.de*
39+
* the https port environment variable should be named ``SORMAS_HTTPS_PORT``. If it is not found, you will be prompted to provide it.
40+
If you press enter without typing a port number the default 443 will be used.
41+
* The password environment variable should be named ``SORMAS_S2S_CERT_PASS``. Please note that the password has to be
42+
at least 6 characters, or you will be prompted for a new one.
43+
* the REST user password environment variable should be named ``SORMAS_S2S_REST_PASSWORD``.
44+
Please note that the password has to be at least 12 characters, or you will be prompted for a new one.
45+
3346
5. After providing the requested data, the certificate files will be generated. <br/>
3447
The generated certificate has a validity of 3 years.
3548
The certificate files will be available in the root SORMAS directory, in the folder ``/sormas2sormas``.
3649
6. A CSV file containing the access data for this instance will also be generated in the folder ``/sormas2sormas``.
37-
It will be named ``server-access-data.csv``.
38-
The file will contain on the first two columns of the first row the Common Name and the Organization, as provided
39-
when creating the certificate. <br/>
40-
**Please fill in on the third column the full URL of the server.** <br/>
41-
You will also have to set up a user for communicating with other SORMAS instances.
50+
It will be named ``{host name}-server-access-data.csv``.
51+
The file will contain the organization identifier, organization name, host name and the REST user password.<br/>
4252
7. The generated ``.p12`` file should not be shared with third parties. <br/>
4353
The generated ``.crt`` file will be verified and shared with other SORMAS instances, from which this instance
4454
will be able to request data. Conversely, in order to enable other SORMAS instances to request data from this
@@ -53,23 +63,42 @@ To enable other SORMAS instances to send and receive data from this instance, th
5363
truststore of this instance. Furthermore, the access data of other instances must be added to the local server
5464
list. To complete this setup, please follow the next steps:
5565
1. Run ``bash ./import-to-truststore.sh``
56-
2. If the ``sormas2sormas`` directory is not found, you will be prompted to provide its path.
57-
3. If the ``SORMAS_PROPERTIES`` environment variable is not available, the script will search for the ``sormas.properties``
58-
file in ``/opt/domains/sormas/sormas.properties`` by default. If it is not found there, you will be prompted to provide
59-
the path to the ``sormas.properties`` file.
66+
2. If the ``SORMAS2SORMAS_DIR`` environment variable is not available, the script will search for ``/opt/sormas2sormas`` by default.
67+
If it is not found there, you will be prompted to provide the path to the *sormas2sormas* directory.
68+
3. If the ``SORMAS_DOMAIN_DIR`` environment variable is not available, the script will search for ``/opt/domains/sormas`` by default.
69+
If it is not found there, you will be prompted to provide the path to the *sormas domain directory*.
70+
>If you don't have a local sormas installation, for example you are using the docker environment,
71+
>you can specify any existing directory and after the script finishes you will find a ``sormas.properties`` file there
72+
>that contains the necessary configuration that must be added to the ``sormas.properties`` file of your installation
73+
6074
4. If ``sormas2sormas.truststore.p12`` is not found in the folder ``/sormas2sormas``, it will be created.
6175
The truststore password may be provided in an environment variable ``SORMAS_S2S_TRUSTSTORE_PASS``.
6276
* If the aforementioned environment variable is not available, the truststore password will be searched in the
6377
``sormas.properties`` file.
6478
* If it is not found there, you will be prompted to provide the truststore password.
6579
* The relevant properties will be automatically set by the script in the ``sormas.properties`` file.
6680
5. If the server address list file ``server-list.csv`` is not found in the folder ``/sormas2sormas``, it will also be created.
67-
6. You will be prompted to provide the file name of the certificate to be imported. This certificate should be located
68-
in the ``/sormas2sormas`` folder. Please provide the name including the extension. E.g ``mycert.crt``
81+
6. You will be prompted to provide the *host name* of the organization that's certificate is being imported.
82+
If the certificate was generated with the `generate-cert.sh` script, the identifier can be found at the beginning of the file.
83+
This certificate should be located in the ``/sormas2sormas`` folder.
6984
7. After providing the requested data, the certificate will be imported to the truststore.
70-
8. You should have also received a CSV file with the server access data. From this file, copy the line corresponding to the
71-
instance you would like to communicate with and add it to the local server address list file. This file is named
72-
``server-list.csv`` and is located in the ``/sormas2sormas`` folder. <br/>
73-
*Note*: You may check that the Common Name and the Organization of the certificate match the ones corresponding to
74-
the server in the CSV file.
75-
9. You may now delete the ``.crt`` file.
85+
8. The content of the ``server-access-data.csv`` provided together with the certificate will be copied to the ``server-list.csv`` file.
86+
9. You may now delete the ``.crt`` and ``server-access-data.csv`` files.
87+
88+
10. *Optional for test systems and other systems with self-signed ssl certificates* <br>
89+
You must import the SSL certificate of the other server into the ``cacerts.jks`` of your sormas domain.
90+
* For getting the SSL certificate you can use ``openssl`` <br>
91+
e.g.
92+
```shell script
93+
openssl s_client -showcerts -servername sormas.gesundheitsamt-musterhausen.de -connect sormas.gesundheitsamt-musterhausen.de:443 </dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > certificate.cer
94+
```
95+
* To import the SSL certificate you can use ``keytool`` <br>
96+
e.g.
97+
```shell script
98+
keytool -importcert -trustcacerts -noprompt -keystore /opt/domains/sormas/config/cacerts.jks -alias sormas_dev -storepass changeit -file certificate.cer
99+
```
100+
Note that the alias can be used only once.
101+
102+
After the certificate is generated and at least one other certificate is imported,
103+
on some pages of the application you will see a new box with a *Share* button and information about sharing.
104+

sormas-api/src/main/java/de/symeda/sormas/api/ConfigFacade.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
*******************************************************************************/
1818
package de.symeda.sormas.api;
1919

20-
import de.symeda.sormas.api.region.GeoLatLon;
21-
2220
import javax.ejb.Remote;
2321

22+
import de.symeda.sormas.api.region.GeoLatLon;
23+
2424
@Remote
2525
public interface ConfigFacade {
2626

@@ -100,9 +100,11 @@ public interface ConfigFacade {
100100

101101
String getPatientDiaryUrl();
102102

103+
String getSormasToSormasUserPassword();
104+
103105
void validateExternalUrls();
104106

105-
Sormas2SormasConfig getSormas2SormasConfig();
107+
SormasToSormasConfig getSormasToSormasConfig();
106108

107109
String getAuthenticationProvider();
108110
}

sormas-api/src/main/java/de/symeda/sormas/api/FacadeProvider.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import de.symeda.sormas.api.sample.AdditionalTestFacade;
6060
import de.symeda.sormas.api.sample.PathogenTestFacade;
6161
import de.symeda.sormas.api.sample.SampleFacade;
62+
import de.symeda.sormas.api.sormastosormas.SormasToSormasFacade;
6263
import de.symeda.sormas.api.symptoms.SymptomsFacade;
6364
import de.symeda.sormas.api.task.TaskFacade;
6465
import de.symeda.sormas.api.therapy.PrescriptionFacade;
@@ -285,6 +286,10 @@ public static CampaignFormDataFacade getCampaignFormDataFacade() {
285286
return get().lookupEjbRemote(CampaignFormDataFacade.class);
286287
}
287288

289+
public static SormasToSormasFacade getSormasToSormasFacade() {
290+
return get().lookupEjbRemote(SormasToSormasFacade.class);
291+
}
292+
288293
public static AreaFacade getAreaFacade() {
289294
return get().lookupEjbRemote(AreaFacade.class);
290295
}

sormas-api/src/main/java/de/symeda/sormas/api/Sormas2SormasConfig.java renamed to sormas-api/src/main/java/de/symeda/sormas/api/SormasToSormasConfig.java

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,34 @@
33
import java.io.Serializable;
44
import java.util.Objects;
55

6-
public class Sormas2SormasConfig implements Serializable, Cloneable {
6+
import javax.enterprise.inject.Alternative;
7+
8+
@Alternative
9+
public class SormasToSormasConfig implements Serializable, Cloneable {
710

811
private static final long serialVersionUID = -7981351672462016280L;
912

10-
private String filePath;
11-
private String keyAlias;
13+
private String path;
14+
private String serverAccessDataFileName;
1215
private String keystoreName;
1316
private String keystorePass;
1417
private String truststoreName;
1518
private String truststorePass;
1619

17-
public String getFilePath() {
18-
return filePath;
20+
public String getPath() {
21+
return path;
1922
}
2023

21-
public void setFilePath(String filePath) {
22-
this.filePath = filePath;
24+
public void setPath(String path) {
25+
this.path = path;
2326
}
2427

25-
public String getKeyAlias() {
26-
return keyAlias;
28+
public String getServerAccessDataFileName() {
29+
return serverAccessDataFileName;
2730
}
2831

29-
public void setKeyAlias(String keyAlias) {
30-
this.keyAlias = keyAlias;
32+
public void setServerAccessDataFileName(String serverAccessDataFileName) {
33+
this.serverAccessDataFileName = serverAccessDataFileName;
3134
}
3235

3336
public String getKeystoreName() {
@@ -68,23 +71,23 @@ public boolean equals(Object o) {
6871
return true;
6972
if (o == null || getClass() != o.getClass())
7073
return false;
71-
Sormas2SormasConfig that = (Sormas2SormasConfig) o;
72-
return Objects.equals(filePath, that.filePath)
73-
&& Objects.equals(keyAlias, that.keyAlias)
74+
SormasToSormasConfig that = (SormasToSormasConfig) o;
75+
return Objects.equals(path, that.path)
76+
&& Objects.equals(serverAccessDataFileName, that.serverAccessDataFileName)
7477
&& Objects.equals(keystorePass, that.keystorePass)
7578
&& Objects.equals(truststoreName, that.truststoreName)
7679
&& Objects.equals(truststorePass, that.truststorePass);
7780
}
7881

7982
@Override
8083
public int hashCode() {
81-
return Objects.hash(filePath, keyAlias, keystorePass, truststoreName, truststorePass);
84+
return Objects.hash(path, serverAccessDataFileName, keystorePass, truststoreName, truststorePass);
8285
}
8386

8487
@Override
85-
public Sormas2SormasConfig clone() {
88+
public SormasToSormasConfig clone() {
8689
try {
87-
return (Sormas2SormasConfig) super.clone();
90+
return (SormasToSormasConfig) super.clone();
8891
} catch (CloneNotSupportedException e) {
8992
throw new RuntimeException("Clone failed", e);
9093
}

sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseDataDto.java

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import de.symeda.sormas.api.Disease;
2626
import de.symeda.sormas.api.ImportIgnore;
27-
import de.symeda.sormas.api.PseudonymizableDto;
2827
import de.symeda.sormas.api.caze.maternalhistory.MaternalHistoryDto;
2928
import de.symeda.sormas.api.caze.porthealthinfo.PortHealthInfoDto;
3029
import de.symeda.sormas.api.clinicalcourse.ClinicalCourseDto;
@@ -42,6 +41,7 @@
4241
import de.symeda.sormas.api.region.CommunityReferenceDto;
4342
import de.symeda.sormas.api.region.DistrictReferenceDto;
4443
import de.symeda.sormas.api.region.RegionReferenceDto;
44+
import de.symeda.sormas.api.sormastosormas.SormasToSormasOriginInfoDto;
4545
import de.symeda.sormas.api.symptoms.SymptomsDto;
4646
import de.symeda.sormas.api.therapy.TherapyDto;
4747
import de.symeda.sormas.api.user.UserReferenceDto;
@@ -56,6 +56,12 @@
5656
import de.symeda.sormas.api.utils.SensitiveData;
5757
import de.symeda.sormas.api.utils.YesNoUnknown;
5858

59+
import de.symeda.sormas.api.utils.pseudonymization.PseudonymizableDto;
60+
import de.symeda.sormas.api.utils.pseudonymization.Pseudonymizer;
61+
import de.symeda.sormas.api.utils.pseudonymization.valuepseudonymizers.LatitudePseudonymizer;
62+
import de.symeda.sormas.api.utils.pseudonymization.valuepseudonymizers.LongitudePseudonymizer;
63+
import java.util.Date;
64+
5965
public class CaseDataDto extends PseudonymizableDto {
6066

6167
private static final long serialVersionUID = 5007131477733638086L;
@@ -232,12 +238,13 @@ public class CaseDataDto extends PseudonymizableDto {
232238
@PersonalData
233239
@SensitiveData
234240
private CommunityReferenceDto community;
235-
@PersonalData
241+
@PersonalData(mandatoryField = true)
242+
@SensitiveData(mandatoryField = true)
236243
private FacilityType facilityType;
237244
@Outbreaks
238245
@Required
239-
@PersonalData
240-
@SensitiveData
246+
@PersonalData(mandatoryField = true)
247+
@SensitiveData(mandatoryField = true)
241248
private FacilityReferenceDto healthFacility;
242249
@Outbreaks
243250
@PersonalData
@@ -330,8 +337,10 @@ public class CaseDataDto extends PseudonymizableDto {
330337
@SensitiveData
331338
private UserReferenceDto caseOfficer;
332339
@SensitiveData
340+
@Pseudonymizer(LatitudePseudonymizer.class)
333341
private Double reportLat;
334342
@SensitiveData
343+
@Pseudonymizer(LongitudePseudonymizer.class)
335344
private Double reportLon;
336345
private Float reportLatLonAccuracy;
337346
private HospitalizationDto hospitalization;
@@ -344,8 +353,8 @@ public class CaseDataDto extends PseudonymizableDto {
344353
@SensitiveData
345354
private PortHealthInfoDto portHealthInfo;
346355
private CaseOrigin caseOrigin;
347-
@PersonalData
348-
@SensitiveData
356+
@PersonalData(mandatoryField = true)
357+
@SensitiveData(mandatoryField = true)
349358
private PointOfEntryReferenceDto pointOfEntry;
350359
@PersonalData
351360
@SensitiveData
@@ -405,6 +414,8 @@ public class CaseDataDto extends PseudonymizableDto {
405414
private String followUpComment;
406415
private Date followUpUntil;
407416
private boolean overwriteFollowUpUntil;
417+
private SormasToSormasOriginInfoDto sormasToSormasOriginInfo;
418+
private boolean ownershipHandedOver;
408419

409420
@HideForCountriesExcept(countries = COUNTRY_CODE_SWITZERLAND)
410421
private Integer caseIdIsm;
@@ -1263,4 +1274,20 @@ public String getEndOfIsolationReasonDetails() {
12631274
public void setEndOfIsolationReasonDetails(String endOfIsolationReasonDetails) {
12641275
this.endOfIsolationReasonDetails = endOfIsolationReasonDetails;
12651276
}
1277+
1278+
public SormasToSormasOriginInfoDto getSormasToSormasOriginInfo() {
1279+
return sormasToSormasOriginInfo;
1280+
}
1281+
1282+
public void setSormasToSormasOriginInfo(SormasToSormasOriginInfoDto sormasToSormasOriginInfo) {
1283+
this.sormasToSormasOriginInfo = sormasToSormasOriginInfo;
1284+
}
1285+
1286+
public boolean isOwnershipHandedOver() {
1287+
return ownershipHandedOver;
1288+
}
1289+
1290+
public void setOwnershipHandedOver(boolean ownershipHandedOver) {
1291+
this.ownershipHandedOver = ownershipHandedOver;
1292+
}
12661293
}

sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseFollowUpDto.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121

2222
import de.symeda.sormas.api.Disease;
2323
import de.symeda.sormas.api.followup.FollowUpDto;
24-
import de.symeda.sormas.api.utils.jurisdiction.WithJurisdiction;
2524

26-
public class CaseFollowUpDto extends FollowUpDto implements WithJurisdiction<CaseJurisdictionDto> {
25+
public class CaseFollowUpDto extends FollowUpDto {
2726

2827
private static final long serialVersionUID = -7782443664670559221L;
2928

sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseIndexDto.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import de.symeda.sormas.api.person.Sex;
3030
import de.symeda.sormas.api.utils.PersonalData;
3131
import de.symeda.sormas.api.utils.SensitiveData;
32-
import de.symeda.sormas.api.utils.jurisdiction.WithJurisdiction;
32+
import de.symeda.sormas.api.utils.pseudonymization.PseudonymizableIndexDto;
3333

34-
public class CaseIndexDto implements WithJurisdiction<CaseJurisdictionDto>, Serializable, Cloneable {
34+
public class CaseIndexDto extends PseudonymizableIndexDto implements Serializable, Cloneable {
3535

3636
private static final long serialVersionUID = -7764607075875188799L;
3737

sormas-api/src/main/java/de/symeda/sormas/api/caze/MapCaseDto.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@ public class MapCaseDto implements Serializable {
4242
private PersonReferenceDto person;
4343
@PersonalData
4444
@SensitiveData
45+
@Pseudonymizer(LatitudePseudonymizer.class)
4546
private Double healthFacilityLat;
4647
@PersonalData
4748
@SensitiveData
49+
@Pseudonymizer(LongitudePseudonymizer.class)
4850
private Double healthFacilityLon;
4951
@SensitiveData
5052
@Pseudonymizer(LatitudePseudonymizer.class)

sormas-api/src/main/java/de/symeda/sormas/api/caze/maternalhistory/MaternalHistoryDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
import java.util.Date;
44

5-
import de.symeda.sormas.api.PseudonymizableDto;
65
import de.symeda.sormas.api.region.CommunityReferenceDto;
76
import de.symeda.sormas.api.region.DistrictReferenceDto;
87
import de.symeda.sormas.api.region.RegionReferenceDto;
98
import de.symeda.sormas.api.utils.DataHelper;
109
import de.symeda.sormas.api.utils.SensitiveData;
1110
import de.symeda.sormas.api.utils.YesNoUnknown;
11+
import de.symeda.sormas.api.utils.pseudonymization.PseudonymizableDto;
1212

1313
public class MaternalHistoryDto extends PseudonymizableDto {
1414

0 commit comments

Comments
 (0)