Skip to content

Commit

Permalink
Improve Logging (#106)
Browse files Browse the repository at this point in the history
* Add Check CertificateType match ID Prefix for ValidationRules

* Improve Logging of ValidationRule Controller
  • Loading branch information
f11h authored Jul 2, 2021
1 parent 279b705 commit 1146c40
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
20 changes: 9 additions & 11 deletions docs/software-design-dgc-gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,19 @@ These key-value-pairs can be followed by additional attributes. The additional a
| **Download Interface**
| Trust List was downloaded by a country | INFO | Downloaded TrustList | downloadedKeys (Number of Keys), downloadedKeysCountry (Downloader Country), downloadedKeysType (optional) |
| **Validation Rule**
| A Member State is trying to upload a new ValidationRule | INFO | Upload validation rule. | n/a |
| Upload of ValidationRule failed | ERROR | Failed to upload validation rule | validationRuleUploadError, validationRuleUploadReason |
| A Member State has uploaded a new ValidationRule | INFO | Inserted validation rule. | n/a |
| A Member State is trying to delete a ValidationRule | INFO | Delete validation rules. | n/a |
| A Member State has deleted ValidationRules | INFO | Deleted validation rules | validationDeleteAmount, validationDownloadId |
| A Member State is downloading ValidationRules | INFO | Downloading validation rules. | n/a |
| A Member State has downloaded ValidationRules | INFO | Downloading validation rules. | validationDownloadAmount, validationDownloadRequester, validationDownloadRequested |
| A Member State is trying to upload a new ValidationRule | INFO | Rule Upload Request | n/a |
| Upload of ValidationRule failed | ERROR | Rule Upload Failed | validationRuleUploadError, validationRuleUploadReason |
| A Member State has uploaded a new ValidationRule | INFO | Rule Upload Success | n/a |
| A Member State is trying to delete a ValidationRule | INFO | Rule Delete Request | n/a |
| A Member State has deleted ValidationRules | INFO | Rule Delete Success | validationDeleteAmount, validationDownloadId |
| A Member State is downloading ValidationRules | INFO | Rule Download Request | n/a |
| A Member State has downloaded ValidationRules | INFO |Rule Download Success | validationDownloadAmount, validationDownloadRequester, validationDownloadRequested |



# Integration into Data Center Infrastructure

## Load Balancer Integration
The load balancer terminates TLS, executes the mutual TLS authentication
and forwards the http request to a worker node.

The load balancer terminates TLS, executes the mutual TLS authentication and forwards the http request to a worker node.

The IP of the load balancer is assigned to registered domain name.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public ResponseEntity<Map<String, List<ValidationRuleDto>>> downloadValidationRu
@RequestAttribute(CertificateAuthenticationFilter.REQUEST_PROP_COUNTRY) String requesterCountryCode
) {

log.info("Downloading validation rules.");
log.info("Rule Download Request");

List<ValidationRuleEntity> validationRuleEntities =
validationRuleService.getActiveValidationRules(requestedCountryCode);
Expand All @@ -126,7 +126,7 @@ public ResponseEntity<Map<String, List<ValidationRuleDto>>> downloadValidationRu
DgcMdc.put(MDC_VALIDATION_RULE_DOWNLOAD_AMOUNT, validationRuleEntities.size());
DgcMdc.put(MDC_VALIDATION_RULE_DOWNLOAD_REQUESTER, requesterCountryCode);
DgcMdc.put(MDC_VALIDATION_RULE_DOWNLOAD_REQUESTED, requestedCountryCode);
log.info("Downloaded validation rules.");
log.info("Rule Download Success");

return ResponseEntity.ok(map);
}
Expand Down Expand Up @@ -170,7 +170,7 @@ public ResponseEntity<Void> uploadValidationRule(
@RequestAttribute(CertificateAuthenticationFilter.REQUEST_PROP_THUMBPRINT) String thumbprint
) {

log.info("Upload validation rule.");
log.info("Rule Upload Request");

if (!signedJson.isVerified()) {
throw new DgcgResponseException(HttpStatus.BAD_REQUEST, "0x260", "CMS signature is invalid", "",
Expand All @@ -188,7 +188,7 @@ public ResponseEntity<Void> uploadValidationRule(
} catch (ValidationRuleService.ValidationRuleCheckException e) {
DgcMdc.put("validationRuleUploadError", e.getMessage());
DgcMdc.put("validationRuleUploadReason", e.getReason().toString());
log.error("Failed to upload validation rule");
log.error("Rule Upload Failed");

switch (e.getReason()) {
case INVALID_JSON:
Expand Down Expand Up @@ -216,7 +216,7 @@ public ResponseEntity<Void> uploadValidationRule(
}


log.info("Inserted validation rule.");
log.info("Rule Upload Success");

auditService.addAuditEvent(
authenticatedCountryCode,
Expand Down Expand Up @@ -273,7 +273,7 @@ public ResponseEntity<Void> deleteValidationRules(
@RequestAttribute(CertificateAuthenticationFilter.REQUEST_PROP_THUMBPRINT) String thumbprint
) {

log.info("Delete validation rules.");
log.info("Rule Delete Request");

if (!signedString.isVerified()) {
throw new DgcgResponseException(HttpStatus.BAD_REQUEST, "0x260", "CMS signature is invalid", "",
Expand Down Expand Up @@ -314,7 +314,7 @@ public ResponseEntity<Void> deleteValidationRules(

DgcMdc.put(MDC_VALIDATION_RULE_DELETE_AMOUNT, deleted);
DgcMdc.put(MDC_VALIDATION_RULE_DELETE_ID, signedString.getPayloadString());
log.info("Deleted validation rules.");
log.info("Rule Delete Success");

auditService.addAuditEvent(
authenticatedCountryCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,7 @@ public List<ValidationRuleEntity> getActiveValidationRules(String country) {
* @return amount of deleted entities.
*/
public int deleteByRuleId(String ruleId) {
int deleted = validationRuleRepository.deleteByRuleId(ruleId);

DgcMdc.put("deletedAmount", deleted);
DgcMdc.put("ruleId", ruleId);
log.info("Deleted Validation Rules");

return deleted;
return validationRuleRepository.deleteByRuleId(ruleId);
}

/**
Expand Down

0 comments on commit 1146c40

Please sign in to comment.