code: public String generate(String url) {
          long expiration = this.expiration;
          if (expiration == 0) {
              if (duration > 0) {
                  final long start = startTime > 0 ? startTime : Calendar.getInstance(TimeZone.getTimeZone("UTC")).getTimeInMillis() / 1000L;
                  expiration = start + duration;
              } else {
                  throw new IllegalArgumentException("Must provide either expiration or duration");
              }
          }
          ArrayList<String> tokenParts = new ArrayList<String>();
          if (ip != null) {
              tokenParts.add("ip=" + ip);
          }
          if (startTime > 0) {
              tokenParts.add("st=" + startTime);
          }
          tokenParts.add("exp=" + expiration);
          if (acl != null) {
              tokenParts.add("acl=" + escapeToLower(acl));
          }
          ArrayList<String> toSign = new ArrayList<String>(tokenParts);
          if (url != null && acl == null) {
              toSign.add("url=" + escapeToLower(url));
          }
          String auth = digest(StringUtils.join(toSign, "~"));
          tokenParts.add("hmac=" + auth);
          return tokenName + "=" + StringUtils.join(tokenParts, "~");
  
      }
docs: Generate a URL token for the given URL.
  
  @param url the URL to be authorized
  @return a URL token