Skip to content

Commit 5a59dcf

Browse files
committed
Add nullability annotations to module/spring-boot-security-oauth2-client
See gh-46587
1 parent e53f90b commit 5a59dcf

File tree

5 files changed

+63
-50
lines changed

5 files changed

+63
-50
lines changed

module/spring-boot-security-oauth2-client/src/main/java/org/springframework/boot/security/oauth2/client/autoconfigure/OAuth2ClientProperties.java

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import java.util.Map;
2121
import java.util.Set;
2222

23+
import org.jspecify.annotations.Nullable;
24+
2325
import org.springframework.beans.factory.InitializingBean;
2426
import org.springframework.boot.context.properties.ConfigurationProperties;
2527
import org.springframework.util.StringUtils;
@@ -80,106 +82,106 @@ public static class Registration {
8082
* 'provider' property or used one of the commonly used providers (google, github,
8183
* facebook, okta).
8284
*/
83-
private String provider;
85+
private @Nullable String provider;
8486

8587
/**
8688
* Client ID for the registration.
8789
*/
88-
private String clientId;
90+
private @Nullable String clientId;
8991

9092
/**
9193
* Client secret of the registration.
9294
*/
93-
private String clientSecret;
95+
private @Nullable String clientSecret;
9496

9597
/**
9698
* Client authentication method. May be left blank when using a pre-defined
9799
* provider.
98100
*/
99-
private String clientAuthenticationMethod;
101+
private @Nullable String clientAuthenticationMethod;
100102

101103
/**
102104
* Authorization grant type. May be left blank when using a pre-defined provider.
103105
*/
104-
private String authorizationGrantType;
106+
private @Nullable String authorizationGrantType;
105107

106108
/**
107109
* Redirect URI. May be left blank when using a pre-defined provider.
108110
*/
109-
private String redirectUri;
111+
private @Nullable String redirectUri;
110112

111113
/**
112114
* Authorization scopes. When left blank the provider's default scopes, if any,
113115
* will be used.
114116
*/
115-
private Set<String> scope;
117+
private @Nullable Set<String> scope;
116118

117119
/**
118120
* Client name. May be left blank when using a pre-defined provider.
119121
*/
120-
private String clientName;
122+
private @Nullable String clientName;
121123

122-
public String getProvider() {
124+
public @Nullable String getProvider() {
123125
return this.provider;
124126
}
125127

126-
public void setProvider(String provider) {
128+
public void setProvider(@Nullable String provider) {
127129
this.provider = provider;
128130
}
129131

130-
public String getClientId() {
132+
public @Nullable String getClientId() {
131133
return this.clientId;
132134
}
133135

134-
public void setClientId(String clientId) {
136+
public void setClientId(@Nullable String clientId) {
135137
this.clientId = clientId;
136138
}
137139

138-
public String getClientSecret() {
140+
public @Nullable String getClientSecret() {
139141
return this.clientSecret;
140142
}
141143

142-
public void setClientSecret(String clientSecret) {
144+
public void setClientSecret(@Nullable String clientSecret) {
143145
this.clientSecret = clientSecret;
144146
}
145147

146-
public String getClientAuthenticationMethod() {
148+
public @Nullable String getClientAuthenticationMethod() {
147149
return this.clientAuthenticationMethod;
148150
}
149151

150-
public void setClientAuthenticationMethod(String clientAuthenticationMethod) {
152+
public void setClientAuthenticationMethod(@Nullable String clientAuthenticationMethod) {
151153
this.clientAuthenticationMethod = clientAuthenticationMethod;
152154
}
153155

154-
public String getAuthorizationGrantType() {
156+
public @Nullable String getAuthorizationGrantType() {
155157
return this.authorizationGrantType;
156158
}
157159

158-
public void setAuthorizationGrantType(String authorizationGrantType) {
160+
public void setAuthorizationGrantType(@Nullable String authorizationGrantType) {
159161
this.authorizationGrantType = authorizationGrantType;
160162
}
161163

162-
public String getRedirectUri() {
164+
public @Nullable String getRedirectUri() {
163165
return this.redirectUri;
164166
}
165167

166-
public void setRedirectUri(String redirectUri) {
168+
public void setRedirectUri(@Nullable String redirectUri) {
167169
this.redirectUri = redirectUri;
168170
}
169171

170-
public Set<String> getScope() {
172+
public @Nullable Set<String> getScope() {
171173
return this.scope;
172174
}
173175

174-
public void setScope(Set<String> scope) {
176+
public void setScope(@Nullable Set<String> scope) {
175177
this.scope = scope;
176178
}
177179

178-
public String getClientName() {
180+
public @Nullable String getClientName() {
179181
return this.clientName;
180182
}
181183

182-
public void setClientName(String clientName) {
184+
public void setClientName(@Nullable String clientName) {
183185
this.clientName = clientName;
184186
}
185187

@@ -190,93 +192,93 @@ public static class Provider {
190192
/**
191193
* Authorization URI for the provider.
192194
*/
193-
private String authorizationUri;
195+
private @Nullable String authorizationUri;
194196

195197
/**
196198
* Token URI for the provider.
197199
*/
198-
private String tokenUri;
200+
private @Nullable String tokenUri;
199201

200202
/**
201203
* User info URI for the provider.
202204
*/
203-
private String userInfoUri;
205+
private @Nullable String userInfoUri;
204206

205207
/**
206208
* User info authentication method for the provider.
207209
*/
208-
private String userInfoAuthenticationMethod;
210+
private @Nullable String userInfoAuthenticationMethod;
209211

210212
/**
211213
* Name of the attribute that will be used to extract the username from the call
212214
* to 'userInfoUri'.
213215
*/
214-
private String userNameAttribute;
216+
private @Nullable String userNameAttribute;
215217

216218
/**
217219
* JWK set URI for the provider.
218220
*/
219-
private String jwkSetUri;
221+
private @Nullable String jwkSetUri;
220222

221223
/**
222224
* URI that can either be an OpenID Connect discovery endpoint or an OAuth 2.0
223225
* Authorization Server Metadata endpoint defined by RFC 8414.
224226
*/
225-
private String issuerUri;
227+
private @Nullable String issuerUri;
226228

227-
public String getAuthorizationUri() {
229+
public @Nullable String getAuthorizationUri() {
228230
return this.authorizationUri;
229231
}
230232

231-
public void setAuthorizationUri(String authorizationUri) {
233+
public void setAuthorizationUri(@Nullable String authorizationUri) {
232234
this.authorizationUri = authorizationUri;
233235
}
234236

235-
public String getTokenUri() {
237+
public @Nullable String getTokenUri() {
236238
return this.tokenUri;
237239
}
238240

239-
public void setTokenUri(String tokenUri) {
241+
public void setTokenUri(@Nullable String tokenUri) {
240242
this.tokenUri = tokenUri;
241243
}
242244

243-
public String getUserInfoUri() {
245+
public @Nullable String getUserInfoUri() {
244246
return this.userInfoUri;
245247
}
246248

247-
public void setUserInfoUri(String userInfoUri) {
249+
public void setUserInfoUri(@Nullable String userInfoUri) {
248250
this.userInfoUri = userInfoUri;
249251
}
250252

251-
public String getUserInfoAuthenticationMethod() {
253+
public @Nullable String getUserInfoAuthenticationMethod() {
252254
return this.userInfoAuthenticationMethod;
253255
}
254256

255-
public void setUserInfoAuthenticationMethod(String userInfoAuthenticationMethod) {
257+
public void setUserInfoAuthenticationMethod(@Nullable String userInfoAuthenticationMethod) {
256258
this.userInfoAuthenticationMethod = userInfoAuthenticationMethod;
257259
}
258260

259-
public String getUserNameAttribute() {
261+
public @Nullable String getUserNameAttribute() {
260262
return this.userNameAttribute;
261263
}
262264

263-
public void setUserNameAttribute(String userNameAttribute) {
265+
public void setUserNameAttribute(@Nullable String userNameAttribute) {
264266
this.userNameAttribute = userNameAttribute;
265267
}
266268

267-
public String getJwkSetUri() {
269+
public @Nullable String getJwkSetUri() {
268270
return this.jwkSetUri;
269271
}
270272

271-
public void setJwkSetUri(String jwkSetUri) {
273+
public void setJwkSetUri(@Nullable String jwkSetUri) {
272274
this.jwkSetUri = jwkSetUri;
273275
}
274276

275-
public String getIssuerUri() {
277+
public @Nullable String getIssuerUri() {
276278
return this.issuerUri;
277279
}
278280

279-
public void setIssuerUri(String issuerUri) {
281+
public void setIssuerUri(@Nullable String issuerUri) {
280282
this.issuerUri = issuerUri;
281283
}
282284

module/spring-boot-security-oauth2-client/src/main/java/org/springframework/boot/security/oauth2/client/autoconfigure/OAuth2ClientPropertiesMapper.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.HashMap;
2020
import java.util.Map;
2121

22+
import org.jspecify.annotations.Nullable;
23+
2224
import org.springframework.boot.context.properties.PropertyMapper;
2325
import org.springframework.boot.convert.ApplicationConversionService;
2426
import org.springframework.boot.security.oauth2.client.autoconfigure.OAuth2ClientProperties.Provider;
@@ -87,8 +89,8 @@ private static ClientRegistration getClientRegistration(String registrationId,
8789
return builder.build();
8890
}
8991

90-
private static Builder getBuilderFromIssuerIfPossible(String registrationId, String configuredProviderId,
91-
Map<String, Provider> providers) {
92+
private static @Nullable Builder getBuilderFromIssuerIfPossible(String registrationId,
93+
@Nullable String configuredProviderId, Map<String, Provider> providers) {
9294
String providerId = (configuredProviderId != null) ? configuredProviderId : registrationId;
9395
if (providers.containsKey(providerId)) {
9496
Provider provider = providers.get(providerId);
@@ -101,7 +103,7 @@ private static Builder getBuilderFromIssuerIfPossible(String registrationId, Str
101103
return null;
102104
}
103105

104-
private static Builder getBuilder(String registrationId, String configuredProviderId,
106+
private static Builder getBuilder(String registrationId, @Nullable String configuredProviderId,
105107
Map<String, Provider> providers) {
106108
String providerId = (configuredProviderId != null) ? configuredProviderId : registrationId;
107109
CommonOAuth2Provider provider = getCommonProvider(providerId);
@@ -116,7 +118,7 @@ private static Builder getBuilder(String registrationId, String configuredProvid
116118
return builder;
117119
}
118120

119-
private static String getErrorMessage(String configuredProviderId, String registrationId) {
121+
private static String getErrorMessage(@Nullable String configuredProviderId, String registrationId) {
120122
return ((configuredProviderId != null) ? "Unknown provider ID '" + configuredProviderId + "'"
121123
: "Provider ID must be specified for client registration '" + registrationId + "'");
122124
}
@@ -134,7 +136,7 @@ private static Builder getBuilder(Builder builder, Provider provider) {
134136
return builder;
135137
}
136138

137-
private static CommonOAuth2Provider getCommonProvider(String providerId) {
139+
private static @Nullable CommonOAuth2Provider getCommonProvider(String providerId) {
138140
try {
139141
return ApplicationConversionService.getSharedInstance().convert(providerId, CommonOAuth2Provider.class);
140142
}

module/spring-boot-security-oauth2-client/src/main/java/org/springframework/boot/security/oauth2/client/autoconfigure/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
/**
1818
* Support for Spring Security's OAuth 2 client.
1919
*/
20+
@NullMarked
2021
package org.springframework.boot.security.oauth2.client.autoconfigure;
22+
23+
import org.jspecify.annotations.NullMarked;

module/spring-boot-security-oauth2-client/src/main/java/org/springframework/boot/security/oauth2/client/autoconfigure/reactive/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
/**
1818
* Auto-configuration for Spring Security's Reactive OAuth 2 client.
1919
*/
20+
@NullMarked
2021
package org.springframework.boot.security.oauth2.client.autoconfigure.reactive;
22+
23+
import org.jspecify.annotations.NullMarked;

module/spring-boot-security-oauth2-client/src/main/java/org/springframework/boot/security/oauth2/client/autoconfigure/servlet/package-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717
/**
1818
* Auto-configuration for Spring Security's OAuth 2 client.
1919
*/
20+
@NullMarked
2021
package org.springframework.boot.security.oauth2.client.autoconfigure.servlet;
22+
23+
import org.jspecify.annotations.NullMarked;

0 commit comments

Comments
 (0)