/** * To protect against replay attacks, make sure the timestamp on the request is valid * by ensuring that the difference between the request time and the current time on the * server does not fall outside the acceptable time range. Note that the request time * may have been generated on a different machine and so it may be ahead or behind the * current server time. * * @param timestamp the timestamp specified on the request (in standard ISO8601 format) * @return true if the timestamp is valid */ private boolean validateTimestamp(String timestamp) { DateTime requestTime = TimeUtils.parse(timestamp); long difference = Math.abs(new Duration(requestTime, nowInUTC()).getMillis()); return difference <= allowedTimestampRange; }
public void encode(ClientRequest request) { String timestamp = TimeUtils.getCurrentTimestamp(); addApiKey(request); addTimestamp(request, timestamp); addSignature(request, timestamp); addVersion(request, Version.V1); }
public static String getCurrentTimestamp() { DateTimeFormatter formatter = ISODateTimeFormat.dateTime(); return formatter.print(nowInUTC()); }
public void encode(ClientRequest request) { String timestamp = TimeUtils.getCurrentTimestamp(); addApiKey(request); addTimestamp(request, timestamp); addSignature(request, timestamp); addVersion(request, Version.V1); }
public static String getCurrentTimestamp() { DateTimeFormatter formatter = ISODateTimeFormat.dateTime(); return formatter.print(nowInUTC()); }
public void encode(ClientRequest request) { String timestamp = TimeUtils.getCurrentTimestamp(); addApiKey(request); addTimestamp(request, timestamp); addSignature(request, timestamp); addVersion(request, Version.V1); }
/** * To protect against replay attacks, make sure the timestamp on the request is valid * by ensuring that the difference between the request time and the current time on the * server does not fall outside the acceptable time range. Note that the request time * may have been generated on a different machine and so it may be ahead or behind the * current server time. * * @param timestamp the timestamp specified on the request (in standard ISO8601 format) * @return true if the timestamp is valid */ private boolean validateTimestamp(String timestamp) { DateTime requestTime = TimeUtils.parse(timestamp); long difference = Math.abs(new Duration(requestTime, nowInUTC()).getMillis()); return difference <= allowedTimestampRange; }