@@ -46,13 +46,13 @@ public class YotiClient {
4646 private final DynamicSharingService dynamicSharingService ;
4747
4848 YotiClient (String applicationId ,
49- KeyPairSource kpSource ,
49+ KeyPair keyPair ,
5050 ReceiptFetcher receiptFetcher ,
51- ActivityDetailsFactory activityDetailsFactory ,
5251 RemoteAmlService remoteAmlService ,
52+ ActivityDetailsFactory activityDetailsFactory ,
5353 DynamicSharingService dynamicSharingService ) throws InitialisationException {
5454 this .appId = notNull (applicationId , "Application id" );
55- this .keyPair = loadKeyPair ( notNull ( kpSource , "Key pair source" )) ;
55+ this .keyPair = keyPair ;
5656 this .receiptFetcher = notNull (receiptFetcher , "receiptFetcher" );
5757 this .remoteAmlService = notNull (remoteAmlService , "amlService" );
5858 this .activityDetailsFactory = notNull (activityDetailsFactory , "activityDetailsFactory" );
@@ -80,7 +80,7 @@ public static YotiClient.Builder builder() {
8080 * @throws ProfileException aggregate exception signalling issues during the call
8181 */
8282 public ActivityDetails getActivityDetails (String encryptedYotiToken ) throws ProfileException {
83- Receipt receipt = receiptFetcher .fetch (encryptedYotiToken , keyPair , appId );
83+ Receipt receipt = receiptFetcher .fetch (encryptedYotiToken , keyPair );
8484 return activityDetailsFactory .create (receipt , keyPair .getPrivate ());
8585 }
8686
@@ -96,7 +96,7 @@ public ActivityDetails getActivityDetails(String encryptedYotiToken) throws Prof
9696 */
9797 public AmlResult performAmlCheck (AmlProfile amlProfile ) throws AmlException {
9898 LOG .debug ("Performing aml check..." );
99- return remoteAmlService .performCheck (keyPair , appId , amlProfile );
99+ return remoteAmlService .performCheck (amlProfile );
100100 }
101101
102102 /**
@@ -113,15 +113,7 @@ public AmlResult performAmlCheck(AmlProfile amlProfile) throws AmlException {
113113 */
114114 public ShareUrlResult createShareUrl (DynamicScenario dynamicScenario ) throws DynamicShareException {
115115 LOG .debug ("Request a share url for a dynamicScenario..." );
116- return dynamicSharingService .createShareUrl (appId , keyPair , dynamicScenario );
117- }
118-
119- private KeyPair loadKeyPair (KeyPairSource kpSource ) throws InitialisationException {
120- try {
121- return kpSource .getFromStream (new KeyStreamVisitor ());
122- } catch (IOException e ) {
123- throw new InitialisationException ("Cannot load key pair" , e );
124- }
116+ return dynamicSharingService .createShareUrl (appId , dynamicScenario );
125117 }
126118
127119 public static class Builder {
@@ -144,14 +136,15 @@ public Builder withKeyPair(KeyPairSource keyPairSource) {
144136
145137 public YotiClient build () {
146138 checkBuilderState ();
139+ KeyPair keyPair = loadKeyPair (notNull (keyPairSource , "Key pair source" ));
147140
148141 return new YotiClient (
149142 sdkId ,
150- keyPairSource ,
151- ReceiptFetcher .newInstance (),
143+ keyPair ,
144+ ReceiptFetcher .newInstance (keyPair , sdkId ),
145+ RemoteAmlService .newInstance (keyPair , sdkId ),
152146 ActivityDetailsFactory .newInstance (),
153- RemoteAmlService .newInstance (),
154- DynamicSharingService .newInstance ()
147+ DynamicSharingService .newInstance (keyPair )
155148 );
156149 }
157150
@@ -164,6 +157,14 @@ private void checkBuilderState() {
164157 }
165158 }
166159
160+ private KeyPair loadKeyPair (KeyPairSource kpSource ) throws InitialisationException {
161+ try {
162+ return kpSource .getFromStream (new KeyStreamVisitor ());
163+ } catch (IOException e ) {
164+ throw new InitialisationException ("Cannot load key pair" , e );
165+ }
166+ }
167+
167168 }
168169
169170}
0 commit comments