LgoSignatureServiceLocalRsa implements LgoSignatureService { @Override public String digestSignedUrlAndBodyHeader(String url, String timestamp, String body) { try { String urlToSign = removeProtocol(url); String signatureBaseString = String.format("%s\n%s\n%s", timestamp, urlToSign, body); return buildHeader(signSHA256RSA(signatureBaseString)); } catch (Exception e) { throw new RuntimeException("Error signing request", e); } } LgoSignatureServiceLocalRsa(@NonNull String apiKey, @NonNull String privKey); @Override String digestSignedUrlAndBodyHeader(String url, String timestamp, String body); @Override String digestSignedUrlHeader(String url, String timestamp); @Override LgoOrderSignature signOrder(String encryptedOrder);  }
@Test public void digestHeaderWithBody() { String timestamp = "123456789"; String urlToSign = "http: String payload = "{\"type\":\"L\",\"side\":\"S\",\"product_id\":\"BTC-USD\",\"quantity\":\"0.5\",\"price\":\"1000\",\"reference\":2468}"; String digest = signatureService.digestSignedUrlAndBodyHeader(urlToSign, timestamp, payload); assertThat(digest) .isEqualTo( String.format( "LGO %s:58590721eccabb3cfd0bf68658bd69cd3bece50332dfbd5e55ccb695fdc5a8cf9f71257c910a1d1c425c0e3e5b591d3cc480ec29032a642512d71592f236b72ccbca1ba53695e3d28002cdb67b22875de9a4ca57b431b25719ad51fedbc961f00b979077126e76a67f5bf8baaef2109133c06aa358d3e0df21ef818db3d9a0d0770f695be4c9f5123815e184534cef8606e64e4117b81bc9dda83c4793bc4d823f66d1d2f152548e0595f031d0a5caa49407a2fdf31f6f8710133abd14cabd5ad9af7893d8360a65438946bedc377c694fd84c260d30ff6916f61a0c0492966c1cf662c3a8b523111e8ecc36b3acf65241d2e6d71ce2085d0e29a8d88655a03e", apiKey)); }