@Test public void retrieveEndpointsForAnotherIssuer() throws OAuth2ServiceException { cut.getOrRetrieveEndpoints(DISCOVERY_URI); cut.getOrRetrieveEndpoints(URI.create("http: Mockito.verify(oidcConfigServiceMock, times(2)) .retrieveEndpoints(any()); }
@Nullable public OAuth2ServiceEndpointsProvider getOrRetrieveEndpoints(URI discoveryEndpointUri) throws OAuth2ServiceException { assertNotNull(discoveryEndpointUri, "discoveryEndpointUri must not be null."); String cacheKey = discoveryEndpointUri.toString(); OAuth2ServiceEndpointsProvider endpointsProvider = getCache().getIfPresent(cacheKey); if (endpointsProvider == null) { endpointsProvider = getOidcConfigurationService().retrieveEndpoints(discoveryEndpointUri); if (endpointsProvider == null) { return null; } getCache().put(cacheKey, endpointsProvider); } return getCache().getIfPresent(cacheKey); }
OidcConfigurationServiceWithCache { @Nullable public OAuth2ServiceEndpointsProvider getOrRetrieveEndpoints(URI discoveryEndpointUri) throws OAuth2ServiceException { assertNotNull(discoveryEndpointUri, "discoveryEndpointUri must not be null."); String cacheKey = discoveryEndpointUri.toString(); OAuth2ServiceEndpointsProvider endpointsProvider = getCache().getIfPresent(cacheKey); if (endpointsProvider == null) { endpointsProvider = getOidcConfigurationService().retrieveEndpoints(discoveryEndpointUri); if (endpointsProvider == null) { return null; } getCache().put(cacheKey, endpointsProvider); } return getCache().getIfPresent(cacheKey); } }
OidcConfigurationServiceWithCache { @Nullable public OAuth2ServiceEndpointsProvider getOrRetrieveEndpoints(URI discoveryEndpointUri) throws OAuth2ServiceException { assertNotNull(discoveryEndpointUri, "discoveryEndpointUri must not be null."); String cacheKey = discoveryEndpointUri.toString(); OAuth2ServiceEndpointsProvider endpointsProvider = getCache().getIfPresent(cacheKey); if (endpointsProvider == null) { endpointsProvider = getOidcConfigurationService().retrieveEndpoints(discoveryEndpointUri); if (endpointsProvider == null) { return null; } getCache().put(cacheKey, endpointsProvider); } return getCache().getIfPresent(cacheKey); } private  OidcConfigurationServiceWithCache(); }
OidcConfigurationServiceWithCache { @Nullable public OAuth2ServiceEndpointsProvider getOrRetrieveEndpoints(URI discoveryEndpointUri) throws OAuth2ServiceException { assertNotNull(discoveryEndpointUri, "discoveryEndpointUri must not be null."); String cacheKey = discoveryEndpointUri.toString(); OAuth2ServiceEndpointsProvider endpointsProvider = getCache().getIfPresent(cacheKey); if (endpointsProvider == null) { endpointsProvider = getOidcConfigurationService().retrieveEndpoints(discoveryEndpointUri); if (endpointsProvider == null) { return null; } getCache().put(cacheKey, endpointsProvider); } return getCache().getIfPresent(cacheKey); } private  OidcConfigurationServiceWithCache(); static OidcConfigurationServiceWithCache getInstance(); OidcConfigurationServiceWithCache withOidcConfigurationService(
			OidcConfigurationService oidcConfigurationService); OidcConfigurationServiceWithCache withCacheTime(int timeInSeconds); OidcConfigurationServiceWithCache withCacheSize(int size); @Nullable OAuth2ServiceEndpointsProvider getOrRetrieveEndpoints(URI discoveryEndpointUri); void clearCache(); }
OidcConfigurationServiceWithCache { @Nullable public OAuth2ServiceEndpointsProvider getOrRetrieveEndpoints(URI discoveryEndpointUri) throws OAuth2ServiceException { assertNotNull(discoveryEndpointUri, "discoveryEndpointUri must not be null."); String cacheKey = discoveryEndpointUri.toString(); OAuth2ServiceEndpointsProvider endpointsProvider = getCache().getIfPresent(cacheKey); if (endpointsProvider == null) { endpointsProvider = getOidcConfigurationService().retrieveEndpoints(discoveryEndpointUri); if (endpointsProvider == null) { return null; } getCache().put(cacheKey, endpointsProvider); } return getCache().getIfPresent(cacheKey); } private  OidcConfigurationServiceWithCache(); static OidcConfigurationServiceWithCache getInstance(); OidcConfigurationServiceWithCache withOidcConfigurationService(
			OidcConfigurationService oidcConfigurationService); OidcConfigurationServiceWithCache withCacheTime(int timeInSeconds); OidcConfigurationServiceWithCache withCacheSize(int size); @Nullable OAuth2ServiceEndpointsProvider getOrRetrieveEndpoints(URI discoveryEndpointUri); void clearCache();  }