private void replaceSignatureUrl(RestInvocation restInvocation, String signature) { String invocationUrl = restInvocation.getInvocationUrl(); String newInvocationUrl = invocationUrl.replace(PLACEHOLDER, signature); try { invocationUrlField.set(restInvocation, newInvocationUrl); } catch (IllegalAccessException e) { throw new IllegalStateException("rescu library has been updated"); } }
private void replaceInvocationUrl(RestInvocation restInvocation, String signature) { String invocationUrl = restInvocation.getInvocationUrl(); String newInvocationUrl = invocationUrl.replace(PLACEHOLDER, signature); try { invocationUrlField.set(restInvocation, newInvocationUrl); } catch (IllegalArgumentException | IllegalAccessException e) { throw new IllegalStateException("rescu library has been updated"); } }
@Override public String digestParams(RestInvocation restInvocation) { String invocationUrl = restInvocation.getInvocationUrl(); Mac mac = getMac(); mac.update(invocationUrl.getBytes()); return String.format("%0128x", new BigInteger(1, mac.doFinal())); } }
@Override public String digestParams(RestInvocation restInvocation) { String invocationUrl = restInvocation.getInvocationUrl(); Mac mac = getMac(); mac.update(invocationUrl.getBytes()); return String.format("%040x", new BigInteger(1, mac.doFinal())); } }
@Override public String digestParams(RestInvocation restInvocation) { final String nonce = restInvocation .getParamValue(HeaderParam.class, TheRockAuthenticated.X_TRT_NONCE) .toString(); mac.update(nonce.getBytes()); mac.update(restInvocation.getInvocationUrl().getBytes()); return String.format("%0128x", new BigInteger(1, mac.doFinal())); } }
@Override public String digestParams(RestInvocation restInvocation) { String invocationUrl = restInvocation.getInvocationUrl(); Mac mac = getMac(); mac.update(invocationUrl.getBytes()); return String.format("%0128x", new BigInteger(1, mac.doFinal())); } }
@Override public String digestParams(RestInvocation restInvocation) { String invocationUrl = restInvocation.getInvocationUrl(); Mac mac = getMac(); mac.update(invocationUrl.getBytes()); return String.format("%0128x", new BigInteger(1, mac.doFinal())); } }
@Override public String digestParams(RestInvocation restInvocation) { String invocationUrl = restInvocation.getParamValue(HeaderParam.class, "Api-Nonce").toString() + restInvocation.getInvocationUrl(); Mac mac = getMac(); mac.update(invocationUrl.getBytes()); return String.format("%064x", new BigInteger(1, mac.doFinal())); } }
@Override public String digestParams(RestInvocation restInvocation) { final String message = restInvocation.getParamValue(HeaderParam.class, "ACCESS_NONCE").toString() + restInvocation.getInvocationUrl() + restInvocation.getRequestBody(); Mac mac256 = getMac(); mac256.update(message.getBytes()); return String.format("%064x", new BigInteger(1, mac256.doFinal())); } }
@Override public String digestParams(RestInvocation restInvocation) { try { String urlMethod = restInvocation.getInvocationUrl(); String nonce = String.valueOf(nonceFactory.createValue()); String body = restInvocation.getRequestBody(); String md5 = Base64.getEncoder() .encodeToString(MessageDigest.getInstance("MD5").digest(body.getBytes("UTF-8"))); String reqSignature = apiKey + "POST" + URLEncoder.encode(urlMethod, StandardCharsets.UTF_8.toString()).toLowerCase() + nonce + md5; return "amx " + apiKey + ":" + Base64.getEncoder().encodeToString(getMac().doFinal(reqSignature.getBytes("UTF-8"))) + ":" + nonce; } catch (Exception e) { throw new IllegalStateException("Faile to sign request", e); } } }
String invocationUrl = restInvocation.getInvocationUrl().trim(); String jsonEncodedArray = new StringBuilder("[\"")
@Override public String digestParams(RestInvocation restInvocation) { String method = restInvocation.getHttpMethod(); String uri = restInvocation.getInvocationUrl(); Map<Class<? extends Annotation>, Params> params = restInvocation.getParamsMap(); if (params.containsKey(QueryParam.class)) {
URL url = new URL(restInvocation.getInvocationUrl());
@Override public String digestParams(RestInvocation restInvocation) { // Step 1: concatenate URL with query string String completeURL = restInvocation.getInvocationUrl(); // Step 2: create md5-Hash of the POST-Parameters for the HMAC-data String httpMethod = restInvocation.getHttpMethod(); String requestBody = restInvocation.getRequestBody(); String md5; if ("POST".equals(httpMethod)) { md5 = getMD5(requestBody); } else { md5 = "d41d8cd98f00b204e9800998ecf8427e"; // no post params for GET methods } // Step 3: concat HMAC-input // http_method+'#'+uri+'#'+api_key+'#'+nonce+'#'+post_parameter_md5_hashed_url_encoded_query_string String nonce = restInvocation.getHttpHeadersFromParams().get("X-API-NONCE"); String hmac_data = String.format("%s#%s#%s#%s#%s", httpMethod, completeURL, apiKey, nonce, md5); // Step 3: Create actual sha256-HMAC Mac mac256 = getMac(); mac256.update(hmac_data.getBytes()); return String.format("%064x", new BigInteger(1, mac256.doFinal())); }
@Override public String digestParams(RestInvocation restInvocation) { return digest( restInvocation.getHttpMethod(), restInvocation.getInvocationUrl(), restInvocation.getReqContentType(), restInvocation.getParamValue(HeaderParam.class, "API_REQUEST_DATE").toString()); }
@Override public String digestParams(RestInvocation restInvocation) { String pathWithQueryString = restInvocation.getInvocationUrl().replace(restInvocation.getBaseUrl(), ""); String message = restInvocation.getParamValue(HeaderParam.class, "CB-ACCESS-TIMESTAMP").toString() + restInvocation.getHttpMethod() + pathWithQueryString + (restInvocation.getRequestBody() != null ? restInvocation.getRequestBody() : ""); Mac mac256 = getMac(); try { mac256.update(message.getBytes("UTF-8")); } catch (Exception e) { throw new ExchangeException("Digest encoding exception", e); } signature = Base64.getEncoder().encodeToString(mac256.doFinal()); return signature; }
@Override public String digestParams(RestInvocation restInvocation) { String nonce = restInvocation.getParamValue(HeaderParam.class, "api-expires").toString(); String path = restInvocation.getInvocationUrl().split(restInvocation.getBaseUrl())[1]; String payload = restInvocation.getHttpMethod() + "/" + path + nonce + restInvocation.getRequestBody(); return digestString(payload); }
String invocationUrl = restInvocation.getInvocationUrl();
@Override public String digestParams(RestInvocation restInvocation) { final String nonce = restInvocation.getParamValue(HeaderParam.class, TheRockAuthenticated.X_TRT_NONCE).toString(); mac.update(nonce.getBytes()); mac.update(restInvocation.getInvocationUrl().getBytes()); return String.format("%0128x", new BigInteger(1, mac.doFinal())); } }
@Override public String digestParams(RestInvocation restInvocation) { String invocationUrl = restInvocation.getInvocationUrl(); Mac mac = getMac(); mac.update(invocationUrl.getBytes()); return String.format("%0128x", new BigInteger(1, mac.doFinal())); } }