Skip to content

Commit

Permalink
Merge pull request #162 from getyoti/hotfix-2.6.1
Browse files Browse the repository at this point in the history
Hotfix-2.6.1
  • Loading branch information
MrBurtyyy authored Feb 12, 2020
2 parents 8e74ab5 + 92e1143 commit 89aca38
Show file tree
Hide file tree
Showing 17 changed files with 125 additions and 30 deletions.
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.6.0</version>
<version>2.6.1</version>
</dependency>
```

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

`compile group: 'com.yoti', name: 'yoti-sdk-impl', version: '2.6.0'`
`compile group: 'com.yoti', name: 'yoti-sdk-impl', version: '2.6.1'`

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

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.6.0</version>
<version>2.6.1</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.6.0</version>
<version>2.6.1</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.6.0</version>
<version>2.6.1</version>
<relativePath>../yoti-sdk-parent</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,37 @@

import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.util.Arrays;

import com.yoti.api.client.Date;
import com.yoti.api.client.DocumentDetails;

class DocumentDetailsAttributeParser {

private static final String MINIMUM_ACCEPTABLE = "([A-Za-z_]*) ([A-Za-z]{3}) ([A-Za-z0-9]{1}).*";
private static final int MINIMUM_ACCEPTABLE = 3;
private static final int TYPE_INDEX = 0;
private static final int COUNTRY_INDEX = 1;
private static final int NUMBER_INDEX = 2;
private static final int EXPIRATION_INDEX = 3;
private static final int AUTHORITY_INDEX = 4;

DocumentDetails parseFrom(String attributeValue) throws UnsupportedEncodingException, ParseException {
if (attributeValue == null || !attributeValue.matches(MINIMUM_ACCEPTABLE)) {
if (attributeValue == null || attributeValue.isEmpty()) {
throw new IllegalArgumentException("Unable to parse attribute value to a DocumentDetails");
}

String[] attributes = attributeValue.split(" ");

if (attributes.length < MINIMUM_ACCEPTABLE) {
throw new IllegalArgumentException("Unable to parse attribute value to a DocumentDetails");
}

for (String s : attributes) {
if (s == null || s.isEmpty()) {
throw new IllegalArgumentException("Invalid Document Details value, multiple consecutive spaces");
}
}

return DocumentDetailsAttributeValue.builder()
.withType(attributes[TYPE_INDEX])
.withIssuingCountry(attributes[COUNTRY_INDEX])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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.6.0";
public static final String SDK_VERSION = JAVA + "-2.6.1";
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.yoti.api.client.spi.remote;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.Arrays;

@RunWith(Parameterized.class)
public class DocumentDetailsAttributeParserConsecutiveSpacesTest {

@Parameterized.Parameters(name = "{index}: Test with {0}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][] {
{"PASSPORT GBR 1234abc"},
{"PASSPORT GBR 1234abc"},
{"DRIVING_LICENCE GBR 1234abc 2016-05-01 DVLA"},
{"DRIVING_LICENCE GBR 1234abc 2016-05-01 DVLA"}
});
}

private String testValue;

public DocumentDetailsAttributeParserConsecutiveSpacesTest(String testValue) {
this.testValue = testValue;
}

@Test(expected = IllegalArgumentException.class)
public void shouldFailForMoreThanoneConsecutiveSpace() throws Exception {
new DocumentDetailsAttributeParser().parseFrom(testValue);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.yoti.api.client.spi.remote;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

import com.yoti.api.client.DocumentDetails;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.Arrays;

@RunWith(Parameterized.class)
public class DocumentDetailsAttributeParserSpecialCharactersTest {

@Parameterized.Parameters(name = "{index}: Test with {0}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][] {
{"****"},
{"~!@#$%^&*()-_=+[]{}|;':,./<>?"},
{"\"\""},
{"\\"},
{"\""},
{"''"},
{"'"}
});
}

private String testValue;

public DocumentDetailsAttributeParserSpecialCharactersTest(String testValue) {
this.testValue = testValue;
}

@Test
public void shouldParseDocumentDetailsWithSpecialCharacters() throws Exception {
DocumentDetails result = new DocumentDetailsAttributeParser()
.parseFrom(String.format("PASS_CARD GBR %s - DVLA", testValue));

assertThat(result.getDocumentNumber(), is(testValue));
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.yoti.api.client.spi.remote;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
Expand All @@ -8,10 +10,13 @@

import com.yoti.api.client.DocumentDetails;

import com.yoti.api.client.spi.remote.call.YotiConstants;
import org.junit.Test;

public class DocumentDetailsAttributeParserTest {

private static final String SOME_AADHAR_DOCUMENT_DETAILS = "NATIONAL_ID IND ********6421 - UIDAI";

DocumentDetailsAttributeParser testObj = new DocumentDetailsAttributeParser();

@Test(expected = IllegalArgumentException.class)
Expand All @@ -24,16 +29,6 @@ public void shouldThrowExceptionWhenAttributesAreMissing() throws Exception {
testObj.parseFrom("PASSPORT GBR");
}

@Test(expected = IllegalArgumentException.class)
public void shouldThrowExceptionForInvalidNumber() throws Exception {
testObj.parseFrom("PASSPORT GBR $%^$%^£ 2016-05-01");
}

@Test(expected = IllegalArgumentException.class)
public void shouldThrowExceptionForInvalidCountry() throws Exception {
testObj.parseFrom("PASSPORT 13 1234abc 2016-05-01");
}

@Test
public void shouldParseMandatoryAttributes() throws Exception {
DocumentDetails result = testObj.parseFrom("PASSPORT GBR 1234abc");
Expand Down Expand Up @@ -99,4 +94,16 @@ public void shouldThrowExceptionForInvalidDate() throws Exception {
testObj.parseFrom("PASSPORT GBR 1234abc" + " X016-05-01");
}

@Test
public void shouldParseRedactedAadhar() throws Exception {
DocumentDetails result = testObj.parseFrom(SOME_AADHAR_DOCUMENT_DETAILS);

assertThat(result, is(notNullValue()));
assertThat(result.getType(), is("NATIONAL_ID"));
assertThat(result.getIssuingCountry(), is("IND"));
assertThat(result.getDocumentNumber(), is("********6421"));
assertThat(result.getExpirationDate(), is(nullValue()));
assertThat(result.getIssuingAuthority(), is("UIDAI"));
}

}
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.6.0</version>
<version>2.6.1</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.6.0</version>
<version>2.6.1</version>
<relativePath>../yoti-sdk-parent</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions yoti-sdk-spring-boot-auto-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ If you are using Maven, you need to add the following dependencies:
<dependency>
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-spring-boot-auto-config</artifactId>
<version>2.6.0</version>
<version>2.6.1</version>
</dependency>
```


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

```
compile group: 'com.yoti', name: 'yoti-sdk-spring-boot-auto-config', version: '2.6.0'
compile group: 'com.yoti', name: 'yoti-sdk-spring-boot-auto-config', version: '2.6.1'
```


Expand Down
2 changes: 1 addition & 1 deletion yoti-sdk-spring-boot-auto-config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-parent</artifactId>
<version>2.6.0</version>
<version>2.6.1</version>
<relativePath>../yoti-sdk-parent</relativePath>
</parent>

Expand Down
6 changes: 3 additions & 3 deletions yoti-sdk-spring-boot-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Before you start, you'll need to create an Application in [Yoti Hub](https://hub
<dependency>
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-impl</artifactId>
<version>2.6.0</version>
<version>2.6.1</version>
</dependency>
```

Expand All @@ -29,8 +29,8 @@ Before you start, you'll need to create an Application in [Yoti Hub](https://hub
1. Run `mvn clean package` to build the project.

## Running
* You can run your server-app by executing `java -jar target/yoti-sdk-spring-boot-example-2.6.0.jar`
* If you are using Java 9, you can run the server-app as follows `java -jar target/yoti-sdk-spring-boot-example-2.6.0.jar --add-exports java.base/jdk.internal.ref=ALL-UNNAMED`
* You can run your server-app by executing `java -jar target/yoti-sdk-spring-boot-example-2.6.1.jar`
* If you are using Java 9, you can run the server-app as follows `java -jar target/yoti-sdk-spring-boot-example-2.6.1.jar --add-exports java.base/jdk.internal.ref=ALL-UNNAMED`
* Navigate to `https://localhost:8443`
* You can then initiate a login using Yoti. The Spring demo is listening for the response on `https://localhost:8443/login`.

Expand Down
2 changes: 1 addition & 1 deletion yoti-sdk-spring-boot-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-spring-boot-example</artifactId>

<version>2.6.0</version>
<version>2.6.1</version>

<name>Yoti Spring Boot Example</name>
<parent>
Expand Down
4 changes: 2 additions & 2 deletions yoti-sdk-spring-security/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ If you are using Maven, you need to add the following dependencies:
<dependency>
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-spring-security</artifactId>
<version>2.6.0</version>
<version>2.6.1</version>
</dependency>
```

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

```
compile group: 'com.yoti', name: 'yoti-sdk-spring-security', version: '2.6.0'
compile group: 'com.yoti', name: 'yoti-sdk-spring-security', version: '2.6.1'
```

### Provide a `YotiClient` instance
Expand Down
2 changes: 1 addition & 1 deletion yoti-sdk-spring-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>com.yoti</groupId>
<artifactId>yoti-sdk-parent</artifactId>
<version>2.6.0</version>
<version>2.6.1</version>
<relativePath>../yoti-sdk-parent</relativePath>
</parent>

Expand Down

0 comments on commit 89aca38

Please sign in to comment.