@@ -66,6 +66,7 @@ public class SDKBuilder {
6666 private SSLFactory sslFactory ;
6767 private AuthorizationGrant authzGrant ;
6868 private ProtocolType protocolType = ProtocolType .CONNECT ;
69+ private SrtSigner srtSigner ;
6970
7071 private static final Logger logger = LoggerFactory .getLogger (SDKBuilder .class );
7172
@@ -177,6 +178,11 @@ public SDKBuilder protocol(ProtocolType protocolType) {
177178 return this ;
178179 }
179180
181+ public SDKBuilder srtSigner (SrtSigner signer ) {
182+ this .srtSigner = signer ;
183+ return this ;
184+ }
185+
180186 private Interceptor getAuthInterceptor (RSAKey rsaKey ) {
181187 if (platformEndpoint == null ) {
182188 throw new SDKException ("cannot build an SDK without specifying the platform endpoint" );
@@ -236,14 +242,16 @@ static class ServicesAndInternals {
236242 final Interceptor interceptor ;
237243 final TrustManager trustManager ;
238244 final ProtocolClient protocolClient ;
245+ final SrtSigner srtSigner ;
239246
240247 final SDK .Services services ;
241248
242- ServicesAndInternals (Interceptor interceptor , TrustManager trustManager , SDK .Services services , ProtocolClient protocolClient ) {
249+ ServicesAndInternals (Interceptor interceptor , TrustManager trustManager , SDK .Services services , ProtocolClient protocolClient , SrtSigner srtSigner ) {
243250 this .interceptor = interceptor ;
244251 this .trustManager = trustManager ;
245252 this .services = services ;
246253 this .protocolClient = protocolClient ;
254+ this .srtSigner = srtSigner ;
247255 }
248256 }
249257
@@ -267,7 +275,8 @@ ServicesAndInternals buildServices() {
267275
268276 this .platformEndpoint = AddressNormalizer .normalizeAddress (this .platformEndpoint , this .usePlainText );
269277 var authInterceptor = getAuthInterceptor (dpopKey );
270- var kasClient = getKASClient (dpopKey , authInterceptor );
278+ var srtSignerToUse = this .srtSigner == null ? new DefaultSrtSigner (dpopKey ) : this .srtSigner ;
279+ var kasClient = getKASClient (srtSignerToUse , authInterceptor );
271280 var httpClient = getHttpClient ();
272281 var client = getProtocolClient (platformEndpoint , httpClient , authInterceptor );
273282 var attributeService = new AttributesServiceClient (client );
@@ -337,18 +346,19 @@ public SDK.KAS kas() {
337346 authInterceptor ,
338347 sslFactory == null ? null : sslFactory .getTrustManager ().orElse (null ),
339348 services ,
340- client );
349+ client ,
350+ srtSignerToUse );
341351 }
342352
343353 @ Nonnull
344- private KASClient getKASClient (RSAKey dpopKey , Interceptor interceptor ) {
354+ private KASClient getKASClient (SrtSigner srtSigner , Interceptor interceptor ) {
345355 BiFunction <OkHttpClient , String , ProtocolClient > protocolClientFactory = (OkHttpClient client , String address ) -> getProtocolClient (address , client , interceptor );
346- return new KASClient (getHttpClient (), protocolClientFactory , dpopKey , usePlainText );
356+ return new KASClient (getHttpClient (), protocolClientFactory , srtSigner , usePlainText );
347357 }
348358
349359 public SDK build () {
350360 var services = buildServices ();
351- return new SDK (services .services , services .trustManager , services .interceptor , services .protocolClient , platformEndpoint );
361+ return new SDK (services .services , services .trustManager , services .interceptor , services .protocolClient , platformEndpoint , services . srtSigner );
352362 }
353363
354364 private ProtocolClient getUnauthenticatedProtocolClient (String endpoint , OkHttpClient httpClient ) {
0 commit comments