Skip to content

Commit 6a6c7a7

Browse files
committed
Add missing @Nullable to setters of Nullable Fields
There are setters and builder methods that initialize members that are `@Nullable` but do not accept `@Nullable` parameters. For example: ``` private @nullable Object foo; public void setFoo(Object foo) { this.foo = foo; } ``` It is an unnecessary restriction that the parameter is unable to be null since the field can be null. This commit fixes these inconsistencies. Closes gh-18618
1 parent b591a0a commit 6a6c7a7

10 files changed

Lines changed: 30 additions & 25 deletions

core/src/main/java/org/springframework/security/authorization/RequiredFactor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public static class Builder {
122122
* @param authority the authority.
123123
* @return the builder.
124124
*/
125-
public Builder authority(String authority) {
125+
public Builder authority(@Nullable String authority) {
126126
this.authority = authority;
127127
return this;
128128
}
@@ -205,7 +205,7 @@ public Builder x509Authority() {
205205
* @param validDuration the {@link Duration}.
206206
* @return
207207
*/
208-
public Builder validDuration(Duration validDuration) {
208+
public Builder validDuration(@Nullable Duration validDuration) {
209209
this.validDuration = validDuration;
210210
return this;
211211
}

webauthn/src/main/java/org/springframework/security/web/webauthn/api/AuthenticatorAssertionResponse.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private AuthenticatorAssertionResponseBuilder() {
155155
* @param authenticatorData the authenticator data.
156156
* @return the {@link AuthenticatorAssertionResponseBuilder}
157157
*/
158-
public AuthenticatorAssertionResponseBuilder authenticatorData(Bytes authenticatorData) {
158+
public AuthenticatorAssertionResponseBuilder authenticatorData(@Nullable Bytes authenticatorData) {
159159
this.authenticatorData = authenticatorData;
160160
return this;
161161
}
@@ -165,7 +165,7 @@ public AuthenticatorAssertionResponseBuilder authenticatorData(Bytes authenticat
165165
* @param signature the signature
166166
* @return the {@link AuthenticatorAssertionResponseBuilder}
167167
*/
168-
public AuthenticatorAssertionResponseBuilder signature(Bytes signature) {
168+
public AuthenticatorAssertionResponseBuilder signature(@Nullable Bytes signature) {
169169
this.signature = signature;
170170
return this;
171171
}
@@ -175,7 +175,7 @@ public AuthenticatorAssertionResponseBuilder signature(Bytes signature) {
175175
* @param userHandle the user handle
176176
* @return the {@link AuthenticatorAssertionResponseBuilder}
177177
*/
178-
public AuthenticatorAssertionResponseBuilder userHandle(Bytes userHandle) {
178+
public AuthenticatorAssertionResponseBuilder userHandle(@Nullable Bytes userHandle) {
179179
this.userHandle = userHandle;
180180
return this;
181181
}
@@ -185,7 +185,7 @@ public AuthenticatorAssertionResponseBuilder userHandle(Bytes userHandle) {
185185
* @param attestationObject the attestation object
186186
* @return the {@link AuthenticatorAssertionResponseBuilder}
187187
*/
188-
public AuthenticatorAssertionResponseBuilder attestationObject(Bytes attestationObject) {
188+
public AuthenticatorAssertionResponseBuilder attestationObject(@Nullable Bytes attestationObject) {
189189
this.attestationObject = attestationObject;
190190
return this;
191191
}
@@ -195,7 +195,7 @@ public AuthenticatorAssertionResponseBuilder attestationObject(Bytes attestation
195195
* @param clientDataJSON the client data JSON
196196
* @return the {@link AuthenticatorAssertionResponseBuilder}
197197
*/
198-
public AuthenticatorAssertionResponseBuilder clientDataJSON(Bytes clientDataJSON) {
198+
public AuthenticatorAssertionResponseBuilder clientDataJSON(@Nullable Bytes clientDataJSON) {
199199
this.clientDataJSON = clientDataJSON;
200200
return this;
201201
}

webauthn/src/main/java/org/springframework/security/web/webauthn/api/AuthenticatorAttestationResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public AuthenticatorAttestationResponseBuilder transports(AuthenticatorTransport
120120
* @param transports the transports
121121
* @return the {@link AuthenticatorAttestationResponseBuilder}
122122
*/
123-
public AuthenticatorAttestationResponseBuilder transports(List<AuthenticatorTransport> transports) {
123+
public AuthenticatorAttestationResponseBuilder transports(@Nullable List<AuthenticatorTransport> transports) {
124124
this.transports = transports;
125125
return this;
126126
}

webauthn/src/main/java/org/springframework/security/web/webauthn/api/AuthenticatorSelectionCriteria.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ private AuthenticatorSelectionCriteriaBuilder() {
133133
* @return the {@link AuthenticatorSelectionCriteriaBuilder}
134134
*/
135135
public AuthenticatorSelectionCriteriaBuilder authenticatorAttachment(
136-
AuthenticatorAttachment authenticatorAttachment) {
136+
@Nullable AuthenticatorAttachment authenticatorAttachment) {
137137
this.authenticatorAttachment = authenticatorAttachment;
138138
return this;
139139
}
@@ -143,7 +143,7 @@ public AuthenticatorSelectionCriteriaBuilder authenticatorAttachment(
143143
* @param residentKey the resident key
144144
* @return the {@link AuthenticatorSelectionCriteriaBuilder}
145145
*/
146-
public AuthenticatorSelectionCriteriaBuilder residentKey(ResidentKeyRequirement residentKey) {
146+
public AuthenticatorSelectionCriteriaBuilder residentKey(@Nullable ResidentKeyRequirement residentKey) {
147147
this.residentKey = residentKey;
148148
return this;
149149
}
@@ -153,7 +153,8 @@ public AuthenticatorSelectionCriteriaBuilder residentKey(ResidentKeyRequirement
153153
* @param userVerification the user verification requirement
154154
* @return the {@link AuthenticatorSelectionCriteriaBuilder}
155155
*/
156-
public AuthenticatorSelectionCriteriaBuilder userVerification(UserVerificationRequirement userVerification) {
156+
public AuthenticatorSelectionCriteriaBuilder userVerification(
157+
@Nullable UserVerificationRequirement userVerification) {
157158
this.userVerification = userVerification;
158159
return this;
159160
}

webauthn/src/main/java/org/springframework/security/web/webauthn/api/ImmutablePublicKeyCredentialUserEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public PublicKeyCredentialUserEntityBuilder id(Bytes id) {
179179
* @param displayName the display name
180180
* @return the {@link PublicKeyCredentialUserEntityBuilder}
181181
*/
182-
public PublicKeyCredentialUserEntityBuilder displayName(String displayName) {
182+
public PublicKeyCredentialUserEntityBuilder displayName(@Nullable String displayName) {
183183
this.displayName = displayName;
184184
return this;
185185
}

webauthn/src/main/java/org/springframework/security/web/webauthn/api/PublicKeyCredential.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public PublicKeyCredentialBuilder id(String id) {
176176
* @param type the type
177177
* @return the PublicKeyCredentialBuilder
178178
*/
179-
public PublicKeyCredentialBuilder type(PublicKeyCredentialType type) {
179+
public PublicKeyCredentialBuilder type(@Nullable PublicKeyCredentialType type) {
180180
this.type = type;
181181
return this;
182182
}
@@ -206,7 +206,8 @@ public PublicKeyCredentialBuilder response(R response) {
206206
* @param authenticatorAttachment the authenticator attachment
207207
* @return the PublicKeyCredentialBuilder
208208
*/
209-
public PublicKeyCredentialBuilder authenticatorAttachment(AuthenticatorAttachment authenticatorAttachment) {
209+
public PublicKeyCredentialBuilder authenticatorAttachment(
210+
@Nullable AuthenticatorAttachment authenticatorAttachment) {
210211
this.authenticatorAttachment = authenticatorAttachment;
211212
return this;
212213
}
@@ -217,7 +218,7 @@ public PublicKeyCredentialBuilder authenticatorAttachment(AuthenticatorAttachmen
217218
* @return the PublicKeyCredentialBuilder
218219
*/
219220
public PublicKeyCredentialBuilder clientExtensionResults(
220-
AuthenticationExtensionsClientOutputs clientExtensionResults) {
221+
@Nullable AuthenticationExtensionsClientOutputs clientExtensionResults) {
221222
this.clientExtensionResults = clientExtensionResults;
222223
return this;
223224
}

webauthn/src/main/java/org/springframework/security/web/webauthn/api/PublicKeyCredentialCreationOptions.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public PublicKeyCredentialCreationOptionsBuilder pubKeyCredParams(
265265
* @param timeout the timeout
266266
* @return the PublicKeyCredentialCreationOptionsBuilder
267267
*/
268-
public PublicKeyCredentialCreationOptionsBuilder timeout(Duration timeout) {
268+
public PublicKeyCredentialCreationOptionsBuilder timeout(@Nullable Duration timeout) {
269269
this.timeout = timeout;
270270
return this;
271271
}
@@ -297,7 +297,8 @@ public PublicKeyCredentialCreationOptionsBuilder authenticatorSelection(
297297
* @param attestation the attestation
298298
* @return the PublicKeyCredentialCreationOptionsBuilder
299299
*/
300-
public PublicKeyCredentialCreationOptionsBuilder attestation(AttestationConveyancePreference attestation) {
300+
public PublicKeyCredentialCreationOptionsBuilder attestation(
301+
@Nullable AttestationConveyancePreference attestation) {
301302
this.attestation = attestation;
302303
return this;
303304
}
@@ -307,7 +308,8 @@ public PublicKeyCredentialCreationOptionsBuilder attestation(AttestationConveyan
307308
* @param extensions the extensions
308309
* @return the PublicKeyCredentialCreationOptionsBuilder
309310
*/
310-
public PublicKeyCredentialCreationOptionsBuilder extensions(AuthenticationExtensionsClientInputs extensions) {
311+
public PublicKeyCredentialCreationOptionsBuilder extensions(
312+
@Nullable AuthenticationExtensionsClientInputs extensions) {
311313
this.extensions = extensions;
312314
return this;
313315
}

webauthn/src/main/java/org/springframework/security/web/webauthn/api/PublicKeyCredentialDescriptor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public PublicKeyCredentialDescriptorBuilder type(PublicKeyCredentialType type) {
124124
* @param id the id
125125
* @return the {@link PublicKeyCredentialDescriptorBuilder}
126126
*/
127-
public PublicKeyCredentialDescriptorBuilder id(Bytes id) {
127+
public PublicKeyCredentialDescriptorBuilder id(@Nullable Bytes id) {
128128
this.id = id;
129129
return this;
130130
}
@@ -134,7 +134,7 @@ public PublicKeyCredentialDescriptorBuilder id(Bytes id) {
134134
* @param transports the transports
135135
* @return the {@link PublicKeyCredentialDescriptorBuilder}
136136
*/
137-
public PublicKeyCredentialDescriptorBuilder transports(Set<AuthenticatorTransport> transports) {
137+
public PublicKeyCredentialDescriptorBuilder transports(@Nullable Set<AuthenticatorTransport> transports) {
138138
this.transports = transports;
139139
return this;
140140
}

webauthn/src/main/java/org/springframework/security/web/webauthn/api/PublicKeyCredentialRequestOptions.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private PublicKeyCredentialRequestOptionsBuilder() {
169169
* @param challenge the challenge
170170
* @return the {@link PublicKeyCredentialRequestOptionsBuilder}
171171
*/
172-
public PublicKeyCredentialRequestOptionsBuilder challenge(Bytes challenge) {
172+
public PublicKeyCredentialRequestOptionsBuilder challenge(@Nullable Bytes challenge) {
173173
this.challenge = challenge;
174174
return this;
175175
}
@@ -190,7 +190,7 @@ public PublicKeyCredentialRequestOptionsBuilder timeout(Duration timeout) {
190190
* @param rpId the rpId property
191191
* @return the {@link PublicKeyCredentialRequestOptionsBuilder}
192192
*/
193-
public PublicKeyCredentialRequestOptionsBuilder rpId(String rpId) {
193+
public PublicKeyCredentialRequestOptionsBuilder rpId(@Nullable String rpId) {
194194
this.rpId = rpId;
195195
return this;
196196
}
@@ -212,7 +212,8 @@ public PublicKeyCredentialRequestOptionsBuilder allowCredentials(
212212
* @param userVerification the user verification
213213
* @return the {@link PublicKeyCredentialRequestOptionsBuilder}
214214
*/
215-
public PublicKeyCredentialRequestOptionsBuilder userVerification(UserVerificationRequirement userVerification) {
215+
public PublicKeyCredentialRequestOptionsBuilder userVerification(
216+
@Nullable UserVerificationRequirement userVerification) {
216217
this.userVerification = userVerification;
217218
return this;
218219
}

webauthn/src/main/java/org/springframework/security/web/webauthn/api/PublicKeyCredentialRpEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private PublicKeyCredentialRpEntityBuilder() {
9191
* @param name the name property
9292
* @return the {@link PublicKeyCredentialRpEntityBuilder}
9393
*/
94-
public PublicKeyCredentialRpEntityBuilder name(String name) {
94+
public PublicKeyCredentialRpEntityBuilder name(@Nullable String name) {
9595
this.name = name;
9696
return this;
9797
}
@@ -101,7 +101,7 @@ public PublicKeyCredentialRpEntityBuilder name(String name) {
101101
* @param id the id
102102
* @return the {@link PublicKeyCredentialRpEntityBuilder}
103103
*/
104-
public PublicKeyCredentialRpEntityBuilder id(String id) {
104+
public PublicKeyCredentialRpEntityBuilder id(@Nullable String id) {
105105
this.id = id;
106106
return this;
107107
}

0 commit comments

Comments
 (0)