Source:
private String getNewAccessToken( String userId, String sourceId, String encodedClientIdSecret, String discoveryUrl, String grantType, Map<String, String> queryParameters, OIDCProviderMetadata metadata) { WebClient webClient = createWebClient(metadata.getTokenEndpointURI()); webClient.header(AUTHORIZATION, BASIC + encodedClientIdSecret); webClient.accept(APPLICATION_JSON); Form formParam = new Form(GRANT_TYPE, grantType); queryParameters.forEach(formParam::param); formParam.param(SCOPE, OPENID_SCOPE); javax.ws.rs.core.Response response = webClient.form(formParam); String body; try { body = IOUtils.toString((InputStream) response.getEntity(), UTF_8); } catch (IOException e) { LOGGER.debug("Unable to retrieve system access token.", e); return null; } if (response.getStatus() != HttpStatus.SC_OK) { LOGGER.debug("Unable to retrieve system access token. {}", body); return null; } Map<String, String> map = GSON.fromJson(body, MAP_STRING_TO_OBJECT_TYPE); String idToken = map.get(ID_TOKEN); String accessToken = map.get(ACCESS_TOKEN); String refreshToken = map.get(REFRESH_TOKEN); JWT jwt = null; try { if (idToken != null) { jwt = SignedJWT.parse(idToken); } } catch (java.text.ParseException e) { LOGGER.debug("Error parsing ID token.", e); } try { OidcTokenValidator.validateAccessToken( new BearerAccessToken(accessToken), jwt, resourceRetriever, metadata, null); } catch (OidcValidationException e) { LOGGER.warn("Error validating system access token.", e); return null; } LOGGER.debug("Successfully retrieved system access token."); int status = tokenStorage.create(userId, sourceId, accessToken, refreshToken, discoveryUrl); if (status != SC_OK) { LOGGER.debug("Error storing user token."); } return accessToken; }

Target:
private String getNewAccessToken( String userId, String sourceId, String encodedClientIdSecret, String discoveryUrl, String grantType, Map<String, String> queryParameters, OIDCProviderMetadata metadata) { WebClient webClient = createWebClient(metadata.getTokenEndpointURI()); webClient.header(AUTHORIZATION, BASIC + encodedClientIdSecret); webClient.accept(APPLICATION_JSON); Form formParam = new Form(GRANT_TYPE, grantType); formParam.param(SCOPE, OPENID_SCOPE); queryParameters.forEach(formParam::param); javax.ws.rs.core.Response response = webClient.form(formParam); String body; try { body = IOUtils.toString((InputStream) response.getEntity(), UTF_8); } catch (IOException e) { LOGGER.debug("Unable to retrieve system access token.", e); return null; } if (response.getStatus() != HttpStatus.SC_OK) { LOGGER.debug("Unable to retrieve system access token. {}", body); return null; } Map<String, String> map = GSON.fromJson(body, MAP_STRING_TO_OBJECT_TYPE); String idToken = map.get(ID_TOKEN); String accessToken = map.get(ACCESS_TOKEN); String refreshToken = map.get(REFRESH_TOKEN); JWT jwt = null; try { if (idToken != null) { jwt = SignedJWT.parse(idToken); } } catch (java.text.ParseException e) { LOGGER.debug("Error parsing ID token.", e); } try { OidcTokenValidator.validateAccessToken( new BearerAccessToken(accessToken), jwt, resourceRetriever, metadata, null); } catch (OidcValidationException e) { LOGGER.warn("Error validating system access token.", e); return null; } LOGGER.debug("Successfully retrieved system access token."); int status = tokenStorage.create(userId, sourceId, accessToken, refreshToken, discoveryUrl); if (status != SC_OK) { LOGGER.debug("Error storing user token."); } return accessToken; }