@Test void testRefreshOidcToken() throws IOException { String clientId = "test-client-id"; String refreshToken = "test-refresh-token"; String clientSecret = "test-client-secret"; String tokenEndpointUrl = "https: mockOkHttpClient(HttpURLConnection.HTTP_OK, "{\""+ ID_TOKEN_PARAM +"\":\"thisisatesttoken\",\"access_token\": \"thisisrefreshtoken\"," + "\"expires_in\": 3599," + "\"scope\": \"openid https: "\"token_type\": \"Bearer\"}"); Map<String, Object> response = OpenIDConnectionUtils.refreshOidcToken(mockClient, clientId, refreshToken, clientSecret, tokenEndpointUrl); assertNotNull(response); assertEquals("thisisatesttoken", response.get(ID_TOKEN_PARAM)); }
static Map<String, Object> refreshOidcToken(OkHttpClient client, String clientId, String refreshToken, String clientSecret, String tokenURL) throws IOException { try (Response response = client.newCall(getTokenRefreshHttpRequest(tokenURL, clientId, refreshToken, clientSecret)).execute()) { String responseBody; if (response.body() != null) { responseBody = response.body().string(); if (response.isSuccessful()) { return convertJsonStringToMap(responseBody); } else { LOGGER.warn("Response: {}", responseBody); } } } return Collections.emptyMap(); }
OpenIDConnectionUtils { static Map<String, Object> refreshOidcToken(OkHttpClient client, String clientId, String refreshToken, String clientSecret, String tokenURL) throws IOException { try (Response response = client.newCall(getTokenRefreshHttpRequest(tokenURL, clientId, refreshToken, clientSecret)).execute()) { String responseBody; if (response.body() != null) { responseBody = response.body().string(); if (response.isSuccessful()) { return convertJsonStringToMap(responseBody); } else { LOGGER.warn("Response: {}", responseBody); } } } return Collections.emptyMap(); } }
OpenIDConnectionUtils { static Map<String, Object> refreshOidcToken(OkHttpClient client, String clientId, String refreshToken, String clientSecret, String tokenURL) throws IOException { try (Response response = client.newCall(getTokenRefreshHttpRequest(tokenURL, clientId, refreshToken, clientSecret)).execute()) { String responseBody; if (response.body() != null) { responseBody = response.body().string(); if (response.isSuccessful()) { return convertJsonStringToMap(responseBody); } else { LOGGER.warn("Response: {}", responseBody); } } } return Collections.emptyMap(); } private  OpenIDConnectionUtils(); }
OpenIDConnectionUtils { static Map<String, Object> refreshOidcToken(OkHttpClient client, String clientId, String refreshToken, String clientSecret, String tokenURL) throws IOException { try (Response response = client.newCall(getTokenRefreshHttpRequest(tokenURL, clientId, refreshToken, clientSecret)).execute()) { String responseBody; if (response.body() != null) { responseBody = response.body().string(); if (response.isSuccessful()) { return convertJsonStringToMap(responseBody); } else { LOGGER.warn("Response: {}", responseBody); } } } return Collections.emptyMap(); } private  OpenIDConnectionUtils(); static String resolveOIDCTokenFromAuthConfig(Map<String, String> currentAuthProviderConfig); }
OpenIDConnectionUtils { static Map<String, Object> refreshOidcToken(OkHttpClient client, String clientId, String refreshToken, String clientSecret, String tokenURL) throws IOException { try (Response response = client.newCall(getTokenRefreshHttpRequest(tokenURL, clientId, refreshToken, clientSecret)).execute()) { String responseBody; if (response.body() != null) { responseBody = response.body().string(); if (response.isSuccessful()) { return convertJsonStringToMap(responseBody); } else { LOGGER.warn("Response: {}", responseBody); } } } return Collections.emptyMap(); } private  OpenIDConnectionUtils(); static String resolveOIDCTokenFromAuthConfig(Map<String, String> currentAuthProviderConfig); static final String ID_TOKEN_KUBECONFIG; static final String ISSUER_KUBECONFIG; static final String REFRESH_TOKEN_KUBECONFIG; static final String REFRESH_TOKEN_PARAM; static final String GRANT_TYPE_PARAM; static final String CLIENT_ID_PARAM; static final String CLIENT_SECRET_PARAM; static final String ID_TOKEN_PARAM; static final String ACCESS_TOKEN_PARAM; static final String CLIENT_ID_KUBECONFIG; static final String CLIENT_SECRET_KUBECONFIG; static final String IDP_CERT_DATA; static final String TOKEN_ENDPOINT_PARAM; static final String WELL_KNOWN_OPENID_CONFIGURATION; static final String GRANT_TYPE_REFRESH_TOKEN; }