Skip to content

Commit ba97dd9

Browse files
Merge pull request #194 from getyoti/release_2.9.0
Release 2.9.0
2 parents 6e4fe69 + 87a7772 commit ba97dd9

File tree

47 files changed

+1838
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1838
-19
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,5 @@ $RECYCLE.BIN/
205205

206206
.idea
207207
*.iml
208+
209+
*.pem

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ If you are using Maven, you need to add the following dependency:
104104
<dependency>
105105
<groupId>com.yoti</groupId>
106106
<artifactId>yoti-sdk-impl</artifactId>
107-
<version>2.8.0</version>
107+
<version>2.9.0</version>
108108
</dependency>
109109
```
110110

111111
If you are using Gradle, here is the dependency to add:
112112

113-
`compile group: 'com.yoti', name: 'yoti-sdk-impl', version: '2.8.0'`
113+
`compile group: 'com.yoti', name: 'yoti-sdk-impl', version: '2.9.0'`
114114

115115
You will find all classes packaged under `com.yoti.api`
116116

examples/doc-scan/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<dependency>
5252
<groupId>com.yoti</groupId>
5353
<artifactId>yoti-sdk-impl</artifactId>
54-
<version>2.8.0</version>
54+
<version>2.9.0</version>
5555
</dependency>
5656
<dependency>
5757
<groupId>org.apache.tika</groupId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>com.yoti</groupId>
66
<artifactId>yoti-sdk</artifactId>
77
<packaging>pom</packaging>
8-
<version>2.8.0</version>
8+
<version>2.9.0</version>
99
<name>Yoti SDK</name>
1010
<description>Java SDK for simple integration with the Yoti platform</description>
1111
<url>https://github.com/getyoti/yoti-java-sdk</url>

yoti-sdk-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>com.yoti</groupId>
1313
<artifactId>yoti-sdk-parent</artifactId>
14-
<version>2.8.0</version>
14+
<version>2.9.0</version>
1515
<relativePath>../yoti-sdk-parent</relativePath>
1616
</parent>
1717

yoti-sdk-impl/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>com.yoti</groupId>
1313
<artifactId>yoti-sdk-parent</artifactId>
14-
<version>2.8.0</version>
14+
<version>2.9.0</version>
1515
<relativePath>../yoti-sdk-parent</relativePath>
1616
</parent>
1717

yoti-sdk-impl/src/main/java/com/yoti/api/client/spi/remote/call/YotiConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private YotiConstants() {}
2525
public static final String CONTENT_TYPE_JPEG = "image/jpeg";
2626

2727
public static final String JAVA = "Java";
28-
public static final String SDK_VERSION = JAVA + "-2.8.0";
28+
public static final String SDK_VERSION = JAVA + "-2.9.0";
2929
public static final String SIGNATURE_ALGORITHM = "SHA256withRSA";
3030
public static final String ASYMMETRIC_CIPHER = "RSA/NONE/PKCS1Padding";
3131
public static final String SYMMETRIC_CIPHER = "AES/CBC/PKCS7Padding";

yoti-sdk-parent/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>com.yoti</groupId>
66
<artifactId>yoti-sdk-parent</artifactId>
77
<packaging>pom</packaging>
8-
<version>2.8.0</version>
8+
<version>2.9.0</version>
99
<name>Yoti SDK Parent Pom</name>
1010
<description>Parent pom for the Java SDK projects</description>
1111
<url>https://github.com/getyoti/yoti-java-sdk</url>

yoti-sdk-sandbox/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>com.yoti</groupId>
1313
<artifactId>yoti-sdk-parent</artifactId>
14-
<version>2.8.0</version>
14+
<version>2.9.0</version>
1515
<relativePath>../yoti-sdk-parent</relativePath>
1616
</parent>
1717

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
package com.yoti.api.client.sandbox.docs;
2+
3+
import static com.yoti.api.client.spi.remote.call.YotiConstants.DEFAULT_YOTI_HOST;
4+
import static com.yoti.api.client.spi.remote.call.YotiConstants.PROPERTY_YOTI_DOCS_URL;
5+
import static com.yoti.api.client.spi.remote.util.Validation.notNull;
6+
import static com.yoti.api.client.spi.remote.util.Validation.notNullOrEmpty;
7+
8+
import java.io.IOException;
9+
import java.net.URISyntaxException;
10+
import java.security.GeneralSecurityException;
11+
import java.security.KeyPair;
12+
13+
import com.yoti.api.client.InitialisationException;
14+
import com.yoti.api.client.KeyPairSource;
15+
import com.yoti.api.client.sandbox.SandboxException;
16+
import com.yoti.api.client.sandbox.docs.request.ResponseConfig;
17+
import com.yoti.api.client.spi.remote.KeyStreamVisitor;
18+
import com.yoti.api.client.spi.remote.call.HttpMethod;
19+
import com.yoti.api.client.spi.remote.call.ResourceException;
20+
import com.yoti.api.client.spi.remote.call.SignedRequest;
21+
import com.yoti.api.client.spi.remote.call.SignedRequestBuilder;
22+
23+
import com.fasterxml.jackson.databind.ObjectMapper;
24+
import org.slf4j.Logger;
25+
import org.slf4j.LoggerFactory;
26+
27+
public class DocScanSandboxClient {
28+
29+
private static final String DOC_SCAN_SANDBOX_PATH_PREFIX = "/sandbox/idverify/v1";
30+
private static final String DEFAULT_DOC_SCAN_SANDBOX_API_URL = DEFAULT_YOTI_HOST + DOC_SCAN_SANDBOX_PATH_PREFIX;
31+
32+
private final String docScanBaseUrl;
33+
private final ObjectMapper mapper;
34+
private final String sdkId;
35+
private final KeyPair keyPair;
36+
37+
DocScanSandboxClient(String sdkId, KeyPair keyPair, ObjectMapper mapper) {
38+
this.sdkId = sdkId;
39+
this.keyPair = keyPair;
40+
this.mapper = mapper;
41+
this.docScanBaseUrl = System.getProperty(PROPERTY_YOTI_DOCS_URL, DEFAULT_DOC_SCAN_SANDBOX_API_URL);
42+
}
43+
44+
public static Builder builder() {
45+
return new Builder();
46+
}
47+
48+
/**
49+
* Configures the response for the given session ID.
50+
*
51+
* @param sessionId the session ID
52+
* @param responseConfig the response configuration
53+
* @throws SandboxException - if there was a problem configuring the response
54+
*/
55+
public void configureSessionResponse(String sessionId, ResponseConfig responseConfig) throws SandboxException {
56+
String path = String.format("/sessions/%s/response-config", sessionId);
57+
58+
try {
59+
byte[] body = mapper.writeValueAsBytes(responseConfig);
60+
61+
SignedRequest signedRequest = getSignedRequestBuilder()
62+
.withBaseUrl(docScanBaseUrl)
63+
.withEndpoint(path)
64+
.withKeyPair(keyPair)
65+
.withHttpMethod(HttpMethod.HTTP_PUT)
66+
.withPayload(body)
67+
.withQueryParameter("sdkId", sdkId)
68+
.build();
69+
70+
signedRequest.execute();
71+
} catch (URISyntaxException | GeneralSecurityException | ResourceException | IOException e) {
72+
throw new SandboxException(e);
73+
}
74+
}
75+
76+
/**
77+
* Configures the default response for the application
78+
*
79+
* @param sandboxExpectation
80+
*/
81+
public void configureApplicationResponse(ResponseConfig sandboxExpectation) throws SandboxException {
82+
String path = String.format("/apps/%s/response-config", sdkId);
83+
84+
try {
85+
byte[] body = mapper.writeValueAsBytes(sandboxExpectation);
86+
87+
SignedRequest signedRequest = getSignedRequestBuilder()
88+
.withBaseUrl(docScanBaseUrl)
89+
.withEndpoint(path)
90+
.withKeyPair(keyPair)
91+
.withHttpMethod(HttpMethod.HTTP_PUT)
92+
.withPayload(body)
93+
.build();
94+
95+
signedRequest.execute();
96+
} catch (URISyntaxException | GeneralSecurityException | ResourceException | IOException e) {
97+
throw new SandboxException(e);
98+
}
99+
}
100+
101+
SignedRequestBuilder getSignedRequestBuilder() {
102+
return SignedRequestBuilder.newInstance();
103+
}
104+
105+
public static class Builder {
106+
107+
private static final Logger LOGGER = LoggerFactory.getLogger(Builder.class);
108+
109+
private String sdkId;
110+
private KeyPair keyPair;
111+
112+
private Builder() {
113+
}
114+
115+
public Builder withSdkId(String sdkId) {
116+
this.sdkId = sdkId;
117+
return this;
118+
}
119+
120+
public Builder withKeyPair(KeyPairSource keyPairSource) {
121+
try {
122+
LOGGER.debug("Loading key pair from '{}'", keyPairSource);
123+
this.keyPair = keyPairSource.getFromStream(new KeyStreamVisitor());
124+
} catch (IOException e) {
125+
throw new InitialisationException("Cannot load key pair", e);
126+
}
127+
return this;
128+
}
129+
130+
public DocScanSandboxClient build() {
131+
notNullOrEmpty(sdkId, "sdkId");
132+
notNull(keyPair, "keyPair");
133+
134+
return new DocScanSandboxClient(sdkId, keyPair, new ObjectMapper());
135+
}
136+
}
137+
}

0 commit comments

Comments
 (0)