public static boolean validateToken(String authToken, UserDetails userDetails) {
    String[] parts = authToken.split(":");
    long expires = Long.parseLong(parts[1]);
    String signature = parts[2];

    if (expires < System.currentTimeMillis()) {
      return false;
    }

    String computedSignature = TokenUtils.computeSignature(userDetails, expires);
    return signature.equals(computedSignature);
  }
  public static String createToken(UserDetails userDetails) {
    /* Expires in one hour */
    long expires = System.currentTimeMillis() + 1000L * 60 * 60;

    StringBuilder tokenBuilder = new StringBuilder();
    tokenBuilder.append(userDetails.getUsername());
    tokenBuilder.append(":");
    tokenBuilder.append(expires);
    tokenBuilder.append(":");
    tokenBuilder.append(TokenUtils.computeSignature(userDetails, expires));

    return tokenBuilder.toString();
  }