@Override public String digestParams(RestInvocation restInvocation) { String postBody = restInvocation.getRequestBody(); if (postBody == null) { postBody = ""; } String uri = restInvocation.getPath() + "?" + restInvocation.getQueryString(); String message = uri + postBody; mac.update(message.getBytes()); return DigestUtils.bytesToHex(mac.doFinal()).toLowerCase(); } }
@Override public String digestParams(RestInvocation restInvocation) { MessageDigest sha256; try { sha256 = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException( "Illegal algorithm for post body digest. Check the implementation."); } String decodedQuery = null; try { decodedQuery = URLDecoder.decode(restInvocation.getQueryString(), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException("Unsupported query encoding", e); } sha256.update(decodedQuery.getBytes()); sha256.update(restInvocation.getParamValue(HeaderParam.class, "Nonce").toString().getBytes()); sha256.update((restInvocation.getPath()).getBytes()); Mac mac512 = getMac(); mac512.update(sha256.digest()); return Base64.getEncoder().encodeToString(mac512.doFinal()).trim(); } }
@Override public String digestParams(RestInvocation restInvocation) { String timestamp = restInvocation.getHttpHeadersFromParams().get("AC-ACCESS-TIMESTAMP"); String method = restInvocation.getHttpMethod(); String path = restInvocation.getPath(); String queryParameters = restInvocation.getQueryString(); if (!queryParameters.isEmpty()) { queryParameters = '?' + queryParameters; } String body = restInvocation.getRequestBody(); body = body == null ? "" : body; String queryArgs = timestamp + method + path + (queryParameters + body); Mac shaMac = getMac(); final byte[] macData = shaMac.doFinal(queryArgs.getBytes()); return Base64.getEncoder().encodeToString(macData); } }
@Override public String digestParams(RestInvocation restInvocation) { String queryString = restInvocation.getQueryString(); // System.out.println("queryString = " + queryString); String httpMethod = restInvocation.getHttpMethod(); String uri = restInvocation.getPath(); if (queryString != null && queryString.length() > 0) { uri += "?" + restInvocation.getQueryString(); } // System.out.println("uri = " + uri); String requestBody = restInvocation.getRequestBody(); String nonce = restInvocation.getHttpHeadersFromParams().get(Bitflyer.ACCESS_TIMESTAMP); // ACCESS-SIGN is the resulting HMAC-SHA256 signature done with the API secret path using the // ACCESS-TIMESTAMP, HTTP method, request path, and // request body linked together as a character string. String hmac_data = String.format("%s%s%s%s", nonce, httpMethod, uri, requestBody); Mac mac256 = getMac(); mac256.update(hmac_data.getBytes()); return DigestUtils.bytesToHex(mac256.doFinal()).trim(); } }
@Override public String digestParams(RestInvocation restInvocation) { String path = "/" + restInvocation.getMethodPath(); String queryString = restInvocation.getQueryString(); if (queryString != null && queryString.length() > 0) path += "?" + restInvocation.getQueryString(); return builder .withClaim("path", path) .withClaim("nonce", String.valueOf(nonceFactory.createValue())) .withClaim("token_id", tokenID) .sign(Algorithm.HMAC256(userSecret)); } }
@Override public String digestParams(RestInvocation restInvocation) { String postBody = restInvocation.getRequestBody(); if (postBody == null) { postBody = ""; } String uri = restInvocation.getPath() + "?" + restInvocation.getQueryString(); String message = uri + postBody; mac.update(message.getBytes()); return DigestUtils.bytesToHex(mac.doFinal()).toLowerCase(); }
@Override public String digestParams(RestInvocation restInvocation) { String postBody = restInvocation.getRequestBody(); if (postBody == null) { postBody = ""; } String uri = restInvocation.getPath() + "?" + restInvocation.getQueryString(); String message = uri + postBody; mac.update(message.getBytes()); return DigestUtils.bytesToHex(mac.doFinal()).toLowerCase(); } }
@Override public String digestParams(RestInvocation restInvocation) { String queryString = restInvocation.getQueryString(); // System.out.println("queryString = " + queryString); String httpMethod = restInvocation.getHttpMethod(); String uri = restInvocation.getPath(); if (queryString != null && queryString.length() > 0) { uri += "?" + restInvocation.getQueryString(); } // System.out.println("uri = " + uri); String requestBody = restInvocation.getRequestBody(); String nonce = restInvocation.getHttpHeadersFromParams().get(Bitflyer.ACCESS_TIMESTAMP); // ACCESS-SIGN is the resulting HMAC-SHA256 signature done with the API secret path using the // ACCESS-TIMESTAMP, HTTP method, request path, and // request body linked together as a character string. String hmac_data = String.format("%s%s%s%s", nonce, httpMethod, uri, requestBody); Mac mac256 = getMac(); mac256.update(hmac_data.getBytes()); return DigestUtils.bytesToHex(mac256.doFinal()).trim(); } }
@Override public String digestParams(RestInvocation restInvocation) { String path = "/" + restInvocation.getMethodPath(); String queryString = restInvocation.getQueryString(); if (queryString != null && queryString.length() > 0) path += "?" + restInvocation.getQueryString(); return builder .withClaim("path", path) .withClaim("nonce", String.valueOf(nonceFactory.createValue())) .withClaim("token_id", tokenID) .sign(Algorithm.HMAC256(userSecret)); } }