Skip to content

Commit

Permalink
removed try-catch blocks
Browse files Browse the repository at this point in the history
Secure api if NNGM feature property is not true
outline V004__site_specific_dml.sql
  • Loading branch information
TasDeniz committed Nov 27, 2020
1 parent 3800b9f commit 566229c
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 137 deletions.
6 changes: 5 additions & 1 deletion src/main/java/de/samply/share/client/rest/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.mchange.rmi.NotAuthorizedException;
import com.sun.jersey.api.NotFoundException;
import de.samply.share.client.control.ApplicationBean;
import de.samply.share.client.feature.ClientFeature;
import de.samply.share.client.model.db.tables.pojos.User;
import de.samply.share.client.util.connector.CTSConnector;
import de.samply.share.client.util.db.UserUtil;
Expand Down Expand Up @@ -33,6 +34,9 @@ public class Api {
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Path("/postcts")
public Response postToCTS(String bundle, @Context HttpHeaders httpHeaders) {
if(!ApplicationBean.getFeatureManager().getFeatureState(ClientFeature.NNGM_CTS).isEnabled()){
return Response.status(403).build();
}
try {
if (!checkUser(httpHeaders.getRequestHeader(AUTHORIZATION).get(0))) {
return Response.status(401).entity("Basic Auth credentials not correct").build();
Expand All @@ -45,7 +49,7 @@ public Response postToCTS(String bundle, @Context HttpHeaders httpHeaders) {
} catch (NotAuthorizedException e) {
return Response.status(401).entity(e.getMessage()).build();
} catch (NotFoundException e) {
return Response.status(404).entity(e.getMessage()).build();
return Response.status(404).entity(e.getResponse().getEntity().toString()).build();
} catch (IOException e) {
return Response.status(500).entity(e.getMessage()).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,7 @@ public Response postPseudonmToCTS(String bundleString, String mediaType) throws
// Make a call to the PL, and replace patient identifying information in the
// bundle with a pseudonym.
Bundle pseudonymBundle = null;
try {
pseudonymBundle = pseudonymiseBundle(bundleString, mediaType);
} catch (ConfigurationException e) {
throw new ConfigurationException(e);
} catch (DataFormatException e) {
throw new DataFormatException(e);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(e);
} catch (NotFoundException e) {
throw new NotFoundException(e.getMessage());
} catch (IOException e) {
throw new IOException(e);
} catch (NotAuthorizedException e) {
throw new NotAuthorizedException(e.getMessage());
}
pseudonymBundle = pseudonymiseBundle(bundleString, mediaType);
// Serialize into a JSON String
String pseudonymBundleJson = fhirResource.convertBundleToJson(pseudonymBundle);

Expand Down Expand Up @@ -151,19 +137,7 @@ private Bundle pseudonymiseBundle(String bundleString, String mediaType) throws
Bundle bundle = fhirResource.convertToBundleResource(bundleString, mediaType);
MainzellisteConnector mainzellisteConnector = ApplicationBean.getMainzellisteConnector();
Bundle pseudonymizedBundle = null;
try {
pseudonymizedBundle = mainzellisteConnector.getPatientPseudonym(bundle);
} catch (ConfigurationException e) {
throw new ConfigurationException(e);
} catch (DataFormatException e) {
throw new DataFormatException(e);
} catch (NotFoundException e) {
throw new NotFoundException(e.getMessage());
} catch (NotAuthorizedException e) {
throw new NotAuthorizedException(e.getMessage());
} catch (IOException e) {
throw new IOException(e);
}
pseudonymizedBundle = mainzellisteConnector.getPatientPseudonym(bundle);
return pseudonymizedBundle;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,7 @@ public Bundle getPatientPseudonym(Bundle bundle) throws IllegalArgumentException
}
if (patient != null && coverage != null) {
JSONObject jsonIdatObject = createJSONPatient(patient, coverage);
try {
encryptedID = getPseudonymFromMainzelliste(jsonIdatObject);
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(e);
} catch (NotFoundException e) {
throw new NotFoundException(e.getMessage());
} catch (IOException e) {
throw new IOException(e);
} catch (NotAuthorizedException e) {
throw new NotAuthorizedException(e.getMessage());
}

encryptedID = getPseudonymFromMainzelliste(jsonIdatObject);
patientPseudonym = addPseudonymToPatient(patientPseudonym, encryptedID);
bundle.getEntry().get(patientEntryIndex).setResource(patientPseudonym);
bundle.getEntry().get(coverageEntryIndex).setResource(coveragePseudonym);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,60 +1,54 @@
WITH
teilerIds AS (SELECT
'TeilerB' AS Berlin,
'ttlrb1' AS BerlinTest,
'TeilerDD' AS Dresden,
'ttlrdd1' AS DresdenTest,
'TeilerE' AS Essen,
'ttlre1' AS EssenTest,
'TeilerF' AS Frankfurt,
'ttlef1' AS FrankfurtTest,
'TeilerFR' AS Freiburg,
'ttlrfr1' AS FreiburgTest,
'TeilerHD' AS Heidelberg,
'ttlrhd1' AS HeidelbergTest,
'TeilerMZ' AS Mainz,
'ttlrmz1' AS MainzTest,
'TeilerML' AS MuenchenLMU,
'ttlrmu1' AS MuenchenLMUTest,
'TeilerMT' AS MuenchenTUM,
'ttlrmu2' AS MuenchenTUMTest,
'TeilerTÜ' AS Tuebingen,
'ttlrtu1' AS TuebingenTest,
'ttlkairos' AS Kairos,
'ttlrhd3' AS Teststandort),

instanceIds AS (SELECT
'berlin' AS Berlin,
'berlin' AS BerlinTest,
'dresden' AS Dresden,
'dresden' AS DresdenTest,
'essen' AS Essen,
'essen' AS EssenTest,
'frankfurt' AS Frankfurt,
'frankfurt' AS FrankfurtTest,
'freiburg' AS Freiburg,
'freiburg' AS FreiburgTest,
'heidelberg' AS Heidelberg,
'heidelberg' AS HeidelbergTest,
'mainz' AS Mainz,
'mainz' AS MainzTest,
'lmu' AS MuenchenLMU,
'lmu' AS MuenchenLMUTest,
'tum' AS MuenchenTUM,
'tum' AS MuenchenTUMTest,
'tübingen' AS Tuebingen,
'teststandort' AS Teststandort,
'kairos' AS Kairos,
'tübingen' AS TuebingenTest)

UPDATE samply.configuration
SET setting = ('/dktk/sites/' ||
(SELECT instanceIds.INSTANCEIDPLACEHOLDER
FROM instanceIds)::TEXT ||
'/teiler/' ||
(SELECT teilerIds.INSTANCEIDPLACEHOLDER
FROM teilerIds)::TEXT ||
'/')
WHERE name = 'CENTRAL_MDS_DATABASE_PATH';

UPDATE samply.configuration SET setting = 'INSTANCEIDPLACEHOLDER' where name = 'ID_MANAGER_INSTANCE_ID';
-- WITH
-- teilerIds AS (SELECT
-- 'TeilerB' AS Berlin,
-- 'ttlrb1' AS BerlinTest,
-- 'TeilerDD' AS Dresden,
-- 'ttlrdd1' AS DresdenTest,
-- 'TeilerE' AS Essen,
-- 'ttlre1' AS EssenTest,
-- 'TeilerF' AS Frankfurt,
-- 'ttlef1' AS FrankfurtTest,
-- 'TeilerFR' AS Freiburg,
-- 'ttlrfr1' AS FreiburgTest,
-- 'TeilerHD' AS Heidelberg,
-- 'ttlrhd1' AS HeidelbergTest,
-- 'TeilerMZ' AS Mainz,
-- 'ttlrmz1' AS MainzTest,
-- 'TeilerML' AS MuenchenLMU,
-- 'ttlrmu1' AS MuenchenLMUTest,
-- 'TeilerMT' AS MuenchenTUM,
-- 'ttlrmu2' AS MuenchenTUMTest,
-- 'TeilerTÜ' AS Tuebingen,
-- 'ttlrtu1' AS TuebingenTest),
-- instanceIds AS (SELECT
-- 'berlin' AS Berlin,
-- 'berlin' AS BerlinTest,
-- 'dresden' AS Dresden,
-- 'dresden' AS DresdenTest,
-- 'essen' AS Essen,
-- 'essen' AS EssenTest,
-- 'frankfurt' AS Frankfurt,
-- 'frankfurt' AS FrankfurtTest,
-- 'freiburg' AS Freiburg,
-- 'freiburg' AS FreiburgTest,
-- 'heidelberg' AS Heidelberg,
-- 'heidelberg' AS HeidelbergTest,
-- 'mainz' AS Mainz,
-- 'mainz' AS MainzTest,
-- 'lmu' AS MuenchenLMU,
-- 'lmu' AS MuenchenLMUTest,
-- 'tum' AS MuenchenTUM,
-- 'tum' AS MuenchenTUMTest,
-- 'tübingen' AS Tuebingen,
-- 'tübingen' AS TuebingenTest)
-- UPDATE samply.configuration
-- SET setting = ('/dktk/sites/' ||
-- (SELECT instanceIds.INSTANCEIDPLACEHOLDER
-- FROM instanceIds)::TEXT ||
-- '/teiler/' ||
-- (SELECT teilerIds.INSTANCEIDPLACEHOLDER
-- FROM teilerIds)::TEXT ||
-- '/')c
-- WHERE name = 'CENTRAL_MDS_DATABASE_PATH';
--
-- UPDATE samply.configuration SET setting = 'INSTANCEIDPLACEHOLDER' where name = 'ID_MANAGER_INSTANCE_ID';

0 comments on commit 566229c

Please sign in to comment.