diff options
author | Thomas <> | 2022-10-21 15:45:15 +0200 |
---|---|---|
committer | Thomas <> | 2022-10-21 15:45:15 +0200 |
commit | ec9bb663b463657643c87e2d7116229fb6a5367c (patch) | |
tree | bea97ff98089b6a998926becd3c82e02ab66ca37 /ms_specific_connector/src | |
parent | e9052aa4d79700a65a099a7d7ab8dfc15be84bff (diff) | |
download | National_eIDAS_Gateway-ec9bb663b463657643c87e2d7116229fb6a5367c.tar.gz National_eIDAS_Gateway-ec9bb663b463657643c87e2d7116229fb6a5367c.tar.bz2 National_eIDAS_Gateway-ec9bb663b463657643c87e2d7116229fb6a5367c.zip |
feat(matching): add detailed matching results into JSON based statistic logger
Diffstat (limited to 'ms_specific_connector/src')
-rw-r--r-- | ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/AdvancedStatisicLogger.java | 30 |
1 files changed, 26 insertions, 4 deletions
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; } |