Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.yoti.api.client.docs.session.create.filters;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Identifies a digital ID provider (e.g. {@code DIGILOCKER}) that is allowed
* to satisfy a {@link DocumentFilter}.
*/
public class AllowedProviderPayload {

@JsonProperty("name")
private final String name;

private AllowedProviderPayload(String name) {
this.name = name;
}

public static AllowedProviderPayload.Builder builder() {
return new AllowedProviderPayload.Builder();
}

/**
* The name of the allowed digital ID provider
*
* @return the provider name
*/
public String getName() {
return name;
}

public static class Builder {

private String name;

private Builder() {}

/**
* Sets the name of the digital ID provider
*
* @param name the provider name
* @return the builder
*/
public Builder withName(String name) {
this.name = name;
return this;
}

public AllowedProviderPayload build() {
return new AllowedProviderPayload(name);
}

}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.yoti.api.client.docs.session.create.filters;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

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

DocumentFilter(String type, Boolean allowNonLatinDocuments, Boolean allowExpiredDocuments) {
@JsonProperty("allow_digital_ids")
private final Boolean allowDigitalIds;

@JsonProperty("allowed_providers")
private final List<AllowedProviderPayload> allowedProviders;

DocumentFilter(String type, Boolean allowNonLatinDocuments, Boolean allowExpiredDocuments,
Boolean allowDigitalIds, List<AllowedProviderPayload> allowedProviders) {
this.type = type;
this.allowNonLatinDocuments = allowNonLatinDocuments;
this.allowExpiredDocuments = allowExpiredDocuments;
this.allowDigitalIds = allowDigitalIds;
this.allowedProviders = allowedProviders;
}

/**
Expand Down Expand Up @@ -50,4 +61,22 @@ public Boolean getAllowExpiredDocuments() {
return allowExpiredDocuments;
}

/**
* Whether to allow digital IDs to satisfy the filter
*
* @return boolean flag
*/
public Boolean getAllowDigitalIds() {
return allowDigitalIds;
}

/**
* The list of digital ID providers that are allowed to satisfy the filter
*
* @return the allowed providers
*/
public List<AllowedProviderPayload> getAllowedProviders() {
return allowedProviders;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public class DocumentRestrictionsFilter extends DocumentFilter {
@JsonProperty("documents")
private final List<DocumentRestriction> documents;

private DocumentRestrictionsFilter(String inclusion, List<DocumentRestriction> documents, Boolean allowNonLatinDocuments, Boolean allowExpiredDocuments) {
super(DocScanConstants.DOCUMENT_RESTRICTIONS, allowNonLatinDocuments, allowExpiredDocuments);
private DocumentRestrictionsFilter(String inclusion, List<DocumentRestriction> documents, Boolean allowNonLatinDocuments,
Boolean allowExpiredDocuments, Boolean allowDigitalIds, List<AllowedProviderPayload> allowedProviders) {
super(DocScanConstants.DOCUMENT_RESTRICTIONS, allowNonLatinDocuments, allowExpiredDocuments, allowDigitalIds, allowedProviders);
this.inclusion = inclusion;
this.documents = documents;
}
Expand All @@ -41,6 +42,8 @@ public static class Builder {
private final List<DocumentRestriction> documents;
private Boolean allowNonLatinDocuments;
private Boolean allowExpiredDocuments;
private Boolean allowDigitalIds;
private List<AllowedProviderPayload> allowedProviders;

private Builder() {
this.documents = new ArrayList<>();
Expand Down Expand Up @@ -111,9 +114,45 @@ public Builder withAllowExpiredDocuments(boolean allowExpiredDocuments) {
return this;
}

/**
* Sets the flag to allow/disallow digital IDs
*
* @param allowDigitalIds the flag
* @return the builder
*/
public Builder withAllowDigitalIds(boolean allowDigitalIds) {
this.allowDigitalIds = allowDigitalIds;
return this;
}

/**
* Sets the list of digital ID providers that are allowed to satisfy the filter
*
* @param allowedProviders the allowed providers
* @return the builder
*/
public Builder withAllowedProviders(List<AllowedProviderPayload> allowedProviders) {
this.allowedProviders = allowedProviders;
return this;
}

/**
* Adds a digital ID provider, by name, to the list of allowed providers
*
* @param name the provider name
* @return the builder
*/
public Builder withAllowedProvider(String name) {
if (this.allowedProviders == null) {
this.allowedProviders = new ArrayList<>();
}
this.allowedProviders.add(AllowedProviderPayload.builder().withName(name).build());
return this;
}

public DocumentRestrictionsFilter build() {
notNullOrEmpty(inclusion, "inclusion");
return new DocumentRestrictionsFilter(inclusion, documents, allowNonLatinDocuments, allowExpiredDocuments);
return new DocumentRestrictionsFilter(inclusion, documents, allowNonLatinDocuments, allowExpiredDocuments, allowDigitalIds, allowedProviders);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.yoti.api.client.docs.session.create.filters;

import java.util.ArrayList;
import java.util.List;

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

private OrthogonalRestrictionsFilter(CountryRestriction countryRestriction, TypeRestriction typeRestriction, Boolean allowNonLatinDocuments, Boolean allowExpiredDocuments) {
super(DocScanConstants.ORTHOGONAL_RESTRICTIONS, allowNonLatinDocuments, allowExpiredDocuments);
private OrthogonalRestrictionsFilter(CountryRestriction countryRestriction, TypeRestriction typeRestriction, Boolean allowNonLatinDocuments,
Boolean allowExpiredDocuments, Boolean allowDigitalIds, List<AllowedProviderPayload> allowedProviders) {
super(DocScanConstants.ORTHOGONAL_RESTRICTIONS, allowNonLatinDocuments, allowExpiredDocuments, allowDigitalIds, allowedProviders);
this.countryRestriction = countryRestriction;
this.typeRestriction = typeRestriction;
}
Expand All @@ -38,6 +40,8 @@ public static class Builder {
private TypeRestriction typeRestriction;
private Boolean allowNonLatinDocuments;
private Boolean allowExpiredDocuments;
private Boolean allowDigitalIds;
private List<AllowedProviderPayload> allowedProviders;

private Builder() {}

Expand Down Expand Up @@ -107,8 +111,44 @@ public Builder withAllowExpiredDocuments(boolean allowExpiredDocuments) {
return this;
}

/**
* Sets the flag to allow/disallow digital IDs
*
* @param allowDigitalIds the flag
* @return the builder
*/
public Builder withAllowDigitalIds(boolean allowDigitalIds) {
this.allowDigitalIds = allowDigitalIds;
return this;
}

/**
* Sets the list of digital ID providers that are allowed to satisfy the filter
*
* @param allowedProviders the allowed providers
* @return the builder
*/
public Builder withAllowedProviders(List<AllowedProviderPayload> allowedProviders) {
this.allowedProviders = allowedProviders;
return this;
}

/**
* Adds a digital ID provider, by name, to the list of allowed providers
*
* @param name the provider name
* @return the builder
*/
public Builder withAllowedProvider(String name) {
if (this.allowedProviders == null) {
this.allowedProviders = new ArrayList<>();
}
this.allowedProviders.add(AllowedProviderPayload.builder().withName(name).build());
return this;
}

public OrthogonalRestrictionsFilter build() {
return new OrthogonalRestrictionsFilter(countryRestriction, typeRestriction, allowNonLatinDocuments, allowExpiredDocuments);
return new OrthogonalRestrictionsFilter(countryRestriction, typeRestriction, allowNonLatinDocuments, allowExpiredDocuments, allowDigitalIds, allowedProviders);
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.yoti.api.client.docs.session.retrieve;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Describes the error that occurred when a digital ID share was not completed successfully.
*/
public class DigitalIdShareErrorResponse {

@JsonProperty("code")
private String code;

@JsonProperty("description")
private String description;

public String getCode() {
return code;
}

public String getDescription() {
return description;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.yoti.api.client.docs.session.retrieve;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Represents a digital ID share that was performed during a session. A share that
* was not completed successfully will have an {@link #getError() error}.
*/
public class DigitalIdShareResponse {

@JsonProperty("id")
private String id;

@JsonProperty("document_type")
private String documentType;

@JsonProperty("issuing_country")
private String issuingCountry;

@JsonProperty("provider")
private String provider;

@JsonProperty("created_at")
private String createdAt;

@JsonProperty("last_updated")
private String lastUpdated;

@JsonProperty("resource_id")
private String resourceId;

@JsonProperty("error")
private DigitalIdShareErrorResponse error;

public String getId() {
return id;
}

public String getDocumentType() {
return documentType;
}

public String getIssuingCountry() {
return issuingCountry;
}

public String getProvider() {
return provider;
}

public String getCreatedAt() {
return createdAt;
}

public String getLastUpdated() {
return lastUpdated;
}

/**
* The id of the resource linked to the share
*
* @return the resource id
*/
public String getResourceId() {
return resourceId;
}

/**
* The error that occurred if the share was not completed successfully, otherwise {@code null}
*
* @return the error, may be {@code null}
*/
public DigitalIdShareErrorResponse getError() {
return error;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;

public class GetSessionResult {

Check warning on line 12 in yoti-sdk-api/src/main/java/com/yoti/api/client/docs/session/retrieve/GetSessionResult.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this “Monster Class” into smaller and more specialized ones to reduce its dependencies on other classes from 22 to the maximum authorized 20 or less.

See more on https://sonarcloud.io/project/issues?id=getyoti%3Ajava&issues=AZ7zytCEgHXYtgnH1bS2&open=AZ7zytCEgHXYtgnH1bS2&pullRequest=521

@JsonProperty("client_session_token_ttl")
private long clientSessionTokenTtl;
Expand Down Expand Up @@ -50,6 +50,9 @@
@JsonProperty("import_token")
private ImportTokenResponse importToken;

@JsonProperty("digital_id_shares")
private List<DigitalIdShareResponse> digitalIdShares;

public long getClientSessionTokenTtl() {
return clientSessionTokenTtl;
}
Expand Down Expand Up @@ -102,6 +105,15 @@
return importToken;
}

/**
* The digital ID shares that were performed during the session
*
* @return the digital ID shares
*/
public List<DigitalIdShareResponse> getDigitalIdShares() {
return digitalIdShares;
}

public ResourceContainer getResourcesForCheck(String checkId) {
CheckResponse checkResponse = this.checks.stream()
.filter(check -> check.getId().equals(checkId))
Expand Down
Loading
Loading