From ced5a1b911af0ae62229645ca08a9ecc5225783b Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Tue, 6 Jun 2023 17:02:04 +0200 Subject: fix(core): add @JsonValue annotation to SpMandateModes enum to serialize the String value --- .../api/data/ExtendedPvpAttributeDefinitions.java | 42 +++++++++++----------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'eaaf_core_api/src/main') diff --git a/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/ExtendedPvpAttributeDefinitions.java b/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/ExtendedPvpAttributeDefinitions.java index 771829c9..1ec33533 100644 --- a/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/ExtendedPvpAttributeDefinitions.java +++ b/eaaf_core_api/src/main/java/at/gv/egiz/eaaf/core/api/data/ExtendedPvpAttributeDefinitions.java @@ -23,12 +23,13 @@ import java.util.NoSuchElementException; import java.util.stream.Stream; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; public interface ExtendedPvpAttributeDefinitions extends PvpAttributeDefinitions { String EIDAS_CONNECTOR_UNIQUEID_NAME = "urn:eidgvat:attributes.eidas.uniqueId"; String EIDAS_CONNECTOR_UNIQUEID_FRIENDLY_NAME = "EidasNode-UniqueId"; - + String SP_UNIQUEID_NAME = "urn:eidgvat:attributes.ServiceProviderUniqueId"; String SP_UNIQUEID_FRIENDLY_NAME = "ServiceProvider-UniqueId"; @@ -43,39 +44,40 @@ public interface ExtendedPvpAttributeDefinitions extends PvpAttributeDefinitions String SP_USED_MANDATE_TYPE_NAME = "urn:eidgvat:attributes.ServiceProviderMandateType"; String SP_USED_MANDATE_TYPE_FRIENDLY_NAME = "ServiceProvider-MandateType"; - + String SP_REQUIRED_ATTRIBUTES_NAME = "urn:eidgvat:attributes.RequiredAttributes"; String SP_REQUIRED_ATTRIBUTES_FRIENDLY_NAME = "ServiceProvider-RequiredAttributes"; - - + enum SpMandateModes { - NONE("none"), + NONE("none"), NATURAL("natural"), NATURAL_FORCE("forceNatural"), - LEGAL("legal"), + LEGAL("legal"), LEGAL_FORCE("forceLegal"), BOTH("all"), BOTH_FORCE("forceAll"); - + private final String mandateMode; SpMandateModes(final String mandateMode) { this.mandateMode = mandateMode; } - + /** * Get Service-Provider mandate-mode from String representation. * * @param s mandate-mode String parameter - * @return mandate mode, or {@link NoSuchElementException} if mode is unknown + * @return mandate mode, or {@link NoSuchElementException} if mode is unknown */ @JsonCreator public static SpMandateModes fromString(final String mode) { - return Stream.of(SpMandateModes.values()) - .filter(el -> el.getMode().equals(mode)) - .findFirst() - .get(); - + return mode == null + ? SpMandateModes.NONE + : Stream.of(SpMandateModes.values()) + .filter(el -> el.getMode().equals(mode)) + .findFirst() + .get(); + } /** @@ -86,19 +88,19 @@ public interface ExtendedPvpAttributeDefinitions extends PvpAttributeDefinitions public String getMode() { return this.mandateMode; } - + @Override + @JsonValue public String toString() { return getMode(); } - + } - + String EID_BINDING_PUBLIC_KEY_NAME = "urn:eidgvat:attributes.binding.pubkey"; String EID_BINDING_PUBLIC_KEY_FRIENDLY_NAME = "Binding-PublicKey"; - /* Attributes for E-ID */ String EID_ENCRYPTED_SOURCEID_NAME = "urn:eidgvat:attributes.vsz.value"; String EID_ENCRYPTED_SOURCEID_FRIENDLY_NAME = "vSZ"; @@ -114,10 +116,10 @@ public interface ExtendedPvpAttributeDefinitions extends PvpAttributeDefinitions String EID_TRANSACTION_ID_NAME = "urn:eidgvat:attributes.transactionId"; String EID_TRANSACTION_ID_FRIENDLY_NAME = "transactionId"; - + String EID_PII_TRANSACTION_ID_NAME = "urn:eidgvat:attributes.piiTransactionId"; String EID_PII_TRANSACTION_ID_FRIENDLY_NAME = "piiTransactionId"; - + String EID_MIS_MANDATE_NAME = "urn:eidgvat:attributes.mis.mandate"; String EID_MIS_MANDATE_FRIENDLY_NAME = "mandate"; -- cgit v1.2.3