@Test void obtainTokenDetailsByRefreshToken() throws Exception { String refreshToken = "refresh token"; when(realmService.getRealmForCurrentRequest()).thenReturn("realm2"); TokenDetails expectedTokenDetails = new TokenDetails(); doReturn(expectedTokenDetails).when(client).obtainTokenDetails(eq("realm2"), paramsCaptor.capture()); assertEquals(expectedTokenDetails, client.obtainTokenDetailsByRefreshToken(refreshToken)); Map<String, String> params = convertParamsToMap(paramsCaptor.getValue()); assertThat(params.size(), is(4)); assertThat(params.get(OAuth2Constants.GRANT_TYPE), is(OAuth2Constants.REFRESH_TOKEN)); assertThat(params.get(OAuth2Constants.REFRESH_TOKEN), is(refreshToken)); assertThat(params.get(OAuth2Constants.CLIENT_ID), is(clientId)); assertThat(params.get(OAuth2Constants.CLIENT_SECRET), is(clientSecret)); }
public TokenDetails obtainTokenDetailsByRefreshToken(String refreshToken) { List<BasicNameValuePair> params = new ArrayList<>(); params.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE, OAuth2Constants.REFRESH_TOKEN)); params.add(new BasicNameValuePair(OAuth2Constants.REFRESH_TOKEN, refreshToken)); params.add(new BasicNameValuePair(OAuth2Constants.CLIENT_ID, config.identityProvider().client())); params.add(new BasicNameValuePair(OAuth2Constants.CLIENT_SECRET, config.identityProvider().secret())); try { return obtainTokenDetails(params); } catch (Exception e) { logger.error("could not obtain token by refresh token: {}", e.getMessage(), e); throw new ObtainRefreshTokenException(); } }
OAuthClient { public TokenDetails obtainTokenDetailsByRefreshToken(String refreshToken) { List<BasicNameValuePair> params = new ArrayList<>(); params.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE, OAuth2Constants.REFRESH_TOKEN)); params.add(new BasicNameValuePair(OAuth2Constants.REFRESH_TOKEN, refreshToken)); params.add(new BasicNameValuePair(OAuth2Constants.CLIENT_ID, config.identityProvider().client())); params.add(new BasicNameValuePair(OAuth2Constants.CLIENT_SECRET, config.identityProvider().secret())); try { return obtainTokenDetails(params); } catch (Exception e) { logger.error("could not obtain token by refresh token: {}", e.getMessage(), e); throw new ObtainRefreshTokenException(); } } }
OAuthClient { public TokenDetails obtainTokenDetailsByRefreshToken(String refreshToken) { List<BasicNameValuePair> params = new ArrayList<>(); params.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE, OAuth2Constants.REFRESH_TOKEN)); params.add(new BasicNameValuePair(OAuth2Constants.REFRESH_TOKEN, refreshToken)); params.add(new BasicNameValuePair(OAuth2Constants.CLIENT_ID, config.identityProvider().client())); params.add(new BasicNameValuePair(OAuth2Constants.CLIENT_SECRET, config.identityProvider().secret())); try { return obtainTokenDetails(params); } catch (Exception e) { logger.error("could not obtain token by refresh token: {}", e.getMessage(), e); throw new ObtainRefreshTokenException(); } } @Autowired  OAuthClient(OidcConfiguration oidcConfiguration,
                       RealmService realmService,
                       PublicKeyCacheService publicKeyCacheService,
                       SecurityConfig config); }
OAuthClient { public TokenDetails obtainTokenDetailsByRefreshToken(String refreshToken) { List<BasicNameValuePair> params = new ArrayList<>(); params.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE, OAuth2Constants.REFRESH_TOKEN)); params.add(new BasicNameValuePair(OAuth2Constants.REFRESH_TOKEN, refreshToken)); params.add(new BasicNameValuePair(OAuth2Constants.CLIENT_ID, config.identityProvider().client())); params.add(new BasicNameValuePair(OAuth2Constants.CLIENT_SECRET, config.identityProvider().secret())); try { return obtainTokenDetails(params); } catch (Exception e) { logger.error("could not obtain token by refresh token: {}", e.getMessage(), e); throw new ObtainRefreshTokenException(); } } @Autowired  OAuthClient(OidcConfiguration oidcConfiguration,
                       RealmService realmService,
                       PublicKeyCacheService publicKeyCacheService,
                       SecurityConfig config); TokenDetails obtainTokenDetailsByAuthorizationCode(String code, String redirectUrl); TokenDetails obtainTokenDetailsByRefreshToken(String refreshToken); TokenDetails obtainTokenDetailsByApplicationCredentials(); TokenDetails obtainTokenDetailsByRunOnBehalfOfUserCredentials(String username, String realm); TokenDetails obtainTokenDetailsByApplicationCredentials(String username, String password); TokenDetails obtainTokenDetailsByApplicationCredentials(String username, String password, String realm); TokenDetails generateTokenDetails(String accessToken, String refreshToken); AccessToken parseAccessToken(String accessToken, String realm); void setConfig(SecurityConfig config); void setRealmService(RealmService realmService); }
OAuthClient { public TokenDetails obtainTokenDetailsByRefreshToken(String refreshToken) { List<BasicNameValuePair> params = new ArrayList<>(); params.add(new BasicNameValuePair(OAuth2Constants.GRANT_TYPE, OAuth2Constants.REFRESH_TOKEN)); params.add(new BasicNameValuePair(OAuth2Constants.REFRESH_TOKEN, refreshToken)); params.add(new BasicNameValuePair(OAuth2Constants.CLIENT_ID, config.identityProvider().client())); params.add(new BasicNameValuePair(OAuth2Constants.CLIENT_SECRET, config.identityProvider().secret())); try { return obtainTokenDetails(params); } catch (Exception e) { logger.error("could not obtain token by refresh token: {}", e.getMessage(), e); throw new ObtainRefreshTokenException(); } } @Autowired  OAuthClient(OidcConfiguration oidcConfiguration,
                       RealmService realmService,
                       PublicKeyCacheService publicKeyCacheService,
                       SecurityConfig config); TokenDetails obtainTokenDetailsByAuthorizationCode(String code, String redirectUrl); TokenDetails obtainTokenDetailsByRefreshToken(String refreshToken); TokenDetails obtainTokenDetailsByApplicationCredentials(); TokenDetails obtainTokenDetailsByRunOnBehalfOfUserCredentials(String username, String realm); TokenDetails obtainTokenDetailsByApplicationCredentials(String username, String password); TokenDetails obtainTokenDetailsByApplicationCredentials(String username, String password, String realm); TokenDetails generateTokenDetails(String accessToken, String refreshToken); AccessToken parseAccessToken(String accessToken, String realm); void setConfig(SecurityConfig config); void setRealmService(RealmService realmService);  }