Skip to content

Commit

Permalink
update rest api to 1.3 spec (#34)
Browse files Browse the repository at this point in the history
* update rest api to 1.3 spec

* checkstyle

* cert controller not only in dev profile

* Update src/main/java/eu/europa/ec/dgc/issuance/restapi/controller/DgciController.java

Co-authored-by: Felix Dittrich <[email protected]>
  • Loading branch information
a-trzewik and f11h authored May 5, 2021
1 parent 9747c95 commit bc84e19
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
* The endpoint here are not public API and should be used only for developing testing
* purposes.
* Only available for spring dev profile
*/
@RestController
@RequestMapping("/cert")
@AllArgsConstructor
Expand All @@ -63,6 +68,9 @@ public class CertController {
/**
* Controller for creating Vaccination Certificate.
*/
@Operation(
summary = "create edgc with process step informations, developing tool"
)
@PostMapping(value = "create", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ChainResult> createVaccinationCertificate(@RequestBody Eudgc eudgc) {
Chain cborProcessingChain =
Expand All @@ -76,6 +84,9 @@ public ResponseEntity<ChainResult> createVaccinationCertificate(@RequestBody Eud
/**
* Rest Controller to decode CBOR.
*/
@Operation(
summary = "dump base64 cbor byte stream, developing tool"
)
@PostMapping(value = "dumpCBOR", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> decodeCbor(@RequestBody String cbor) throws IOException {
StringWriter stringWriter = new StringWriter();
Expand All @@ -95,7 +106,7 @@ public ResponseEntity<String> decodeCbor(@RequestBody String cbor) throws IOExce
* @throws IOException IOException
*/
@Operation(
summary = "decode edgc",
summary = "decode edgc, developing tool",
description = "decode and validate edgc raw string, extract raw data of each decode stage"
)
@PostMapping(value = "decodeEGC", consumes = MediaType.APPLICATION_JSON_VALUE)
Expand All @@ -110,6 +121,9 @@ public ResponseEntity<EgcDecodeResult> decodeEgCert(
/**
* Rest Controller to get Public Key Information.
*/
@Operation(
summary = "get information about edgc public key, developing tool"
)
@GetMapping(value = "publicKey")
public ResponseEntity<PublicKeyInfo> getPublic() {
PublicKeyInfo result = new PublicKeyInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ public class DgciController {


@Operation(
summary = "Creates new dgci",
summary = "Creates new dgci (deprecated)",
description = "Creates new dgci and return meta data for certificate creation"
)
@PostMapping(value = "", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<DgciIdentifier> initDgci(@Valid @RequestBody DgciInit dgciInit) {
@Deprecated
public ResponseEntity<DgciIdentifier> initDgciDepr(@Valid @RequestBody DgciInit dgciInit) {
return ResponseEntity.ok(dgciService.initDgci(dgciInit));
}

@Operation(
summary = "calculate cose signature for edgc",
summary = "calculate cose signature for edgc (deprecated)",
description = "calculate cose signature for given certificate hash, "
+ "generate TAN and update DGCI Registry database"
)
Expand All @@ -70,6 +71,32 @@ public ResponseEntity<DgciIdentifier> initDgci(@Valid @RequestBody DgciInit dgci
@ApiResponse(responseCode = "404", description = "dgci with related id not found"),
@ApiResponse(responseCode = "400", description = "wrong issue data")})
@PutMapping(value = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE)
@Deprecated
public ResponseEntity<SignatureData> finalizeDgciDepr(@PathVariable long id,
@Valid @RequestBody IssueData issueData)
throws Exception {
return ResponseEntity.ok(dgciService.finishDgci(id, issueData));
}

@Operation(
summary = "Prepares an DGCI for the Code Generation in Frontend",
description = "Creates new dgci and return meta data for certificate creation"
)
@PostMapping(value = "/issue", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<DgciIdentifier> initDgci(@Valid @RequestBody DgciInit dgciInit) {
return ResponseEntity.ok(dgciService.initDgci(dgciInit));
}

@Operation(
summary = "Completes the issuing process",
description = "calculate cose signature for given certificate hash, "
+ "generate TAN and update DGCI Registry database"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "201", description = "signature created"),
@ApiResponse(responseCode = "404", description = "dgci with related id not found"),
@ApiResponse(responseCode = "400", description = "wrong issue data")})
@PutMapping(value = "/issue/{id}", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<SignatureData> finalizeDgci(@PathVariable long id, @Valid @RequestBody IssueData issueData)
throws Exception {
return ResponseEntity.ok(dgciService.finishDgci(id, issueData));
Expand All @@ -82,24 +109,27 @@ public ResponseEntity<SignatureData> finalizeDgci(@PathVariable long id, @Valid
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "signed edgc qr code created"),
@ApiResponse(responseCode = "400", description = "wrong issue data")})
@PutMapping(value = "/", consumes = MediaType.APPLICATION_JSON_VALUE)
@PutMapping(value = "/issue", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EgdcCodeData> createEdgc(@Valid @RequestBody Eudgc eudgc) {
EgdcCodeData egdcCodeData = dgciService.createEdgc(eudgc);
return ResponseEntity.ok(egdcCodeData);
}

// Public API to get DID document of certification not needed in current architecture
@GetMapping(value = "/V1/DE/{opaque}/{hash}")
@Operation(
summary = "Returns a DID document"
)
@GetMapping(value = "/{hash}")
public ResponseEntity<DidDocument> getDidDocument(@PathVariable String opaque, String hash) {
return ResponseEntity.ok(dgciService.getDidDocument(opaque, hash));
return ResponseEntity.ok(dgciService.getDidDocument(hash));
}

@Operation(
summary = "Produce status message",
summary = "Checks the status of DGCI",
description = "Produce status message"
)
@GetMapping(value = "/status")
public ResponseEntity<String> hello() {
public ResponseEntity<String> status() {
// not was not really specified what it is good for
return ResponseEntity.ok("fine");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,23 @@ public class WalletController {
private final DgciService dgciService;

@Operation(
summary = "claim dgci",
summary = "Claims the DGCI for a TAN and certificate Holder",
description = "claim, assign dgci public key by TAN"
)
@ApiResponses(value = {
@ApiResponse(responseCode = "204", description = "successful claim"),
@ApiResponse(responseCode = "404", description = "dgci not found"),
@ApiResponse(responseCode = "400", description = "wrong claim data")})
@PostMapping(value = "", consumes = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "/claim", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Void> claimUpdate(@Valid @RequestBody ClaimRequest claimRequest) {

return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}

@PatchMapping(value = "", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(
summary = "Claims the DGCI for a new TAN and certificate Holder"
)
@PatchMapping(value = "/claim", consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ClaimResponse> claim(@Valid @RequestBody ClaimRequest claimRequest) {

return ResponseEntity.ok(dgciService.claimUpdate(claimRequest));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,10 @@ public SignatureData finishDgci(long dgciId, IssueData issueData) throws Excepti
/**
* get did document.
*
* @param opaque opaque
* @param hash hash
* @param hash hash
* @return didDocument
*/
public DidDocument getDidDocument(String opaque, String hash) {
public DidDocument getDidDocument(String hash) {
DidDocument didDocument = new DidDocument();
didDocument.setContext("https://w3id.org/did/v1");
// TODO DID fake data
Expand Down

0 comments on commit bc84e19

Please sign in to comment.