Skip to content

Commit 89aca38

Browse files
authored
Merge pull request #162 from getyoti/hotfix-2.6.1
Hotfix-2.6.1
2 parents 8e74ab5 + 92e1143 commit 89aca38

File tree

17 files changed

+125
-30
lines changed

17 files changed

+125
-30
lines changed

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.6.0</version>
107+
<version>2.6.1</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.6.0'`
113+
`compile group: 'com.yoti', name: 'yoti-sdk-impl', version: '2.6.1'`
114114

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

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.6.0</version>
8+
<version>2.6.1</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.6.0</version>
14+
<version>2.6.1</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.6.0</version>
14+
<version>2.6.1</version>
1515
<relativePath>../yoti-sdk-parent</relativePath>
1616
</parent>
1717

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,37 @@
22

33
import java.io.UnsupportedEncodingException;
44
import java.text.ParseException;
5+
import java.util.Arrays;
56

67
import com.yoti.api.client.Date;
78
import com.yoti.api.client.DocumentDetails;
89

910
class DocumentDetailsAttributeParser {
1011

11-
private static final String MINIMUM_ACCEPTABLE = "([A-Za-z_]*) ([A-Za-z]{3}) ([A-Za-z0-9]{1}).*";
12+
private static final int MINIMUM_ACCEPTABLE = 3;
1213
private static final int TYPE_INDEX = 0;
1314
private static final int COUNTRY_INDEX = 1;
1415
private static final int NUMBER_INDEX = 2;
1516
private static final int EXPIRATION_INDEX = 3;
1617
private static final int AUTHORITY_INDEX = 4;
1718

1819
DocumentDetails parseFrom(String attributeValue) throws UnsupportedEncodingException, ParseException {
19-
if (attributeValue == null || !attributeValue.matches(MINIMUM_ACCEPTABLE)) {
20+
if (attributeValue == null || attributeValue.isEmpty()) {
2021
throw new IllegalArgumentException("Unable to parse attribute value to a DocumentDetails");
2122
}
23+
2224
String[] attributes = attributeValue.split(" ");
2325

26+
if (attributes.length < MINIMUM_ACCEPTABLE) {
27+
throw new IllegalArgumentException("Unable to parse attribute value to a DocumentDetails");
28+
}
29+
30+
for (String s : attributes) {
31+
if (s == null || s.isEmpty()) {
32+
throw new IllegalArgumentException("Invalid Document Details value, multiple consecutive spaces");
33+
}
34+
}
35+
2436
return DocumentDetailsAttributeValue.builder()
2537
.withType(attributes[TYPE_INDEX])
2638
.withIssuingCountry(attributes[COUNTRY_INDEX])

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
@@ -21,7 +21,7 @@ private YotiConstants() {}
2121
public static final String CONTENT_TYPE_JPEG = "image/jpeg";
2222

2323
public static final String JAVA = "Java";
24-
public static final String SDK_VERSION = JAVA + "-2.6.0";
24+
public static final String SDK_VERSION = JAVA + "-2.6.1";
2525
public static final String SIGNATURE_ALGORITHM = "SHA256withRSA";
2626
public static final String ASYMMETRIC_CIPHER = "RSA/NONE/PKCS1Padding";
2727
public static final String SYMMETRIC_CIPHER = "AES/CBC/PKCS7Padding";
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.yoti.api.client.spi.remote;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.junit.runners.Parameterized;
6+
7+
import java.util.Arrays;
8+
9+
@RunWith(Parameterized.class)
10+
public class DocumentDetailsAttributeParserConsecutiveSpacesTest {
11+
12+
@Parameterized.Parameters(name = "{index}: Test with {0}")
13+
public static Iterable<Object[]> data() {
14+
return Arrays.asList(new Object[][] {
15+
{"PASSPORT GBR 1234abc"},
16+
{"PASSPORT GBR 1234abc"},
17+
{"DRIVING_LICENCE GBR 1234abc 2016-05-01 DVLA"},
18+
{"DRIVING_LICENCE GBR 1234abc 2016-05-01 DVLA"}
19+
});
20+
}
21+
22+
private String testValue;
23+
24+
public DocumentDetailsAttributeParserConsecutiveSpacesTest(String testValue) {
25+
this.testValue = testValue;
26+
}
27+
28+
@Test(expected = IllegalArgumentException.class)
29+
public void shouldFailForMoreThanoneConsecutiveSpace() throws Exception {
30+
new DocumentDetailsAttributeParser().parseFrom(testValue);
31+
}
32+
33+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.yoti.api.client.spi.remote;
2+
3+
import static org.hamcrest.MatcherAssert.assertThat;
4+
import static org.hamcrest.Matchers.is;
5+
6+
import com.yoti.api.client.DocumentDetails;
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
import org.junit.runners.Parameterized;
10+
11+
import java.util.Arrays;
12+
13+
@RunWith(Parameterized.class)
14+
public class DocumentDetailsAttributeParserSpecialCharactersTest {
15+
16+
@Parameterized.Parameters(name = "{index}: Test with {0}")
17+
public static Iterable<Object[]> data() {
18+
return Arrays.asList(new Object[][] {
19+
{"****"},
20+
{"~!@#$%^&*()-_=+[]{}|;':,./<>?"},
21+
{"\"\""},
22+
{"\\"},
23+
{"\""},
24+
{"''"},
25+
{"'"}
26+
});
27+
}
28+
29+
private String testValue;
30+
31+
public DocumentDetailsAttributeParserSpecialCharactersTest(String testValue) {
32+
this.testValue = testValue;
33+
}
34+
35+
@Test
36+
public void shouldParseDocumentDetailsWithSpecialCharacters() throws Exception {
37+
DocumentDetails result = new DocumentDetailsAttributeParser()
38+
.parseFrom(String.format("PASS_CARD GBR %s - DVLA", testValue));
39+
40+
assertThat(result.getDocumentNumber(), is(testValue));
41+
}
42+
43+
}

yoti-sdk-impl/src/test/java/com/yoti/api/client/spi/remote/DocumentDetailsAttributeParserTest.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.yoti.api.client.spi.remote;
22

3+
import static org.hamcrest.MatcherAssert.assertThat;
4+
import static org.hamcrest.Matchers.*;
35
import static org.junit.Assert.assertEquals;
46
import static org.junit.Assert.assertNotNull;
57
import static org.junit.Assert.assertNull;
@@ -8,10 +10,13 @@
810

911
import com.yoti.api.client.DocumentDetails;
1012

13+
import com.yoti.api.client.spi.remote.call.YotiConstants;
1114
import org.junit.Test;
1215

1316
public class DocumentDetailsAttributeParserTest {
1417

18+
private static final String SOME_AADHAR_DOCUMENT_DETAILS = "NATIONAL_ID IND ********6421 - UIDAI";
19+
1520
DocumentDetailsAttributeParser testObj = new DocumentDetailsAttributeParser();
1621

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

27-
@Test(expected = IllegalArgumentException.class)
28-
public void shouldThrowExceptionForInvalidNumber() throws Exception {
29-
testObj.parseFrom("PASSPORT GBR $%^$%^£ 2016-05-01");
30-
}
31-
32-
@Test(expected = IllegalArgumentException.class)
33-
public void shouldThrowExceptionForInvalidCountry() throws Exception {
34-
testObj.parseFrom("PASSPORT 13 1234abc 2016-05-01");
35-
}
36-
3732
@Test
3833
public void shouldParseMandatoryAttributes() throws Exception {
3934
DocumentDetails result = testObj.parseFrom("PASSPORT GBR 1234abc");
@@ -99,4 +94,16 @@ public void shouldThrowExceptionForInvalidDate() throws Exception {
9994
testObj.parseFrom("PASSPORT GBR 1234abc" + " X016-05-01");
10095
}
10196

97+
@Test
98+
public void shouldParseRedactedAadhar() throws Exception {
99+
DocumentDetails result = testObj.parseFrom(SOME_AADHAR_DOCUMENT_DETAILS);
100+
101+
assertThat(result, is(notNullValue()));
102+
assertThat(result.getType(), is("NATIONAL_ID"));
103+
assertThat(result.getIssuingCountry(), is("IND"));
104+
assertThat(result.getDocumentNumber(), is("********6421"));
105+
assertThat(result.getExpirationDate(), is(nullValue()));
106+
assertThat(result.getIssuingAuthority(), is("UIDAI"));
107+
}
108+
102109
}

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.6.0</version>
8+
<version>2.6.1</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>

0 commit comments

Comments
 (0)