|
2 | 2 |
|
3 | 3 | import static java.util.Optional.ofNullable; |
4 | 4 |
|
| 5 | +import java.util.Optional; |
5 | 6 | import java.util.Set; |
6 | 7 | import lombok.Data; |
7 | 8 | import org.springframework.boot.context.properties.ConfigurationProperties; |
@@ -33,31 +34,34 @@ class OAuth2ClientRegistrationProperties { |
33 | 34 | private String jwkSetUri; |
34 | 35 | private String issuerUri; |
35 | 36 |
|
36 | | - ClientRegistration getClientRegistration() { |
37 | | - ClientRegistration.Builder builder = ClientRegistration.withRegistrationId("graphql") |
38 | | - .clientId(getClientId()) |
39 | | - .clientSecret(getClientSecret()) |
40 | | - .redirectUriTemplate(getRedirectUri()) |
41 | | - .scope(getScope()) |
42 | | - .clientName(getClientName()) |
43 | | - .authorizationUri(getAuthorizationUri()) |
44 | | - .tokenUri(getTokenUri()) |
45 | | - .userInfoUri(getUserInfoUri()) |
46 | | - .jwkSetUri(getJwkSetUri()); |
47 | | - |
48 | | - ofNullable(getClientAuthenticationMethod()) |
49 | | - .map(ClientAuthenticationMethod::new) |
50 | | - .ifPresent(builder::clientAuthenticationMethod); |
51 | | - |
52 | | - ofNullable(getAuthorizationGrantType()) |
53 | | - .map(AuthorizationGrantType::new) |
54 | | - .ifPresent(builder::authorizationGrantType); |
55 | | - |
56 | | - ofNullable(getUserInfoAuthenticationMethod()) |
57 | | - .map(AuthenticationMethod::new) |
58 | | - .ifPresent(builder::userInfoAuthenticationMethod); |
59 | | - |
60 | | - return builder.build(); |
| 37 | + Optional<ClientRegistration> getClientRegistration() { |
| 38 | + if (clientId != null) { |
| 39 | + ClientRegistration.Builder builder = ClientRegistration.withRegistrationId("graphql") |
| 40 | + .clientId(getClientId()) |
| 41 | + .clientSecret(getClientSecret()) |
| 42 | + .redirectUriTemplate(getRedirectUri()) |
| 43 | + .scope(getScope()) |
| 44 | + .clientName(getClientName()) |
| 45 | + .authorizationUri(getAuthorizationUri()) |
| 46 | + .tokenUri(getTokenUri()) |
| 47 | + .userInfoUri(getUserInfoUri()) |
| 48 | + .jwkSetUri(getJwkSetUri()); |
| 49 | + |
| 50 | + ofNullable(getClientAuthenticationMethod()) |
| 51 | + .map(ClientAuthenticationMethod::new) |
| 52 | + .ifPresent(builder::clientAuthenticationMethod); |
| 53 | + |
| 54 | + ofNullable(getAuthorizationGrantType()) |
| 55 | + .map(AuthorizationGrantType::new) |
| 56 | + .ifPresent(builder::authorizationGrantType); |
| 57 | + |
| 58 | + ofNullable(getUserInfoAuthenticationMethod()) |
| 59 | + .map(AuthenticationMethod::new) |
| 60 | + .ifPresent(builder::userInfoAuthenticationMethod); |
| 61 | + |
| 62 | + return Optional.of(builder.build()); |
| 63 | + } |
| 64 | + return Optional.empty(); |
61 | 65 | } |
62 | 66 |
|
63 | 67 | } |
0 commit comments