Skip to content

Commit 177a464

Browse files
authored
Merge pull request #15 from getyoti/java-sdk-spring-security
Spring Security SDK
2 parents 10f0788 + 6c1b68f commit 177a464

File tree

37 files changed

+1198
-138
lines changed

37 files changed

+1198
-138
lines changed

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ The Modules above explained
3535
1) [Spring Boot Auto Configuration](#spring-boot-auto-configuration)-
3636
Description of utilising Spring Boot
3737

38+
1) [Spring Security Integration](#spring-security-integration)-
39+
Integrating Yoti Authentication with Spring Boot.
40+
3841
1) [Misc](#misc)
3942

4043
1) [Known Issues](#known-issues)-
@@ -91,12 +94,12 @@ If you are using Maven, you need to add the following dependency:
9194
<dependency>
9295
<groupId>com.yoti</groupId>
9396
<artifactId>java-sdk-impl</artifactId>
94-
<version>1.1</version>
97+
<version>1.2</version>
9598
</dependency>
9699
```
97100
If you are using Gradle, here is the dependency to add:
98101

99-
`compile group: 'com.yoti', name: 'java-sdk-impl', version: '1.1'`
102+
`compile group: 'com.yoti', name: 'java-sdk-impl', version: '1.2'`
100103

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

@@ -205,13 +208,21 @@ Dummy implementation without connectivity to any platform services. Can be used
205208
Real SDK implementation that takes care of decrypting the token, fetching the user profile from Yoti servers by issuing a signed request and finally decrypting the fetched profile.
206209
### java-sdk-spring-boot-auto-config
207210
A module that can be used in Spring Boot applications to automatically configure the YotiClient and KeyPairSource with standard application properties.
211+
### java-sdk-spring-security
212+
A module that can be used in Spring applications that use Spring Security to add Yoti authentication.
208213

209214
## Spring Boot Auto Configuration
210215

211216
As a convenience, if your application happens to use Spring Boot, you can utilise the Spring Boot auto configuration module that will take care of configuring the Yoti Client and Key Pair for you based on standard application properties.
212217

213218
For more information and to see an example of this in use take a look at the Spring Boot Auto Configuration module and Spring Boot example in this repository.
214219

220+
## Spring Security Integration
221+
222+
If you use Spring Security you can use the `java-sdk-spring-security` module to make integration easier. You are provided with some classes that fit into Spring Security's existing authentication model.
223+
224+
Combining this with the Spring Boot Auto Configuration can make integration very easy with very little code needing to be written.
225+
215226
## Misc
216227

217228
* By default, Yoti SDKs fetch profiles from [https://api.yoti.com/api/v1](https://api.yoti.com/api/v1).

java-sdk-api/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ Temporary Items
175175
Session.vim
176176
# temporary
177177
.netrwhist
178-
*~
179178
# auto-generated tag files
180179
tags
181180

java-sdk-api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.yoti</groupId>
66
<artifactId>java-sdk-api</artifactId>
7-
<version>1.1</version>
7+
<version>1.2</version>
88
<name>Yoti Java SDK API</name>
99
<description>Java SDK for simple integration with the Yoti platform</description>
1010
<url>https://github.com/getyoti/java</url>

java-sdk-api/src/main/java/com/yoti/api/client/HumanProfile.java

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,50 @@
22

33
/**
44
* Profile of an human user with convenience methods to access well-known attributes.
5-
*
6-
*
75
*/
86
public interface HumanProfile extends Profile {
97
/**
10-
* Corresponds to primary name in passport, and surname in English.
8+
* Corresponds to primary name in passport, and surname in English.
9+
*
1110
* @return the surname
1211
*/
1312
String getFamilyName();
1413

1514
/**
1615
* Corresponds to secondary names in passport, and first/middle names in English.
17-
*
16+
*
1817
* @return the name
1918
*/
2019
String getGivenNames();
2120

2221
/**
2322
* Equal to ${given_names} + " " + ${family_name}.
24-
*
23+
*
2524
* @return the given names + the surname
25+
* @deprecated this method has never featured as intended (it has always returned null). Deprecated since version 1.2, likely to be removed in version 2.0. Instead please use {@link #getGivenAndLastNames()}
2626
*/
27+
@Deprecated
2728
String getFullName();
2829

30+
/**
31+
* Equal to ${given_names} + " " + ${family_name}.
32+
*
33+
* @return the given names + the surname
34+
* @since 1.2
35+
*/
36+
String getGivenAndLastNames();
37+
2938
/**
3039
* Date of birth
31-
*
40+
*
3241
* @return Date of birth
3342
*/
3443
Date getDateOfBirth();
3544

3645
/**
3746
* Corresponds to the gender in the passport; will be one of the strings "MALE", "FEMALE" or "OTHER".
3847
*
39-
*@return the gender
48+
* @return the gender
4049
*/
4150
Gender getGender();
4251

@@ -50,28 +59,28 @@ public interface HumanProfile extends Profile {
5059
/**
5160
* The user's phone number, as verified at registration time. This will be a number with + for international prefix
5261
* and no spaces, e.g. "+447777123456".
53-
*
62+
*
5463
* @return the phone number
5564
*/
5665
String getPhoneNumber();
5766

5867
/**
5968
* Photograph of user, encoded as a JPEG image.
60-
*
69+
*
6170
* @return the selfie
6271
*/
6372
Image getSelfie();
6473

6574
/**
6675
* The user's verified email address.
67-
*
76+
*
6877
* @return the email address
6978
*/
7079
String getEmailAddress();
7180

7281
/**
7382
* Document details
74-
*
83+
*
7584
* @return the document details
7685
*/
7786
DocumentDetails getDocumentDetails();

java-sdk-api/src/test/java/com/yoti/api/client/AttributeTest.java

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

3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertNull;
5-
63
import org.junit.Test;
74

8-
import com.yoti.api.client.Attribute;
5+
import static org.hamcrest.CoreMatchers.is;
6+
import static org.junit.Assert.*;
97

108
public class AttributeTest {
119
private static final String NAME = "test";
@@ -24,7 +22,7 @@ public void shouldReturnNullIfValueIsNull() {
2422
}
2523

2624
@Test
27-
public void shouldReturnNullIfValueTypeIsDiffernet() {
25+
public void shouldReturnNullIfValueTypeIsDifferent() {
2826
Attribute a = new Attribute(NAME, "testString");
2927
assertNull(a.getValue(Integer.class));
3028
}
@@ -38,12 +36,12 @@ public void shouldReturnValueNotDefault() {
3836
@Test
3937
public void shouldReturnDefaultIfValueTypeIsDifferent() {
4038
Attribute a = new Attribute(NAME, "testString");
41-
assertEquals(new Integer(1), a.getValueOrDefault(Integer.class, new Integer(1)));
39+
assertThat(1, is(a.getValueOrDefault(Integer.class, 1)));
4240
}
4341

4442
@Test
4543
public void shouldReturnDefaultIfValueIsNull() {
4644
Attribute a = new Attribute(NAME, null);
47-
assertEquals(new Integer(1), a.getValueOrDefault(Integer.class, new Integer(1)));
45+
assertThat(1, is(a.getValueOrDefault(Integer.class, 1)));
4846
}
4947
}

java-sdk-dummy/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ Temporary Items
175175
Session.vim
176176
# temporary
177177
.netrwhist
178-
*~
179178
# auto-generated tag files
180179
tags
181180

java-sdk-dummy/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.yoti</groupId>
66
<artifactId>java-sdk-dummy</artifactId>
7-
<version>1.0</version>
7+
<version>1.1</version>
88
<name>Yoti Java SDK mock testing package</name>
99
<description>Java SDK for simple integration with the Yoti platform</description>
1010
<url>https://github.com/getyoti/java</url>
@@ -117,7 +117,7 @@
117117
<dependency>
118118
<groupId>com.yoti</groupId>
119119
<artifactId>java-sdk-api</artifactId>
120-
<version>1.1</version>
120+
<version>1.2</version>
121121
</dependency>
122122
</dependencies>
123123

java-sdk-dummy/src/main/java/com/yoti/api/client/spi/dummy/DummyYotiClient.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
package com.yoti.api.client.spi.dummy;
22

3+
import com.yoti.api.client.*;
4+
35
import java.util.Collection;
46
import java.util.HashMap;
57
import java.util.HashSet;
68
import java.util.Map;
79

8-
import com.yoti.api.client.ActivityDetails;
9-
import com.yoti.api.client.ApplicationProfile;
10-
import com.yoti.api.client.Attribute;
11-
import com.yoti.api.client.Date;
12-
import com.yoti.api.client.DocumentDetails;
13-
import com.yoti.api.client.HumanProfile;
14-
import com.yoti.api.client.Image;
15-
import com.yoti.api.client.InitialisationException;
16-
import com.yoti.api.client.ProfileException;
17-
import com.yoti.api.client.YotiClient;
18-
import com.yoti.api.client.YotiClientConfiguration;
19-
import com.yoti.api.client.YotiClientFactory;
20-
2110
public class DummyYotiClient implements YotiClient, YotiClientFactory {
2211
private static final String EXCEPTION_TRIGGER_PREFIX = "exception-";
2312
private static final String DUMMY_PREFIX = "dummy-";
@@ -65,10 +54,16 @@ public String getGivenNames() {
6554
}
6655

6756
@Override
57+
@Deprecated
6858
public String getFullName() {
6959
return "John Doe";
7060
}
7161

62+
@Override
63+
public String getGivenAndLastNames() {
64+
return "John Doe";
65+
}
66+
7267
@Override
7368
public Date getDateOfBirth() {
7469
return null;

java-sdk-impl/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ Temporary Items
177177
Session.vim
178178
# temporary
179179
.netrwhist
180-
*~
181180
# auto-generated tag files
182181
tags
183182

java-sdk-impl/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.yoti</groupId>
66
<artifactId>java-sdk-impl</artifactId>
7-
<version>1.1</version>
7+
<version>1.2</version>
88
<name>Yoti Java SDK implementation package</name>
99
<description>Java SDK for simple integration with the Yoti platform</description>
1010
<url>https://github.com/getyoti/java</url>
@@ -81,7 +81,7 @@
8181
<dependency>
8282
<groupId>com.yoti</groupId>
8383
<artifactId>java-sdk-api</artifactId>
84-
<version>1.1</version>
84+
<version>1.2</version>
8585
</dependency>
8686
<!-- Testing dependencies -->
8787
<dependency>

0 commit comments

Comments
 (0)