diff options
author | Thomas <> | 2023-12-07 16:20:16 +0100 |
---|---|---|
committer | Thomas <> | 2023-12-07 16:20:16 +0100 |
commit | e6de77b0e259d623328deaa67040beaeac50a446 (patch) | |
tree | 1fd532696c914fc6159a4b31920a87f314d5d81f /ms_specific_connector | |
parent | 9b2f0b9308937d8d1b35fd2644e57dfb3b6e0ef3 (diff) | |
download | National_eIDAS_Gateway-e6de77b0e259d623328deaa67040beaeac50a446.tar.gz National_eIDAS_Gateway-e6de77b0e259d623328deaa67040beaeac50a446.tar.bz2 National_eIDAS_Gateway-e6de77b0e259d623328deaa67040beaeac50a446.zip |
feat(logger): add data model of json based statistic logger
Diffstat (limited to 'ms_specific_connector')
-rw-r--r-- | ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/AdvancedStatisticLogger.java | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/AdvancedStatisticLogger.java b/ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/AdvancedStatisticLogger.java index 06fb1aba..b18ce89e 100644 --- a/ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/AdvancedStatisticLogger.java +++ b/ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/AdvancedStatisticLogger.java @@ -39,6 +39,9 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class AdvancedStatisticLogger implements IStatisticLogger { + private static final String SUCCES_CODE = "success.00"; + private static final String SUCCES_MSG = "success"; + private static final String DATEFORMATER = "yyyy.MM.dd-HH:mm:ss,SSS"; private static final String DEFAULT_NO_IDP_ID = "no idpId available"; private static final String DEFAULT_NO_SP_ID = "no appId available"; @@ -62,6 +65,8 @@ public class AdvancedStatisticLogger implements IStatisticLogger { public void logSuccessOperation(IRequest protocolRequest, IAuthData authData, boolean isSsoSession) { final StatisticLogEntry entry = buildCoreEntry(protocolRequest); entry.setSuccess(SuccessEntry.builder() + .statusCode(SUCCES_CODE) + .statusMessage(SUCCES_MSG) .spSector(protocolRequest.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier()) .spCountry("AT") .citizenCountryCode(authData.getCiticenCountryCode()) @@ -83,7 +88,14 @@ public class AdvancedStatisticLogger implements IStatisticLogger { @Override public void logErrorOperation(Throwable throwable, IRequest errorRequest) { final StatisticLogEntry entry = buildCoreEntry(errorRequest); - entry.setError(new ErrorEntry(messageService.getResponseErrorCode(throwable), throwable.getMessage())); + entry.setSuccess(SuccessEntry.builder() + .statusCode(messageService.getResponseErrorCode(throwable)) + .statusMessage(throwable.getMessage()) + .spSector(errorRequest.getServiceProviderConfiguration() != null + ? errorRequest.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier() + : "") + .spCountry("AT") + .build()); entry.setMatching(MatchingDetails.builder() .matchingMethod(extractMatchingState(errorRequest)) .matchingDetails(extractMatchingDetails(errorRequest)) @@ -147,7 +159,7 @@ public class AdvancedStatisticLogger implements IStatisticLogger { @Getter @Setter @RequiredArgsConstructor - @JsonInclude(Include.NON_NULL) + @JsonInclude(Include.ALWAYS) private static class StatisticLogEntry { @JsonSerialize(using = LocalDateTimeSerializer.class) @@ -167,9 +179,6 @@ public class AdvancedStatisticLogger implements IStatisticLogger { @JsonProperty("result") private SuccessEntry success; - - @JsonProperty("error") - private ErrorEntry error; @JsonProperty("identityMatching") private MatchingDetails matching; @@ -179,9 +188,15 @@ public class AdvancedStatisticLogger implements IStatisticLogger { @Getter @Setter @Builder - @JsonInclude(Include.NON_NULL) + @JsonInclude(Include.ALWAYS) private static class SuccessEntry { + @JsonProperty("code") + private final String statusCode; + + @JsonProperty("msg") + private final String statusMessage; + @JsonProperty("spSector") private final String spSector; @@ -196,7 +211,7 @@ public class AdvancedStatisticLogger implements IStatisticLogger { @Getter @Setter @Builder - @JsonInclude(Include.NON_NULL) + @JsonInclude(Include.ALWAYS) private static class MatchingDetails { @JsonProperty("finalMatchingMethod") @@ -207,17 +222,4 @@ public class AdvancedStatisticLogger implements IStatisticLogger { } - @Getter - @Setter - @RequiredArgsConstructor - private static class ErrorEntry { - - @JsonProperty("code") - private final String errorCode; - - @JsonProperty("msg") - private final String errorMessage; - - } - } |