@Test void retrieveUsersTokenDetailsTokenIsNotExpired() { SecurityContextHolder.getContext().setAuthentication( new UsernamePasswordAuthenticationToken("login", tokenDetails, new ArrayList<>())); when(oidcAuthenticationHelper.isTokenExpiredOrShouldBeRefreshed(tokenDetails)).thenReturn(true); TokenDetails updatedTokenDetails = new TokenDetails(); when(oAuthClient.obtainTokenDetailsByRefreshToken((tokenDetails.getRefreshToken()))) .thenReturn(updatedTokenDetails); doNothing().when(oidcAuthenticationHelper).authenticateCurrentThread(updatedTokenDetails); assertEquals(service.retrieveUsersTokenDetails(), updatedTokenDetails); }
public TokenDetails retrieveUsersTokenDetails() { TokenDetails tokenDetails = retrieveUsersTokenDetailsFromSecurityContext(); if (tokenDetails.isNotEmpty() && oidcAuthenticationHelper.isTokenExpiredOrShouldBeRefreshed(tokenDetails)) { return retrieveUpdatedUsersTokenDetails(tokenDetails); } return tokenDetails; }
UsersTokenService { public TokenDetails retrieveUsersTokenDetails() { TokenDetails tokenDetails = retrieveUsersTokenDetailsFromSecurityContext(); if (tokenDetails.isNotEmpty() && oidcAuthenticationHelper.isTokenExpiredOrShouldBeRefreshed(tokenDetails)) { return retrieveUpdatedUsersTokenDetails(tokenDetails); } return tokenDetails; } }
UsersTokenService { public TokenDetails retrieveUsersTokenDetails() { TokenDetails tokenDetails = retrieveUsersTokenDetailsFromSecurityContext(); if (tokenDetails.isNotEmpty() && oidcAuthenticationHelper.isTokenExpiredOrShouldBeRefreshed(tokenDetails)) { return retrieveUpdatedUsersTokenDetails(tokenDetails); } return tokenDetails; } @Autowired  UsersTokenService(OidcAuthenticationHelper oidcAuthenticationHelper,
                             OAuthClient oAuthClient); }
UsersTokenService { public TokenDetails retrieveUsersTokenDetails() { TokenDetails tokenDetails = retrieveUsersTokenDetailsFromSecurityContext(); if (tokenDetails.isNotEmpty() && oidcAuthenticationHelper.isTokenExpiredOrShouldBeRefreshed(tokenDetails)) { return retrieveUpdatedUsersTokenDetails(tokenDetails); } return tokenDetails; } @Autowired  UsersTokenService(OidcAuthenticationHelper oidcAuthenticationHelper,
                             OAuthClient oAuthClient); TokenDetails retrieveUsersTokenDetails(); }
UsersTokenService { public TokenDetails retrieveUsersTokenDetails() { TokenDetails tokenDetails = retrieveUsersTokenDetailsFromSecurityContext(); if (tokenDetails.isNotEmpty() && oidcAuthenticationHelper.isTokenExpiredOrShouldBeRefreshed(tokenDetails)) { return retrieveUpdatedUsersTokenDetails(tokenDetails); } return tokenDetails; } @Autowired  UsersTokenService(OidcAuthenticationHelper oidcAuthenticationHelper,
                             OAuthClient oAuthClient); TokenDetails retrieveUsersTokenDetails();  }