From f8dd693c754f308e0f7071086f8fbfa5b872c11d Mon Sep 17 00:00:00 2001 From: bergmann-dierk <84856774+bergmann-dierk@users.noreply.github.com> Date: Thu, 28 Oct 2021 12:11:57 +0200 Subject: [PATCH] introduced bsnr (Betriebsstaettennummer) for new PoCs (#205) --- .../coronawarn/quicktest/config/QuickTestConfig.java | 1 + .../model/keycloak/KeycloakGroupDetails.java | 3 +++ .../quicktest/service/KeycloakService.java | 12 +++++++++--- src/main/resources/application.yml | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/app/coronawarn/quicktest/config/QuickTestConfig.java b/src/main/java/app/coronawarn/quicktest/config/QuickTestConfig.java index af666ee3..932a38ca 100644 --- a/src/main/java/app/coronawarn/quicktest/config/QuickTestConfig.java +++ b/src/main/java/app/coronawarn/quicktest/config/QuickTestConfig.java @@ -35,6 +35,7 @@ public class QuickTestConfig { private String pointOfCareIdName; private String tenantIdKey; private String groupKey; + private String bsnrKey; private String tenantPointOfCareIdKey; private String pointOfCareInformationName; private String pointOfCareInformationDelimiter; diff --git a/src/main/java/app/coronawarn/quicktest/model/keycloak/KeycloakGroupDetails.java b/src/main/java/app/coronawarn/quicktest/model/keycloak/KeycloakGroupDetails.java index 450025eb..15a11c67 100644 --- a/src/main/java/app/coronawarn/quicktest/model/keycloak/KeycloakGroupDetails.java +++ b/src/main/java/app/coronawarn/quicktest/model/keycloak/KeycloakGroupDetails.java @@ -55,4 +55,7 @@ public class KeycloakGroupDetails { private Boolean appointmentRequired; + // Optional Betriebsstaettennummer of a poc + @Size(min = 9, max = 9) + private String bsnr; } diff --git a/src/main/java/app/coronawarn/quicktest/service/KeycloakService.java b/src/main/java/app/coronawarn/quicktest/service/KeycloakService.java index 1dc501d2..97ee8267 100644 --- a/src/main/java/app/coronawarn/quicktest/service/KeycloakService.java +++ b/src/main/java/app/coronawarn/quicktest/service/KeycloakService.java @@ -71,6 +71,7 @@ public class KeycloakService { private static final String POC_ID_ATTRIBUTE = "poc_id"; private static final String POC_DETAILS_ATTRIBUTE = "poc_details"; + private static final String BSNR_ATTRIBUTE = "bsnr"; /** * Creates a new Keycloak User in the Main Realm and sets roles and the root group. @@ -237,6 +238,7 @@ public KeycloakGroupDetails getSubGroupDetails(String groupId) { groupDetails.setName(group.getName()); groupDetails.setPocDetails(getFromAttributes(group.getAttributes(), POC_DETAILS_ATTRIBUTE)); groupDetails.setPocId(getFromAttributes(group.getAttributes(), POC_ID_ATTRIBUTE)); + groupDetails.setBsnr(getFromAttributes(group.getAttributes(), BSNR_ATTRIBUTE)); MapEntrySingleResponse mapEntry = mapEntryService.getMapEntry(groupId); if (mapEntry != null) { log.info(mapEntry.toString()); @@ -497,7 +499,7 @@ public void updateGroup(KeycloakGroupDetails details) group.setName(details.getName()); // do not update POC ID group.setAttributes(getGroupAttributes(details.getPocDetails(), - getFromAttributes(group.getAttributes(), POC_ID_ATTRIBUTE))); + getFromAttributes(group.getAttributes(), POC_ID_ATTRIBUTE), details.getBsnr())); try { groupResource.update(group); @@ -541,7 +543,7 @@ public void createGroup(KeycloakGroupDetails details, String parent) log.info("created group"); // setting group properties with Group Details and POC ID newGroup = response.readEntity(GroupRepresentation.class); - newGroup.setAttributes(getGroupAttributes(details.getPocDetails(), newGroup.getId())); + newGroup.setAttributes(getGroupAttributes(details.getPocDetails(), newGroup.getId(), details.getBsnr())); realm().groups().group(newGroup.getId()).update(newGroup); if (details.getSearchPortalConsent()) { details.setId(newGroup.getId()); @@ -634,7 +636,7 @@ private String getFromAttributes(Map> attributes, String ke } } - private Map> getGroupAttributes(String pocDetails, String pocId) { + private Map> getGroupAttributes(String pocDetails, String pocId, String bsnr) { Map> attributes = new HashMap<>(); if (pocDetails != null) { attributes.put(POC_DETAILS_ATTRIBUTE, List.of(pocDetails)); @@ -644,6 +646,10 @@ private Map> getGroupAttributes(String pocDetails, String p attributes.put(POC_ID_ATTRIBUTE, List.of(pocId)); } + if (bsnr != null) { + attributes.put(BSNR_ATTRIBUTE, List.of(bsnr)); + } + return attributes; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index aac14f8c..ffc08bd4 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -78,6 +78,7 @@ quicktest: pointOfCareIdName: poc_id tenantIdKey: tenantId groupKey: groups + bsnrKey: bsnr tenantPointOfCareIdKey: pocId pointOfCareInformationName: poc_details pointOfCareInformationDelimiter: \,