in src/main/java/com/googlesource/gerrit/plugins/oauth/GoogleOAuthService.java [157:181]
private JsonObject retrieveJWTToken(OAuthToken token) throws IOException {
JsonElement idToken = JSON.newGson().fromJson(token.getRaw(), JsonElement.class);
if (idToken != null && idToken.isJsonObject()) {
JsonObject idTokenObj = idToken.getAsJsonObject();
JsonElement idTokenElement = idTokenObj.get("id_token");
if (idTokenElement != null && !idTokenElement.isJsonNull()) {
String payload;
try {
payload = decodePayload(idTokenElement.getAsString());
} catch (UnsupportedEncodingException e) {
throw new IOException(
String.format(
"%s support is required to interact with JWTs", StandardCharsets.UTF_8.name()),
e);
}
if (!Strings.isNullOrEmpty(payload)) {
JsonElement tokenJsonElement = JSON.newGson().fromJson(payload, JsonElement.class);
if (tokenJsonElement.isJsonObject()) {
return tokenJsonElement.getAsJsonObject();
}
}
}
}
return null;
}