Skip to content

Commit

Permalink
update acc to review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sita04 authored and Shabirmean committed May 19, 2023
1 parent eb7106d commit 09b8263
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions media_cdn/src/main/java/token/DualToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ public static void main(String[] args) throws NoSuchAlgorithmException, InvalidK
// TODO(developer): Replace these variables before running the sample.
// Secret key as a base64 encoded string.
byte[] base64Key = new byte[]{};
// Algorithm can be either `SHA1` or `SHA256` or `Ed25519`.
// Algorithm can be one of these: SHA1, SHA256, or Ed25519.
String signatureAlgorithm = "ed25519";
// (Optional) Start time as a UTC datetime object.
DateTimeFormatter formatter = DateTimeFormatter.ISO_INSTANT;
Optional<Instant> startTime = Optional.empty();
// Expiration time as a UTC datetime object.
// If None, an expiration time 1 hour from now will be used.
// If None, an expiration time that's an hour after the current time is used.
Instant expiresTime = Instant.from(formatter.parse("2022-09-13T12:00:00Z"));

// ONE OF (`urlPrefix`, `fullPath`, `pathGlobs`) must be included in each input.
// The URL prefix to sign, including protocol.
// The URL prefix and protocol to sign.
// For example: http://example.com/path/ for URLs under /path or http://example.com/path?param=1
Optional<String> urlPrefix = Optional.empty();
// A full path to sign, starting with the first '/'.
// For example: /path/to/content.mp4
Optional<String> fullPath = Optional.of("http://10.20.30.40/");
// A set of ','- or '!'-delimited path glob strings.
// A set of path glob strings delimited by ',' or '!'.
// For example: /tv/*!/film/* to sign paths starting with /tv/ or /film/ in any URL.
Optional<String> pathGlobs = Optional.empty();

Expand All @@ -68,7 +68,7 @@ public static void main(String[] args) throws NoSuchAlgorithmException, InvalidK
// May be specified more than once.
// For example: [{'name': 'foo', 'value': 'bar'}, {'name': 'baz', 'value': 'qux'}]
Optional<List<Header>> headers = Optional.empty();
// (Optional) A list of comma separated ip ranges. Both IPv4 and IPv6 ranges are acceptable.
// (Optional) A list of comma-separated IP ranges. Both IPv4 and IPv6 ranges are acceptable.
// For example: "203.0.113.0/24,2001:db8:4a7f:a732/64"
Optional<String> ipRanges = Optional.empty();

Expand All @@ -86,10 +86,10 @@ public static void main(String[] args) throws NoSuchAlgorithmException, InvalidK
ipRanges);
}

// Gets the Signed URL Suffix string for the 'Media CDN' Short token URL requests.
// Gets the signed URL suffix string for the Media CDN short token URL requests.
// Result:
// The Signed URL appended with the query parameters based on the
// specified URL prefix and configuration.
// The signed URL appended with the query parameters based on the
// specified URL prefix and configuration.
public static void signToken(
byte[] base64Key, String signatureAlgorithm, Optional<Instant> startTime,
Instant expirationTime, Optional<String> urlPrefix, Optional<String> fullPath,
Expand All @@ -100,9 +100,9 @@ public static void signToken(
String field = "";
byte[] decodedKey = Base64.getUrlDecoder().decode(base64Key);

// For most fields, the value we put in the token and the value we must sign
// are the same. The FullPath and Headers use a different string for the
// value to be signed compared to the token. To illustrate this difference,
// For most fields, the value in the token and the value to sign
// are the same. Compared to the token, the FullPath and Headers
// use a different string for the value to sign. To illustrate this difference,
// we'll keep the token and the value to be signed separate.
List<String> tokens = new ArrayList<>();
List<String> toSign = new ArrayList<>();
Expand Down Expand Up @@ -204,7 +204,7 @@ public static void signToken(
"Input Missing Error: `signatureAlgorithm` can only be one of `sha1`, `sha256` or "
+ "`ed25519`");
}
// The Signed URL appended with the query parameters based on the
// The signed URL appended with the query parameters based on the
// specified URL prefix and configuration.
System.out.println(String.join("~", tokens));
}
Expand Down

0 comments on commit 09b8263

Please sign in to comment.