Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for FiCom AdditionalServices #3

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>laverca-rest</groupId>
<artifactId>laverca-rest</artifactId>
<version>1.3.3</version>
<version>1.4.0</version>
<name>Laverca REST MSS client</name>

<build>
Expand Down
65 changes: 62 additions & 3 deletions src/main/java/fi/methics/laverca/rest/json/AdditionalService.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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;
}

}
20 changes: 20 additions & 0 deletions src/main/java/fi/methics/laverca/rest/json/EventID.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
25 changes: 25 additions & 0 deletions src/main/java/fi/methics/laverca/rest/json/NoSpamCode.java
Original file line number Diff line number Diff line change
@@ -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;
}

}
21 changes: 21 additions & 0 deletions src/main/java/fi/methics/laverca/rest/json/UserLang.java
Original file line number Diff line number Diff line change
@@ -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;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -35,6 +36,7 @@ public class MSS_SignatureReqBuilder {
private String mssFormat;
private int timeout;

private List<AdditionalService> services = new ArrayList<>();
private List<BatchSignatureReq> batchReqs = new ArrayList<>();

public MSS_SignatureReqBuilder() {
Expand All @@ -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);
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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
* <p>Default is 60000 ms (60 sec)
Expand Down
Loading