-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #413 from getyoti/SDK-2230
SDK-2230: Expose share v2 API
- Loading branch information
Showing
79 changed files
with
5,063 additions
and
726 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
yoti-sdk-api/src/main/java/com/yoti/api/client/DigitalIdentityClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package com.yoti.api.client; | ||
|
||
import java.io.IOException; | ||
import java.security.KeyPair; | ||
import java.security.Security; | ||
|
||
import com.yoti.api.client.identity.ShareSession; | ||
import com.yoti.api.client.identity.ShareSessionQrCode; | ||
import com.yoti.api.client.identity.ShareSessionRequest; | ||
import com.yoti.api.client.spi.remote.KeyStreamVisitor; | ||
import com.yoti.api.client.spi.remote.call.identity.DigitalIdentityException; | ||
import com.yoti.api.client.spi.remote.call.identity.DigitalIdentityService; | ||
import com.yoti.api.client.spi.remote.call.identity.Receipt; | ||
import com.yoti.validation.Validation; | ||
|
||
import org.bouncycastle.jce.provider.BouncyCastleProvider; | ||
|
||
public class DigitalIdentityClient { | ||
|
||
static { | ||
Security.addProvider(new BouncyCastleProvider()); | ||
} | ||
|
||
private final String sdkId; | ||
private final KeyPair keyPair; | ||
private final DigitalIdentityService identityService; | ||
|
||
DigitalIdentityClient(String sdkId, KeyPairSource keyPair, DigitalIdentityService identityService) { | ||
Validation.notNullOrEmpty(sdkId, "SDK ID"); | ||
Validation.notNull(keyPair, "Application Key Pair"); | ||
|
||
this.sdkId = sdkId; | ||
this.keyPair = loadKeyPair(keyPair); | ||
this.identityService = identityService; | ||
} | ||
|
||
public ShareSession createShareSession(ShareSessionRequest request) throws DigitalIdentityException { | ||
return identityService.createShareSession(sdkId, keyPair, request); | ||
} | ||
|
||
public ShareSession fetchShareSession(String sessionId) throws DigitalIdentityException { | ||
return identityService.fetchShareSession(sdkId, keyPair, sessionId); | ||
} | ||
|
||
public ShareSessionQrCode createShareQrCode(String sessionId) throws DigitalIdentityException { | ||
return identityService.createShareQrCode(sdkId, keyPair, sessionId); | ||
} | ||
|
||
public ShareSessionQrCode fetchShareQrCode(String qrCodeId) throws DigitalIdentityException { | ||
return identityService.fetchShareQrCode(sdkId, keyPair, qrCodeId); | ||
} | ||
|
||
public Receipt fetchShareReceipt(String receiptId) throws DigitalIdentityException { | ||
return identityService.fetchShareReceipt(sdkId, keyPair, receiptId); | ||
} | ||
|
||
private KeyPair loadKeyPair(KeyPairSource keyPairSource) throws InitialisationException { | ||
try { | ||
return keyPairSource.getFromStream(new KeyStreamVisitor()); | ||
} catch (IOException ex) { | ||
throw new InitialisationException("Cannot load Key Pair", ex); | ||
} | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
|
||
private String sdkId; | ||
private KeyPairSource keyPairSource; | ||
|
||
private Builder() { } | ||
|
||
public Builder withClientSdkId(String sdkId) { | ||
Validation.notNullOrEmpty(sdkId, "SDK ID"); | ||
|
||
this.sdkId = sdkId; | ||
return this; | ||
} | ||
|
||
public Builder withKeyPairSource(KeyPairSource keyPairSource) { | ||
Validation.notNull(keyPairSource, "Key Pair Source"); | ||
|
||
this.keyPairSource = keyPairSource; | ||
return this; | ||
} | ||
|
||
public DigitalIdentityClient build() { | ||
return new DigitalIdentityClient(sdkId, keyPairSource, DigitalIdentityService.newInstance()); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
yoti-sdk-api/src/main/java/com/yoti/api/client/identity/ShareSession.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.yoti.api.client.identity; | ||
|
||
import java.util.Map; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class ShareSession { | ||
|
||
private String id; | ||
private String status; | ||
private String created; | ||
private String updated; | ||
private String expiry; | ||
private String qrCodeId; | ||
private String receiptId; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public String getStatus() { | ||
return status; | ||
} | ||
|
||
public String getCreated() { | ||
return created; | ||
} | ||
|
||
public String getUpdated() { | ||
return updated; | ||
} | ||
|
||
public String getExpiry() { | ||
return expiry; | ||
} | ||
|
||
public String getQrCodeId() { | ||
return qrCodeId; | ||
} | ||
|
||
public String getReceiptId() { | ||
return receiptId; | ||
} | ||
|
||
@JsonProperty(Property.ID) | ||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
@JsonProperty(Property.STATUS) | ||
public void setStatus(String status) { | ||
this.status = status; | ||
} | ||
|
||
@JsonProperty(Property.CREATED) | ||
public void setCreated(String created) { | ||
this.created = created; | ||
} | ||
|
||
@JsonProperty(Property.UPDATED) | ||
public void setUpdated(String updated) { | ||
this.updated = updated; | ||
} | ||
|
||
@JsonProperty(Property.EXPIRY) | ||
public void setExpiry(String expiry) { | ||
this.expiry = expiry; | ||
} | ||
|
||
@JsonProperty(Property.QR_CODE) | ||
public void setQrCodeId(Map<String, Object> qrCode) { | ||
this.qrCodeId = (String) qrCode.get(Property.ID); | ||
} | ||
|
||
@JsonProperty(Property.RECEIPT) | ||
public void setReceiptId(Map<String, Object> receipt) { | ||
this.receiptId = (String) receipt.get(Property.ID); | ||
} | ||
|
||
private static final class Property { | ||
|
||
private static final String ID = "id"; | ||
private static final String CREATED = "created"; | ||
private static final String UPDATED = "updated"; | ||
private static final String STATUS = "status"; | ||
private static final String EXPIRY = "expiry"; | ||
private static final String QR_CODE = "qrCode"; | ||
private static final String RECEIPT = "receipt"; | ||
|
||
} | ||
|
||
} |
104 changes: 104 additions & 0 deletions
104
yoti-sdk-api/src/main/java/com/yoti/api/client/identity/ShareSessionNotification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.yoti.api.client.identity; | ||
|
||
import java.net.URI; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.yoti.validation.Validation; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public final class ShareSessionNotification { | ||
|
||
@JsonProperty(Property.URL) | ||
private final String url; | ||
|
||
@JsonProperty(Property.METHOD) | ||
private final String method; | ||
|
||
@JsonProperty(Property.VERIFY_TLS) | ||
private final boolean verifyTls; | ||
|
||
@JsonProperty(Property.HEADERS) | ||
private final Map<String, String> headers; | ||
|
||
private ShareSessionNotification(Builder builder) { | ||
url = builder.url; | ||
method = builder.method; | ||
verifyTls = builder.verifyTls; | ||
headers = builder.headers; | ||
} | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public String getMethod() { | ||
return method; | ||
} | ||
|
||
public boolean isVerifyTls() { | ||
return verifyTls; | ||
} | ||
|
||
public Map<String, String> getHeaders() { | ||
return headers; | ||
} | ||
|
||
public static Builder builder(URI uri) { | ||
return new Builder(uri); | ||
} | ||
|
||
public static final class Builder { | ||
|
||
private final String url; | ||
private final Map<String, String> headers; | ||
|
||
private String method; | ||
private boolean verifyTls; | ||
|
||
private Builder(URI uri) { | ||
url = uri.toString(); | ||
method = "POST"; | ||
verifyTls = true; | ||
headers = new HashMap<>(); | ||
} | ||
|
||
public Builder withMethod(String method) { | ||
this.method = method; | ||
return this; | ||
} | ||
|
||
public Builder withVerifyTls(boolean verifyTls) { | ||
this.verifyTls = verifyTls; | ||
return this; | ||
} | ||
|
||
public Builder withHeaders(Map<String, String> headers) { | ||
this.headers.putAll(headers); | ||
return this; | ||
} | ||
|
||
public Builder withHeader(String key, String value) { | ||
headers.put(key, value); | ||
return this; | ||
} | ||
|
||
public ShareSessionNotification build() { | ||
Validation.notNullOrEmpty(url, Property.URL); | ||
|
||
return new ShareSessionNotification(this); | ||
} | ||
|
||
} | ||
|
||
private static final class Property { | ||
|
||
private static final String URL = "url"; | ||
private static final String METHOD = "method"; | ||
private static final String VERIFY_TLS = "verifyTls"; | ||
private static final String HEADERS = "headers"; | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.