@@ -40,23 +40,23 @@ public static void main(String[] args) throws NoSuchAlgorithmException, InvalidK
40
40
// TODO(developer): Replace these variables before running the sample.
41
41
// Secret key as a base64 encoded string.
42
42
byte [] base64Key = new byte []{};
43
- // Algorithm can be either `SHA1` or ` SHA256` or ` Ed25519` .
43
+ // Algorithm can be one of these: SHA1, SHA256, or Ed25519.
44
44
String signatureAlgorithm = "ed25519" ;
45
45
// (Optional) Start time as a UTC datetime object.
46
46
DateTimeFormatter formatter = DateTimeFormatter .ISO_INSTANT ;
47
47
Optional <Instant > startTime = Optional .empty ();
48
48
// Expiration time as a UTC datetime object.
49
- // If None, an expiration time 1 hour from now will be used.
49
+ // If None, an expiration time that's an hour after the current time is used.
50
50
Instant expiresTime = Instant .from (formatter .parse ("2022-09-13T12:00:00Z" ));
51
51
52
52
// ONE OF (`urlPrefix`, `fullPath`, `pathGlobs`) must be included in each input.
53
- // The URL prefix to sign, including protocol .
53
+ // The URL prefix and protocol to sign .
54
54
// For example: http://example.com/path/ for URLs under /path or http://example.com/path?param=1
55
55
Optional <String > urlPrefix = Optional .empty ();
56
56
// A full path to sign, starting with the first '/'.
57
57
// For example: /path/to/content.mp4
58
58
Optional <String > fullPath = Optional .of ("http://10.20.30.40/" );
59
- // A set of ','- or '!'-delimited path glob strings .
59
+ // A set of path glob strings delimited by ',' or '!'.
60
60
// For example: /tv/*!/film/* to sign paths starting with /tv/ or /film/ in any URL.
61
61
Optional <String > pathGlobs = Optional .empty ();
62
62
@@ -68,7 +68,7 @@ public static void main(String[] args) throws NoSuchAlgorithmException, InvalidK
68
68
// May be specified more than once.
69
69
// For example: [{'name': 'foo', 'value': 'bar'}, {'name': 'baz', 'value': 'qux'}]
70
70
Optional <List <Header >> headers = Optional .empty ();
71
- // (Optional) A list of comma separated ip ranges. Both IPv4 and IPv6 ranges are acceptable.
71
+ // (Optional) A list of comma- separated IP ranges. Both IPv4 and IPv6 ranges are acceptable.
72
72
// For example: "203.0.113.0/24,2001:db8:4a7f:a732/64"
73
73
Optional <String > ipRanges = Optional .empty ();
74
74
@@ -86,10 +86,10 @@ public static void main(String[] args) throws NoSuchAlgorithmException, InvalidK
86
86
ipRanges );
87
87
}
88
88
89
- // Gets the Signed URL Suffix string for the ' Media CDN' Short token URL requests.
89
+ // Gets the signed URL suffix string for the Media CDN short token URL requests.
90
90
// Result:
91
- // The Signed URL appended with the query parameters based on the
92
- // specified URL prefix and configuration.
91
+ // The signed URL appended with the query parameters based on the
92
+ // specified URL prefix and configuration.
93
93
public static void signToken (
94
94
byte [] base64Key , String signatureAlgorithm , Optional <Instant > startTime ,
95
95
Instant expirationTime , Optional <String > urlPrefix , Optional <String > fullPath ,
@@ -100,9 +100,9 @@ public static void signToken(
100
100
String field = "" ;
101
101
byte [] decodedKey = Base64 .getUrlDecoder ().decode (base64Key );
102
102
103
- // For most fields, the value we put in the token and the value we must sign
104
- // are the same. The FullPath and Headers use a different string for the
105
- // value to be signed compared to the token . To illustrate this difference,
103
+ // For most fields, the value in the token and the value to sign
104
+ // are the same. Compared to the token, the FullPath and Headers
105
+ // use a different string for the value to sign . To illustrate this difference,
106
106
// we'll keep the token and the value to be signed separate.
107
107
List <String > tokens = new ArrayList <>();
108
108
List <String > toSign = new ArrayList <>();
@@ -204,7 +204,7 @@ public static void signToken(
204
204
"Input Missing Error: `signatureAlgorithm` can only be one of `sha1`, `sha256` or "
205
205
+ "`ed25519`" );
206
206
}
207
- // The Signed URL appended with the query parameters based on the
207
+ // The signed URL appended with the query parameters based on the
208
208
// specified URL prefix and configuration.
209
209
System .out .println (String .join ("~" , tokens ));
210
210
}
0 commit comments