@Test public void retrieveEndpoints_parameterIsNull_throwsException() throws OAuth2ServiceException { assertThatThrownBy(() -> retrieveEndpoints(null)) .isInstanceOf(IllegalArgumentException.class); }
@Override public OAuth2ServiceEndpointsProvider retrieveEndpoints(@Nonnull URI discoveryEndpointUri) throws OAuth2ServiceException { Assertions.assertNotNull(discoveryEndpointUri, "discoveryEndpointUri must not be null!"); try { ResponseEntity<String> response = restOperations.getForEntity(discoveryEndpointUri, String.class); if (HttpStatus.OK.value() == response.getStatusCode().value()) { return new DefaultOidcConfigurationService.OidcEndpointsProvider(response.getBody()); } else { throw OAuth2ServiceException.builder("Error retrieving configured oidc endpoints") .withUri(discoveryEndpointUri) .withStatusCode(response.getStatusCodeValue()) .withResponseBody(response.getBody()) .build(); } } catch (HttpClientErrorException ex) { throw OAuth2ServiceException.builder("Error retrieving configured oidc endpoints") .withUri(discoveryEndpointUri) .withStatusCode(ex.getStatusCode().value()) .withResponseBody(ex.getResponseBodyAsString()) .build(); } }
SpringOidcConfigurationService implements OidcConfigurationService { @Override public OAuth2ServiceEndpointsProvider retrieveEndpoints(@Nonnull URI discoveryEndpointUri) throws OAuth2ServiceException { Assertions.assertNotNull(discoveryEndpointUri, "discoveryEndpointUri must not be null!"); try { ResponseEntity<String> response = restOperations.getForEntity(discoveryEndpointUri, String.class); if (HttpStatus.OK.value() == response.getStatusCode().value()) { return new DefaultOidcConfigurationService.OidcEndpointsProvider(response.getBody()); } else { throw OAuth2ServiceException.builder("Error retrieving configured oidc endpoints") .withUri(discoveryEndpointUri) .withStatusCode(response.getStatusCodeValue()) .withResponseBody(response.getBody()) .build(); } } catch (HttpClientErrorException ex) { throw OAuth2ServiceException.builder("Error retrieving configured oidc endpoints") .withUri(discoveryEndpointUri) .withStatusCode(ex.getStatusCode().value()) .withResponseBody(ex.getResponseBodyAsString()) .build(); } } }
SpringOidcConfigurationService implements OidcConfigurationService { @Override public OAuth2ServiceEndpointsProvider retrieveEndpoints(@Nonnull URI discoveryEndpointUri) throws OAuth2ServiceException { Assertions.assertNotNull(discoveryEndpointUri, "discoveryEndpointUri must not be null!"); try { ResponseEntity<String> response = restOperations.getForEntity(discoveryEndpointUri, String.class); if (HttpStatus.OK.value() == response.getStatusCode().value()) { return new DefaultOidcConfigurationService.OidcEndpointsProvider(response.getBody()); } else { throw OAuth2ServiceException.builder("Error retrieving configured oidc endpoints") .withUri(discoveryEndpointUri) .withStatusCode(response.getStatusCodeValue()) .withResponseBody(response.getBody()) .build(); } } catch (HttpClientErrorException ex) { throw OAuth2ServiceException.builder("Error retrieving configured oidc endpoints") .withUri(discoveryEndpointUri) .withStatusCode(ex.getStatusCode().value()) .withResponseBody(ex.getResponseBodyAsString()) .build(); } } SpringOidcConfigurationService(@Nonnull RestOperations restOperations); }
SpringOidcConfigurationService implements OidcConfigurationService { @Override public OAuth2ServiceEndpointsProvider retrieveEndpoints(@Nonnull URI discoveryEndpointUri) throws OAuth2ServiceException { Assertions.assertNotNull(discoveryEndpointUri, "discoveryEndpointUri must not be null!"); try { ResponseEntity<String> response = restOperations.getForEntity(discoveryEndpointUri, String.class); if (HttpStatus.OK.value() == response.getStatusCode().value()) { return new DefaultOidcConfigurationService.OidcEndpointsProvider(response.getBody()); } else { throw OAuth2ServiceException.builder("Error retrieving configured oidc endpoints") .withUri(discoveryEndpointUri) .withStatusCode(response.getStatusCodeValue()) .withResponseBody(response.getBody()) .build(); } } catch (HttpClientErrorException ex) { throw OAuth2ServiceException.builder("Error retrieving configured oidc endpoints") .withUri(discoveryEndpointUri) .withStatusCode(ex.getStatusCode().value()) .withResponseBody(ex.getResponseBodyAsString()) .build(); } } SpringOidcConfigurationService(@Nonnull RestOperations restOperations); @Override OAuth2ServiceEndpointsProvider retrieveEndpoints(@Nonnull URI discoveryEndpointUri); }
SpringOidcConfigurationService implements OidcConfigurationService { @Override public OAuth2ServiceEndpointsProvider retrieveEndpoints(@Nonnull URI discoveryEndpointUri) throws OAuth2ServiceException { Assertions.assertNotNull(discoveryEndpointUri, "discoveryEndpointUri must not be null!"); try { ResponseEntity<String> response = restOperations.getForEntity(discoveryEndpointUri, String.class); if (HttpStatus.OK.value() == response.getStatusCode().value()) { return new DefaultOidcConfigurationService.OidcEndpointsProvider(response.getBody()); } else { throw OAuth2ServiceException.builder("Error retrieving configured oidc endpoints") .withUri(discoveryEndpointUri) .withStatusCode(response.getStatusCodeValue()) .withResponseBody(response.getBody()) .build(); } } catch (HttpClientErrorException ex) { throw OAuth2ServiceException.builder("Error retrieving configured oidc endpoints") .withUri(discoveryEndpointUri) .withStatusCode(ex.getStatusCode().value()) .withResponseBody(ex.getResponseBodyAsString()) .build(); } } SpringOidcConfigurationService(@Nonnull RestOperations restOperations); @Override OAuth2ServiceEndpointsProvider retrieveEndpoints(@Nonnull URI discoveryEndpointUri);  }