Skip to content

Commit edbdf07

Browse files
committed
SDK-2771: Rename SignedRequest->YotiHttpRequest
1 parent b1d4a4f commit edbdf07

27 files changed

Lines changed: 467 additions & 459 deletions

yoti-sdk-api/spotbugs/exclude-filter.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
</Match>
2828

2929
<Match>
30-
<Class name="com.yoti.api.client.spi.remote.call.SignedRequest"/>
30+
<Class name="com.yoti.api.client.spi.remote.call.YotiHttpRequest"/>
3131
<Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
3232
</Match>
3333

3434
<Match>
35-
<Class name="com.yoti.api.client.spi.remote.call.SignedRequestBuilder"/>
35+
<Class name="com.yoti.api.client.spi.remote.call.YotiHttpRequestBuilder"/>
3636
<Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
3737
</Match>
3838

yoti-sdk-api/src/main/java/com/yoti/api/client/docs/DocScanService.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
import com.yoti.api.client.docs.support.SupportedDocumentsResponse;
3535
import com.yoti.api.client.spi.remote.MediaValue;
3636
import com.yoti.api.client.spi.remote.call.ResourceException;
37-
import com.yoti.api.client.spi.remote.call.SignedRequest;
38-
import com.yoti.api.client.spi.remote.call.SignedRequestBuilderFactory;
39-
import com.yoti.api.client.spi.remote.call.SignedRequestResponse;
37+
import com.yoti.api.client.spi.remote.call.YotiHttpRequest;
38+
import com.yoti.api.client.spi.remote.call.YotiHttpRequestBuilderFactory;
39+
import com.yoti.api.client.spi.remote.call.YotiHttpResponse;
4040
import com.yoti.api.client.spi.remote.call.factory.UnsignedPathFactory;
4141

4242
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -62,15 +62,15 @@ final class DocScanService {
6262

6363
private final UnsignedPathFactory unsignedPathFactory;
6464
private final ObjectMapper objectMapper;
65-
private final SignedRequestBuilderFactory signedRequestBuilderFactory;
65+
private final YotiHttpRequestBuilderFactory yotiHttpRequestBuilderFactory;
6666
private final String apiUrl;
6767

6868
private DocScanService(UnsignedPathFactory pathFactory,
6969
ObjectMapper objectMapper,
70-
SignedRequestBuilderFactory signedRequestBuilderFactory) {
70+
YotiHttpRequestBuilderFactory yotiHttpRequestBuilderFactory) {
7171
this.unsignedPathFactory = pathFactory;
7272
this.objectMapper = objectMapper;
73-
this.signedRequestBuilderFactory = signedRequestBuilderFactory;
73+
this.yotiHttpRequestBuilderFactory = yotiHttpRequestBuilderFactory;
7474

7575
apiUrl = System.getProperty(PROPERTY_YOTI_DOCS_URL, DEFAULT_YOTI_DOCS_URL);
7676
}
@@ -82,7 +82,7 @@ public static DocScanService newInstance() {
8282
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
8383
objectMapper.registerModule(new JavaTimeModule());
8484

85-
return new DocScanService(new UnsignedPathFactory(), objectMapper, new SignedRequestBuilderFactory());
85+
return new DocScanService(new UnsignedPathFactory(), objectMapper, new YotiHttpRequestBuilderFactory());
8686
}
8787

8888
/**
@@ -105,7 +105,7 @@ public CreateSessionResult createSession(String sdkId, KeyPair keyPair, SessionS
105105
try {
106106
byte[] payload = objectMapper.writeValueAsBytes(sessionSpec);
107107

108-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
108+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
109109
.withKeyPair(keyPair)
110110
.withBaseUrl(apiUrl)
111111
.withEndpoint(path)
@@ -114,7 +114,7 @@ public CreateSessionResult createSession(String sdkId, KeyPair keyPair, SessionS
114114
.withHeader(CONTENT_TYPE, CONTENT_TYPE_JSON)
115115
.build();
116116

117-
return signedRequest.execute(CreateSessionResult.class);
117+
return yotiHttpRequest.execute(CreateSessionResult.class);
118118
} catch (GeneralSecurityException ex) {
119119
throw new DocScanException("Error signing the request: " + ex.getMessage(), ex);
120120
} catch (ResourceException ex) {
@@ -144,14 +144,14 @@ public GetSessionResult retrieveSession(String sdkId, KeyPair keyPair, String se
144144
LOG.info("Fetching session from '{}'", path);
145145

146146
try {
147-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
147+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
148148
.withKeyPair(keyPair)
149149
.withBaseUrl(apiUrl)
150150
.withEndpoint(path)
151151
.withHttpMethod(HTTP_GET)
152152
.build();
153153

154-
return signedRequest.execute(GetSessionResult.class);
154+
return yotiHttpRequest.execute(GetSessionResult.class);
155155
} catch (GeneralSecurityException ex) {
156156
throw new DocScanException("Error signing the request: " + ex.getMessage(), ex);
157157
} catch (ResourceException ex) {
@@ -180,14 +180,14 @@ public void deleteSession(String sdkId, KeyPair keyPair, String sessionId) throw
180180
LOG.info("Deleting session from '{}'", path);
181181

182182
try {
183-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
183+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
184184
.withKeyPair(keyPair)
185185
.withBaseUrl(apiUrl)
186186
.withEndpoint(path)
187187
.withHttpMethod(HTTP_DELETE)
188188
.build();
189189

190-
signedRequest.execute();
190+
yotiHttpRequest.execute();
191191
} catch (GeneralSecurityException ex) {
192192
throw new DocScanException("Error signing the request: " + ex.getMessage(), ex);
193193
} catch (ResourceException ex) {
@@ -219,13 +219,13 @@ public Media getMediaContent(String sdkId, KeyPair keyPair, String sessionId, St
219219
LOG.info("Fetching media from '{}'", path);
220220

221221
try {
222-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
222+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
223223
.withKeyPair(keyPair)
224224
.withBaseUrl(apiUrl)
225225
.withEndpoint(path)
226226
.withHttpMethod(HTTP_GET)
227227
.build();
228-
SignedRequestResponse response = signedRequest.execute();
228+
YotiHttpResponse response = yotiHttpRequest.execute();
229229

230230
if (response.getResponseCode() == HTTP_STATUS_NO_CONTENT) {
231231
return null;
@@ -259,14 +259,14 @@ public void deleteMediaContent(String sdkId, KeyPair keyPair, String sessionId,
259259
LOG.info("Deleting media at '{}'", path);
260260

261261
try {
262-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
262+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
263263
.withKeyPair(keyPair)
264264
.withBaseUrl(apiUrl)
265265
.withEndpoint(path)
266266
.withHttpMethod(HTTP_DELETE)
267267
.build();
268268

269-
signedRequest.execute();
269+
yotiHttpRequest.execute();
270270
} catch (GeneralSecurityException ex) {
271271
throw new DocScanException("Error signing the request: " + ex.getMessage(), ex);
272272
} catch (ResourceException ex) {
@@ -288,15 +288,15 @@ public void putIbvInstructions(String sdkId, KeyPair keyPair, String sessionId,
288288
try {
289289
byte[] payload = objectMapper.writeValueAsBytes(instructions);
290290

291-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
291+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
292292
.withKeyPair(keyPair)
293293
.withBaseUrl(apiUrl)
294294
.withEndpoint(path)
295295
.withHttpMethod(HTTP_PUT)
296296
.withPayload(payload)
297297
.build();
298298

299-
signedRequest.execute();
299+
yotiHttpRequest.execute();
300300
} catch (GeneralSecurityException ex) {
301301
throw new DocScanException("Error signing the request: " + ex.getMessage(), ex);
302302
} catch (ResourceException ex) {
@@ -315,14 +315,14 @@ public InstructionsResponse getIbvInstructions(String sdkId, KeyPair keyPair, St
315315
LOG.info("Fetching IBV instructions at '{}'", path);
316316

317317
try {
318-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
318+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
319319
.withKeyPair(keyPair)
320320
.withBaseUrl(apiUrl)
321321
.withEndpoint(path)
322322
.withHttpMethod(HTTP_GET)
323323
.build();
324324

325-
return signedRequest.execute(InstructionsResponse.class);
325+
return yotiHttpRequest.execute(InstructionsResponse.class);
326326
} catch (GeneralSecurityException ex) {
327327
throw new DocScanException("Error signing the request: " + ex.getMessage(), ex);
328328
} catch (ResourceException ex) {
@@ -350,14 +350,14 @@ public ContactProfileResponse fetchInstructionsContactProfile(String sdkId, KeyP
350350
LOG.info("Fetching instruction contact profile from '{}'", path);
351351

352352
try {
353-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
353+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
354354
.withKeyPair(keyPair)
355355
.withBaseUrl(apiUrl)
356356
.withEndpoint(path)
357357
.withHttpMethod(HTTP_GET)
358358
.build();
359359

360-
return signedRequest.execute(ContactProfileResponse.class);
360+
return yotiHttpRequest.execute(ContactProfileResponse.class);
361361
} catch (GeneralSecurityException ex) {
362362
throw new DocScanException("Error signing the request: " + ex.getMessage(), ex);
363363
} catch (ResourceException ex) {
@@ -376,13 +376,13 @@ public Media getIbvInstructionsPdf(String sdkId, KeyPair keyPair, String session
376376
LOG.info("Fetching instructions PDF at '{}'", path);
377377

378378
try {
379-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
379+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
380380
.withKeyPair(keyPair)
381381
.withBaseUrl(apiUrl)
382382
.withEndpoint(path)
383383
.withHttpMethod(HTTP_GET)
384384
.build();
385-
SignedRequestResponse response = signedRequest.execute();
385+
YotiHttpResponse response = yotiHttpRequest.execute();
386386

387387
if (response.getResponseCode() == HTTP_STATUS_NO_CONTENT) {
388388
return null;
@@ -406,14 +406,14 @@ public SessionConfigurationResponse fetchSessionConfiguration(String sdkId, KeyP
406406
LOG.info("Fetching session configuration from '{}'", path);
407407

408408
try {
409-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
409+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
410410
.withKeyPair(keyPair)
411411
.withBaseUrl(apiUrl)
412412
.withEndpoint(path)
413413
.withHttpMethod(HTTP_GET)
414414
.build();
415415

416-
return signedRequest.execute(SessionConfigurationResponse.class);
416+
return yotiHttpRequest.execute(SessionConfigurationResponse.class);
417417
} catch (GeneralSecurityException ex) {
418418
throw new DocScanException("Error signing the request: " + ex.getMessage(), ex);
419419
} catch (ResourceException ex) {
@@ -438,15 +438,15 @@ public CreateFaceCaptureResourceResponse createFaceCaptureResource(String sdkId,
438438
try {
439439
byte[] payload = objectMapper.writeValueAsBytes(createFaceCaptureResourcePayload);
440440

441-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
441+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
442442
.withKeyPair(keyPair)
443443
.withBaseUrl(apiUrl)
444444
.withEndpoint(path)
445445
.withPayload(payload)
446446
.withHttpMethod(HTTP_POST)
447447
.build();
448448

449-
return signedRequest.execute(CreateFaceCaptureResourceResponse.class);
449+
return yotiHttpRequest.execute(CreateFaceCaptureResourceResponse.class);
450450
} catch (GeneralSecurityException ex) {
451451
throw new DocScanException("Error signing the request: " + ex.getMessage(), ex);
452452
} catch (ResourceException ex) {
@@ -468,7 +468,7 @@ public void uploadFaceCaptureImage(String sdkId, KeyPair keyPair, String session
468468
LOG.info("Uploading image to Face Capture resource at '{}'", path);
469469

470470
try {
471-
signedRequestBuilderFactory.create()
471+
yotiHttpRequestBuilderFactory.create()
472472
.withMultipartBoundary(YOTI_MULTIPART_BOUNDARY)
473473
.withMultipartBinaryBody(
474474
"binary-content",
@@ -494,14 +494,14 @@ public SupportedDocumentsResponse getSupportedDocuments(KeyPair keyPair, boolean
494494
String path = unsignedPathFactory.createGetSupportedDocumentsPath(includeNonLatin);
495495

496496
try {
497-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
497+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
498498
.withKeyPair(keyPair)
499499
.withBaseUrl(apiUrl)
500500
.withEndpoint(path)
501501
.withHttpMethod(HTTP_GET)
502502
.build();
503503

504-
return signedRequest.execute(SupportedDocumentsResponse.class);
504+
return yotiHttpRequest.execute(SupportedDocumentsResponse.class);
505505
} catch (GeneralSecurityException | ResourceException ex) {
506506
throw new DocScanException("Error executing the GET: " + ex.getMessage(), ex);
507507
} catch (IOException | URISyntaxException ex) {
@@ -518,7 +518,7 @@ public void triggerIbvEmailNotification(String sdkId, KeyPair keyPair, String se
518518
LOG.info("Triggering IBV email notification at '{}'", path);
519519

520520
try {
521-
signedRequestBuilderFactory.create()
521+
yotiHttpRequestBuilderFactory.create()
522522
.withKeyPair(keyPair)
523523
.withBaseUrl(apiUrl)
524524
.withEndpoint(path)
@@ -541,14 +541,14 @@ public List<MetadataResponse> getTrackedDevices(String sdkId, KeyPair keyPair, S
541541
LOG.info("Fetching tracked devices at '{}'", path);
542542

543543
try {
544-
SignedRequest signedRequest = signedRequestBuilderFactory.create()
544+
YotiHttpRequest yotiHttpRequest = yotiHttpRequestBuilderFactory.create()
545545
.withKeyPair(keyPair)
546546
.withBaseUrl(apiUrl)
547547
.withEndpoint(path)
548548
.withHttpMethod(HTTP_GET)
549549
.build();
550550

551-
return signedRequest.execute(METADATA_RESPONSE_TYPE_REF);
551+
return yotiHttpRequest.execute(METADATA_RESPONSE_TYPE_REF);
552552
} catch (GeneralSecurityException | ResourceException ex) {
553553
throw new DocScanException("Error executing the GET: " + ex.getMessage(), ex);
554554
} catch (IOException | URISyntaxException ex) {
@@ -565,7 +565,7 @@ public void deleteTrackedDevices(String sdkId, KeyPair keyPair, String sessionId
565565
LOG.info("Deleting tracked devices at '{}'", path);
566566

567567
try {
568-
signedRequestBuilderFactory.create()
568+
yotiHttpRequestBuilderFactory.create()
569569
.withKeyPair(keyPair)
570570
.withBaseUrl(apiUrl)
571571
.withEndpoint(path)
@@ -579,7 +579,7 @@ public void deleteTrackedDevices(String sdkId, KeyPair keyPair, String sessionId
579579
}
580580
}
581581

582-
private String findContentType(SignedRequestResponse response) {
582+
private String findContentType(YotiHttpResponse response) {
583583
List<String> contentTypeValues = null;
584584
for (Map.Entry<String, List<String>> entry : response.getResponseHeaders().entrySet()) {
585585
if (entry.getKey() != null && entry.getKey().toLowerCase(Locale.ENGLISH).equals(CONTENT_TYPE.toLowerCase(Locale.ENGLISH))) {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ private ImageResourceFetcher(RawResourceFetcher rawResourceFetcher) {
2929
this.rawResourceFetcher = rawResourceFetcher;
3030
}
3131

32-
Image doRequest(SignedRequest signedRequest) throws IOException, ResourceException {
33-
SignedRequestResponse signedRequestResponse = rawResourceFetcher.doRequest(signedRequest);
34-
String contentType = getContentType(signedRequestResponse.getResponseHeaders());
35-
byte[] responseBody = signedRequestResponse.getResponseBody();
32+
Image doRequest(YotiHttpRequest yotiHttpRequest) throws IOException, ResourceException {
33+
YotiHttpResponse yotiHttpResponse = rawResourceFetcher.doRequest(yotiHttpRequest);
34+
String contentType = getContentType(yotiHttpResponse.getResponseHeaders());
35+
byte[] responseBody = yotiHttpResponse.getResponseBody();
3636
switch (contentType) {
3737
case CONTENT_TYPE_PNG:
3838
return new PngAttributeValue(responseBody);
3939
case CONTENT_TYPE_JPEG:
4040
return new JpegAttributeValue(responseBody);
4141
default:
4242
LOG.error("Failed to convert image of type: (" + contentType + ")");
43-
throw new ResourceException(signedRequestResponse.getResponseCode(), "Failed to convert image of type: (" + contentType + ")", null);
43+
throw new ResourceException(yotiHttpResponse.getResponseCode(), "Failed to convert image of type: (" + contentType + ")", null);
4444
}
4545
}
4646

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ private JsonResourceFetcher(ObjectMapper objectMapper,
3636
}
3737

3838
@Override
39-
public <T> T doRequest(SignedRequest signedRequest, Class<T> resourceClass) throws ResourceException, IOException {
40-
SignedRequestResponse signedRequestResponse = rawResourceFetcher.doRequest(signedRequest);
41-
return objectMapper.readValue(signedRequestResponse.getResponseBody(), resourceClass);
39+
public <T> T doRequest(YotiHttpRequest yotiHttpRequest, Class<T> resourceClass) throws ResourceException, IOException {
40+
YotiHttpResponse yotiHttpResponse = rawResourceFetcher.doRequest(yotiHttpRequest);
41+
return objectMapper.readValue(yotiHttpResponse.getResponseBody(), resourceClass);
4242
}
4343

44-
public <T> T doRequest(SignedRequest signedRequest, TypeReference<T> resourceClass) throws ResourceException, IOException {
45-
SignedRequestResponse signedRequestResponse = rawResourceFetcher.doRequest(signedRequest);
46-
return objectMapper.readValue(signedRequestResponse.getResponseBody(), resourceClass);
44+
public <T> T doRequest(YotiHttpRequest yotiHttpRequest, TypeReference<T> resourceClass) throws ResourceException, IOException {
45+
YotiHttpResponse yotiHttpResponse = rawResourceFetcher.doRequest(yotiHttpRequest);
46+
return objectMapper.readValue(yotiHttpResponse.getResponseBody(), resourceClass);
4747
}
4848

4949
}

0 commit comments

Comments
 (0)