Skip to content

Commit 5d089f6

Browse files
ngocnhan-tran1996jzheaux
authored andcommitted
Consistently NonNull annotation
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
1 parent 31fb7fe commit 5d089f6

File tree

6 files changed

+44
-49
lines changed

6 files changed

+44
-49
lines changed

core/src/main/java/org/springframework/security/authorization/method/PreAuthorizeExpressionAttributeRegistry.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,10 +20,9 @@
2020
import java.util.Arrays;
2121
import java.util.function.Function;
2222

23-
import reactor.util.annotation.NonNull;
24-
2523
import org.springframework.context.ApplicationContext;
2624
import org.springframework.expression.Expression;
25+
import org.springframework.lang.NonNull;
2726
import org.springframework.security.access.prepost.PreAuthorize;
2827
import org.springframework.security.core.annotation.AnnotationTemplateExpressionDefaults;
2928
import org.springframework.security.core.annotation.SecurityAnnotationScanner;

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/authentication/BaseOpenSamlAuthenticationProvider.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,6 @@
2929
import java.util.Set;
3030
import java.util.function.Consumer;
3131

32-
import javax.annotation.Nonnull;
3332
import javax.xml.namespace.QName;
3433

3534
import org.apache.commons.logging.Log;
@@ -67,6 +66,7 @@
6766

6867
import org.springframework.core.convert.converter.Converter;
6968
import org.springframework.core.log.LogMessage;
69+
import org.springframework.lang.NonNull;
7070
import org.springframework.security.authentication.AbstractAuthenticationToken;
7171
import org.springframework.security.authentication.AuthenticationProvider;
7272
import org.springframework.security.core.Authentication;
@@ -565,13 +565,13 @@ static class SAML20AssertionValidators {
565565
conditions.add(new AudienceRestrictionConditionValidator());
566566
conditions.add(new DelegationRestrictionConditionValidator());
567567
conditions.add(new ConditionValidator() {
568-
@Nonnull
568+
@NonNull
569569
@Override
570570
public QName getServicedCondition() {
571571
return OneTimeUse.DEFAULT_ELEMENT_NAME;
572572
}
573573

574-
@Nonnull
574+
@NonNull
575575
@Override
576576
public ValidationResult validate(Condition condition, Assertion assertion, ValidationContext context) {
577577
// applications should validate their own OneTimeUse conditions
@@ -580,16 +580,16 @@ public ValidationResult validate(Condition condition, Assertion assertion, Valid
580580
});
581581
conditions.add(new ProxyRestrictionConditionValidator());
582582
subjects.add(new BearerSubjectConfirmationValidator() {
583-
@Nonnull
584-
protected ValidationResult validateAddress(@Nonnull SubjectConfirmation confirmation,
585-
@Nonnull Assertion assertion, @Nonnull ValidationContext context, boolean required)
583+
@NonNull
584+
protected ValidationResult validateAddress(@NonNull SubjectConfirmation confirmation,
585+
@NonNull Assertion assertion, @NonNull ValidationContext context, boolean required)
586586
throws AssertionValidationException {
587587
return ValidationResult.VALID;
588588
}
589589

590-
@Nonnull
591-
protected ValidationResult validateAddress(@Nonnull SubjectConfirmationData confirmationData,
592-
@Nonnull Assertion assertion, @Nonnull ValidationContext context, boolean required)
590+
@NonNull
591+
protected ValidationResult validateAddress(@NonNull SubjectConfirmationData confirmationData,
592+
@NonNull Assertion assertion, @NonNull ValidationContext context, boolean required)
593593
throws AssertionValidationException {
594594
// applications should validate their own addresses - gh-7514
595595
return ValidationResult.VALID;
@@ -599,7 +599,7 @@ protected ValidationResult validateAddress(@Nonnull SubjectConfirmationData conf
599599

600600
static final SAML20AssertionValidator attributeValidator = new SAML20AssertionValidator(conditions, subjects,
601601
statements, null, null, null) {
602-
@Nonnull
602+
@NonNull
603603
@Override
604604
protected ValidationResult validateSignature(Assertion token, ValidationContext context) {
605605
return ValidationResult.VALID;

saml2/saml2-service-provider/src/opensaml4Main/java/org/springframework/security/saml2/provider/service/registration/OpenSaml4AssertingPartyMetadataRepository.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,8 +26,6 @@
2626
import java.util.Iterator;
2727
import java.util.function.Consumer;
2828

29-
import javax.annotation.Nonnull;
30-
3129
import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
3230
import org.opensaml.core.criterion.EntityIdCriterion;
3331
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
@@ -265,7 +263,7 @@ public File getFile() throws IOException {
265263
return this.resource.getFile();
266264
}
267265

268-
@Nonnull
266+
@NonNull
269267
@Override
270268
public InputStream getInputStream() throws IOException {
271269
return this.resource.getInputStream();

saml2/saml2-service-provider/src/opensaml4Test/java/org/springframework/security/saml2/provider/service/authentication/TestCustomOpenSaml4Objects.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
1919
import java.util.Collections;
2020
import java.util.List;
2121

22-
import javax.annotation.Nonnull;
2322
import javax.annotation.Nullable;
2423
import javax.xml.namespace.QName;
2524

@@ -40,6 +39,7 @@
4039
import org.opensaml.saml.saml2.core.AttributeValue;
4140
import org.w3c.dom.Element;
4241

42+
import org.springframework.lang.NonNull;
4343
import org.springframework.security.saml2.core.OpenSamlInitializationService;
4444

4545
public final class TestCustomOpenSaml4Objects {
@@ -103,7 +103,7 @@ public interface CustomOpenSamlObject extends ElementExtensibleXMLObject {
103103

104104
public static class CustomOpenSamlObjectImpl extends AbstractXMLObject implements CustomOpenSamlObject {
105105

106-
@Nonnull
106+
@NonNull
107107
private IndexedXMLObjectChildrenList<XMLObject> unknownXMLObjects;
108108

109109
/**
@@ -113,22 +113,22 @@ public static class CustomOpenSamlObjectImpl extends AbstractXMLObject implement
113113
* represents
114114
* @param namespacePrefix the prefix for the given namespace
115115
*/
116-
protected CustomOpenSamlObjectImpl(@Nullable String namespaceURI, @Nonnull String elementLocalName,
117-
@Nullable String namespacePrefix) {
116+
protected CustomOpenSamlObjectImpl(@javax.annotation.Nullable String namespaceURI,
117+
@NonNull String elementLocalName, @Nullable String namespacePrefix) {
118118
super(namespaceURI, elementLocalName, namespacePrefix);
119119
super.getNamespaceManager().registerNamespaceDeclaration(new Namespace(CUSTOM_NS, TYPE_CUSTOM_PREFIX));
120120
this.unknownXMLObjects = new IndexedXMLObjectChildrenList<>(this);
121121
}
122122

123-
@Nonnull
123+
@NonNull
124124
@Override
125125
public List<XMLObject> getUnknownXMLObjects() {
126126
return this.unknownXMLObjects;
127127
}
128128

129-
@Nonnull
129+
@NonNull
130130
@Override
131-
public List<XMLObject> getUnknownXMLObjects(@Nonnull QName typeOrName) {
131+
public List<XMLObject> getUnknownXMLObjects(@NonNull QName typeOrName) {
132132
return (List<XMLObject>) this.unknownXMLObjects.subList(typeOrName);
133133
}
134134

@@ -162,9 +162,9 @@ public String getCity() {
162162

163163
public static class CustomSamlObjectBuilder extends AbstractXMLObjectBuilder<CustomOpenSamlObject> {
164164

165-
@Nonnull
165+
@NonNull
166166
@Override
167-
public CustomOpenSamlObject buildObject(@Nullable String namespaceURI, @Nonnull String localName,
167+
public CustomOpenSamlObject buildObject(@Nullable String namespaceURI, @NonNull String localName,
168168
@Nullable String namespacePrefix) {
169169
return new CustomOpenSamlObjectImpl(namespaceURI, localName, namespacePrefix);
170170
}
@@ -178,7 +178,7 @@ public CustomSamlObjectMarshaller() {
178178
}
179179

180180
@Override
181-
protected void marshallElementContent(@Nonnull XMLObject xmlObject, @Nonnull Element domElement) {
181+
protected void marshallElementContent(@NonNull XMLObject xmlObject, @NonNull Element domElement) {
182182
final CustomOpenSamlObject customSamlObject = (CustomOpenSamlObject) xmlObject;
183183

184184
for (XMLObject object : customSamlObject.getOrderedChildren()) {
@@ -195,15 +195,15 @@ public CustomSamlObjectUnmarshaller() {
195195
}
196196

197197
@Override
198-
protected void processChildElement(@Nonnull XMLObject parentXMLObject, @Nonnull XMLObject childXMLObject)
198+
protected void processChildElement(@NonNull XMLObject parentXMLObject, @NonNull XMLObject childXMLObject)
199199
throws UnmarshallingException {
200200
final CustomOpenSamlObject customSamlObject = (CustomOpenSamlObject) parentXMLObject;
201201
customSamlObject.getUnknownXMLObjects().add(childXMLObject);
202202
}
203203

204-
@Nonnull
204+
@NonNull
205205
@Override
206-
protected XMLObject buildXMLObject(@Nonnull Element domElement) {
206+
protected XMLObject buildXMLObject(@NonNull Element domElement) {
207207
return new CustomOpenSamlObjectImpl(SAMLConstants.SAML20_NS, AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME,
208208
CustomOpenSamlObject.TYPE_CUSTOM_PREFIX);
209209
}

saml2/saml2-service-provider/src/opensaml5Main/java/org/springframework/security/saml2/provider/service/registration/OpenSaml5AssertingPartyMetadataRepository.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,8 +26,6 @@
2626
import java.util.Iterator;
2727
import java.util.function.Consumer;
2828

29-
import javax.annotation.Nonnull;
30-
3129
import net.shibboleth.shared.resolver.CriteriaSet;
3230
import org.opensaml.core.criterion.EntityIdCriterion;
3331
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
@@ -266,7 +264,7 @@ public File getFile() throws IOException {
266264
return this.resource.getFile();
267265
}
268266

269-
@Nonnull
267+
@NonNull
270268
@Override
271269
public InputStream getInputStream() throws IOException {
272270
return this.resource.getInputStream();

saml2/saml2-service-provider/src/opensaml5Test/java/org/springframework/security/saml2/provider/service/authentication/TestCustomOpenSaml5Objects.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
1919
import java.util.Collections;
2020
import java.util.List;
2121

22-
import javax.annotation.Nonnull;
2322
import javax.annotation.Nullable;
2423
import javax.xml.namespace.QName;
2524

@@ -40,6 +39,7 @@
4039
import org.opensaml.saml.saml2.core.AttributeValue;
4140
import org.w3c.dom.Element;
4241

42+
import org.springframework.lang.NonNull;
4343
import org.springframework.security.saml2.core.OpenSamlInitializationService;
4444

4545
public final class TestCustomOpenSaml5Objects {
@@ -103,7 +103,7 @@ public interface CustomOpenSamlObject extends ElementExtensibleXMLObject {
103103

104104
public static class CustomOpenSamlObjectImpl extends AbstractXMLObject implements CustomOpenSamlObject {
105105

106-
@Nonnull
106+
@NonNull
107107
private IndexedXMLObjectChildrenList<XMLObject> unknownXMLObjects;
108108

109109
/**
@@ -113,22 +113,22 @@ public static class CustomOpenSamlObjectImpl extends AbstractXMLObject implement
113113
* represents
114114
* @param namespacePrefix the prefix for the given namespace
115115
*/
116-
protected CustomOpenSamlObjectImpl(@Nullable String namespaceURI, @Nonnull String elementLocalName,
116+
protected CustomOpenSamlObjectImpl(@Nullable String namespaceURI, @NonNull String elementLocalName,
117117
@Nullable String namespacePrefix) {
118118
super(namespaceURI, elementLocalName, namespacePrefix);
119119
super.getNamespaceManager().registerNamespaceDeclaration(new Namespace(CUSTOM_NS, TYPE_CUSTOM_PREFIX));
120120
this.unknownXMLObjects = new IndexedXMLObjectChildrenList<>(this);
121121
}
122122

123-
@Nonnull
123+
@NonNull
124124
@Override
125125
public List<XMLObject> getUnknownXMLObjects() {
126126
return this.unknownXMLObjects;
127127
}
128128

129-
@Nonnull
129+
@NonNull
130130
@Override
131-
public List<XMLObject> getUnknownXMLObjects(@Nonnull QName typeOrName) {
131+
public List<XMLObject> getUnknownXMLObjects(@NonNull QName typeOrName) {
132132
return (List<XMLObject>) this.unknownXMLObjects.subList(typeOrName);
133133
}
134134

@@ -162,9 +162,9 @@ public String getCity() {
162162

163163
public static class CustomSamlObjectBuilder extends AbstractXMLObjectBuilder<CustomOpenSamlObject> {
164164

165-
@Nonnull
165+
@NonNull
166166
@Override
167-
public CustomOpenSamlObject buildObject(@Nullable String namespaceURI, @Nonnull String localName,
167+
public CustomOpenSamlObject buildObject(@Nullable String namespaceURI, @NonNull String localName,
168168
@Nullable String namespacePrefix) {
169169
return new CustomOpenSamlObjectImpl(namespaceURI, localName, namespacePrefix);
170170
}
@@ -178,7 +178,7 @@ public CustomSamlObjectMarshaller() {
178178
}
179179

180180
@Override
181-
protected void marshallElementContent(@Nonnull XMLObject xmlObject, @Nonnull Element domElement) {
181+
protected void marshallElementContent(@NonNull XMLObject xmlObject, @NonNull Element domElement) {
182182
final CustomOpenSamlObject customSamlObject = (CustomOpenSamlObject) xmlObject;
183183

184184
for (XMLObject object : customSamlObject.getOrderedChildren()) {
@@ -195,15 +195,15 @@ public CustomSamlObjectUnmarshaller() {
195195
}
196196

197197
@Override
198-
protected void processChildElement(@Nonnull XMLObject parentXMLObject, @Nonnull XMLObject childXMLObject)
198+
protected void processChildElement(@NonNull XMLObject parentXMLObject, @NonNull XMLObject childXMLObject)
199199
throws UnmarshallingException {
200200
final CustomOpenSamlObject customSamlObject = (CustomOpenSamlObject) parentXMLObject;
201201
customSamlObject.getUnknownXMLObjects().add(childXMLObject);
202202
}
203203

204-
@Nonnull
204+
@NonNull
205205
@Override
206-
protected XMLObject buildXMLObject(@Nonnull Element domElement) {
206+
protected XMLObject buildXMLObject(@NonNull Element domElement) {
207207
return new CustomOpenSamlObjectImpl(SAMLConstants.SAML20_NS, AttributeValue.DEFAULT_ELEMENT_LOCAL_NAME,
208208
CustomOpenSamlObject.TYPE_CUSTOM_PREFIX);
209209
}

0 commit comments

Comments
 (0)