From 7ba6fecaf1bc00c3e21102d6ba5fb6c6fc5f3398 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Wed, 14 Apr 2021 14:53:57 +0200 Subject: some code optimization to reduce memory consumption --- .../eaaf/core/impl/idp/AuthenticationData.java | 12 ++++------ .../egiz/eaaf/core/api/idp/ISpConfiguration.java | 5 ++-- .../core/impl/idp/conf/SpConfigurationImpl.java | 28 +++++++++++----------- .../data/GenericSignatureVerificationResponse.java | 22 +++++++++++++++-- eaaf_modules/eaaf_module_pvp2_core/pom.xml | 6 +++++ 5 files changed, 48 insertions(+), 25 deletions(-) diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/AuthenticationData.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/AuthenticationData.java index a8695885..00324a9a 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/AuthenticationData.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/AuthenticationData.java @@ -27,15 +27,14 @@ import java.util.Date; import java.util.Map; import java.util.TimeZone; +import org.apache.commons.collections4.map.HashedMap; +import org.apache.commons.lang3.StringUtils; + import at.gv.egiz.eaaf.core.api.idp.IAuthData; import at.gv.egiz.eaaf.core.api.idp.auth.data.IIdentityLink; import at.gv.egiz.eaaf.core.exceptions.EaafStorageException; import at.gv.egiz.eaaf.core.impl.builder.BpkBuilder; - -import org.apache.commons.collections4.map.HashedMap; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.extern.slf4j.Slf4j; /** * Service-Provider specific authentication data. @@ -43,10 +42,9 @@ import org.slf4j.LoggerFactory; * @author tlenz * */ +@Slf4j public class AuthenticationData implements IAuthData, Serializable { - private static final Logger log = LoggerFactory.getLogger(AuthenticationData.class); - private static final long serialVersionUID = -1042697056735596866L; public static final String IDENTITY_LINK_DATE_FORMAT = "yyyy-MM-dd"; public static final String ISSUE_INSTANT_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; diff --git a/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/idp/ISpConfiguration.java b/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/idp/ISpConfiguration.java index 5a16f655..dd4041fc 100644 --- a/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/idp/ISpConfiguration.java +++ b/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/idp/ISpConfiguration.java @@ -22,6 +22,7 @@ package at.gv.egiz.eaaf.core.api.idp; import java.io.Serializable; import java.util.List; import java.util.Map; +import java.util.Set; public interface ISpConfiguration extends Serializable { @@ -121,7 +122,7 @@ public interface ISpConfiguration extends Serializable { * * @return */ - List getTargetsWithNoBaseIdInternalProcessingRestriction(); + Set getTargetsWithNoBaseIdInternalProcessingRestriction(); /** * Get the {@link List} of identifier's that indicates no baseID transfer @@ -131,7 +132,7 @@ public interface ISpConfiguration extends Serializable { * * @return */ - List getTargetsWithNoBaseIdTransferRestriction(); + Set getTargetsWithNoBaseIdTransferRestriction(); /** * Get the List eIDAS LoA that are required by this service provider. diff --git a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/idp/conf/SpConfigurationImpl.java b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/idp/conf/SpConfigurationImpl.java index de54d103..2f4e18fa 100644 --- a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/idp/conf/SpConfigurationImpl.java +++ b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/idp/conf/SpConfigurationImpl.java @@ -20,8 +20,10 @@ package at.gv.egiz.eaaf.core.impl.idp.conf; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,8 +40,8 @@ public class SpConfigurationImpl implements ISpConfiguration { private static final Logger log = LoggerFactory.getLogger(SpConfigurationImpl.class); private final Map spConfiguration; - private final List targetAreasWithNoInteralBaseIdRestriction; - private final List targetAreasWithNoBaseIdTransmissionRestriction; + private final Set targetAreasWithNoInteralBaseIdRestriction; + private final Set targetAreasWithNoBaseIdTransmissionRestriction; /** * Service-provider configuration holder. @@ -52,21 +54,19 @@ public class SpConfigurationImpl implements ISpConfiguration { // set oa specific restrictions targetAreasWithNoInteralBaseIdRestriction = Collections - .unmodifiableList(KeyValueUtils.getListOfCsvValues(authConfig.getBasicConfiguration( - CONFIG_KEY_RESTRICTIONS_BASEID_INTERNAL, EaafConstants.URN_PREFIX_CDID))); + .unmodifiableSet(new HashSet(KeyValueUtils.getListOfCsvValues(authConfig.getBasicConfiguration( + CONFIG_KEY_RESTRICTIONS_BASEID_INTERNAL, EaafConstants.URN_PREFIX_CDID)))); targetAreasWithNoBaseIdTransmissionRestriction = Collections - .unmodifiableList(KeyValueUtils.getListOfCsvValues(authConfig.getBasicConfiguration( - CONFIG_KEY_RESTRICTIONS_BASEID_TRANSMISSION, EaafConstants.URN_PREFIX_CDID))); + .unmodifiableSet(new HashSet(KeyValueUtils.getListOfCsvValues(authConfig.getBasicConfiguration( + CONFIG_KEY_RESTRICTIONS_BASEID_TRANSMISSION, EaafConstants.URN_PREFIX_CDID)))); if (log.isTraceEnabled()) { log.trace("Internal policy for OA: " + getUniqueIdentifier()); - for (final String el : targetAreasWithNoInteralBaseIdRestriction) { - log.trace(" Allow baseID processing for prefix " + el); - } - for (final String el : targetAreasWithNoBaseIdTransmissionRestriction) { - log.trace(" Allow baseID transfer for prefix " + el); - } + targetAreasWithNoInteralBaseIdRestriction.stream() + .forEach(el -> log.trace(" Allow baseID processing for prefix " + el)); + targetAreasWithNoBaseIdTransmissionRestriction.stream() + .forEach(el -> log.trace(" Allow baseID transfer for prefix " + el)); } } @@ -143,12 +143,12 @@ public class SpConfigurationImpl implements ISpConfiguration { } @Override - public final List getTargetsWithNoBaseIdInternalProcessingRestriction() { + public final Set getTargetsWithNoBaseIdInternalProcessingRestriction() { return this.targetAreasWithNoInteralBaseIdRestriction; } @Override - public final List getTargetsWithNoBaseIdTransferRestriction() { + public final Set getTargetsWithNoBaseIdTransferRestriction() { return this.targetAreasWithNoBaseIdTransmissionRestriction; } diff --git a/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/GenericSignatureVerificationResponse.java b/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/GenericSignatureVerificationResponse.java index 28501c54..6006b731 100644 --- a/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/GenericSignatureVerificationResponse.java +++ b/eaaf_modules/eaaf_module_moa-sig/src/main/java/at/gv/egiz/eaaf/modules/sigverify/moasig/impl/data/GenericSignatureVerificationResponse.java @@ -3,6 +3,7 @@ package at.gv.egiz.eaaf.modules.sigverify.moasig.impl.data; import java.io.Serializable; import java.security.cert.CertificateException; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.List; @@ -54,7 +55,7 @@ public class GenericSignatureVerificationResponse private ExtendedCertificateValidation extendedCertificateValidation; - private List formValidationResults = new ArrayList<>(); + private List formValidationResults = null; @Override public Date getSigningDateTime() { @@ -105,6 +106,17 @@ public class GenericSignatureVerificationResponse } + @Override + public List getFormValidationResults() { + if (formValidationResults == null) { + return Collections.emptyList(); + + } else { + return formValidationResults; + + } + } + /** * Set signature creation timestramp. * @@ -161,7 +173,13 @@ public class GenericSignatureVerificationResponse if (formCheckResult != null) { for (Object elObj : formCheckResult) { if (elObj instanceof AdESFormResults) { - AdESFormResults el = (AdESFormResults)elObj; + AdESFormResults el = (AdESFormResults)elObj; + + if (formValidationResults == null) { + formValidationResults = new ArrayList<>(); + + } + formValidationResults.add(ExtendedResult.builder() .code(el.getCode()) .info(el.getName()) diff --git a/eaaf_modules/eaaf_module_pvp2_core/pom.xml b/eaaf_modules/eaaf_module_pvp2_core/pom.xml index ee20ef56..1ce539ee 100644 --- a/eaaf_modules/eaaf_module_pvp2_core/pom.xml +++ b/eaaf_modules/eaaf_module_pvp2_core/pom.xml @@ -56,6 +56,12 @@ org.cryptacular cryptacular + + + org.bouncycastle + bcprov-jdk15on + + org.bouncycastle -- cgit v1.2.3