|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2018 the original author or authors. |
| 2 | + * Copyright 2002-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
13 | 13 | * See the License for the specific language governing permissions and
|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 |
| - |
17 | 16 | package org.springframework.security.oauth2.client.userinfo;
|
18 | 17 |
|
19 | 18 |
|
|
22 | 21 | import java.util.Map;
|
23 | 22 | import java.util.Set;
|
24 | 23 |
|
| 24 | +import com.nimbusds.oauth2.sdk.ErrorObject; |
| 25 | +import com.nimbusds.openid.connect.sdk.UserInfoErrorResponse; |
| 26 | +import net.minidev.json.JSONObject; |
| 27 | +import reactor.core.publisher.Mono; |
| 28 | + |
25 | 29 | import org.springframework.core.ParameterizedTypeReference;
|
26 | 30 | import org.springframework.http.HttpHeaders;
|
27 | 31 | import org.springframework.http.HttpStatus;
|
|
41 | 45 | import org.springframework.web.reactive.function.client.ClientResponse;
|
42 | 46 | import org.springframework.web.reactive.function.client.WebClient;
|
43 | 47 |
|
44 |
| -import com.nimbusds.oauth2.sdk.ErrorObject; |
45 |
| -import com.nimbusds.openid.connect.sdk.UserInfoErrorResponse; |
46 |
| - |
47 |
| -import net.minidev.json.JSONObject; |
48 |
| -import reactor.core.publisher.Mono; |
49 |
| - |
50 | 48 | /**
|
51 | 49 | * An implementation of an {@link ReactiveOAuth2UserService} that supports standard OAuth 2.0 Provider's.
|
52 | 50 | * <p>
|
@@ -119,7 +117,7 @@ public Mono<OAuth2User> loadUser(OAuth2UserRequest userRequest)
|
119 | 117 | }
|
120 | 118 | Mono<Map<String, Object>> userAttributes = requestHeadersSpec
|
121 | 119 | .retrieve()
|
122 |
| - .onStatus(s -> s != HttpStatus.OK, response -> parse(response).map(userInfoErrorResponse -> { |
| 120 | + .onStatus(HttpStatus::isError, response -> parse(response).map(userInfoErrorResponse -> { |
123 | 121 | String description = userInfoErrorResponse.getErrorObject().getDescription();
|
124 | 122 | OAuth2Error oauth2Error = new OAuth2Error(
|
125 | 123 | INVALID_USER_INFO_RESPONSE_ERROR_CODE, description,
|
|
0 commit comments