From ec9bb663b463657643c87e2d7116229fb6a5367c Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Fri, 21 Oct 2022 15:45:15 +0200 Subject: feat(matching): add detailed matching results into JSON based statistic logger --- .../core/logger/AdvancedStatisicLogger.java | 30 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'ms_specific_connector') diff --git a/ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/AdvancedStatisicLogger.java b/ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/AdvancedStatisicLogger.java index f3c43579..6cbe11bf 100644 --- a/ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/AdvancedStatisicLogger.java +++ b/ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/AdvancedStatisicLogger.java @@ -16,10 +16,13 @@ import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import at.asitplus.eidas.specific.core.MsEidasNodeConstants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.log.statistic.DetailedMatchtingStatistic; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.MatchingTaskUtils; import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.IStatusMessenger; import at.gv.egiz.eaaf.core.api.idp.IAuthData; import at.gv.egiz.eaaf.core.api.logging.IStatisticLogger; +import at.gv.egiz.eaaf.core.exceptions.EaafStorageException; import lombok.Builder; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -59,7 +62,8 @@ public class AdvancedStatisicLogger implements IStatisticLogger { entry.setSuccess(SuccessEntry.builder() .spSector(protocolRequest.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier()) .citizenCountryCode(authData.getCiticenCountryCode()) - .matchingMethod(extractMatchingState(protocolRequest.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE))) + .matchingMethod(extractMatchingState(protocolRequest)) + .matchingDetails(extractMatchingDetails(protocolRequest)) .build()); writeEntryToLog(entry); @@ -97,12 +101,29 @@ public class AdvancedStatisicLogger implements IStatisticLogger { ? (String)appId : DEFAULT_NO_SP_ID); } - - private String extractMatchingState(Object state) { + + private String extractMatchingState(IRequest protocolRequest) { + Object state = protocolRequest.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE); return state != null ? state.toString() : MsEidasNodeConstants.MatchingStates.NO_REQUIRED.toString(); } + private DetailedMatchtingStatistic extractMatchingDetails(IRequest protocolRequest) { + try { + if (!MsEidasNodeConstants.MatchingStates.NO_REQUIRED.toString().equals( + extractMatchingState(protocolRequest))) { + return MatchingTaskUtils.getDetailedMatchingStatistic(protocolRequest); + + } + + } catch (EaafStorageException e) { + log.warn("Can not generate detailed matching statistic", e); + + } + + return null; + } + private void writeEntryToLog(StatisticLogEntry entry) { try { log.info(mapper.writeValueAsString(entry)); @@ -146,7 +167,6 @@ public class AdvancedStatisicLogger implements IStatisticLogger { @Getter @Setter @Builder - @RequiredArgsConstructor @JsonInclude(Include.NON_NULL) private static class SuccessEntry { @@ -159,6 +179,8 @@ public class AdvancedStatisicLogger implements IStatisticLogger { @JsonProperty("finalMatchingMethod") private final String matchingMethod; + @JsonProperty("matchingProcessDetails") + private final DetailedMatchtingStatistic matchingDetails; } -- cgit v1.2.3