Skip to content

Commit bc9db69

Browse files
committed
SDK-2815: Add support for Digital IDs in IDV
1 parent dfb332c commit bc9db69

14 files changed

Lines changed: 488 additions & 9 deletions
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.yoti.api.client.docs.session.create.filters;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
/**
6+
* Identifies a digital ID provider (e.g. {@code DIGILOCKER}) that is allowed
7+
* to satisfy a {@link DocumentFilter}.
8+
*/
9+
public class AllowedProviderPayload {
10+
11+
@JsonProperty("name")
12+
private final String name;
13+
14+
private AllowedProviderPayload(String name) {
15+
this.name = name;
16+
}
17+
18+
public static AllowedProviderPayload.Builder builder() {
19+
return new AllowedProviderPayload.Builder();
20+
}
21+
22+
/**
23+
* The name of the allowed digital ID provider
24+
*
25+
* @return the provider name
26+
*/
27+
public String getName() {
28+
return name;
29+
}
30+
31+
public static class Builder {
32+
33+
private String name;
34+
35+
private Builder() {}
36+
37+
/**
38+
* Sets the name of the digital ID provider
39+
*
40+
* @param name the provider name
41+
* @return the builder
42+
*/
43+
public Builder withName(String name) {
44+
this.name = name;
45+
return this;
46+
}
47+
48+
public AllowedProviderPayload build() {
49+
return new AllowedProviderPayload(name);
50+
}
51+
52+
}
53+
54+
}

yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/filters/DocumentFilter.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.yoti.api.client.docs.session.create.filters;
22

3+
import java.util.List;
4+
35
import com.fasterxml.jackson.annotation.JsonProperty;
46

57
/**
@@ -17,10 +19,19 @@ public abstract class DocumentFilter {
1719
@JsonProperty("allow_expired_documents")
1820
private final Boolean allowExpiredDocuments;
1921

20-
DocumentFilter(String type, Boolean allowNonLatinDocuments, Boolean allowExpiredDocuments) {
22+
@JsonProperty("allow_digital_ids")
23+
private final Boolean allowDigitalIds;
24+
25+
@JsonProperty("allowed_providers")
26+
private final List<AllowedProviderPayload> allowedProviders;
27+
28+
DocumentFilter(String type, Boolean allowNonLatinDocuments, Boolean allowExpiredDocuments,
29+
Boolean allowDigitalIds, List<AllowedProviderPayload> allowedProviders) {
2130
this.type = type;
2231
this.allowNonLatinDocuments = allowNonLatinDocuments;
2332
this.allowExpiredDocuments = allowExpiredDocuments;
33+
this.allowDigitalIds = allowDigitalIds;
34+
this.allowedProviders = allowedProviders;
2435
}
2536

2637
/**
@@ -50,4 +61,22 @@ public Boolean getAllowExpiredDocuments() {
5061
return allowExpiredDocuments;
5162
}
5263

64+
/**
65+
* Whether to allow digital IDs to satisfy the filter
66+
*
67+
* @return boolean flag
68+
*/
69+
public Boolean getAllowDigitalIds() {
70+
return allowDigitalIds;
71+
}
72+
73+
/**
74+
* The list of digital ID providers that are allowed to satisfy the filter
75+
*
76+
* @return the allowed providers
77+
*/
78+
public List<AllowedProviderPayload> getAllowedProviders() {
79+
return allowedProviders;
80+
}
81+
5382
}

yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/filters/DocumentRestrictionsFilter.java

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ public class DocumentRestrictionsFilter extends DocumentFilter {
1717
@JsonProperty("documents")
1818
private final List<DocumentRestriction> documents;
1919

20-
private DocumentRestrictionsFilter(String inclusion, List<DocumentRestriction> documents, Boolean allowNonLatinDocuments, Boolean allowExpiredDocuments) {
21-
super(DocScanConstants.DOCUMENT_RESTRICTIONS, allowNonLatinDocuments, allowExpiredDocuments);
20+
private DocumentRestrictionsFilter(String inclusion, List<DocumentRestriction> documents, Boolean allowNonLatinDocuments,
21+
Boolean allowExpiredDocuments, Boolean allowDigitalIds, List<AllowedProviderPayload> allowedProviders) {
22+
super(DocScanConstants.DOCUMENT_RESTRICTIONS, allowNonLatinDocuments, allowExpiredDocuments, allowDigitalIds, allowedProviders);
2223
this.inclusion = inclusion;
2324
this.documents = documents;
2425
}
@@ -41,6 +42,8 @@ public static class Builder {
4142
private final List<DocumentRestriction> documents;
4243
private Boolean allowNonLatinDocuments;
4344
private Boolean allowExpiredDocuments;
45+
private Boolean allowDigitalIds;
46+
private List<AllowedProviderPayload> allowedProviders;
4447

4548
private Builder() {
4649
this.documents = new ArrayList<>();
@@ -111,9 +114,45 @@ public Builder withAllowExpiredDocuments(boolean allowExpiredDocuments) {
111114
return this;
112115
}
113116

117+
/**
118+
* Sets the flag to allow/disallow digital IDs
119+
*
120+
* @param allowDigitalIds the flag
121+
* @return the builder
122+
*/
123+
public Builder withAllowDigitalIds(boolean allowDigitalIds) {
124+
this.allowDigitalIds = allowDigitalIds;
125+
return this;
126+
}
127+
128+
/**
129+
* Sets the list of digital ID providers that are allowed to satisfy the filter
130+
*
131+
* @param allowedProviders the allowed providers
132+
* @return the builder
133+
*/
134+
public Builder withAllowedProviders(List<AllowedProviderPayload> allowedProviders) {
135+
this.allowedProviders = allowedProviders;
136+
return this;
137+
}
138+
139+
/**
140+
* Adds a digital ID provider, by name, to the list of allowed providers
141+
*
142+
* @param name the provider name
143+
* @return the builder
144+
*/
145+
public Builder withAllowedProvider(String name) {
146+
if (this.allowedProviders == null) {
147+
this.allowedProviders = new ArrayList<>();
148+
}
149+
this.allowedProviders.add(AllowedProviderPayload.builder().withName(name).build());
150+
return this;
151+
}
152+
114153
public DocumentRestrictionsFilter build() {
115154
notNullOrEmpty(inclusion, "inclusion");
116-
return new DocumentRestrictionsFilter(inclusion, documents, allowNonLatinDocuments, allowExpiredDocuments);
155+
return new DocumentRestrictionsFilter(inclusion, documents, allowNonLatinDocuments, allowExpiredDocuments, allowDigitalIds, allowedProviders);
117156
}
118157

119158
}

yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/create/filters/OrthogonalRestrictionsFilter.java

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.yoti.api.client.docs.session.create.filters;
22

3+
import java.util.ArrayList;
34
import java.util.List;
45

56
import com.yoti.api.client.docs.DocScanConstants;
@@ -14,8 +15,9 @@ public class OrthogonalRestrictionsFilter extends DocumentFilter {
1415
@JsonProperty("type_restriction")
1516
private final TypeRestriction typeRestriction;
1617

17-
private OrthogonalRestrictionsFilter(CountryRestriction countryRestriction, TypeRestriction typeRestriction, Boolean allowNonLatinDocuments, Boolean allowExpiredDocuments) {
18-
super(DocScanConstants.ORTHOGONAL_RESTRICTIONS, allowNonLatinDocuments, allowExpiredDocuments);
18+
private OrthogonalRestrictionsFilter(CountryRestriction countryRestriction, TypeRestriction typeRestriction, Boolean allowNonLatinDocuments,
19+
Boolean allowExpiredDocuments, Boolean allowDigitalIds, List<AllowedProviderPayload> allowedProviders) {
20+
super(DocScanConstants.ORTHOGONAL_RESTRICTIONS, allowNonLatinDocuments, allowExpiredDocuments, allowDigitalIds, allowedProviders);
1921
this.countryRestriction = countryRestriction;
2022
this.typeRestriction = typeRestriction;
2123
}
@@ -38,6 +40,8 @@ public static class Builder {
3840
private TypeRestriction typeRestriction;
3941
private Boolean allowNonLatinDocuments;
4042
private Boolean allowExpiredDocuments;
43+
private Boolean allowDigitalIds;
44+
private List<AllowedProviderPayload> allowedProviders;
4145

4246
private Builder() {}
4347

@@ -107,8 +111,44 @@ public Builder withAllowExpiredDocuments(boolean allowExpiredDocuments) {
107111
return this;
108112
}
109113

114+
/**
115+
* Sets the flag to allow/disallow digital IDs
116+
*
117+
* @param allowDigitalIds the flag
118+
* @return the builder
119+
*/
120+
public Builder withAllowDigitalIds(boolean allowDigitalIds) {
121+
this.allowDigitalIds = allowDigitalIds;
122+
return this;
123+
}
124+
125+
/**
126+
* Sets the list of digital ID providers that are allowed to satisfy the filter
127+
*
128+
* @param allowedProviders the allowed providers
129+
* @return the builder
130+
*/
131+
public Builder withAllowedProviders(List<AllowedProviderPayload> allowedProviders) {
132+
this.allowedProviders = allowedProviders;
133+
return this;
134+
}
135+
136+
/**
137+
* Adds a digital ID provider, by name, to the list of allowed providers
138+
*
139+
* @param name the provider name
140+
* @return the builder
141+
*/
142+
public Builder withAllowedProvider(String name) {
143+
if (this.allowedProviders == null) {
144+
this.allowedProviders = new ArrayList<>();
145+
}
146+
this.allowedProviders.add(AllowedProviderPayload.builder().withName(name).build());
147+
return this;
148+
}
149+
110150
public OrthogonalRestrictionsFilter build() {
111-
return new OrthogonalRestrictionsFilter(countryRestriction, typeRestriction, allowNonLatinDocuments, allowExpiredDocuments);
151+
return new OrthogonalRestrictionsFilter(countryRestriction, typeRestriction, allowNonLatinDocuments, allowExpiredDocuments, allowDigitalIds, allowedProviders);
112152
}
113153

114154
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.yoti.api.client.docs.session.retrieve;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
/**
6+
* Describes the error that occurred when a digital ID share was not completed successfully.
7+
*/
8+
public class DigitalIdShareErrorResponse {
9+
10+
@JsonProperty("code")
11+
private String code;
12+
13+
@JsonProperty("description")
14+
private String description;
15+
16+
public String getCode() {
17+
return code;
18+
}
19+
20+
public String getDescription() {
21+
return description;
22+
}
23+
24+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.yoti.api.client.docs.session.retrieve;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
/**
6+
* Represents a digital ID share that was performed during a session. A share that
7+
* was not completed successfully will have an {@link #getError() error}.
8+
*/
9+
public class DigitalIdShareResponse {
10+
11+
@JsonProperty("id")
12+
private String id;
13+
14+
@JsonProperty("document_type")
15+
private String documentType;
16+
17+
@JsonProperty("issuing_country")
18+
private String issuingCountry;
19+
20+
@JsonProperty("provider")
21+
private String provider;
22+
23+
@JsonProperty("created_at")
24+
private String createdAt;
25+
26+
@JsonProperty("last_updated")
27+
private String lastUpdated;
28+
29+
@JsonProperty("resource_id")
30+
private String resourceId;
31+
32+
@JsonProperty("error")
33+
private DigitalIdShareErrorResponse error;
34+
35+
public String getId() {
36+
return id;
37+
}
38+
39+
public String getDocumentType() {
40+
return documentType;
41+
}
42+
43+
public String getIssuingCountry() {
44+
return issuingCountry;
45+
}
46+
47+
public String getProvider() {
48+
return provider;
49+
}
50+
51+
public String getCreatedAt() {
52+
return createdAt;
53+
}
54+
55+
public String getLastUpdated() {
56+
return lastUpdated;
57+
}
58+
59+
/**
60+
* The id of the resource linked to the share
61+
*
62+
* @return the resource id
63+
*/
64+
public String getResourceId() {
65+
return resourceId;
66+
}
67+
68+
/**
69+
* The error that occurred if the share was not completed successfully, otherwise {@code null}
70+
*
71+
* @return the error, may be {@code null}
72+
*/
73+
public DigitalIdShareErrorResponse getError() {
74+
return error;
75+
}
76+
77+
}

yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/retrieve/GetSessionResult.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public class GetSessionResult {
5050
@JsonProperty("import_token")
5151
private ImportTokenResponse importToken;
5252

53+
@JsonProperty("digital_id_shares")
54+
private List<DigitalIdShareResponse> digitalIdShares;
55+
5356
public long getClientSessionTokenTtl() {
5457
return clientSessionTokenTtl;
5558
}
@@ -102,6 +105,15 @@ public ImportTokenResponse getImportToken() {
102105
return importToken;
103106
}
104107

108+
/**
109+
* The digital ID shares that were performed during the session
110+
*
111+
* @return the digital ID shares
112+
*/
113+
public List<DigitalIdShareResponse> getDigitalIdShares() {
114+
return digitalIdShares;
115+
}
116+
105117
public ResourceContainer getResourcesForCheck(String checkId) {
106118
CheckResponse checkResponse = this.checks.stream()
107119
.filter(check -> check.getId().equals(checkId))

0 commit comments

Comments
 (0)