|
| 1 | +/* |
| 2 | + * Copyright 2002-2018 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.security.oauth2.client.web.reactive.function.client; |
| 18 | + |
| 19 | +import org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository; |
| 20 | +import org.springframework.web.reactive.function.client.WebClient; |
| 21 | + |
| 22 | +import java.util.function.Consumer; |
| 23 | + |
| 24 | +/** |
| 25 | + * @author Rob Winch |
| 26 | + * @since 5.1 |
| 27 | + */ |
| 28 | +public final class OAuth2ExchangeFilterFunctions { |
| 29 | + |
| 30 | + /** |
| 31 | + * Configures the WebClient for OAuth2 support in a servlet environment. |
| 32 | + * @param repository the repository to use |
| 33 | + * @return the {@link Consumer} to configure the WebClient |
| 34 | + */ |
| 35 | + public static Consumer<WebClient.Builder> oauth2ServletConfig(OAuth2AuthorizedClientRepository repository) { |
| 36 | + return new ServletOAuth2AuthorizedClientExchangeFilterFunction(repository) |
| 37 | + .oauth2Configuration(); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * Configures the WebClient for OAuth2 support in a servlet environment. |
| 42 | + * @return the {@link Consumer} to configure the WebClient |
| 43 | + */ |
| 44 | + public static Consumer<WebClient.Builder> oauth2ServletConfig() { |
| 45 | + return new ServletOAuth2AuthorizedClientExchangeFilterFunction() |
| 46 | + .oauth2Configuration(); |
| 47 | + } |
| 48 | + |
| 49 | + private OAuth2ExchangeFilterFunctions() {} |
| 50 | +} |
0 commit comments