https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java File google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java (left): https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java#oldcode127 google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java:127: transport = builder.transport; On 2013/08/17 00:28:21, peleyal wrote: > ...
13 years, 2 months ago
(2013-08-19 16:24:27 UTC)
#8
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
File
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java
(left):
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java:127:
transport = builder.transport;
On 2013/08/17 00:28:21, peleyal wrote:
> Don't you need to call:
> super(builder)?
Done.
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
File
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java
(right):
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java:86:
* Returns the Google public certificates manager.
On 2013/08/17 00:28:21, peleyal wrote:
> manager? where did that come from?
It is initialized inside the Builder.
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java:303:
.setClock(publicCerts.getClock()).build();
On 2013/08/17 00:28:21, peleyal wrote:
> you are just creating publicCerts, how can you call it's publicCerts.getClock.
> Am I missing something?
It is guaranteed to be initialized inside the constructor.
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
File
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCerts.java
(right):
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCerts.java:66:
private List<PublicKey> publicKeys;
On 2013/08/17 00:28:21, peleyal wrote:
> why not final?
It is changed inside refresh()
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCerts.java:90:
public GooglePublicCerts(HttpTransport transport, JsonFactory jsonFactory) {
On 2013/08/17 00:28:21, peleyal wrote:
> Why you want to provide this constructor, isn't it enough to have just the
> protected GooglePublicCerts(Builder builder) ?
This is the builder pattern style we are using throughout the library. We
provide a constructor with just the required parameters, and then provide a
builder-based constructor if you want to specify optional parameters.
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCerts.java:130:
* within 5 minutes of expiring), {@link #refresh()} will be called before
returning the value.
On 2013/08/17 00:28:21, peleyal wrote:
> within {@code 5} minutes...?
I don't think 5 by itself is "code". "5" is used in common speech as well.
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCerts.java:136:
if (publicKeys == null || clock.currentTimeMillis() + 300000 >
expirationTimeMilliseconds) {
On 2013/08/17 00:28:21, peleyal wrote:
> 30000 -> CONST
Done.
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/test...
File
google-api-client/src/test/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCertsTest.java
(right):
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/test...
google-api-client/src/test/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCertsTest.java:113:
assertEquals(100 + (12345 - 42) * 1000, certs.getExpirationTimeMilliseconds());
On 2013/08/17 00:28:21, peleyal wrote:
> Please save all those numbers as consts
Done, though just for the AGE & MAX_AGE since that's shared code.
LGTM (sorry for the months of delay) Just notice my optional comments. https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java File google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java ...
13 years, 2 months ago
(2013-08-20 20:07:31 UTC)
#9
LGTM (sorry for the months of delay)
Just notice my optional comments.
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
File
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java
(right):
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java:86:
* Returns the Google public certificates manager.
[optional]
I don't like this name, can you rephrase?
On 2013/08/19 16:24:27, yanivi wrote:
> On 2013/08/17 00:28:21, peleyal wrote:
> > manager? where did that come from?
>
> It is initialized inside the Builder.
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
File
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCerts.java
(right):
https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main...
google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCerts.java:90:
public GooglePublicCerts(HttpTransport transport, JsonFactory jsonFactory) {
[optional]
Don't like it, but ACK.
I prefer to have here only one constructor that uses the builder. I'm pretty
sure we are doing so in some classes in the library (but I'm not sure... you
know better than I'm)
On 2013/08/19 16:24:27, yanivi wrote:
> On 2013/08/17 00:28:21, peleyal wrote:
> > Why you want to provide this constructor, isn't it enough to have just the
> > protected GooglePublicCerts(Builder builder) ?
>
> This is the builder pattern style we are using throughout the library. We
> provide a constructor with just the required parameters, and then provide a
> builder-based constructor if you want to specify optional parameters.
https://codereview.appspot.com/10053044/diff/44001/google-api-client/src/test...
File
google-api-client/src/test/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCertsTest.java
(right):
https://codereview.appspot.com/10053044/diff/44001/google-api-client/src/test...
google-api-client/src/test/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCertsTest.java:124:
new HttpHeaders().setAge(345L).setCacheControl("max-age=" + MAX_AGE)));
[optional]
I prefer 345L to be a const too, because it's shared in 3 different place in
this method.
Also consdier to define
const int EXPECTED_TIME = 12000;
const int AGE = 345L;
assertEquals(EXPECTED_TIME, certs.getCacheTimeInSec(
new HttpHeaders().setAge(AGE).setCacheControl("max-age=" + MAX_AGE)));
It looks better to me.
Submitting now... On Tuesday, August 20, 2013, wrote: > LGTM (sorry for the months of ...
13 years, 2 months ago
(2013-08-20 21:16:05 UTC)
#10
Submitting now...
On Tuesday, August 20, 2013, wrote:
> LGTM (sorry for the months of delay)
> Just notice my optional comments.
>
>
>
> https://codereview.appspot.**com/10053044/diff/37001/**
> google-api-client/src/main/**java/com/google/api/client/**
>
googleapis/auth/oauth2/**GoogleIdTokenVerifier.java<https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java>
> File
> google-api-client/src/main/**java/com/google/api/client/**
> googleapis/auth/oauth2/**GoogleIdTokenVerifier.java
> (right):
>
> https://codereview.appspot.**com/10053044/diff/37001/**
> google-api-client/src/main/**java/com/google/api/client/**
>
googleapis/auth/oauth2/**GoogleIdTokenVerifier.java#**newcode86<https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GoogleIdTokenVerifier.java#newcode86>
> google-api-client/src/main/**java/com/google/api/client/**
> googleapis/auth/oauth2/**GoogleIdTokenVerifier.java:86:
> * Returns the Google public certificates manager.
> [optional]
> I don't like this name, can you rephrase?
>
Done: renamed to GooglePublicKeysManager
On 2013/08/19 16:24:27, yanivi wrote:
>
>> On 2013/08/17 00:28:21, peleyal wrote:
>> > manager? where did that come from?
>>
>
> It is initialized inside the Builder.
>>
>
> https://codereview.appspot.**com/10053044/diff/37001/**
> google-api-client/src/main/**java/com/google/api/client/**
>
googleapis/auth/oauth2/**GooglePublicCerts.java<https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCerts.java>
> File
> google-api-client/src/main/**java/com/google/api/client/**
> googleapis/auth/oauth2/**GooglePublicCerts.java
> (right):
>
> https://codereview.appspot.**com/10053044/diff/37001/**
> google-api-client/src/main/**java/com/google/api/client/**
>
googleapis/auth/oauth2/**GooglePublicCerts.java#**newcode90<https://codereview.appspot.com/10053044/diff/37001/google-api-client/src/main/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCerts.java#newcode90>
> google-api-client/src/main/**java/com/google/api/client/**
> googleapis/auth/oauth2/**GooglePublicCerts.java:90:
> public GooglePublicCerts(**HttpTransport transport, JsonFactory
> jsonFactory) {
> [optional]
> Don't like it, but ACK.
> I prefer to have here only one constructor that uses the builder. I'm
> pretty sure we are doing so in some classes in the library (but I'm not
> sure... you know better than I'm)
Again, I'm following standard style, and if any classes aren't following it
then they should be updated to follow the latest standard style.
On 2013/08/19 16:24:27, yanivi wrote:
>
>> On 2013/08/17 00:28:21, peleyal wrote:
>> > Why you want to provide this constructor, isn't it enough to have
>>
> just the
>
>> > protected GooglePublicCerts(Builder builder) ?
>>
>
> This is the builder pattern style we are using throughout the library.
>>
> We
>
>> provide a constructor with just the required parameters, and then
>>
> provide a
>
>> builder-based constructor if you want to specify optional parameters.
>>
>
> https://codereview.appspot.**com/10053044/diff/44001/**
> google-api-client/src/test/**java/com/google/api/client/**
>
googleapis/auth/oauth2/**GooglePublicCertsTest.java<https://codereview.appspot.com/10053044/diff/44001/google-api-client/src/test/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCertsTest.java>
> File
> google-api-client/src/test/**java/com/google/api/client/**
> googleapis/auth/oauth2/**GooglePublicCertsTest.java
> (right):
>
> https://codereview.appspot.**com/10053044/diff/44001/**
> google-api-client/src/test/**java/com/google/api/client/**
>
googleapis/auth/oauth2/**GooglePublicCertsTest.java#**newcode124<https://codereview.appspot.com/10053044/diff/44001/google-api-client/src/test/java/com/google/api/client/googleapis/auth/oauth2/GooglePublicCertsTest.java#newcode124>
> google-api-client/src/test/**java/com/google/api/client/**
> googleapis/auth/oauth2/**GooglePublicCertsTest.java:**124:
> new HttpHeaders().setAge(345L).**setCacheControl("max-age=" + MAX_AGE)));
> [optional]
> I prefer 345L to be a const too, because it's shared in 3 different
> place in this method.
> Also consdier to define
>
> const int EXPECTED_TIME = 12000;
> const int AGE = 345L;
>
> assertEquals(EXPECTED_TIME, certs.getCacheTimeInSec(
> new HttpHeaders().setAge(AGE).**setCacheControl("max-age=" + MAX_AGE)));
>
> It looks better to me.
>
I disagree when it comes to unit tests. I like seeing the numbers
directly. It makes the test more readable in this case.
>
>
https://codereview.appspot.**com/10053044/<https://codereview.appspot.com/100...
>
Issue 10053044: api issue 793: New GooglePublicCerts and improvements to GoogleIdTokenVerifier
(Closed)
Created 13 years, 4 months ago by yanivi
Modified 13 years, 2 months ago
Reviewers: peleyal
Base URL: https://code.google.com/p/google-api-java-client/
Comments: 19