diff --git a/pom.xml b/pom.xml index 7448e26..460846e 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 laverca-rest laverca-rest - 1.3.3 + 1.4.0 Laverca REST MSS client diff --git a/src/main/java/fi/methics/laverca/rest/json/AdditionalService.java b/src/main/java/fi/methics/laverca/rest/json/AdditionalService.java index 7198532..3dd7f5c 100644 --- a/src/main/java/fi/methics/laverca/rest/json/AdditionalService.java +++ b/src/main/java/fi/methics/laverca/rest/json/AdditionalService.java @@ -5,14 +5,34 @@ import com.google.gson.annotations.SerializedName; + /** * MSS AdditionalService that can be used to amend the request */ public class AdditionalService { public static final AdditionalService VALIDATION_AS = new AdditionalService("http://uri.etsi.org/TS102204/v1.1.2#validate"); - public static final String BATCH_AS = "http://www.methics.fi/KiuruMSSP/v5.0.0#batchsign"; + public static final String BATCH_AS = "http://www.methics.fi/KiuruMSSP/v5.0.0#batchsign"; + public static final String NO_SPAM_AS = "http://mss.ficom.fi/TS102204/v1.0.0#noSpam"; + public static final String EVENT_ID_AS = "http://mss.ficom.fi/TS102204/v1.0.0#eventId"; + public static final String USER_LANG_AS = "http://mss.ficom.fi/TS102204/v1.0.0#userLang"; + public static final String PERSON_ID_AS = "http://mss.ficom.fi/TS102204/v1.0.0#personIdentity"; + public static final String VALIDATE_AS = "http://mss.ficom.fi/TS102204/v1.0.0#validate"; + public static final String DISPLAY_NAME_AS = "http://mss.ficom.fi/TS102204/v1.0.0#displayName"; + + @SerializedName("Description") + public String Description; // URI controlling parse of the rest of the data + + @SerializedName("EventID") + public EventID EventID; + + @SerializedName( "NoSpamCode") + public NoSpamCode NoSpamCode; + + @SerializedName("UserLang") + public UserLang UserLang; + /** * Default constructor */ @@ -28,7 +48,46 @@ public AdditionalService(final String description) { this.Description = description; } - @SerializedName("Description") - public String Description; // URI controlling parse of the rest of the data + /** + * Create a new Validation AdditionalService. + * @return AS + */ + public static AdditionalService createValidationService() { + return VALIDATION_AS; + } + /** + * Create a new Validation AdditionalService. + * @param eventid AP generated EventID to display to user + * @return AS + */ + public static AdditionalService createEventIdService(String eventid) { + AdditionalService as = new AdditionalService(EVENT_ID_AS); + as.EventID = new EventID(eventid); + return as; + } + + /** + * Create a new NoSpamCode AdditionalService. + * @param validate Should the NoSpamCode be validated? + * @param nospam The NoSpamCode entered by user + * @return AS + */ + public static AdditionalService createNoSpamCodeService(boolean validate, String nospam) { + AdditionalService as = new AdditionalService(EVENT_ID_AS); + as.NoSpamCode = new NoSpamCode(validate, nospam); + return as; + } + + /** + * Create a new UserLang AdditionalService. + * @param language Should the NoSpamCode be validated? + * @return AS + */ + public static AdditionalService createNoSpamCodeService(String language) { + AdditionalService as = new AdditionalService(EVENT_ID_AS); + as.UserLang = new UserLang(language); + return as; + } + } diff --git a/src/main/java/fi/methics/laverca/rest/json/EventID.java b/src/main/java/fi/methics/laverca/rest/json/EventID.java new file mode 100644 index 0000000..c418298 --- /dev/null +++ b/src/main/java/fi/methics/laverca/rest/json/EventID.java @@ -0,0 +1,20 @@ +// +// (c) Copyright 2003-2023 Methics Oy. All rights reserved. +// +package fi.methics.laverca.rest.json; + +import com.google.gson.annotations.SerializedName; + +/** + * FiCom EventID AdditionalService element that delivers AP generated EventID to display to user. + */ +public class EventID { + + @SerializedName("Value") + public String Value; + + public EventID(String value) { + this.Value = value; + } + +} diff --git a/src/main/java/fi/methics/laverca/rest/json/NoSpamCode.java b/src/main/java/fi/methics/laverca/rest/json/NoSpamCode.java new file mode 100644 index 0000000..5ed57dd --- /dev/null +++ b/src/main/java/fi/methics/laverca/rest/json/NoSpamCode.java @@ -0,0 +1,25 @@ +// +// (c) Copyright 2003-2023 Methics Oy. All rights reserved. +// +package fi.methics.laverca.rest.json; + +import com.google.gson.annotations.SerializedName; + +/** + * FiCom NoSpamCode AdditionalService element that allows delivering NoSpamCode input by the user. + */ +public class NoSpamCode { + + // "yes" or "no" + @SerializedName("Verify") + public String Verify = "no"; + + @SerializedName("Code") + public String Code; + + public NoSpamCode(boolean verify, String code) { + this.Verify = verify ? "yes" : "no"; + this.Code = code; + } + +} diff --git a/src/main/java/fi/methics/laverca/rest/json/UserLang.java b/src/main/java/fi/methics/laverca/rest/json/UserLang.java new file mode 100644 index 0000000..a17ba62 --- /dev/null +++ b/src/main/java/fi/methics/laverca/rest/json/UserLang.java @@ -0,0 +1,21 @@ +// +// (c) Copyright 2003-2023 Methics Oy. All rights reserved. +// +package fi.methics.laverca.rest.json; + +import com.google.gson.annotations.SerializedName; + +/** + * FiCom UserLang AdditionalService element used to deliver user language. + */ +public class UserLang { + + @SerializedName("Value") + public String Value; + + public UserLang(String value) { + this.Value = value; + } + + +} diff --git a/src/main/java/fi/methics/laverca/rest/util/MSS_SignatureReqBuilder.java b/src/main/java/fi/methics/laverca/rest/util/MSS_SignatureReqBuilder.java index fd8b71c..d2bc460 100644 --- a/src/main/java/fi/methics/laverca/rest/util/MSS_SignatureReqBuilder.java +++ b/src/main/java/fi/methics/laverca/rest/util/MSS_SignatureReqBuilder.java @@ -8,6 +8,7 @@ import java.util.UUID; import fi.methics.laverca.rest.MssClient; +import fi.methics.laverca.rest.json.AdditionalService; import fi.methics.laverca.rest.json.BatchSignatureReq; import fi.methics.laverca.rest.json.MSS_BatchSignatureReq; import fi.methics.laverca.rest.json.MSS_SignatureReq; @@ -35,6 +36,7 @@ public class MSS_SignatureReqBuilder { private String mssFormat; private int timeout; + private List services = new ArrayList<>(); private List batchReqs = new ArrayList<>(); public MSS_SignatureReqBuilder() { @@ -56,6 +58,9 @@ public MSS_SignatureReq build() { if (this.timeout > 0) { req.TimeOut = String.valueOf(this.timeout); } + if (this.services.size() > 0) { + req.AdditionalServices = this.services; + } return req; } else { MSS_BatchSignatureReq req = new MSS_BatchSignatureReq(this.msisdn, this.dtbs, this.dtbd); @@ -70,6 +75,9 @@ public MSS_SignatureReq build() { for (BatchSignatureReq br : this.batchReqs) { req.addBatchSignatureRequest(br); } + if (this.services.size() > 0) { + req.AdditionalServices = this.services; + } return req; } } @@ -158,6 +166,16 @@ public MSS_SignatureReqBuilder withSignatureProfile(String signatureprofile) { return this; } + /** + * Add an AdditionalService + * @param as AdditionalService + * @return this builder + */ + public MSS_SignatureReqBuilder withAdditionalService(AdditionalService as) { + this.services.add(as); + return this; + } + /** * Set timeout in milliseconds *

Default is 60000 ms (60 sec)