This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Select Health Authority when issueing PIW Tan (#114)
* Rename TeleTAN Portal to CWA Tan Portal Add Health Authority Selector for PIW TAN * Add Server-Side Check of HA ID
- Loading branch information
Showing
15 changed files
with
303 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
.../app/coronawarn/verification/portal/config/VerificationPortalConfigurationProperties.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Corona-Warn-App / cwa-verification-portal | ||
* | ||
* (C) 2020, T-Systems International GmbH | ||
* | ||
* Deutsche Telekom AG and all other contributors / | ||
* copyright owners license this file to you under the Apache | ||
* License, Version 2.0 (the "License"); you may not use this | ||
* file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package app.coronawarn.verification.portal.config; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@ConfigurationProperties(prefix = "cwa.verification-portal") | ||
@Getter | ||
@Setter | ||
@Configuration | ||
public class VerificationPortalConfigurationProperties { | ||
|
||
private String healthAuthoritiesList; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/main/java/app/coronawarn/verification/portal/service/HealthAuthorityService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Corona-Warn-App / cwa-verification-portal | ||
* | ||
* (C) 2020, T-Systems International GmbH | ||
* | ||
* Deutsche Telekom AG and all other contributors / | ||
* copyright owners license this file to you under the Apache | ||
* License, Version 2.0 (the "License"); you may not use this | ||
* file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package app.coronawarn.verification.portal.service; | ||
|
||
import app.coronawarn.verification.portal.config.VerificationPortalConfigurationProperties; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.annotation.PostConstruct; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class HealthAuthorityService { | ||
|
||
private final VerificationPortalConfigurationProperties configurationProperties; | ||
|
||
private final ObjectMapper objectMapper; | ||
|
||
private List<HealthAuthority> healthAuthorities = new ArrayList<>(); | ||
|
||
@PostConstruct | ||
private void loadData() throws JsonProcessingException { | ||
healthAuthorities = objectMapper.readValue( | ||
configurationProperties.getHealthAuthoritiesList(), | ||
objectMapper.getTypeFactory().constructCollectionType(List.class, HealthAuthority.class)); | ||
} | ||
|
||
/** | ||
* Method to check whether a given Health-Authority ID is valid. | ||
* | ||
* @param haid ID (Nr) of the Health Authority | ||
* @return The corresponding name or null if HAID is invalid. | ||
*/ | ||
public String checkHealthAuthority(String haid) { | ||
return healthAuthorities.stream() | ||
.filter(healthAuthority -> healthAuthority.nr.equals(haid)) | ||
.findFirst() | ||
.map(HealthAuthority::getName) | ||
.orElse(null); | ||
} | ||
|
||
@Getter | ||
@Setter | ||
public static class HealthAuthority { | ||
|
||
private String name; | ||
|
||
private String nr; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(() => { | ||
$(document).ready(() => { | ||
const healthAuthorityInput = $("#health-authority"); | ||
const healthAuthorityIdInput = $("#health-authority-id"); | ||
const healthAuthorityDataList = $("#health-authorities"); | ||
const piwTanButton = $("#piw-tan-button"); | ||
|
||
piwTanButton.prop("disabled", true); | ||
|
||
const healthAuthorities = JSON.parse(healthAuthorityRawData); | ||
fillHealthAuthorityDataList(healthAuthorities, healthAuthorityDataList); | ||
|
||
healthAuthorityInput.on("change keyup", () => { | ||
const foundId = healthAuthorities.find(ha => ha.name === healthAuthorityInput.val()); | ||
|
||
if (foundId) { | ||
piwTanButton.prop("disabled", false); | ||
healthAuthorityIdInput.val(foundId.nr); | ||
} else { | ||
piwTanButton.prop("disabled", true); | ||
} | ||
}) | ||
}) | ||
|
||
function fillHealthAuthorityDataList(healthAuthorities, healthAuthorityDataList) { | ||
healthAuthorities.forEach((healthAuthority => { | ||
const newElement = $("<option></option>"); | ||
newElement.text(healthAuthority.name); | ||
healthAuthorityDataList.append(newElement); | ||
})); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.