diff options
-rw-r--r-- | modules/core_common_webapp/src/main/java/at/asitplus/eidas/specific/core/logger/StatisticLogger.java | 20 | ||||
-rw-r--r-- | ms_specific_connector/pom.xml | 4 | ||||
-rw-r--r-- | ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/AdvancedStatisticLogger.java (renamed from ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/AdvancedStatisicLogger.java) | 24 | ||||
-rw-r--r-- | ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/MultipleStatisticLogger.java | 4 | ||||
-rw-r--r-- | ms_specific_proxyservice/pom.xml | 4 | ||||
-rw-r--r-- | ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java (renamed from ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisicLogger.java) | 20 | ||||
-rw-r--r-- | ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/MultipleStatisticLogger.java | 4 | ||||
-rw-r--r-- | pom.xml | 5 |
8 files changed, 64 insertions, 21 deletions
diff --git a/modules/core_common_webapp/src/main/java/at/asitplus/eidas/specific/core/logger/StatisticLogger.java b/modules/core_common_webapp/src/main/java/at/asitplus/eidas/specific/core/logger/StatisticLogger.java index 22cace10..fd2be89b 100644 --- a/modules/core_common_webapp/src/main/java/at/asitplus/eidas/specific/core/logger/StatisticLogger.java +++ b/modules/core_common_webapp/src/main/java/at/asitplus/eidas/specific/core/logger/StatisticLogger.java @@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory; import at.asitplus.eidas.specific.core.MsEidasNodeConstants; import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.IStatusMessenger; +import at.gv.egiz.eaaf.core.api.data.EaafConstants; 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.EaafException; @@ -50,6 +51,8 @@ public class StatisticLogger implements IStatisticLogger { protocolRequest.getSpEntityId(), protocolRequest.getRawData(MsEidasNodeConstants.DATA_REQUESTERID), protocolRequest.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier(), + extractSpCountryCode(protocolRequest.getServiceProviderConfiguration() + .getAreaSpecificTargetIdentifier()), authData.getCiticenCountryCode(), extractMatchingState(protocolRequest.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE)), STATUS_SUCCESS, @@ -72,6 +75,7 @@ public class StatisticLogger implements IStatisticLogger { StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, + StringUtils.EMPTY, STATUS_ERROR, errorId, throwable.getMessage())); @@ -91,6 +95,8 @@ public class StatisticLogger implements IStatisticLogger { errorRequest.getSpEntityId(), errorRequest.getRawData(MsEidasNodeConstants.DATA_REQUESTERID), errorRequest.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier(), + extractSpCountryCode(errorRequest.getServiceProviderConfiguration() + .getAreaSpecificTargetIdentifier()), StringUtils.EMPTY, extractMatchingState(errorRequest.getRawData(MsEidasNodeConstants.DATA_MATCHING_STATE)), STATUS_ERROR, @@ -104,6 +110,7 @@ public class StatisticLogger implements IStatisticLogger { StringUtils.EMPTY, StringUtils.EMPTY, StringUtils.EMPTY, + StringUtils.EMPTY, STATUS_ERROR, errorId, throwable.getMessage())); @@ -117,13 +124,23 @@ public class StatisticLogger implements IStatisticLogger { } + private String extractSpCountryCode(String target) { + if (target.startsWith(EaafConstants.URN_PREFIX_EIDAS)) { + return target.split("\\+")[2]; + + } else { + return "AT"; + + } + } + private String extractMatchingState(Object state) { return state != null ? state.toString() : MsEidasNodeConstants.MatchingStates.NO_REQUIRED.toString(); } private String buildLogMessage(String transId, String entityId, Object requesterId, String target, - String cc, String matchingState, + String spCountry, String cc, String matchingState, String status, String errorCode, String errorMsg) { String logMsg = StringUtils.EMPTY; @@ -140,6 +157,7 @@ public class StatisticLogger implements IStatisticLogger { } logMsg += target + ","; + logMsg += spCountry + ","; logMsg += cc + ","; logMsg += matchingState + ","; diff --git a/ms_specific_connector/pom.xml b/ms_specific_connector/pom.xml index 253768ca..b618e3d9 100644 --- a/ms_specific_connector/pom.xml +++ b/ms_specific_connector/pom.xml @@ -127,6 +127,10 @@ <artifactId>cxf-rt-transports-http</artifactId> </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-properties</artifactId> + </dependency> <!-- Testing --> <dependency> 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/AdvancedStatisticLogger.java index cfa93286..06fb1aba 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/AdvancedStatisticLogger.java @@ -1,5 +1,6 @@ package at.asitplus.eidas.specific.core.logger; +import java.io.IOException; import java.time.LocalDateTime; import org.apache.commons.lang3.StringUtils; @@ -8,10 +9,10 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.dataformat.javaprop.JavaPropsMapper; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; @@ -36,13 +37,14 @@ import lombok.extern.slf4j.Slf4j; * */ @Slf4j -public class AdvancedStatisicLogger implements IStatisticLogger { +public class AdvancedStatisticLogger implements IStatisticLogger { - private static final String DATEFORMATER = "yyyy.MM.dd-HH:mm:ss"; + 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"; private static final ObjectMapper mapper = new ObjectMapper(); + private static final JavaPropsMapper propsMapper = new JavaPropsMapper(); private final IStatusMessenger messageService; @@ -51,7 +53,7 @@ public class AdvancedStatisicLogger implements IStatisticLogger { * * @param source i18n message source */ - public AdvancedStatisicLogger(IStatusMessenger source) { + public AdvancedStatisticLogger(IStatusMessenger source) { this.messageService = source; } @@ -61,6 +63,7 @@ public class AdvancedStatisicLogger implements IStatisticLogger { final StatisticLogEntry entry = buildCoreEntry(protocolRequest); entry.setSuccess(SuccessEntry.builder() .spSector(protocolRequest.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier()) + .spCountry("AT") .citizenCountryCode(authData.getCiticenCountryCode()) .build()); entry.setMatching(MatchingDetails.builder() @@ -132,9 +135,9 @@ public class AdvancedStatisicLogger implements IStatisticLogger { private void writeEntryToLog(StatisticLogEntry entry) { try { - log.info(mapper.writeValueAsString(entry)); + log.info(mapper.writeValueAsString(propsMapper.writeValueAsProperties(entry))); - } catch (final JsonProcessingException e) { + } catch (final IOException e) { log.error("Can NOT generate statistic entry for logging", e); } @@ -162,13 +165,13 @@ public class AdvancedStatisicLogger implements IStatisticLogger { @JsonProperty("unique-sp-id") private final String uniqueId; - @JsonProperty("success") + @JsonProperty("result") private SuccessEntry success; @JsonProperty("error") private ErrorEntry error; - @JsonProperty("idenityMatching") + @JsonProperty("identityMatching") private MatchingDetails matching; } @@ -182,7 +185,10 @@ public class AdvancedStatisicLogger implements IStatisticLogger { @JsonProperty("spSector") private final String spSector; - @JsonProperty("ccc") + @JsonProperty("spCountry") + private final String spCountry; + + @JsonProperty("citizenCountryCode") private final String citizenCountryCode; } diff --git a/ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/MultipleStatisticLogger.java b/ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/MultipleStatisticLogger.java index 008a5691..723da3ba 100644 --- a/ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/MultipleStatisticLogger.java +++ b/ms_specific_connector/src/main/java/at/asitplus/eidas/specific/core/logger/MultipleStatisticLogger.java @@ -23,7 +23,7 @@ public class MultipleStatisticLogger implements IStatisticLogger { private final Set<IStatisticLogger> internalLoggers; /** - * Build a statistic logger that logs into {@link StatisticLogger} and {@link AdvancedStatisicLogger}. + * Build a statistic logger that logs into {@link StatisticLogger} and {@link AdvancedStatisticLogger}. * * @param messageService i18n message-source implementation. */ @@ -31,7 +31,7 @@ public class MultipleStatisticLogger implements IStatisticLogger { internalLoggers = Collections.unmodifiableSet( Sets.newHashSet( new StatisticLogger(), - new AdvancedStatisicLogger(messageService))); + new AdvancedStatisticLogger(messageService))); } diff --git a/ms_specific_proxyservice/pom.xml b/ms_specific_proxyservice/pom.xml index 78b425fe..4d388b2d 100644 --- a/ms_specific_proxyservice/pom.xml +++ b/ms_specific_proxyservice/pom.xml @@ -68,6 +68,10 @@ <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-properties</artifactId> + </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> diff --git a/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisicLogger.java b/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java index cf55281d..55833b8b 100644 --- a/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisicLogger.java +++ b/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/AdvancedStatisticLogger.java @@ -1,15 +1,16 @@ package at.asitplus.eidas.specific.proxy.logger; +import java.io.IOException; import java.time.LocalDateTime; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.dataformat.javaprop.JavaPropsMapper; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; @@ -33,12 +34,13 @@ import lombok.extern.slf4j.Slf4j; * */ @Slf4j -public class AdvancedStatisicLogger implements IStatisticLogger { +public class AdvancedStatisticLogger implements IStatisticLogger { - private static final String DATEFORMATER = "yyyy.MM.dd-HH:mm:ss"; + 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 ObjectMapper mapper = new ObjectMapper(); + private static final JavaPropsMapper propsMapper = new JavaPropsMapper(); private final IStatusMessenger messageService; @@ -47,7 +49,7 @@ public class AdvancedStatisicLogger implements IStatisticLogger { * * @param source i18n message source */ - public AdvancedStatisicLogger(IStatusMessenger source) { + public AdvancedStatisticLogger(IStatusMessenger source) { this.messageService = source; } @@ -59,6 +61,7 @@ public class AdvancedStatisicLogger implements IStatisticLogger { .spSector(protocolRequest.getServiceProviderConfiguration().getAreaSpecificTargetIdentifier()) .spCountry(protocolRequest.getServiceProviderConfiguration().getConfigurationValue( MsProxyServiceConstants.CONIG_PROPS_CONNECTOR_COUNTRYCODE)) + .citizenCountryCode("AT") .withMandates(selectMandateProcessType(authData)) .build()); writeEntryToLog(entry); @@ -108,9 +111,9 @@ public class AdvancedStatisicLogger implements IStatisticLogger { private void writeEntryToLog(StatisticLogEntry entry) { try { - log.info(mapper.writeValueAsString(entry)); + log.info(mapper.writeValueAsString(propsMapper.writeValueAsProperties(entry))); - } catch (final JsonProcessingException e) { + } catch (final IOException e) { log.error("Can NOT generate statistic entry for logging", e); } @@ -136,7 +139,7 @@ public class AdvancedStatisicLogger implements IStatisticLogger { @JsonProperty("entityId") private final String idpEntityId; - @JsonProperty("success") + @JsonProperty("result") private SuccessEntry success; @JsonProperty("error") @@ -156,6 +159,9 @@ public class AdvancedStatisicLogger implements IStatisticLogger { @JsonProperty("spCountry") private final String spCountry; + @JsonProperty("citizenCountryCode") + private final String citizenCountryCode; + @JsonProperty("withMandates") private final MandateProcess withMandates; diff --git a/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/MultipleStatisticLogger.java b/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/MultipleStatisticLogger.java index bd771fb2..ccd81a27 100644 --- a/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/MultipleStatisticLogger.java +++ b/ms_specific_proxyservice/src/main/java/at/asitplus/eidas/specific/proxy/logger/MultipleStatisticLogger.java @@ -24,7 +24,7 @@ public class MultipleStatisticLogger implements IStatisticLogger { private final Set<IStatisticLogger> internalLoggers; /** - * Build a statistic logger that logs into {@link StatisticLogger} and {@link AdvancedStatisicLogger}. + * Build a statistic logger that logs into {@link StatisticLogger} and {@link AdvancedStatisticLogger}. * * @param messageService i18n message-source implementation. */ @@ -32,7 +32,7 @@ public class MultipleStatisticLogger implements IStatisticLogger { internalLoggers = Collections.unmodifiableSet( Sets.newHashSet( new StatisticLogger(), - new AdvancedStatisicLogger(messageService))); + new AdvancedStatisticLogger(messageService))); } @@ -431,6 +431,11 @@ <artifactId>jackson-dataformat-yaml</artifactId> <version>${jackson.version}</version> </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-properties</artifactId> + <version>${jackson.version}</version> + </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jsr310</artifactId> |