Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions yoti-sdk-api/spotbugs/exclude-filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
</Match>

<Match>
<Class name="com.yoti.api.client.spi.remote.call.SignedRequest"/>
<Class name="com.yoti.api.client.spi.remote.call.YotiHttpRequest"/>
<Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
</Match>

<Match>
<Class name="com.yoti.api.client.spi.remote.call.SignedRequestBuilder"/>
<Class name="com.yoti.api.client.spi.remote.call.YotiHttpRequestBuilder"/>
<Bug pattern="UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR"/>
</Match>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,36 @@ public class DigitalIdentityClient {
Security.addProvider(new BouncyCastleProvider());
}

private final String sdkId;
private final KeyPair keyPair;
private final DigitalIdentityService identityService;

DigitalIdentityClient(String sdkId, KeyPairSource keyPair, DigitalIdentityService identityService) {
Validation.notNullOrEmpty(sdkId, "SDK ID");
Validation.notNull(keyPair, "Application Key Pair");

this.sdkId = sdkId;
this.keyPair = loadKeyPair(keyPair);
private DigitalIdentityClient(KeyPair keyPair, DigitalIdentityService identityService) {
this.keyPair = keyPair;
this.identityService = identityService;
}

public ShareSession createShareSession(ShareSessionRequest request) throws DigitalIdentityException {
return identityService.createShareSession(sdkId, keyPair, request);
return identityService.createShareSession(request);
}

public ShareSession fetchShareSession(String sessionId) throws DigitalIdentityException {
return identityService.fetchShareSession(sdkId, keyPair, sessionId);
return identityService.fetchShareSession(sessionId);
}

public ShareSessionQrCode createShareQrCode(String sessionId) throws DigitalIdentityException {
return identityService.createShareQrCode(sdkId, keyPair, sessionId);
return identityService.createShareQrCode(sessionId);
}

public ShareSessionQrCode fetchShareQrCode(String qrCodeId) throws DigitalIdentityException {
return identityService.fetchShareQrCode(sdkId, keyPair, qrCodeId);
return identityService.fetchShareQrCode(qrCodeId);
}

public Receipt fetchShareReceipt(String receiptId) throws DigitalIdentityException {
return identityService.fetchShareReceipt(sdkId, keyPair, receiptId);
return identityService.fetchShareReceipt(keyPair, receiptId);
}

public MatchResult fetchMatch(MatchRequest request) throws DigitalIdentityException {
return identityService.fetchMatch(sdkId, keyPair, request);
}

private KeyPair loadKeyPair(KeyPairSource keyPairSource) throws InitialisationException {
try {
return keyPairSource.getFromStream(new KeyStreamVisitor());
} catch (IOException ex) {
throw new InitialisationException("Cannot load Key Pair", ex);
}
return identityService.fetchMatch(request);
}

public static Builder builder() {
Expand Down Expand Up @@ -94,7 +81,19 @@ public Builder withKeyPairSource(KeyPairSource keyPairSource) {
}

public DigitalIdentityClient build() {
return new DigitalIdentityClient(sdkId, keyPairSource, DigitalIdentityService.newInstance());
Validation.notNullOrEmpty(sdkId, "SDK ID");
Validation.notNull(keyPairSource, "Application Key Pair");

KeyPair keyPair = loadKeyPair(keyPairSource);
return new DigitalIdentityClient(keyPair, DigitalIdentityService.newInstance(keyPair, sdkId));
}

private KeyPair loadKeyPair(KeyPairSource keyPairSource) throws InitialisationException {
try {
return keyPairSource.getFromStream(new KeyStreamVisitor());
} catch (IOException ex) {
throw new InitialisationException("Cannot load Key Pair", ex);
}
}

}
Expand Down
37 changes: 19 additions & 18 deletions yoti-sdk-api/src/main/java/com/yoti/api/client/YotiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ public class YotiClient {
private final DynamicSharingService dynamicSharingService;

YotiClient(String applicationId,
KeyPairSource kpSource,
KeyPair keyPair,
ReceiptFetcher receiptFetcher,
ActivityDetailsFactory activityDetailsFactory,
RemoteAmlService remoteAmlService,
ActivityDetailsFactory activityDetailsFactory,
DynamicSharingService dynamicSharingService) throws InitialisationException {
this.appId = notNull(applicationId, "Application id");
this.keyPair = loadKeyPair(notNull(kpSource, "Key pair source"));
this.keyPair = keyPair;
this.receiptFetcher = notNull(receiptFetcher, "receiptFetcher");
this.remoteAmlService = notNull(remoteAmlService, "amlService");
this.activityDetailsFactory = notNull(activityDetailsFactory, "activityDetailsFactory");
Expand Down Expand Up @@ -80,7 +80,7 @@ public static YotiClient.Builder builder() {
* @throws ProfileException aggregate exception signalling issues during the call
*/
public ActivityDetails getActivityDetails(String encryptedYotiToken) throws ProfileException {
Receipt receipt = receiptFetcher.fetch(encryptedYotiToken, keyPair, appId);
Receipt receipt = receiptFetcher.fetch(encryptedYotiToken, keyPair);
return activityDetailsFactory.create(receipt, keyPair.getPrivate());
}

Expand All @@ -96,7 +96,7 @@ public ActivityDetails getActivityDetails(String encryptedYotiToken) throws Prof
*/
public AmlResult performAmlCheck(AmlProfile amlProfile) throws AmlException {
LOG.debug("Performing aml check...");
return remoteAmlService.performCheck(keyPair, appId, amlProfile);
return remoteAmlService.performCheck(amlProfile);
}

/**
Expand All @@ -113,15 +113,7 @@ public AmlResult performAmlCheck(AmlProfile amlProfile) throws AmlException {
*/
public ShareUrlResult createShareUrl(DynamicScenario dynamicScenario) throws DynamicShareException {
LOG.debug("Request a share url for a dynamicScenario...");
return dynamicSharingService.createShareUrl(appId, keyPair, dynamicScenario);
}

private KeyPair loadKeyPair(KeyPairSource kpSource) throws InitialisationException {
try {
return kpSource.getFromStream(new KeyStreamVisitor());
} catch (IOException e) {
throw new InitialisationException("Cannot load key pair", e);
}
return dynamicSharingService.createShareUrl(appId, dynamicScenario);
}

public static class Builder {
Expand All @@ -144,14 +136,15 @@ public Builder withKeyPair(KeyPairSource keyPairSource) {

public YotiClient build() {
checkBuilderState();
KeyPair keyPair = loadKeyPair(notNull(keyPairSource, "Key pair source"));

return new YotiClient(
sdkId,
keyPairSource,
ReceiptFetcher.newInstance(),
keyPair,
ReceiptFetcher.newInstance(keyPair, sdkId),
RemoteAmlService.newInstance(keyPair, sdkId),
ActivityDetailsFactory.newInstance(),
RemoteAmlService.newInstance(),
DynamicSharingService.newInstance()
DynamicSharingService.newInstance(keyPair)
);
}

Expand All @@ -164,6 +157,14 @@ private void checkBuilderState() {
}
}

private KeyPair loadKeyPair(KeyPairSource kpSource) throws InitialisationException {
try {
return kpSource.getFromStream(new KeyStreamVisitor());
} catch (IOException e) {
throw new InitialisationException("Cannot load key pair", e);
}
}

}

}
Loading