org.springframework.web.reactive.function.client.ExchangeFilterFunctions Java Examples
The following examples show how to use
org.springframework.web.reactive.function.client.ExchangeFilterFunctions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebClientTransportClientFactory.java From spring-cloud-netflix with Apache License 2.0 | 6 votes |
private WebClient.Builder of(String serviceUrl) { String url = serviceUrl; WebClient.Builder builder = WebClient.builder(); try { URI serviceURI = new URI(serviceUrl); if (serviceURI.getUserInfo() != null) { String[] credentials = serviceURI.getUserInfo().split(":"); if (credentials.length == 2) { builder.filter(ExchangeFilterFunctions .basicAuthentication(credentials[0], credentials[1])); url = serviceUrl.replace(credentials[0] + ":" + credentials[1] + "@", ""); } } } catch (URISyntaxException ignore) { } return builder.baseUrl(url); }
Example #2
Source File: ReactiveBackendWebClientConfig.java From spring-5-examples with MIT License | 5 votes |
@Bean public WebClient webClient(final ReactiveBackendConfig backend) { return WebClient.builder() .baseUrl(backend.getBaseUrl()) .filter(ExchangeFilterFunctions.basicAuthentication(backend.getCredentials().getUsername(), backend.getCredentials().getPassword())) .build(); }
Example #3
Source File: ReactiveBackendWebClientConfig.java From spring-5-examples with MIT License | 5 votes |
@Bean public WebClient webClient(final ReactiveBackendConfig backend) { return WebClient.builder() .baseUrl(backend.getBaseUrl()) .filter(ExchangeFilterFunctions.basicAuthentication(backend.getCredentials().getUsername(), backend.getCredentials().getPassword())) .build(); }
Example #4
Source File: ReactiveBackendWebClientConfig.java From spring-5-examples with MIT License | 5 votes |
@Bean public WebClient webClient(final ReactiveBackendConfig backend) { return WebClient.builder() .baseUrl(backend.getBaseUrl()) .filter(ExchangeFilterFunctions.basicAuthentication(backend.getCredentials().getUsername(), backend.getCredentials().getPassword())) .build(); }
Example #5
Source File: ReactiveBackendWebClientConfig.java From spring-5-examples with MIT License | 5 votes |
@Bean public WebClient webClient(final ReactiveBackendConfig backend) { return WebClient.builder() .baseUrl(backend.getBaseUrl()) .filter(ExchangeFilterFunctions.basicAuthentication(backend.getCredentials().getUsername(), backend.getCredentials().getPassword())) .build(); }
Example #6
Source File: FilteredWebClientUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void testBasicAuthFilter() { stubFor(get(urlPathEqualTo(PATH)).willReturn(aResponse().withStatus(200) .withBody("authorized"))); WebClient webClient = WebClient.builder() .filter(ExchangeFilterFunctions.basicAuthentication("user", "password")) .build(); String actual = sendGetRequest(webClient); assertThat(actual).isEqualTo("authorized"); verify(getRequestedFor(urlPathEqualTo(PATH)).withHeader("Authorization", containing("Basic"))); }
Example #7
Source File: SecurityConfiguration.java From microservices-dashboard with Apache License 2.0 | 4 votes |
@Bean("ms-dashboard-m2m-basic-filter") @Conditional(BasicClientSecurityConfigured.class) MachineToMachineWebClientConfigurer basicFilter(BasicClientSecurityProperties properties) { return builder -> builder.filter(ExchangeFilterFunctions.basicAuthentication( properties.getUsername(), properties.getPassword())); }
Example #8
Source File: CommonConfiguration.java From microservices-dashboard with Apache License 2.0 | 4 votes |
private void applyWebClientResponseExceptionFilter(WebClient.Builder builder) { builder.filter(ExchangeFilterFunctions.statusError(HttpStatus::isError, WebClientResponseExceptionCreator::createResponseException)); }