/** @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(); }
final Map<String, String> nameValueMap = params.asHttpHeaders(); 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); newParams.add(param.getKey(), param.getValue()); final String message = newParams.toString() + "&secret_key=" + secretKey;
Map<Class<? extends Annotation>, Params> params = restInvocation.getParamsMap(); if (params.containsKey(QueryParam.class)) { uri = params.get(QueryParam.class).applyToPath(uri);
@Override public String digestParams(RestInvocation restInvocation) { // Get Parameters Map<String, String> params = restInvocation.getParamsMap().get(FormParam.class).asHttpHeaders(); // TODO: Find More Elegant Solution To Remove Sign // Order By Key Alphabetically, Concancecate Values byte[] unsigned = params .entrySet() .stream() .sorted(Map.Entry.<String, String>comparingByKey()) .filter(e -> !e.getKey().equalsIgnoreCase("sign")) .map(e -> e.getValue()) .collect(Collectors.joining()) .getBytes(); // TODO: Determine Charceter Encoding return String.valueOf(md5.digest(unsigned)); } }
String paramName = getParamName(paramAnn); if (paramName != null) { paramsMap.get(paramAnn.annotationType()).add(paramName, args[i]); if (annotation != null) { String paramName = getParamName(annotation); paramsMap.get(paramAnnotationClass).add(paramName, methodMetadata.getMethodName()); params.replaceValueFactories(); path = appendPath(path, methodPath); String queryString = paramsMap.get(QueryParam.class).asQueryString(); String invocationUrl = getInvocationUrl(methodMetadata.getBaseUrl(), path, queryString); params.digestAll(invocation);
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))); }
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; }
@Override public String digestParams(RestInvocation restInvocation) { Params params = restInvocation.getParamsMap().get(FormParam.class); StringBuilder queryString = new StringBuilder(params.asQueryString()); Mac mac = getMac(); byte[] source = mac.doFinal(queryString.toString().getBytes()); return String.format("%0128x", new BigInteger(1, source)); }
Solver solver = ctx.mkSolver(); Params solver_params = ctx.mkParams(); solver_params.add("ignore_solver1", true); solver.setParameters(solver_params);
private String toQueryString(boolean encode) { StringBuilder b = new StringBuilder(); for (String paramName : data.keySet()) { if (isParamSet(paramName)) { Object originalValue = getParamValue(paramName); boolean createArrayParameters = originalValue instanceof Iterable && paramName.endsWith("[]"); @SuppressWarnings("unchecked") Iterable<Object> paramValues = createArrayParameters ? (Iterable<Object>)originalValue : Collections.singleton(originalValue); for (Object paramValue : paramValues) { if (b.length() > 0) { b.append('&'); } String paramValueAsString = toString(paramValue); b.append(paramName).append('=').append(urlEncode(paramValueAsString, encode)); } } } return b.toString(); }
private String getParamValueAsString(String key) { Object paramValue = getParamValue(key); return toString(paramValue); }
String iterableToString(Iterable iterable) { final StringBuilder sb = new StringBuilder(); for (Object o : iterable) { if (sb.length() > 0) { sb.append(","); } sb.append(toString(o)); } return sb.toString(); }
@Override public String digestParams(RestInvocation restInvocation) { Params params; if (restInvocation.getHttpMethod().equals("GET")) params = restInvocation.getParamsMap().get(QueryParam.class); else params = restInvocation.getParamsMap().get(FormParam.class); Map<String, String> sorted = new TreeMap<>(params.asHttpHeaders()); String queryString = buildQueryString(sorted); Mac mac = getMac(); mac.update(queryString.getBytes(StandardCharsets.UTF_8)); return String.format("%064x", new BigInteger(1, mac.doFinal())).toUpperCase(); } }
String paramName = getParamName(paramAnn); if (paramName != null) { paramsMap.get(paramAnn.annotationType()).add(paramName, args[i]); if (annotation != null) { String paramName = getParamName(annotation); paramsMap.get(paramAnnotationClass).add(paramName, methodMetadata.getMethodName()); params.replaceValueFactories(); path = appendPath(path, methodPath); String queryString = paramsMap.get(QueryParam.class).asQueryString(); String invocationUrl = getInvocationUrl(methodMetadata.getBaseUrl(), path, queryString); params.digestAll(invocation);
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; }
private String toQueryString(boolean encode) { StringBuilder b = new StringBuilder(); for (String paramName : data.keySet()) { if (isParamSet(paramName)) { Object originalValue = getParamValue(paramName); boolean createArrayParameters = originalValue instanceof Iterable && paramName.endsWith("[]"); @SuppressWarnings("unchecked") Iterable<Object> paramValues = createArrayParameters ? (Iterable<Object>)originalValue : Collections.singleton(originalValue); for (Object paramValue : paramValues) { if (b.length() > 0) { b.append('&'); } String paramValueAsString = toString(paramValue); b.append(paramName).append('=').append(urlEncode(paramValueAsString, encode)); } } } return b.toString(); }
private String getParamValueAsString(String key) { Object paramValue = getParamValue(key); return toString(paramValue); }
String iterableToString(Iterable iterable) { final StringBuilder sb = new StringBuilder(); for (Object o : iterable) { if (sb.length() > 0) { sb.append(","); } sb.append(toString(o)); } return sb.toString(); }