Skip to content

Commit

Permalink
Merge pull request #194 from getyoti/release_2.9.0
Browse files Browse the repository at this point in the history
Release 2.9.0
  • Loading branch information
davidgrayston authored May 28, 2020
2 parents 6e4fe69 + 87a7772 commit ba97dd9
Show file tree
Hide file tree
Showing 47 changed files with 1,838 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,5 @@ $RECYCLE.BIN/

.idea
*.iml

*.pem
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ If you are using Maven, you need to add the following dependency:
<dependency>
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-impl</artifactId>
<version>2.8.0</version>
<version>2.9.0</version>
</dependency>
```

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion examples/doc-scan/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<dependency>
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-impl</artifactId>
<version>2.8.0</version>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.tika</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk</artifactId>
<packaging>pom</packaging>
<version>2.8.0</version>
<version>2.9.0</version>
<name>Yoti SDK</name>
<description>Java SDK for simple integration with the Yoti platform</description>
<url>https://github.com/getyoti/yoti-java-sdk</url>
Expand Down
2 changes: 1 addition & 1 deletion yoti-sdk-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-parent</artifactId>
<version>2.8.0</version>
<version>2.9.0</version>
<relativePath>../yoti-sdk-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion yoti-sdk-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-parent</artifactId>
<version>2.8.0</version>
<version>2.9.0</version>
<relativePath>../yoti-sdk-parent</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private YotiConstants() {}
public static final String CONTENT_TYPE_JPEG = "image/jpeg";

public static final String JAVA = "Java";
public static final String SDK_VERSION = JAVA + "-2.8.0";
public static final String SDK_VERSION = JAVA + "-2.9.0";
public static final String SIGNATURE_ALGORITHM = "SHA256withRSA";
public static final String ASYMMETRIC_CIPHER = "RSA/NONE/PKCS1Padding";
public static final String SYMMETRIC_CIPHER = "AES/CBC/PKCS7Padding";
Expand Down
2 changes: 1 addition & 1 deletion yoti-sdk-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-parent</artifactId>
<packaging>pom</packaging>
<version>2.8.0</version>
<version>2.9.0</version>
<name>Yoti SDK Parent Pom</name>
<description>Parent pom for the Java SDK projects</description>
<url>https://github.com/getyoti/yoti-java-sdk</url>
Expand Down
2 changes: 1 addition & 1 deletion yoti-sdk-sandbox/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-parent</artifactId>
<version>2.8.0</version>
<version>2.9.0</version>
<relativePath>../yoti-sdk-parent</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package com.yoti.api.client.sandbox.docs;

import static com.yoti.api.client.spi.remote.call.YotiConstants.DEFAULT_YOTI_HOST;
import static com.yoti.api.client.spi.remote.call.YotiConstants.PROPERTY_YOTI_DOCS_URL;
import static com.yoti.api.client.spi.remote.util.Validation.notNull;
import static com.yoti.api.client.spi.remote.util.Validation.notNullOrEmpty;

import java.io.IOException;
import java.net.URISyntaxException;
import java.security.GeneralSecurityException;
import java.security.KeyPair;

import com.yoti.api.client.InitialisationException;
import com.yoti.api.client.KeyPairSource;
import com.yoti.api.client.sandbox.SandboxException;
import com.yoti.api.client.sandbox.docs.request.ResponseConfig;
import com.yoti.api.client.spi.remote.KeyStreamVisitor;
import com.yoti.api.client.spi.remote.call.HttpMethod;
import com.yoti.api.client.spi.remote.call.ResourceException;
import com.yoti.api.client.spi.remote.call.SignedRequest;
import com.yoti.api.client.spi.remote.call.SignedRequestBuilder;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DocScanSandboxClient {

private static final String DOC_SCAN_SANDBOX_PATH_PREFIX = "/sandbox/idverify/v1";
private static final String DEFAULT_DOC_SCAN_SANDBOX_API_URL = DEFAULT_YOTI_HOST + DOC_SCAN_SANDBOX_PATH_PREFIX;

private final String docScanBaseUrl;
private final ObjectMapper mapper;
private final String sdkId;
private final KeyPair keyPair;

DocScanSandboxClient(String sdkId, KeyPair keyPair, ObjectMapper mapper) {
this.sdkId = sdkId;
this.keyPair = keyPair;
this.mapper = mapper;
this.docScanBaseUrl = System.getProperty(PROPERTY_YOTI_DOCS_URL, DEFAULT_DOC_SCAN_SANDBOX_API_URL);
}

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

/**
* Configures the response for the given session ID.
*
* @param sessionId the session ID
* @param responseConfig the response configuration
* @throws SandboxException - if there was a problem configuring the response
*/
public void configureSessionResponse(String sessionId, ResponseConfig responseConfig) throws SandboxException {
String path = String.format("/sessions/%s/response-config", sessionId);

try {
byte[] body = mapper.writeValueAsBytes(responseConfig);

SignedRequest signedRequest = getSignedRequestBuilder()
.withBaseUrl(docScanBaseUrl)
.withEndpoint(path)
.withKeyPair(keyPair)
.withHttpMethod(HttpMethod.HTTP_PUT)
.withPayload(body)
.withQueryParameter("sdkId", sdkId)
.build();

signedRequest.execute();
} catch (URISyntaxException | GeneralSecurityException | ResourceException | IOException e) {
throw new SandboxException(e);
}
}

/**
* Configures the default response for the application
*
* @param sandboxExpectation
*/
public void configureApplicationResponse(ResponseConfig sandboxExpectation) throws SandboxException {
String path = String.format("/apps/%s/response-config", sdkId);

try {
byte[] body = mapper.writeValueAsBytes(sandboxExpectation);

SignedRequest signedRequest = getSignedRequestBuilder()
.withBaseUrl(docScanBaseUrl)
.withEndpoint(path)
.withKeyPair(keyPair)
.withHttpMethod(HttpMethod.HTTP_PUT)
.withPayload(body)
.build();

signedRequest.execute();
} catch (URISyntaxException | GeneralSecurityException | ResourceException | IOException e) {
throw new SandboxException(e);
}
}

SignedRequestBuilder getSignedRequestBuilder() {
return SignedRequestBuilder.newInstance();
}

public static class Builder {

private static final Logger LOGGER = LoggerFactory.getLogger(Builder.class);

private String sdkId;
private KeyPair keyPair;

private Builder() {
}

public Builder withSdkId(String sdkId) {
this.sdkId = sdkId;
return this;
}

public Builder withKeyPair(KeyPairSource keyPairSource) {
try {
LOGGER.debug("Loading key pair from '{}'", keyPairSource);
this.keyPair = keyPairSource.getFromStream(new KeyStreamVisitor());
} catch (IOException e) {
throw new InitialisationException("Cannot load key pair", e);
}
return this;
}

public DocScanSandboxClient build() {
notNullOrEmpty(sdkId, "sdkId");
notNull(keyPair, "keyPair");

return new DocScanSandboxClient(sdkId, keyPair, new ObjectMapper());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.yoti.api.client.sandbox.docs.request;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class ResponseConfig {

@JsonProperty("task_results")
private SandboxTaskResults taskResults;

@JsonProperty("check_reports")
private SandboxCheckReports checkReports;

ResponseConfig(SandboxTaskResults taskResults, SandboxCheckReports checkReports) {
this.taskResults = taskResults;
this.checkReports = checkReports;
}

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

public SandboxTaskResults getTaskResults() {
return taskResults;
}

public SandboxCheckReports getCheckReports() {
return checkReports;
}

/**
* Builder for {@link ResponseConfig}
*/
public static class Builder {

private SandboxTaskResults taskResults;

private SandboxCheckReports sandboxCheckReports;

public Builder withTaskResults(SandboxTaskResults taskResults) {
this.taskResults = taskResults;
return this;
}

public Builder withCheckReports(SandboxCheckReports sandboxCheckReports) {
this.sandboxCheckReports = sandboxCheckReports;
return this;
}

public ResponseConfig build() {
return new ResponseConfig(taskResults, sandboxCheckReports);
}

}

}
Loading

0 comments on commit ba97dd9

Please sign in to comment.