diff --git a/google-oauth-client/src/main/java/com/google/api/client/auth/openidconnect/IdTokenVerifier.java b/google-oauth-client/src/main/java/com/google/api/client/auth/openidconnect/IdTokenVerifier.java index 6cf3eb0ea..8e769fd72 100644 --- a/google-oauth-client/src/main/java/com/google/api/client/auth/openidconnect/IdTokenVerifier.java +++ b/google-oauth-client/src/main/java/com/google/api/client/auth/openidconnect/IdTokenVerifier.java @@ -25,7 +25,6 @@ import com.google.api.client.json.gson.GsonFactory; import com.google.api.client.json.webtoken.JsonWebSignature.Header; import com.google.api.client.util.Base64; -import com.google.api.client.util.Beta; import com.google.api.client.util.Clock; import com.google.api.client.util.ExponentialBackOff; import com.google.api.client.util.Key; @@ -66,12 +65,11 @@ import java.util.logging.Logger; /** - * {@link Beta}
* Thread-safe ID token verifier based on ID Token * Validation. * - *

Call {@link #verify(IdToken)} to verify a ID token. This is a light-weight object, so you may + *

Call {@link #verify(IdToken)} to verify an ID token. This is a light-weight object, so you may * use a new instance for each configuration of expected issuer and trusted client IDs. Sample * usage: * @@ -101,7 +99,7 @@ * * * not recommended: this check can be disabled with OAUTH_CLIENT_SKIP_SIGNATURE environment variable - * set to true. + * set to true. Use {@link #verifyPayload(IdToken)} instead. * *

Note that {@link #verify(IdToken)} only implements a subset of the verification steps, mostly * just the MUST steps. Please read getAudience() { return audience; } + /** + * Verifies that the given ID token is valid using the cached public keys. + * + *

It verifies: + * + *

+ * + * Deprecated. This method returns false if network requests to get certificates fail. Use {@link + * IdTokenVerifier.verfyOrThrow(IdToken)} instead to differentiate between potentially retryable + * network errors and false verification results. + * + * @param idToken ID token + * @return {@code true} if verified successfully or {@code false} if failed + */ + @Deprecated + public boolean verify(IdToken idToken) { + try { + return verifyOrThrow(idToken); + } catch (IOException ex) { + LOGGER.log(Level.SEVERE, ex.getMessage(), ex); + return false; + } + } + /** * Verifies that the given ID token is valid using the cached public keys. * @@ -233,11 +269,11 @@ public final Collection getAudience() { *

Overriding is allowed, but it must call the super implementation. * * @param idToken ID token - * @return {@code true} if verified successfully or {@code false} if failed + * @return {@code true} if verified successfully or {@code false} if payload validation failed * @throws IOException if verification fails to run. For example, if it fails to get public keys - * for signature validation. + * for signature verification. */ - public boolean verify(IdToken idToken) throws IOException { + public boolean verifyOrThrow(IdToken idToken) throws IOException { boolean payloadValid = verifyPayload(idToken); if (!payloadValid) { @@ -331,14 +367,12 @@ private String getCertificateLocation(Header header) throws VerificationExceptio } /** - * {@link Beta}
* Builder for {@link IdTokenVerifier}. * *

Implementation is not thread-safe. * * @since 1.16 */ - @Beta public static class Builder { /** Clock. */