-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat/list-signature jks signing optional
- Loading branch information
Showing
26 changed files
with
473 additions
and
25 deletions.
There are no files selected for viewing
Binary file not shown.
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
15 changes: 15 additions & 0 deletions
15
src/main/java/eu/europa/ec/dgc/businessrule/config/JksSigningConfig.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,15 @@ | ||
package eu.europa.ec.dgc.businessrule.config; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@Getter | ||
@Setter | ||
@ConfigurationProperties("jks-signing") | ||
public class JksSigningConfig { | ||
private String keyStoreFile; | ||
private String keyStorePassword; | ||
private String certAlias; | ||
private String privateKeyPassword; | ||
} |
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
5 changes: 5 additions & 0 deletions
5
src/main/java/eu/europa/ec/dgc/businessrule/entity/ListType.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,5 @@ | ||
package eu.europa.ec.dgc.businessrule.entity; | ||
|
||
public enum ListType { | ||
Rules, ValueSets | ||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/eu/europa/ec/dgc/businessrule/entity/SignedListEntity.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,36 @@ | ||
package eu.europa.ec.dgc.businessrule.entity; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.EnumType; | ||
import javax.persistence.Enumerated; | ||
import javax.persistence.Id; | ||
import javax.persistence.Lob; | ||
import javax.persistence.Table; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@Entity | ||
@Table(name = "signed_list") | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class SignedListEntity { | ||
@Id | ||
@Column(name = "list_type", nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
private ListType listType; | ||
|
||
@Column(name = "hash", nullable = false, length = 64) | ||
private String hash; | ||
|
||
@Column(name = "signature", nullable = false, length = 256) | ||
private String signature; | ||
|
||
@Lob | ||
@Column(name = "raw_data", nullable = false) | ||
String rawData; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/eu/europa/ec/dgc/businessrule/repository/SignedListRepository.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,8 @@ | ||
package eu.europa.ec.dgc.businessrule.repository; | ||
|
||
import eu.europa.ec.dgc.businessrule.entity.ListType; | ||
import eu.europa.ec.dgc.businessrule.entity.SignedListEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface SignedListRepository extends JpaRepository<SignedListEntity, ListType> { | ||
} |
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
47 changes: 47 additions & 0 deletions
47
src/main/java/eu/europa/ec/dgc/businessrule/restapi/controller/SigningController.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,47 @@ | ||
package eu.europa.ec.dgc.businessrule.restapi.controller; | ||
|
||
import eu.europa.ec.dgc.businessrule.service.SigningService; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import java.util.Optional; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
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("/publickey") | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class SigningController { | ||
private final Optional<SigningService> signingService; | ||
|
||
/** | ||
* Http Method for getting the business rules list. | ||
*/ | ||
@GetMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE) | ||
@Operation( | ||
summary = "Gets the signing public key (der base64 encoded)", | ||
description = "Gets the signing public key (der base64 encoded)", | ||
tags = {"Business Rules"}, | ||
responses = { | ||
@ApiResponse( | ||
responseCode = "200", | ||
description = "public key"), | ||
@ApiResponse( | ||
responseCode = "404", | ||
description = "signing not supported"), | ||
} | ||
) | ||
public ResponseEntity<String> getPublicKey() { | ||
if (signingService.isPresent()) { | ||
return ResponseEntity.ok(signingService.get().getPublicKey()); | ||
} else { | ||
return ResponseEntity.status(HttpStatus.NOT_FOUND).build(); | ||
} | ||
} | ||
} |
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.