-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
src/main/java/eu/europa/ec/dgc/verifier/restapi/controller/ContextController.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,70 @@ | ||
/*- | ||
* ---license-start | ||
* eu-digital-green-certificates / dgca-verifier-service | ||
* --- | ||
* Copyright (C) 2021 T-Systems International GmbH and all other contributors | ||
* --- | ||
* Licensed 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. | ||
* ---license-end | ||
*/ | ||
|
||
package eu.europa.ec.dgc.verifier.restapi.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.commons.io.IOUtils; | ||
import org.springframework.core.io.ClassPathResource; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/context") | ||
@Slf4j | ||
public class ContextController { | ||
|
||
/** | ||
* Http Method for getting the current context. | ||
*/ | ||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) | ||
@Operation( | ||
summary = "Provide configuration information for the verifier app", | ||
tags = {"Configuration"}, | ||
responses = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "Returns the current context for the verifier app.", | ||
content = @Content( | ||
mediaType = MediaType.APPLICATION_JSON_VALUE, | ||
schema = @Schema(implementation = String.class))) | ||
} | ||
) | ||
public ResponseEntity<String> getContext() { | ||
Resource resource = new ClassPathResource("/static/context.jsonc"); | ||
try { | ||
return ResponseEntity.ok(IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8)); | ||
} catch (IOException e) { | ||
log.error("Could not read context file"); | ||
} | ||
return ResponseEntity.ok(""); | ||
} | ||
|
||
} |
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,38 @@ | ||
{ | ||
// Origin in ISO alpha 2 code: | ||
"origin": "DE", | ||
"versions": { | ||
"default": { | ||
// catch-all for normal versions | ||
"privacyUrl": "https://publications.europa.eu/en/web/about-us/legal-notices/eu-mobile-apps", | ||
"context": { | ||
// Currently this url is empty still, subject to change: | ||
"url": "https://dgca-verifier-service.cfapps.eu10.hana.ondemand.com/context", | ||
"pubKeys": [ | ||
"lKdU1EbQubxyDDm2q3N8KclZ2C94Num3xXjG0pk+3eI=", | ||
"r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=" | ||
] | ||
}, | ||
"endpoints": { | ||
"status": { | ||
"url": "https://dgca-verifier-service.cfapps.eu10.hana.ondemand.com/signercertificateStatus", | ||
"pubKeys": [ | ||
"lKdU1EbQubxyDDm2q3N8KclZ2C94Num3xXjG0pk+3eI=", | ||
"r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=" | ||
] | ||
}, | ||
"update": { | ||
"url": "https://dgca-verifier-service.cfapps.eu10.hana.ondemand.com/signercertificateUpdate", | ||
"pubKeys": [ | ||
"lKdU1EbQubxyDDm2q3N8KclZ2C94Num3xXjG0pk+3eI=", | ||
"r/mIkG3eEpVdm+u/ko/cwxzOMo1bk4TyHIlByibiA5E=" | ||
] | ||
} | ||
} | ||
}, | ||
"0.1.0": { | ||
// Example for a version that is insecure and shouldn't start. | ||
"outdated": true | ||
} | ||
} | ||
} |