/** @return the query string except of the "signature" parameter */ private static String getQuery(RestInvocation restInvocation) { final Params p = Params.of(); restInvocation .getParamsMap() .get(QueryParam.class) .asHttpHeaders() .entrySet() .stream() .filter(e -> !BinanceAuthenticated.SIGNATURE.equals(e.getKey())) .forEach(e -> p.add(e.getKey(), e.getValue())); return p.asQueryString(); }
/** {@inheritDoc} */ @Override public String digestParams(RestInvocation restInvocation) { Params params = restInvocation.getParamsMap().get(FormParam.class); Map<String, String> nameValues = params.asHttpHeaders(); nameValues.remove("signature"); Params newParams = Params.of(); for (Map.Entry<String, String> nameValue : nameValues.entrySet()) { newParams.add(nameValue.getKey(), nameValue.getValue()); } String message = newParams.asQueryString(); Mac mac = getMac(); mac.update(message.getBytes()); return String.format("%064x", new BigInteger(1, mac.doFinal())); } }
@Override public String digestParams(RestInvocation restInvocation) { // Create Query String From Form Parameters Params params = Params.of(); restInvocation .getParamsMap() .get(FormParam.class) .asHttpHeaders() .entrySet() .stream() .filter(e -> !e.getKey().equalsIgnoreCase("signature")) .forEach(e -> params.add(e.getKey(), e.getValue())); // Parse Query String byte[] queryString = params.asQueryString().trim().getBytes(UTF8); // Create And Return Signature return hex(getMac().doFinal(queryString)); } }
Collections.sort(nameValueList, (e1, e2) -> e1.getKey().compareTo(e2.getKey())); final Params newParams = Params.of(); for (int i = 0; i < nameValueList.size(); i++) { Map.Entry<String, String> param = nameValueList.get(i);
public static HashMap<Class<? extends Annotation>, Params> createEmptyParamsMap(Map<Class<? extends Annotation>, Params> defaultParamsMap) { HashMap<Class<? extends Annotation>, Params> paramsMap = new HashMap<>(); for (Class<? extends Annotation> annotationClass : PARAM_ANNOTATION_CLASSES) { paramsMap.put(annotationClass, Params.of()); } if (defaultParamsMap != null) { paramsMap.putAll(defaultParamsMap); } return paramsMap; }
public static HashMap<Class<? extends Annotation>, Params> createEmptyParamsMap(Map<Class<? extends Annotation>, Params> defaultParamsMap) { HashMap<Class<? extends Annotation>, Params> paramsMap = new HashMap<>(); for (Class<? extends Annotation> annotationClass : PARAM_ANNOTATION_CLASSES) { paramsMap.put(annotationClass, Params.of()); } if (defaultParamsMap != null) { paramsMap.putAll(defaultParamsMap); } return paramsMap; }
public ClientConfig addDefaultParam(Class<? extends Annotation> paramType, String paramName, Object paramValue) { Params params = defaultParamsMap.get(paramType); if (params == null) { params = Params.of(); defaultParamsMap.put(paramType, params); } params.add(paramName, paramValue); return this; }
public ClientConfig addDefaultParam(Class<? extends Annotation> paramType, String paramName, Object paramValue) { Params params = defaultParamsMap.get(paramType); if (params == null) { params = Params.of(); defaultParamsMap.put(paramType, params); } params.add(paramName, paramValue); return this; }
public static Params of(String p1, Object v1, String p2, Object v2) { return of(p1, v1).add(p2, v2); }
public static Params of(String p1, Object v1, String p2, Object v2, String p3, Object v3, String p4, Object v4) { return of(p1, v1, p2, v2, p3, v3).add(p4, v4); }
public static Params of(String param, Object value) { return of().add(param, value); }
public static Params of(String p1, Object v1, String p2, Object v2, String p3, Object v3) { return of(p1, v1, p2, v2).add(p3, v3); }
public static Params of(String p1, Object v1, String p2, Object v2, String p3, Object v3, String p4, Object v4) { return of(p1, v1, p2, v2, p3, v3).add(p4, v4); }
public static Params of(String p1, Object v1, String p2, Object v2) { return of(p1, v1).add(p2, v2); }
public static Params of(String p1, Object v1, String p2, Object v2, String p3, Object v3) { return of(p1, v1, p2, v2).add(p3, v3); }
public static Params of(String param, Object value) { return of().add(param, value); }
public String digestParams(Map<String, String> parameters) { Params params = Params.of(); new TreeMap<>(parameters) .entrySet() .stream() .filter(e -> !e.getKey().equals("sign")) .forEach(e -> params.add(e.getKey(), e.getValue())); String payload = format("%s&secret_key=%s", params.toString(), secretKey); log.trace("payload: {}", payload); return DigestUtils.bytesToHex(md.digest(payload.getBytes(UTF_8))); }
/** @return the query string except of the "signature" parameter */ private static String getQuery(RestInvocation restInvocation) { final Params p = Params.of(); restInvocation.getParamsMap().get(QueryParam.class).asHttpHeaders().entrySet().stream() .filter(e -> !BinanceAuthenticated.SIGNATURE.equals(e.getKey())) .forEach(e -> p.add(e.getKey(), e.getValue())); return p.asQueryString(); }
/** {@inheritDoc} */ @Override public String digestParams(RestInvocation restInvocation) { Params params = restInvocation.getParamsMap().get(FormParam.class); Map<String, String> nameValues = params.asHttpHeaders(); nameValues.remove("signature"); Params newParams = Params.of(); for (Map.Entry<String, String> nameValue : nameValues.entrySet()) { newParams.add(nameValue.getKey(), nameValue.getValue()); } String message = newParams.asQueryString(); Mac mac = getMac(); mac.update(message.getBytes()); return String.format("%064x", new BigInteger(1, mac.doFinal())); } }
/** * {@inheritDoc} */ @Override public String digestParams(RestInvocation restInvocation) { Params params = restInvocation.getParamsMap().get(FormParam.class); Map<String, String> nameValues = params.asHttpHeaders(); nameValues.remove("signature"); Params newParams = Params.of(); for (Map.Entry<String, String> nameValue : nameValues.entrySet()) { newParams.add(nameValue.getKey(), nameValue.getValue()); } String message = newParams.asQueryString(); Mac mac = getMac(); mac.update(message.getBytes()); return String.format("%064x", new BigInteger(1, mac.doFinal())); }