aboutsummaryrefslogtreecommitdiff
path: root/ms_specific_proxyservice
diff options
context:
space:
mode:
authorThomas <>2023-12-07 16:20:16 +0100
committerThomas <>2023-12-07 16:20:16 +0100
commite6de77b0e259d623328deaa67040beaeac50a446 (patch)
tree1fd532696c914fc6159a4b31920a87f314d5d81f /ms_specific_proxyservice
parent9b2f0b9308937d8d1b35fd2644e57dfb3b6e0ef3 (diff)
downloadNational_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_proxyservice')
-rw-r--r--ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java45
1 files changed, 25 insertions, 20 deletions
diff --git a/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java b/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java
index 55833b8b..1d7e1f73 100644
--- a/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java
+++ b/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java
@@ -36,6 +36,8 @@ 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";
@@ -58,6 +60,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(protocolRequest.getServiceProviderConfiguration().getConfigurationValue(
MsProxyServiceConstants.CONIG_PROPS_CONNECTOR_COUNTRYCODE))
@@ -76,8 +80,19 @@ 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()));
+ final StatisticLogEntry entry = buildCoreEntry(errorRequest);
+ entry.setSuccess(SuccessEntry.builder()
+ .statusCode(messageService.getResponseErrorCode(throwable))
+ .statusMessage(throwable.getMessage())
+ .spSector(errorRequest.getServiceProviderConfiguration() != null
+ ? errorRequest.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier()
+ : "")
+ .spCountry(errorRequest.getServiceProviderConfiguration() != null
+ ? errorRequest.getServiceProviderConfiguration().getConfigurationValue(
+ MsProxyServiceConstants.CONIG_PROPS_CONNECTOR_COUNTRYCODE)
+ : "")
+ .citizenCountryCode("AT")
+ .build());
writeEntryToLog(entry);
}
@@ -124,7 +139,7 @@ public class AdvancedStatisticLogger implements IStatisticLogger {
@Getter
@Setter
@RequiredArgsConstructor
- @JsonInclude(Include.NON_NULL)
+ @JsonInclude(Include.ALWAYS)
private static class StatisticLogEntry {
@JsonSerialize(using = LocalDateTimeSerializer.class)
@@ -141,18 +156,21 @@ public class AdvancedStatisticLogger implements IStatisticLogger {
@JsonProperty("result")
private SuccessEntry success;
-
- @JsonProperty("error")
- private ErrorEntry error;
}
@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;
@@ -166,17 +184,4 @@ public class AdvancedStatisticLogger implements IStatisticLogger {
private final MandateProcess withMandates;
}
-
- @Getter
- @Setter
- @RequiredArgsConstructor
- private static class ErrorEntry {
-
- @JsonProperty("code")
- private final String errorCode;
-
- @JsonProperty("msg")
- private final String errorMessage;
-
- }
}