From d754d9af2e9bf0660a0dcedfcd3a98588899e27a Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Wed, 2 Sep 2020 14:13:40 +0200 Subject: opimize logging of BpkBuilder implementation --- .../eaaf/core/impl/idp/auth/builder/BpkBuilder.java | 19 +++++++++++-------- .../resources/messages/eaaf_core_messages.properties | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java index 7b9ffcf0..81d50d76 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/BpkBuilder.java @@ -28,19 +28,19 @@ import java.util.Date; import java.util.Map.Entry; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; +import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.Base64Utils; import at.gv.egiz.eaaf.core.api.data.EaafConstants; import at.gv.egiz.eaaf.core.exceptions.EaafBuilderException; -import at.gv.egiz.eaaf.core.impl.data.Pair; import lombok.extern.slf4j.Slf4j; @@ -53,9 +53,12 @@ import lombok.extern.slf4j.Slf4j; */ @Slf4j public class BpkBuilder { + + private static final String ERROR_CODE_33 = "builder.33"; private static final String ERROR_MSG_WRONG_TARGET_FORMAT = "bPK-target format must be full URI"; + /** * Calculates an area specific unique person-identifier from a baseID. * @@ -88,17 +91,17 @@ public class BpkBuilder { public static Pair generateAreaSpecificPersonIdentifier(final String baseID, final String baseIdType, final String targetIdentifier) throws EaafBuilderException { if (StringUtils.isEmpty(baseID)) { - throw new EaafBuilderException("builder.00", new Object[] { "baseID is empty or null" }, + throw new EaafBuilderException(ERROR_CODE_33, new Object[] { "baseID is empty or null" }, "BaseId is empty or null"); } if (StringUtils.isEmpty(baseIdType)) { - throw new EaafBuilderException("builder.00", + throw new EaafBuilderException(ERROR_CODE_33, new Object[] { "the type of baseID is empty or null" }, "Type of baseId is empty or null"); } if (StringUtils.isEmpty(targetIdentifier)) { - throw new EaafBuilderException("builder.00", + throw new EaafBuilderException(ERROR_CODE_33, new Object[] { "SP specific target identifier is empty or null" }, "SP specific target identifier is empty or null"); } @@ -130,7 +133,7 @@ public class BpkBuilder { return buildEidasIdentifer(baseID, baseIdType, cititzenCountryCode, eidasOutboundCountry); } else { - throw new EaafBuilderException("builder.00", + throw new EaafBuilderException(ERROR_CODE_33, new Object[] { "Target identifier: " + targetIdentifier + " is NOT allowed or unknown" }, "Target identifier: " + targetIdentifier + " is NOT allowed or unknown"); } @@ -145,7 +148,7 @@ public class BpkBuilder { } else { log.warn("Get unique identifier for target: " + baseIdType + " but target: " + targetIdentifier + " is required!"); - throw new EaafBuilderException("builder.00", + throw new EaafBuilderException(ERROR_CODE_33, new Object[] { "Get unique identifier for target: " + baseIdType + " but target: " + targetIdentifier + " is required" }, "Get unique identifier for target: " + baseIdType + " but target: " + targetIdentifier @@ -373,7 +376,7 @@ public class BpkBuilder { return hashBase64; } catch (final Exception ex) { - throw new EaafBuilderException("builder.00", new Object[] { "bPK/wbPK", ex.toString() }, + throw new EaafBuilderException(ERROR_CODE_33, new Object[] {ex.toString() }, ex.getMessage(), ex); } diff --git a/eaaf_core/src/main/resources/messages/eaaf_core_messages.properties b/eaaf_core/src/main/resources/messages/eaaf_core_messages.properties index 064554b9..ff0be478 100644 --- a/eaaf_core/src/main/resources/messages/eaaf_core_messages.properties +++ b/eaaf_core/src/main/resources/messages/eaaf_core_messages.properties @@ -4,4 +4,4 @@ builder.08=Authentication process could NOT completed. Reason: {0} builder.30=Decrypted bPK target: {0} does not match to required target: {1} builder.31=Encrypted bPK has a suspect format and consists of #{0} elements builder.32=bPK-target format must be full URI - +builder.33=bPK caluclation not possible. Reason: {0} -- cgit v1.2.3