@Test void isTokenExpiredOrShouldBeRefreshed() { OidcConfiguration oidcConfiguration = new OidcConfiguration() { @Override public int getTokenShouldBeRefreshed() { return 75; } }; helper.setOidcConfiguration(oidcConfiguration); TokenDetails tokenDetails = new TokenDetails(); assertThat(helper.isTokenExpiredOrShouldBeRefreshed(tokenDetails), is(true)); tokenDetails.setAccessTokenExpiration(LocalDateTime.now().plusMinutes(5)); assertThat(helper.isTokenExpiredOrShouldBeRefreshed(tokenDetails), is(false)); tokenDetails.setAccessTokenExpiration(LocalDateTime.now().plusMinutes(1)); assertThat(helper.isTokenExpiredOrShouldBeRefreshed(tokenDetails), is(true)); }
public boolean isTokenExpiredOrShouldBeRefreshed(TokenDetails tokenDetails) { if (tokenDetails.getAccessTokenExpiration() == null) return true; LocalDateTime refreshDate = LocalDateTime.now().plusSeconds(oidcConfiguration.getTokenShouldBeRefreshed()); return tokenDetails.getAccessTokenExpiration().isBefore(refreshDate); }
OidcAuthenticationHelper { public boolean isTokenExpiredOrShouldBeRefreshed(TokenDetails tokenDetails) { if (tokenDetails.getAccessTokenExpiration() == null) return true; LocalDateTime refreshDate = LocalDateTime.now().plusSeconds(oidcConfiguration.getTokenShouldBeRefreshed()); return tokenDetails.getAccessTokenExpiration().isBefore(refreshDate); } }
OidcAuthenticationHelper { public boolean isTokenExpiredOrShouldBeRefreshed(TokenDetails tokenDetails) { if (tokenDetails.getAccessTokenExpiration() == null) return true; LocalDateTime refreshDate = LocalDateTime.now().plusSeconds(oidcConfiguration.getTokenShouldBeRefreshed()); return tokenDetails.getAccessTokenExpiration().isBefore(refreshDate); } OidcAuthenticationHelper();  OidcAuthenticationHelper(OidcConfiguration oidcConfiguration,
                                    OAuthClient oAuthClient,
                                    SecurityConfig config,
                                    RealmService realmService); }
OidcAuthenticationHelper { public boolean isTokenExpiredOrShouldBeRefreshed(TokenDetails tokenDetails) { if (tokenDetails.getAccessTokenExpiration() == null) return true; LocalDateTime refreshDate = LocalDateTime.now().plusSeconds(oidcConfiguration.getTokenShouldBeRefreshed()); return tokenDetails.getAccessTokenExpiration().isBefore(refreshDate); } OidcAuthenticationHelper();  OidcAuthenticationHelper(OidcConfiguration oidcConfiguration,
                                    OAuthClient oAuthClient,
                                    SecurityConfig config,
                                    RealmService realmService); String getBearerToken(HttpServletRequest request); String getBearerToken(HttpServletResponse response); TokenDetails getTokenDetails(HttpServletResponse response); String getRefreshToken(HttpServletResponse response); String getAccessToken(HttpServletRequest request); String getRefreshToken(HttpServletRequest request); String createRedirectUrl(String redirectUrlTemplate, HttpServletRequest request); void setRealmForCurrentRequest(String realm); String getRealmForCurrentRequest(); String getRealmForCurrentRequest(HttpServletResponse response); void validateRealm(TokenDetails tokenDetails); void removeRealmFromCurrentRequest(); boolean shouldApplyUrl(String method, String path); boolean shouldApplyUrl(HttpRequest request); boolean shouldSkip(HttpRequest request); void authenticateCurrentThread(String accessToken, String refreshToken); void authenticateCurrentThread(TokenDetails tokenDetails); @Deprecated AccessToken parseAccessToken(TokenDetails tokenDetails); String removeCodeFromUrl(String url, String code); String removeCodeFromUrl(HttpServletRequest request); boolean isTokenExpiredOrShouldBeRefreshed(TokenDetails tokenDetails); @Deprecated TokenDetails generateTokenDetails(String accessToken, String refreshToken); void safeCleanupSecurityContext(Class clazz); @Autowired void setOidcConfiguration(OidcConfiguration oidcConfiguration); @Autowired void setOAuthClient(OAuthClient oAuthClient); @Autowired void setConfig(SecurityConfig config); @Autowired void setRealmService(RealmService realmService); }
OidcAuthenticationHelper { public boolean isTokenExpiredOrShouldBeRefreshed(TokenDetails tokenDetails) { if (tokenDetails.getAccessTokenExpiration() == null) return true; LocalDateTime refreshDate = LocalDateTime.now().plusSeconds(oidcConfiguration.getTokenShouldBeRefreshed()); return tokenDetails.getAccessTokenExpiration().isBefore(refreshDate); } OidcAuthenticationHelper();  OidcAuthenticationHelper(OidcConfiguration oidcConfiguration,
                                    OAuthClient oAuthClient,
                                    SecurityConfig config,
                                    RealmService realmService); String getBearerToken(HttpServletRequest request); String getBearerToken(HttpServletResponse response); TokenDetails getTokenDetails(HttpServletResponse response); String getRefreshToken(HttpServletResponse response); String getAccessToken(HttpServletRequest request); String getRefreshToken(HttpServletRequest request); String createRedirectUrl(String redirectUrlTemplate, HttpServletRequest request); void setRealmForCurrentRequest(String realm); String getRealmForCurrentRequest(); String getRealmForCurrentRequest(HttpServletResponse response); void validateRealm(TokenDetails tokenDetails); void removeRealmFromCurrentRequest(); boolean shouldApplyUrl(String method, String path); boolean shouldApplyUrl(HttpRequest request); boolean shouldSkip(HttpRequest request); void authenticateCurrentThread(String accessToken, String refreshToken); void authenticateCurrentThread(TokenDetails tokenDetails); @Deprecated AccessToken parseAccessToken(TokenDetails tokenDetails); String removeCodeFromUrl(String url, String code); String removeCodeFromUrl(HttpServletRequest request); boolean isTokenExpiredOrShouldBeRefreshed(TokenDetails tokenDetails); @Deprecated TokenDetails generateTokenDetails(String accessToken, String refreshToken); void safeCleanupSecurityContext(Class clazz); @Autowired void setOidcConfiguration(OidcConfiguration oidcConfiguration); @Autowired void setOAuthClient(OAuthClient oAuthClient); @Autowired void setConfig(SecurityConfig config); @Autowired void setRealmService(RealmService realmService); static final String AUTH_HEADER_VALUE_PREFIX; }